Peter Urbanec : wintab32: Better handling of XInput initialisation errors.
Alexandre Julliard
julliard at winehq.org
Thu Mar 3 11:46:22 CST 2011
Module: wine
Branch: master
Commit: 0ea8bf17fa1df2b18d8d3a9fda56db472da94948
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ea8bf17fa1df2b18d8d3a9fda56db472da94948
Author: Peter Urbanec <winehq.org at urbanec.net>
Date: Thu Mar 3 19:26:33 2011 +1100
wintab32: Better handling of XInput initialisation errors.
---
dlls/winex11.drv/wintab.c | 16 ++++++++++------
dlls/wintab32/context.c | 31 +++++++++++++++++++++++--------
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index 7d7bfcc..7a9e749 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -484,7 +484,7 @@ static void disable_system_cursors(void)
/***********************************************************************
* X11DRV_LoadTabletInfo (X11DRV.@)
*/
-void CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
+BOOL CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
{
const WCHAR SZ_CONTEXT_NAME[] = {'W','i','n','e',' ','T','a','b','l','e','t',' ','C','o','n','t','e','x','t',0};
const WCHAR SZ_DEVICE_NAME[] = {'W','i','n','e',' ','T','a','b','l','e','t',' ','D','e','v','i','c','e',0};
@@ -507,7 +507,7 @@ void CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
if (!X11DRV_XInput_Init())
{
ERR("Unable to initialize the XInput library.\n");
- return;
+ return FALSE;
}
hwndTabletDefault = hwnddefault;
@@ -555,9 +555,9 @@ void CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
devices = pXListInputDevices(data->display, &num_devices);
if (!devices)
{
- WARN("XInput Extensions reported as not avalable\n");
+ WARN("XInput Extensions reported as not available\n");
wine_tsx11_unlock();
- return;
+ return FALSE;
}
TRACE("XListInputDevices reports %d devices\n", num_devices);
for (loop=0; loop < num_devices; loop++)
@@ -778,6 +778,7 @@ void CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
}
wine_tsx11_unlock();
+ return TRUE;
}
static int figure_deg(int x, int y)
@@ -971,7 +972,7 @@ int CDECL X11DRV_AttachEventQueueToTablet(HWND hOwner)
XEventClass event_list[7];
Window win = X11DRV_get_whole_window( hOwner );
- if (!win) return 0;
+ if (!win || !xinput_handle) return 0;
TRACE("Creating context for window %p (%lx) %i cursors\n", hOwner, win, gNumCursors);
@@ -1080,6 +1081,8 @@ UINT CDECL X11DRV_WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
LPWTI_CURSORS_INFO tgtcursor;
TRACE("(%u, %u, %p)\n", wCategory, nIndex, lpOutput);
+ if (!xinput_handle) return 0;
+
switch(wCategory)
{
case 0:
@@ -1512,8 +1515,9 @@ int CDECL X11DRV_GetCurrentPacket(LPWTPACKET packet)
/***********************************************************************
* LoadTabletInfo (X11DRV.@)
*/
-void CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
+BOOL CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
{
+ return FALSE;
}
/***********************************************************************
diff --git a/dlls/wintab32/context.c b/dlls/wintab32/context.c
index 30f0021..c8940b3 100644
--- a/dlls/wintab32/context.c
+++ b/dlls/wintab32/context.c
@@ -42,7 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wintab32);
* http://www.csl.sony.co.jp/projects/ar/restricted/wintabl.html
*/
-static BOOL gLoaded;
static LPOPENCONTEXT gOpenContexts;
static HCTX gTopContext = (HCTX)0xc00;
@@ -151,12 +150,26 @@ static LPOPENCONTEXT TABLET_FindOpenContext(HCTX hCtx)
return NULL;
}
-static void LoadTablet(void)
+static inline BOOL LoadTablet(void)
{
- TRACE("Initializing the tablet to hwnd %p\n",hwndDefault);
- gLoaded= TRUE;
- if (pLoadTabletInfo)
- pLoadTabletInfo(hwndDefault);
+ static enum {TI_START = 0, TI_OK, TI_FAIL} loaded = TI_START;
+
+ if (loaded == TI_START)
+ {
+ TRACE("Initializing the tablet to hwnd %p\n",hwndDefault);
+
+ if (pLoadTabletInfo && pLoadTabletInfo(hwndDefault))
+ {
+ loaded = TI_OK;
+ }
+ else
+ {
+ loaded = TI_FAIL;
+ ERR("LoadTabletInfo(%p) failed\n", hwndDefault);
+ }
+ }
+
+ return loaded == TI_OK;
}
int TABLET_PostTabletMessage(LPOPENCONTEXT newcontext, UINT msg, WPARAM wParam,
@@ -366,9 +379,9 @@ static UINT WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
{
UINT result;
+ if (!LoadTablet()) return 0;
+
TRACE("(%d, %d, %p, %d)\n", wCategory, nIndex, lpOutput, bUnicode);
- if (gLoaded == FALSE)
- LoadTablet();
/*
* Handle system extents here, as we can use user32.dll code to set them.
@@ -450,6 +463,8 @@ HCTX WINAPI WTOpenW(HWND hWnd, LPLOGCONTEXTW lpLogCtx, BOOL fEnable)
{
LPOPENCONTEXT newcontext;
+ if (!LoadTablet()) return 0;
+
TRACE("hWnd=%p, lpLogCtx=%p, fEnable=%u\n", hWnd, lpLogCtx, fEnable);
DUMPCONTEXT(*lpLogCtx);
More information about the wine-cvs
mailing list