wintab32/winex11.drv: Add CDECL to imported functions.
[wine/wine64.git] / dlls / wintab32 / wintab32.c
blobb52b429d9494c7abffa6aa93cf0a05a572a9b10f
1 /*
2 * WinTab32 library
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "winuser.h"
27 #include "winerror.h"
28 #include "wintab.h"
29 #include "wintab_internal.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wintab32);
34 HWND hwndDefault = NULL;
35 static const WCHAR
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 (CDECL *pLoadTabletInfo)(HWND hwnddefault) = NULL;
40 int (CDECL *pGetCurrentPacket)(LPWTPACKET packet) = NULL;
41 int (CDECL *pAttachEventQueueToTablet)(HWND hOwner) = NULL;
42 UINT (CDECL *pWTInfoW)(UINT wCategory, UINT nIndex, LPVOID lpOutput) = NULL;
44 static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
45 LPARAM lParam);
47 static VOID TABLET_Register(void)
49 WNDCLASSW wndClass;
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(void)
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};
69 HMODULE hx11drv;
71 TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved);
72 switch (fdwReason)
74 case DLL_PROCESS_ATTACH:
75 TRACE("Initialization\n");
76 DisableThreadLibraryCalls(hInstDLL);
77 InitializeCriticalSection(&csTablet);
78 csTablet.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": csTablet");
79 hx11drv = GetModuleHandleA("winex11.drv");
80 if (hx11drv)
82 pLoadTabletInfo = (void *)GetProcAddress(hx11drv, "LoadTabletInfo");
83 pAttachEventQueueToTablet = (void *)GetProcAddress(hx11drv, "AttachEventQueueToTablet");
84 pGetCurrentPacket = (void *)GetProcAddress(hx11drv, "GetCurrentPacket");
85 pWTInfoW = (void *)GetProcAddress(hx11drv, "WTInfoW");
86 TABLET_Register();
87 hwndDefault = CreateWindowW(WC_TABLETCLASSNAME, name,
88 WS_POPUPWINDOW,0,0,0,0,0,0,hInstDLL,0);
90 else
91 return FALSE;
92 break;
93 case DLL_PROCESS_DETACH:
94 TRACE("Detaching\n");
95 if (hwndDefault)
97 DestroyWindow(hwndDefault);
98 hwndDefault = 0;
100 TABLET_Unregister();
101 csTablet.DebugInfo->Spare[0] = 0;
102 DeleteCriticalSection(&csTablet);
103 break;
105 return TRUE;
110 * The window proc for the default TABLET window
112 static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
113 LPARAM lParam)
115 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", uMsg, (UINT)wParam,
116 (UINT)lParam);
118 switch(uMsg)
120 case WM_NCCREATE:
121 return TRUE;
123 case WT_PACKET:
125 WTPACKET packet;
126 LPOPENCONTEXT handler;
127 pGetCurrentPacket(&packet);
128 handler = AddPacketToContextQueue(&packet,(HWND)lParam);
129 if (handler && handler->context.lcOptions & CXO_MESSAGES)
130 TABLET_PostTabletMessage(handler, _WT_PACKET(handler->context.lcMsgBase),
131 (WPARAM)packet.pkSerialNumber,
132 (LPARAM)handler->handle, FALSE);
133 break;
135 case WT_PROXIMITY:
137 WTPACKET packet;
138 LPOPENCONTEXT handler;
139 pGetCurrentPacket(&packet);
140 handler = AddPacketToContextQueue(&packet,(HWND)wParam);
141 if (handler)
142 TABLET_PostTabletMessage(handler, WT_PROXIMITY,
143 (WPARAM)handler->handle, lParam, TRUE);
144 break;
147 return 0;