4 * Copyright 2003 CodeWeavers, Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wintab_internal.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wintab32
);
34 HWND hwndDefault
= NULL
;
36 WC_TABLETCLASSNAME
[] = {'W','i','n','e','T','a','b','l','e','t','C','l','a','s','s',0};
37 CRITICAL_SECTION csTablet
;
39 int (*pLoadTabletInfo
)(HWND hwnddefault
) = NULL
;
40 int (*pGetCurrentPacket
)(LPWTPACKET packet
) = NULL
;
41 int (*pAttachEventQueueToTablet
)(HWND hOwner
) = NULL
;
42 UINT (*pWTInfoA
)(UINT wCategory
, UINT nIndex
, LPVOID lpOutput
) = NULL
;
44 static LRESULT WINAPI
TABLET_WindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
,
47 static VOID
TABLET_Register()
50 ZeroMemory(&wndClass
, sizeof(WNDCLASSW
));
51 wndClass
.style
= CS_GLOBALCLASS
;
52 wndClass
.lpfnWndProc
= TABLET_WindowProc
;
53 wndClass
.cbClsExtra
= 0;
54 wndClass
.cbWndExtra
= 0;
55 wndClass
.hCursor
= NULL
;
56 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
57 wndClass
.lpszClassName
= WC_TABLETCLASSNAME
;
58 RegisterClassW(&wndClass
);
61 static VOID
TABLET_Unregister()
63 UnregisterClassW(WC_TABLETCLASSNAME
, NULL
);
66 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpReserved
)
68 static const WCHAR name
[] = {'T','a','b','l','e','t',0};
71 TRACE("%p, %lx, %p\n",hInstDLL
,fdwReason
,lpReserved
);
74 case DLL_PROCESS_ATTACH
:
75 TRACE("Initialization\n");
76 InitializeCriticalSection(&csTablet
);
77 hx11drv
= GetModuleHandleA("winex11.drv");
80 pLoadTabletInfo
= (void *)GetProcAddress(hx11drv
, "LoadTabletInfo");
81 pAttachEventQueueToTablet
= (void *)GetProcAddress(hx11drv
, "AttachEventQueueToTablet");
82 pGetCurrentPacket
= (void *)GetProcAddress(hx11drv
, "GetCurrentPacket");
83 pWTInfoA
= (void *)GetProcAddress(hx11drv
, "WTInfoA");
85 hwndDefault
= CreateWindowW(WC_TABLETCLASSNAME
, name
,
86 WS_POPUPWINDOW
,0,0,0,0,0,0,hInstDLL
,0);
91 case DLL_PROCESS_DETACH
:
95 DestroyWindow(hwndDefault
);
99 DeleteCriticalSection(&csTablet
);
107 * The window proc for the default TABLET window
109 static LRESULT WINAPI
TABLET_WindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
,
112 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", uMsg
, (UINT
)wParam
,
123 LPOPENCONTEXT handler
;
124 pGetCurrentPacket(&packet
);
125 handler
= AddPacketToContextQueue(&packet
,(HWND
)lParam
);
126 if (handler
&& handler
->context
.lcOptions
& CXO_MESSAGES
)
127 TABLET_PostTabletMessage(handler
, _WT_PACKET(handler
->context
.lcMsgBase
),
128 (WPARAM
)packet
.pkSerialNumber
,
129 (LPARAM
)handler
->handle
, FALSE
);
135 LPOPENCONTEXT handler
;
137 pGetCurrentPacket(&packet
);
138 handler
= AddPacketToContextQueue(&packet
,(HWND
)lParam
);
141 prox
= MAKELPARAM( wParam
, 1 );
142 TABLET_PostTabletMessage(handler
, WT_PROXIMITY
,
143 (WPARAM
)handler
->handle
, (LPARAM
)prox
,