winex11.drv/wintab32[3/4]: implement WTInfoW

Mikolaj Zalewski mikolajz at google.com
Fri Aug 31 13:13:47 CDT 2007


-------------- next part --------------
From d175035d06eba11ea4cc5d72c74a255871650746 Mon Sep 17 00:00:00 2001
From: Mikolaj Zalewski <mikolaj at zalewski.pl>
Date: Fri, 31 Aug 2007 11:03:25 -0700
Subject: [PATCH] winex11.drv/wintab32: implement WTInfoW
---
 dlls/winex11.drv/winex11.drv.spec |    2 +-
 dlls/winex11.drv/wintab.c         |   37 ++++++++++++++++++++++++++-----------
 dlls/wintab32/context.c           |   37 ++++++++++++++++++++++++++-----------
 dlls/wintab32/wintab32.c          |    4 ++--
 dlls/wintab32/wintab_internal.h   |    2 +-
 5 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index 6a6c173..e134138 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -119,7 +119,7 @@ # WinTab32
 @ cdecl AttachEventQueueToTablet(long) X11DRV_AttachEventQueueToTablet
 @ cdecl GetCurrentPacket(ptr) X11DRV_GetCurrentPacket
 @ cdecl LoadTabletInfo(long) X11DRV_LoadTabletInfo
-@ cdecl WTInfoA(long long ptr) X11DRV_WTInfoA
+@ cdecl WTInfoT(long long ptr long) X11DRV_WTInfoT
 
 # X11 locks
 @ cdecl -norelay wine_tsx11_lock()
diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index 149bb12..dc1dbba 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -778,27 +778,42 @@ static inline int CopyTabletData(LPVOID 
     return(size);
 }
 
-static inline int CopyTabletStringN(LPVOID target, LPWSTR str, INT buf_size)
+static inline int CopyTabletStringN(LPVOID target, LPWSTR str, INT cchBufSize, BOOL bUnicode)
 {
+    if (bUnicode)
+    {
+        if (target != NULL)
+            lstrcpynW(target, str, cchBufSize);
+        return cchBufSize*sizeof(WCHAR);
+    }
+
     if (target != NULL)
     {
         char *buf = (char *)target;
-        WideCharToMultiByte(CP_ACP, 0, str, -1, buf, buf_size, NULL, NULL);
-        buf[buf_size - 1] = 0;
+        WideCharToMultiByte(CP_ACP, 0, str, -1, buf, cchBufSize, NULL, NULL);
+        buf[cchBufSize - 1] = 0;
     }
-    return buf_size;
+    return cchBufSize;
 }
 
