Ignore:
Timestamp:
Oct 30, 2009, 2:12:10 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Broadcast a special message to let interested parties re-add their icons when the system tray restarts (especially useful after a WPS/XCenter crash, etc).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/3rdparty/os2/xsystray/xsystray.c

    r269 r270  
    162162         // how often to perform alive checks
    163163
     164
     165
     166
    164167/* ******************************************************************
    165168 *
     
    531534MRESULT EXPENTRY fnwpXSysTray(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    532535{
    533     MRESULT mrc = 0;
    534536    // get widget data from QWL_USER (stored there by WM_CREATE)
    535537    PXCENTERWIDGET pWidget = (PXCENTERWIDGET)WinQueryWindowPtr(hwnd, QWL_USER);
     
    557559        case WM_CREATE:
    558560        {
     561
     562
    559563            PSYSTRAYDATA pSysTrayData = NULL;
    560 
    561             mrc = (MPARAM)TRUE; // being pessimistic gives more compact code
    562564
    563565            WinSetWindowPtr(hwnd, QWL_USER, mp1);
     
    566568               )
    567569                // shouldn't happen... stop window creation!!
    568                 break;
     570                ;
    569571
    570572            pSysTrayData = malloc(sizeof(*pSysTrayData));
    571573            if (pSysTrayData == NULL)
    572                 break;
     574                ;
    573575
    574576            // initialize the SYSTRAYDATA structure
     
    582584            {
    583585                free(pSysTrayData);
    584                 break;
     586                ;
    585587            }
    586588            pSysTrayData->cIcons = 0;
     
    598600                free(pSysTrayData->pIcons);
    599601                free(pSysTrayData);
    600                 break;
     602                ;
    601603            }
    602604
    603605            pWidget->pUser = pSysTrayData;
    604606
    605             mrc = FALSE; // confirm success
     607            // inform all interested parties that we are fired up
     608            // (NOTE: keep in sync with xstGetSysTrayCreatedMsgId())
     609            WinBroadcastMsg(HWND_DESKTOP,
     610                            WinAddAtom(WinQuerySystemAtomTable(),
     611                                       "ExtendedSysTray.WM_XST_CREATED"),
     612                            NULL, NULL,
     613                            BMSG_POST);
     614
     615            return FALSE; // confirm success
     616        }
     617        break;
     618
     619        /*
     620         * WM_DESTROY:
     621         *      clean up. This _must_ be passed on to
     622         *      ctrDefWidgetProc.
     623         */
     624
     625        case WM_DESTROY:
     626        {
     627            LOGF(("WM_DESTROY\n"));
     628
     629            PSYSTRAYDATA pSysTrayData = (PSYSTRAYDATA)pWidget->pUser;
     630            size_t i;
     631
     632            // destroy the server
     633            WinDestroyWindow(pSysTrayData->hwndServer);
     634            pSysTrayData->hwndServer = NULLHANDLE;
     635
     636            // free all system tray data
     637            for (i = 0; i < pSysTrayData->cIcons; ++i)
     638                FreeIconData(&pSysTrayData->pIcons[i]);
     639            pSysTrayData->cIcons = 0;
     640            free(pSysTrayData->pIcons);
     641            pSysTrayData->pIcons = NULL;
     642
     643            // make sure we remove the check alive timer
     644            WgtXSysTrayUpdateAfterIconAddRemove(pWidget);
     645
     646            free(pSysTrayData);
     647            pWidget->pUser = NULL;
     648
     649            // We _MUST_ pass this on, or the default widget proc
     650            // cannot clean up, so break
    606651        }
    607652        break;
     
    613658
    614659        case WM_CONTROL:
    615             mrc = (MPARAM)WgtControl(pWidget, mp1, mp2);
     660            (MPARAM)WgtControl(pWidget, mp1, mp2);
    616661        break;
    617662
     
    623668        case WM_PAINT:
    624669            WgtPaint(hwnd, pWidget);
     670
    625671        break;
    626672
     
    634680        break; */
    635681
    636         /*
    637          * WM_DESTROY:
    638          *      clean up. This _must_ be passed on to
    639          *      ctrDefWidgetProc.
    640          */
    641 
    642         case WM_DESTROY:
    643         {
    644             // free all system tray data
    645             PSYSTRAYDATA pSysTrayData = (PSYSTRAYDATA)pWidget->pUser;
    646             size_t i;
    647             for (i = 0; i < pSysTrayData->cIcons; ++i)
    648                 FreeIconData(&pSysTrayData->pIcons[i]);
    649             free(pSysTrayData->pIcons);
    650             free(pSysTrayData);
    651             pWidget->pUser = NULL;
    652             // We _MUST_ pass this on, or the default widget proc
    653             // cannot clean up.
    654             mrc = pWidget->pfnwpDefWidgetProc(hwnd, msg, mp1, mp2);
    655         }
    656         break;
    657 
    658682        default:
    659             mrc = pWidget->pfnwpDefWidgetProc(hwnd, msg, mp1, mp2);
     683            ;
    660684
    661685    } // end switch(msg)
    662686
    663     return mrc;
     687    return ;
    664688}
    665689
     
    689713    }
    690714
    691     // ask XCenter to take our new size into account
    692     // (this will also invalidate us)
    693     WinPostMsg(pWidget->pGlobals->hwndClient,
    694                XCM_REFORMAT,
    695                (MPARAM)XFMF_GETWIDGETSIZES,
    696                0);
     715    if (pSysTrayData->pIcons != NULL)
     716    {
     717        // ask XCenter to take our new size into account (this will also
     718        // invalidate us). If pIcons is NULL it means that we are in WM_DESTROY,
     719        // in which case XCenter will do everything for us
     720        WinPostMsg(pWidget->pGlobals->hwndClient,
     721                   XCM_REFORMAT,
     722                   (MPARAM)XFMF_GETWIDGETSIZES,
     723                   0);
     724    }
    697725}
    698726
     
    927955MRESULT EXPENTRY fnwpXSysTrayServer(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    928956{
    929     MRESULT mrc = 0;
    930957    // get widget data from QWL_USER_SERVER_DATA (stored there by WM_CREATE)
    931958    PXCENTERWIDGET pWidget =
     
    936963    {
    937964        case WM_CREATE:
     965
    938966            WinSetWindowPtr(hwnd, QWL_USER_SERVER_DATA, mp1);
     967
     968
     969
     970
     971
    939972        break;
    940973
     
    947980
    948981        case WM_XST_CONTROL:
    949             mrc = (MRESULT)WgtXSysTrayControl(hwnd, pWidget,
    950                                               (PSYSTRAYCTLDATA)mp1);
     982            (MRESULT)WgtXSysTrayControl(hwnd, pWidget,
     983                                              (PSYSTRAYCTLDATA)mp1);
    951984        break;
    952985
     
    958991        case WM_TIMER:
    959992            WgtXSysTrayTimer(hwnd, pWidget, SHORT1FROMMP(mp1));
     993
    960994        break;
    961995
    962996        default:
    963             mrc = WinDefWindowProc(hwnd, msg, mp1, mp2);
     997            ;
    964998    } // end switch(msg)
    965999
    966     return mrc;
     1000    return ;
    9671001}
    9681002
     
    11231157VOID EXPENTRY WgtUnInitModule(VOID)
    11241158{
     1159
    11251160}
    11261161
Note: See TracChangeset for help on using the changeset viewer.