Ignore:
Timestamp:
Oct 30, 2009, 2:27:42 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Implemented adding and removing icons.

File:
1 edited

Legend:

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

    r268 r269  
    133133typedef struct
    134134{
     135
     136
    135137    LONG        lIconWidth;
    136138                // system icon width in px
     
    148150} SYSTRAYDATA, *PSYSTRAYDATA;
    149151
     152
     153
     154
     155
    150156static ULONG QWL_USER_SERVER_DATA = 0;
    151157             // offset to the PXCENTERWIDGET pointer in the widget data array
     
    303309        pData->pszToolTip = NULL;
    304310    }
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
    305341}
    306342
     
    492528 */
    493529
     530
    494531MRESULT EXPENTRY fnwpXSysTray(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    495532{
     
    539576            pSysTrayData->lIconHeight = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) / 2;
    540577            pSysTrayData->lIconPad = pSysTrayData->lIconHeight / 8;
    541             pSysTrayData->cIconsMax = 4;
     578            pSysTrayData->cIconsMax = ;
    542579            pSysTrayData->pIcons = malloc(sizeof(*pSysTrayData->pIcons) *
    543580                                          pSysTrayData->cIconsMax);
     
    548585            }
    549586            pSysTrayData->cIcons = 0;
    550             pWidget->pUser = pSysTrayData;
    551587
    552588            // create the "server" window (note that we pass the XCENTERWIDGET
    553589            // pointer on to it)
    554             HWND hwndServer =
     590            hwndServer =
    555591                WinCreateWindow(HWND_DESKTOP, WNDCLASS_WIDGET_XSYSTRAY_SERVER,
    556592                                NULL, WS_MINIMIZED,
     
    558594                                HWND_DESKTOP, HWND_BOTTOM,
    559595                                0, mp1, NULL);
    560             if (hwndServer == NULLHANDLE)
     596            if (pSysTrayData->hwndServer == NULLHANDLE)
     597            {
     598                free(pSysTrayData->pIcons);
     599                free(pSysTrayData);
    561600                break;
     601
     602
     603
    562604
    563605            mrc = FALSE; // confirm success
     
    623665
    624666/*
     667
     668
     669
     670
     671
     672
     673
     674
     675
     676
     677
     678
     679
     680
     681
     682
     683
     684
     685
     686
     687
     688
     689
     690
     691
     692
     693
     694
     695
     696
     697
     698
     699
    625700 *@@ WgtXSysTrayControl:
    626701 *      implementation for WM_XST_CONTROL in fnwpXSysTrayServer.
     
    659734            POINTERINFO Info;
    660735            HPOINTER hIcon = NULLHANDLE;
     736
     737
    661738
    662739            LOGF(("SYSTRAYCMD_ADDICON\n"));
    663             LOGF(("hIcon %x\n", pCtlData->u.icon.hIcon));
     740            LOGF((" hwnd  %x\n", pCtlData->hwndSender));
     741            LOGF((" ulId  %ld\n", pCtlData->u.icon.ulId));
     742            LOGF((" hIcon %x\n", pCtlData->u.icon.hIcon));
    664743
    665744            pCtlData->bAcknowledged = TRUE;
     
    677756            }
    678757
    679             // @todo just testing....
    680             if (pSysTrayData->pIcons[0].hIcon != NULLHANDLE)
    681                 WinDestroyPointer(pSysTrayData->pIcons[0].hIcon);
    682             pSysTrayData->cIcons = 1;
    683             pSysTrayData->pIcons[0].hwnd = pCtlData->hwndSender;
    684             pSysTrayData->pIcons[0].ulId = pCtlData->u.icon.ulId;
    685             pSysTrayData->pIcons[0].hIcon = hIcon;
    686             pSysTrayData->pIcons[0].ulMsgId = pCtlData->u.icon.ulMsgId;
    687 
    688             // ask XCenter to take our new size into account
    689             // (this will also invalidate us)
    690             WinPostMsg(pWidget->pGlobals->hwndClient,
    691                        XCM_REFORMAT,
    692                        (MPARAM)XFMF_GETWIDGETSIZES,
    693                        0);
    694 
    695             if (pSysTrayData->cIcons == 1)
     758            pData = FindIconData(pSysTrayData, pCtlData->hwndSender,
     759                                 pCtlData->u.icon.ulId, &i);
     760            if (pData)
    696761            {
    697                 // start a timer to perform "is window alive" checks
    698                 WinStartTimer(pWidget->habWidget, hwnd,
    699                               TID_CHECKALIVE,
    700                               TID_CHECKALIVE_TIMEOUT);
     762                LOGF((" Updating hIcon %x\n", hIcon));
     763
     764                WinDestroyPointer(pData->hIcon);
     765                pData->hIcon = hIcon;
     766                pData->ulMsgId = pCtlData->u.icon.ulMsgId;
     767
     768                // we didn't change the number of icons so simply invalidate
     769                WinInvalidateRect(pWidget->hwndWidget, NULL, FALSE);
    701770            }
     771
     772
     773
     774
     775
     776
     777
     778
     779
     780
     781
     782
     783
     784
     785
     786
     787
     788
     789
     790
     791
     792
     793
     794
     795
     796
     797
     798
     799
     800
     801
     802
     803
     804
     805
    702806
    703807            brc = TRUE;
    704808        }
     809
     810
     811
     812
     813
     814
     815
     816
     817
     818
     819
     820
     821
     822
     823
     824
     825
     826
     827
     828
     829
     830
     831
     832
     833
     834
     835
     836
     837
     838
     839
     840
     841
     842
     843
     844
     845
    705846
    706847        default:
     
    735876            if (!WinIsWindow(pWidget->habWidget, pSysTrayData->pIcons[i].hwnd))
    736877            {
     878
     879
     880
     881
     882
    737883                bAnyDead = TRUE;
    738884                FreeIconData(&pSysTrayData->pIcons[i]);
     
    761907            }
    762908
    763             if (pSysTrayData->cIcons == 0)
    764             {
    765                 // stop the check alive timer
    766                 WinStopTimer(pWidget->habWidget, hwnd,
    767                               TID_CHECKALIVE);
    768             }
    769 
    770             // ask XCenter to take our new size into account
    771             // (this will also invalidate us)
    772             WinPostMsg(pWidget->pGlobals->hwndClient,
    773                        XCM_REFORMAT,
    774                        (MPARAM)XFMF_GETWIDGETSIZES,
    775                        0);
     909            WgtXSysTrayUpdateAfterIconAddRemove(pWidget);
    776910        }
    777911    }
Note: See TracChangeset for help on using the changeset viewer.