-static inline int CopyTabletString(LPVOID target, LPWSTR str)
+static inline int CopyTabletString(LPVOID target, LPWSTR str, BOOL bUnicode)
 {
     int len = lstrlenW(str) + 1;
-    return WideCharToMultiByte(CP_ACP, 0, str, len, (char *)target, target ? len : 0, NULL, NULL);
+
+    if (bUnicode)
+    {
+        if (target != NULL)
+            lstrcpyW(target, str);
+        return len*sizeof(WCHAR);
+    }
+    else
+        return WideCharToMultiByte(CP_ACP, 0, str, len, (char *)target, target ? len : 0, NULL, NULL);
 }
 
 #define WTINFO_COPY_STRING_N(data_index, string, len) \
     if (nIndex == data_index || nIndex == 0) \
     { \
-        int size = CopyTabletStringN(lpBuffer, string, len); \
+        int size = CopyTabletStringN(lpBuffer, string, len, bUnicode); \
         total_size += size; \
         if (lpBuffer != NULL) \
             lpBuffer += size; \
@@ -807,7 +822,7 @@ #define WTINFO_COPY_STRING_N(data_index,
 #define WTINFO_COPY_STRING(data_index, string) \
     if (nIndex == data_index || nIndex == 0) \
     { \
-        int size = CopyTabletString(lpBuffer, string); \
+        int size = CopyTabletString(lpBuffer, string, bUnicode); \
         total_size += size; \
         if (lpBuffer != NULL) \
             lpBuffer += size; \
@@ -848,14 +863,14 @@ #define WTINFO_END_CATEGORY \
  * lpOutput == NULL signifies the user only wishes to find the size of
  * the data. 
  */
-UINT X11DRV_WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+UINT X11DRV_WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
 {
     int total_size = 0;
     BOOL bSkipedKnownIdx = FALSE;
     BOOL bFoundCategory = FALSE;
     char *lpBuffer = (char *)lpOutput;
     LPWTI_CURSORS_INFO  tgtcursor;
-    TRACE("(%u, %u, %p)\n", wCategory, nIndex, lpOutput);
+    TRACE("(%u, %u, %p, %c)\n", wCategory, nIndex, lpOutput, bUnicode?'W':'A');
 
     /* Apps often starts with a call to WTInfo(0, 0, NULL) to check if there is any cursor
      */
@@ -1030,7 +1045,7 @@ void X11DRV_LoadTabletInfo(HWND hwnddefa
 /***********************************************************************
  *		WTInfoA (X11DRV.@)
  */
-UINT X11DRV_WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+UINT X11DRV_WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
 {
     return 0;
 }
diff --git a/dlls/wintab32/context.c b/dlls/wintab32/context.c
index 5b538ad..aaa6744 100644
--- a/dlls/wintab32/context.c
+++ b/dlls/wintab32/context.c
@@ -347,9 +347,11 @@ static VOID TABLET_BlankPacketData(LPOPE
 
 
 /***********************************************************************
- *		WTInfoA (WINTAB32.20)
+ *		WTInfoT [Internal]
+ *
+ * Implements both WTInfoA and WTInfoW
  */
-UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+UINT WINAPI WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
 {
     UINT result;
     if (gLoaded == FALSE)
@@ -374,30 +376,43 @@ UINT WINAPI WTInfoA(UINT wCategory, UINT
         }
     }
 
-    result =  pWTInfoA( wCategory, nIndex, lpOutput );
+    result =  pWTInfoT( wCategory, nIndex, lpOutput, bUnicode );
 
     /*
      *  Handle system extents here, as we can use user32.dll code to set them.
      */
     if(wCategory == WTI_DEFSYSCTX && nIndex == 0)
     {
-        LPLOGCONTEXTA lpCtx = (LPLOGCONTEXTA)lpOutput;
-        lpCtx->lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
-        lpCtx->lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
+        if (bUnicode)
+        {
+            LPLOGCONTEXTW lpCtx = (LPLOGCONTEXTW)lpOutput;
+            lpCtx->lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
+            lpCtx->lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
+        }
+        else
+        {
+            LPLOGCONTEXTA lpCtx = (LPLOGCONTEXTA)lpOutput;
+            lpCtx->lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
+            lpCtx->lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
+        }
     }
     return result;
 }
 
 /***********************************************************************
+ *		WTInfoA (WINTAB32.20)
+ */
+UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+{
+    return WTInfoT(wCategory, nIndex, lpOutput, FALSE);
+}
+
+/***********************************************************************
  *		WTInfoW (WINTAB32.1020)
  */
 UINT WINAPI WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
 {
-    FIXME("(%u, %u, %p): stub\n", wCategory, nIndex, lpOutput);
-
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-
-    return 0;
+    return WTInfoT(wCategory, nIndex, lpOutput, TRUE);
 }
 
 /***********************************************************************
diff --git a/dlls/wintab32/wintab32.c b/dlls/wintab32/wintab32.c
index c34a681..651d47c 100644
--- a/dlls/wintab32/wintab32.c
+++ b/dlls/wintab32/wintab32.c
@@ -39,7 +39,7 @@ CRITICAL_SECTION csTablet;
 int (*pLoadTabletInfo)(HWND hwnddefault) = NULL;
 int (*pGetCurrentPacket)(LPWTPACKET packet) = NULL;
 int (*pAttachEventQueueToTablet)(HWND hOwner) = NULL;
-UINT (*pWTInfoA)(UINT wCategory, UINT nIndex, LPVOID lpOutput) = NULL;
+UINT (*pWTInfoT)(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode) = NULL;
 
 static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
                                           LPARAM lParam);
@@ -81,7 +81,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, 
                 pLoadTabletInfo = (void *)GetProcAddress(hx11drv, "LoadTabletInfo");
                 pAttachEventQueueToTablet = (void *)GetProcAddress(hx11drv, "AttachEventQueueToTablet");
                 pGetCurrentPacket = (void *)GetProcAddress(hx11drv, "GetCurrentPacket");
-                pWTInfoA = (void *)GetProcAddress(hx11drv, "WTInfoA");
+                pWTInfoT = (void *)GetProcAddress(hx11drv, "WTInfoT");
                 TABLET_Register();
                 hwndDefault = CreateWindowW(WC_TABLETCLASSNAME, name,
                                 WS_POPUPWINDOW,0,0,0,0,0,0,hInstDLL,0);
diff --git a/dlls/wintab32/wintab_internal.h b/dlls/wintab32/wintab_internal.h
index 711a48f..5db60d3 100644
--- a/dlls/wintab32/wintab_internal.h
+++ b/dlls/wintab32/wintab_internal.h
@@ -155,7 +155,7 @@ LPOPENCONTEXT FindOpenContext(HWND hwnd)
 extern int (*pLoadTabletInfo)(HWND hwnddefault);
 extern int (*pGetCurrentPacket)(LPWTPACKET packet);
 extern int (*pAttachEventQueueToTablet)(HWND hOwner);
-extern UINT (*pWTInfoA)(UINT wCategory, UINT nIndex, LPVOID lpOutput);
+extern UINT (*pWTInfoT)(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode);
 
 extern HWND hwndDefault;
 extern CRITICAL_SECTION csTablet;
-- 
1.4.1


More information about the wine-patches mailing list