Ignore:
Timestamp:
Mar 18, 2011, 11:37:52 PM (14 years ago)
Author:
dmik
Message:

shell32: Implemented xsystray support (#16).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/systray_os2.c

    r21591 r21592  
    9797    ULONG fcf = FCF_TITLEBAR;
    9898
    99     if ( !SYSTRAY_Old_RegisterClass() )
     99    if (!SYSTRAY_Old_RegisterClass())
    100100    {
    101101        return FALSE;
    102102    }
    103103
    104 
    105     memset( ptrayItem, 0, sizeof(SystrayItem) );
    106     ptrayItem->hWndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &fcf, NULL,
    107                                                "", 0, NULLHANDLE, 0, NULL );
    108     if ( !ptrayItem->hWndFrame ) {
     104    ptrayItem->hWndFrame = WinCreateStdWindow(HWND_DESKTOP, 0, &fcf, NULL,
     105                                              "", 0, NULLHANDLE, 0, NULL);
     106    if (!ptrayItem->hWndFrame)
     107    {
    109108        return FALSE;
    110109    }
    111110    ptrayItem->hWndClient = WinCreateWindow(ptrayItem->hWndFrame, systraysupclass, "",
    112111                                            0, 0, 0, 0, 0, ptrayItem->hWndFrame,
    113                                             HWND_TOP, FID_CLIENT, ptrayItem, NULL );
    114     if ( !ptrayItem->hWndClient ) {
     112                                            HWND_TOP, FID_CLIENT, ptrayItem, NULL);
     113    if (!ptrayItem->hWndClient)
     114    {
    115115        return FALSE;
    116116    }
    117117
    118     WinDdeInitiate(ptrayItem->hWndClient,SZAPP,SZTOPIC,NULL);
     118    WinDdeInitiate(ptrayItem->hWndClient, SZAPP, SZTOPIC, NULL);
    119119    if (hwndTrayServer)
    120         WinPostMsg(hwndTrayServer,WM_TRAYICON,(MPARAM)ptrayItem->hWndClient,(MPARAM)NULL);
     120        WinPostMsg(hwndTrayServer, WM_TRAYICON,
     121                   (MPARAM)ptrayItem->hWndClient, (MPARAM)NULL);
    121122
    122     return (hwndTrayServer!=NULLHANDLE);
     123    return (hwndTrayServer != NULLHANDLE);
    123124}
    124125
     
    132133}
    133134
     135static void SYSTRAY_Old_ItemUpdate(SystrayItem *ptrayItem, ULONG uFlags)
     136{
     137    // uFlags = 0 means it's the first time, add everything
    134138
    135 static void SYSTRAY_Old_ItemSetMessage(SystrayItem *ptrayItem, ULONG uCallbackMessage)
    136 {
    137   ptrayItem->notifyIcon.uCallbackMessage = uCallbackMessage;
     139    if (uFlags == 0 || (uFlags & NIF_ICON))
     140    {
     141        // Windows seems to make a copy of icons displayed in the tray area. At
     142        // least, calling DestroyIcon() after passing the icon handle to
     143        // Shell_NotifyIcon() doesn't harm the icon displayed in the tray.
     144        // Behave similarly on OS/2 (some applications do call DestroyIcon()).
     145        // The copy is deleted in SYSTRAY_Old_ItemTerm().
     146
     147        POINTERINFO Info;
     148        HPOINTER hIcon = NULLHANDLE;
     149        BOOL brc;
     150        brc = WinQueryPointerInfo(ptrayItem->notifyIcon.hIcon, &Info);
     151        if (brc)
     152        {
     153            hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
     154            if (hIcon != NULLHANDLE)
     155            {
     156                WinSendMsg(ptrayItem->hWndFrame, WM_SETICON,
     157                           MPFROMLONG(hIcon), MPVOID);
     158                if (hwndTrayServer)
     159                    WinPostMsg(hwndTrayServer, WM_TRAYICON,
     160                               (MPARAM)ptrayItem->hWndClient, (MPARAM)NULL);
     161            }
     162        }
     163    }
     164    if (uFlags == 0 || (uFlags & NIF_TIP))
     165    {
     166        WinSetWindowText(ptrayItem->hWndFrame, ptrayItem->notifyIcon.szTip);
     167        if (hwndTrayServer)
     168            WinPostMsg(hwndTrayServer, WM_TRAYICON,
     169                       (MPARAM)ptrayItem->hWndClient, (MPARAM)NULL);
     170    }
    138171}
    139 
    140 
    141 static void SYSTRAY_Old_ItemSetIcon(SystrayItem *ptrayItem, HPOINTER hIcon)
    142 {
    143     // Windows seems to make a copy of icons displayed in the tray area. At
    144     // least, calling DestroyIcon() after passing the icon handle to
    145     // Shell_NotifyIcon() doesn't harm the icon displayed in the tray. Behave
    146     // similarly on OS/2 (some applications do call DestroyIcon()). The copy is
    147     // deleted in SYSTRAY_Old_ItemTerm().
    148 
    149     POINTERINFO Info;
    150     HPOINTER hIcon2 = NULLHANDLE;
    151     APIRET arc;
    152     arc = WinQueryPointerInfo(hIcon, &Info);
    153     if (!arc)
    154         return;
    155     hIcon2 = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
    156     if (hIcon2 == NULLHANDLE)
    157         return;
    158     hIcon = hIcon2;
    159 
    160     WinSendMsg( ptrayItem->hWndFrame, WM_SETICON, MPFROMLONG( hIcon ), MPVOID );
    161     if (hwndTrayServer)
    162         WinPostMsg(hwndTrayServer,WM_TRAYICON,(MPARAM)ptrayItem->hWndClient,(MPARAM)NULL);
    163 }
    164 
    165 
    166 static void SYSTRAY_Old_ItemSetTip(SystrayItem *ptrayItem, CHAR* szTip, int modify)
    167 {
    168         char tmp[ 64 ];
    169     strncpy(ptrayItem->notifyIcon.szTip, szTip, 64 );
    170     ptrayItem->notifyIcon.szTip[ 63 ] = 0;
    171     DoWin32CharToOem( ptrayItem->notifyIcon.szTip, tmp );
    172     WinSetWindowText( ptrayItem->hWndFrame, tmp );
    173     if (hwndTrayServer)
    174         WinPostMsg(hwndTrayServer,WM_TRAYICON,(MPARAM)ptrayItem->hWndClient,(MPARAM)NULL);
    175 }
    176 
    177172
    178173BOOL SYSTRAY_Init(void)
     
    185180    SYSTRAY_ItemInit = SYSTRAY_Old_ItemInit;
    186181    SYSTRAY_ItemTerm = SYSTRAY_Old_ItemTerm;
    187     SYSTRAY_ItemSetMessage = SYSTRAY_Old_ItemSetMessage;
    188     SYSTRAY_ItemSetIcon = SYSTRAY_Old_ItemSetIcon;
    189     SYSTRAY_ItemSetTip = SYSTRAY_Old_ItemSetTip;
     182    SYSTRAY_ItemUpdate = SYSTRAY_Old_ItemUpdate;
    190183
    191184    return TRUE;
Note: See TracChangeset for help on using the changeset viewer.