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

3rdparty: os2/xsystray: Implemented the client-side notification message interception and delivery to the target window (experimental, needs some tuning, see @todo).

File:
1 edited

Legend:

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

    r273 r276  
    2020#define INCL_WINATOM
    2121#define INCL_WINPOINTERS
     22#define INCL_WINHOOKS
    2223#include <os2.h>
    2324
     
    2728#include <string.h>
    2829#include <sys/builtin.h>        // atomics
     30
     31static ULONG WM_XST_CREATED = 0;
     32             // identity of the WM_XST_CREATED message taken from the atom table
     33static ULONG WM_XST_NOTIFY = 0;
     34             // identity of the WM_XST_NOTIFY message taken from the atom table
    2935
    3036static
     
    170176
    171177/*
     178 *@@ InputHook:
     179 *      This is used to intercept posted XST_NOTIFY messages and apply special
     180 *      processing to them (compose a client window-specific notification
     181 *      message, free the NOTIFYDATA structure and post the composed message to
     182 *      the target window).
     183 */
     184
     185static BOOL EXPENTRY InputHook(HAB hab, PQMSG pQmsg, ULONG fs)
     186{
     187    if (pQmsg->msg == WM_XST_NOTIFY)
     188    {
     189        PNOTIFYDATA pNotifyData = (PNOTIFYDATA)pQmsg->mp1;
     190        PVOID pvMemoryPool = (PVOID)pQmsg->mp2;
     191
     192        // copy NOTIFYDATA and free it
     193        NOTIFYDATA NotifyData = *pNotifyData;
     194        FreeNotifyDataPtr(pvMemoryPool, pQmsg->hwnd, pNotifyData);
     195
     196        // start with a copy of the message and change the fields we need
     197        QMSG newMsg = *pQmsg;
     198        newMsg.msg = NotifyData.msg;
     199        newMsg.mp1 = NotifyData.mp1;
     200        newMsg.mp2 = NotifyData.mp2;
     201
     202        // deliver the message
     203        WinDispatchMsg(hab, &newMsg);
     204
     205        return TRUE;
     206    }
     207
     208    return FALSE;
     209}
     210
     211/*
    172212 *@@ xstQuerySysTrayVersion:
    173213 *
     
    262302        return FALSE;
    263303
     304    // install the message hook if not already done so
     305    // @todo the code is temporary and incorrect, it's just for testing
     306    // (we should use an array of HMQ to check if we already installed the filter)
     307    if (WM_XST_NOTIFY == 0)
     308    {
     309        WM_XST_NOTIFY = WinAddAtom(WinQuerySystemAtomTable(),
     310                                   WM_XST_NOTIFY_ATOM);
     311
     312        brc = WinSetHook(WinQueryAnchorBlock(hwnd),
     313                         HMQ_CURRENT, HK_INPUT, (PFN)InputHook, NULLHANDLE);
     314        if (!brc)
     315            return FALSE;
     316    }
     317
    264318    // give all processes temporary access to hIcon
    265319    brc = WinSetPointerOwner(hIcon, 0, FALSE);
     
    400454ULONG xstGetSysTrayCreatedMsgId()
    401455{
    402     static ULONG WM_XST_CREATED = 0;
    403456    if (WM_XST_CREATED == 0)
    404457        WM_XST_CREATED = WinAddAtom(WinQuerySystemAtomTable(),
Note: See TracChangeset for help on using the changeset viewer.