Ignore:
Timestamp:
Nov 2, 2009, 11:32:16 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Implemented array of HMQ to track HK_INPUT hook installation/removal.

File:
1 edited

Legend:

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

    r280 r281  
    2626#define INCL_WINPOINTERS
    2727#define INCL_WINHOOKS
     28
    2829#include <os2.h>
    2930
     
    3334#include <string.h>
    3435#include <sys/builtin.h>        // atomics
     36
     37
    3538
    3639static ULONG WM_XST_CREATED = 0;
     
    5659        // sounds sane
    5760
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
    5880// @todo to be on the safe side with casting in __atomic_cmpxchg32() we need
    5981// compile-time assertions like this:
     
    78100}
    79101
    80 static BOOL SendSysTrayCtlMsg(PSYSTRAYCTLDATA pData)
     102static SendSysTrayCtlMsg(PSYSTRAYCTLDATA pData)
    81103{
    82104    APIRET arc;
     
    112134
    113135        mrc = WinSendMsg(G_hwndSysTray, WM_XST_CONTROL, pData, NULL);
    114         if (mrc == (MRESULT)TRUE && pData->bAcknowledged)
    115             return TRUE;
     136        if (pData->bAcknowledged)
     137            return ;
    116138
    117139        // if we failed to send the message, it may mean that XCenter was restarted
     
    126148        break;
    127149    }
    128     while (TRUE);
    129 
    130     return FALSE;
     150    while ();
     151
     152    return ;
    131153}
    132154
     
    183205/*
    184206 *@@ InputHook:
    185  *      This is used to intercept posted XST_NOTIFY messages and apply special
    186  *      processing to them (compose a client window-specific notification
    187  *      message, free the NOTIFYDATA structure and post the composed message to
    188  *      the target window).
     207 *      This is used to intercept posted
     208 *     
     209 *     
     210 *      the target window).
    189211 */
    190212
     
    243265    pData->hwndSender = NULLHANDLE;
    244266
    245     brc = SendSysTrayCtlMsg(pData);
     267    brc = SendSysTrayCtlMsg(pData);
    246268    if (brc)
    247269    {
     
    302324                       ULONG ulFlags)   // in: flags (not currently used, must be 0)
    303325{
    304     BOOL brc;
    305     PPIB ppib;
     326    BOOL    brc;
     327    ULONG   xrc;
     328    PPIB    ppib;
     329    HAB     hab;
     330    HMQ     hmq;
     331    size_t  i;
     332
    306333    PSYSTRAYCTLDATA pData = AllocSysTrayCtlDataPtr();
    307334    if (!pData)
    308335        return FALSE;
    309336
    310     // install the message hook if not already done so
    311     // @todo the code is temporary and incorrect, it's just for testing
    312     // (we should use an array of HMQ to check if we already installed the filter)
    313337    if (WM_XST_NOTIFY == 0)
    314     {
    315338        WM_XST_NOTIFY = WinAddAtom(WinQuerySystemAtomTable(),
    316339                                   WM_XST_NOTIFY_ATOM);
    317340
    318         brc = WinSetHook(WinQueryAnchorBlock(hwnd),
    319                          HMQ_CURRENT, HK_INPUT, (PFN)InputHook, NULLHANDLE);
    320         if (!brc)
     341    hab = WinQueryAnchorBlock(hwnd);
     342    hmq = WinQueryWindowULong(hwnd, QWL_HMQ);
     343    if (hmq == NULLHANDLE)
     344        return FALSE;
     345
     346    // initialize the HMQ refs array
     347    // @todo remove _smutex usage when we get into the DLL and initialize
     348    // _fmutex + array in the DLL init routine
     349    _smutex_request(&G_smtx);
     350    if (!G_pHmqRefs)
     351    {
     352        if (_fmutex_create(&G_fmtx, 0))
    321353            return FALSE;
    322     }
     354        G_pHmqRefs = malloc(sizeof(*G_pHmqRefs) * HMQREFS_GROW);
     355        if (!G_pHmqRefs)
     356            return FALSE;
     357        G_cHmqRefs = 0;
     358        G_cHmqRefsMax = HMQREFS_GROW;
     359    }
     360    _smutex_release(&G_smtx);
    323361
    324362    // give all processes temporary access to hIcon
     
    332370        pData->u.icon.ulMsgId = ulMsgId;
    333371
    334         brc = SendSysTrayCtlMsg(pData);
     372        xrc = SendSysTrayCtlMsg(pData);
     373        brc = xrc == XST_OK || xrc == XST_REPLACED;
    335374
    336375        // revoke temporary access to hIcon
     
    341380    FreeSysTrayCtlDataPtr(pData);
    342381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
    343423    return brc;
    344424}
     
    355435BOOL xstRemoveSysTrayIcon(HWND hwnd,    // in: window handle associated with the icon
    356436                          USHORT usId)  // in: icon ID to remove
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
    357503{
    358504    BOOL brc;
     
    361507        return FALSE;
    362508
    363     pData->ulCommand = SYSTRAYCMD_REMOVEICON;
    364     pData->hwndSender = hwnd;
    365     pData->u.icon.usId = usId;
    366 
    367     brc = SendSysTrayCtlMsg(pData);
    368 
    369     FreeSysTrayCtlDataPtr(pData);
    370 
    371     return brc;
    372 }
    373 
    374 /*
    375  *@@ xstSetSysTrayIconToolTip:
    376  *
    377  *      Sets the tooltip text for the given icon in the system tray. This text
    378  *      is shown when the mouse pointer is held still over the icon area for
    379  *      some time.
    380  *
    381  *      If pszText is NULL, the tooltip text is reset and will not be shown next
    382  *      time. The old tooltip is hidden if it is being currently shown.
    383  *
    384  *      Returns TRUE on success and FALSE otherwise.
    385  *
    386  *      NOTE: The maximum tooltip text length (including terminating null) is
    387  *      limited to a value returned by xstGetSysTrayMaxTextLen(). If the
    388  *      supplied string is longer, it will be truncated.
    389  */
    390 
    391 BOOL xstSetSysTrayIconToolTip(HWND hwnd,    // in: window handle associated with the icon
    392                               USHORT usId,  // in: icon ID to set the tooltip for
    393                               PSZ pszText)  // in: tooltip text
    394 {
    395     BOOL brc;
    396     PSYSTRAYCTLDATA pData = AllocSysTrayCtlDataPtr();
    397     if (!pData)
    398         return FALSE;
    399 
    400509    pData->ulCommand = SYSTRAYCMD_SETTOOLTIP;
    401510    pData->hwndSender = hwnd;
     
    412521    }
    413522
    414     brc = SendSysTrayCtlMsg(pData);
     523    brc = SendSysTrayCtlMsg(pData);
    415524
    416525    FreeSysTrayCtlDataPtr(pData);
Note: See TracChangeset for help on using the changeset viewer.