Commit 29a63472 authored by Mikolaj Zalewski's avatar Mikolaj Zalewski Committed by Alexandre Julliard

winex11.drv/wintab32: Make wintab strings in winex11.drv Unicode, implement WTInfoW.

parent 5d0dc481
......@@ -119,7 +119,7 @@
@ cdecl AttachEventQueueToTablet(long) X11DRV_AttachEventQueueToTablet
@ cdecl GetCurrentPacket(ptr) X11DRV_GetCurrentPacket
@ cdecl LoadTabletInfo(long) X11DRV_LoadTabletInfo
@ cdecl WTInfoA(long long ptr) X11DRV_WTInfoA
@ cdecl WTInfoW(long long ptr) X11DRV_WTInfoW
# X11 locks
@ cdecl -norelay wine_tsx11_lock()
......
......@@ -28,6 +28,7 @@
#include "winerror.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "wintab.h"
#include "wintab_internal.h"
......@@ -45,6 +46,32 @@ static BOOL gLoaded;
static LPOPENCONTEXT gOpenContexts;
static HCTX gTopContext = (HCTX)0xc00;
static void LOGCONTEXTWtoA(const LOGCONTEXTW *in, LOGCONTEXTA *out)
{
WideCharToMultiByte(CP_ACP, 0, in->lcName, LCNAMELEN, out->lcName, LCNAMELEN, NULL, NULL);
out->lcName[LCNAMELEN - 1] = 0;
/* we use the fact that the fields after lcName are the same in LOGCONTEXTA and W */
memcpy(&out->lcOptions, &in->lcOptions, sizeof(LOGCONTEXTW) - FIELD_OFFSET(LOGCONTEXTW, lcOptions));
}
static BOOL is_logcontext_category(UINT wCategory)
{
return wCategory == WTI_DEFSYSCTX || wCategory == WTI_DEFCONTEXT || wCategory == WTI_DDCTXS;
}
static BOOL is_string_field(UINT wCategory, UINT nIndex)
{
if (wCategory == WTI_INTERFACE && nIndex == IFC_WINTABID)
return TRUE;
if (is_logcontext_category(wCategory) && nIndex == CTX_NAME)
return TRUE;
if (wCategory >= WTI_CURSORS && wCategory <= WTI_CURSORS + 9)
return TRUE;
if (wCategory == WTI_DEVICES && (nIndex == DVC_NAME || nIndex == DVC_PNPID))
return TRUE;
return FALSE;
}
static char* DUMPBITS(int x, char* buf)
{
strcpy(buf,"{");
......@@ -346,10 +373,7 @@ static VOID TABLET_BlankPacketData(LPOPENCONTEXT context, LPVOID lpPkt, INT n)
}
/***********************************************************************
* WTInfoA (WINTAB32.20)
*/
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 +398,57 @@ UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
}
}
result = pWTInfoA( wCategory, nIndex, lpOutput );
if (is_logcontext_category(wCategory) && nIndex == 0)
{
if (lpOutput)
{
LOGCONTEXTW buf;
pWTInfoW(wCategory, nIndex, &buf);
/*
* Handle system extents here, as we can use user32.dll code to set them.
*/
if(wCategory == WTI_DEFSYSCTX && nIndex == 0)
/* Handle system extents here, as we can use user32.dll code to set them */
if(wCategory == WTI_DEFSYSCTX && nIndex == 0)
{
buf.lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
buf.lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
}
if (bUnicode)
memcpy(lpOutput, &buf, sizeof(buf));
else
LOGCONTEXTWtoA(&buf, lpOutput);
}
return bUnicode ? sizeof(LOGCONTEXTW) : sizeof(LOGCONTEXTA);
}
else if (is_string_field(wCategory, nIndex) && !bUnicode)
{
LPLOGCONTEXTA lpCtx = (LPLOGCONTEXTA)lpOutput;
lpCtx->lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
lpCtx->lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
int size = pWTInfoW(wCategory, nIndex, NULL);
WCHAR *buf = HeapAlloc(GetProcessHeap(), 0, size);
pWTInfoW(wCategory, nIndex, buf);
result = WideCharToMultiByte(CP_ACP, 0, buf, size/sizeof(WCHAR), lpOutput, lpOutput ? 2*size : 0, NULL, NULL);
HeapFree(GetProcessHeap(), 0, buf);
}
else
result = pWTInfoW(wCategory, nIndex, lpOutput);
return result;
}
/***********************************************************************
* WTInfoW (WINTAB32.1020)
* WTInfoA (WINTAB32.20)
*/
UINT WINAPI WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
{
FIXME("(%u, %u, %p): stub\n", wCategory, nIndex, lpOutput);
return WTInfoT(wCategory, nIndex, lpOutput, FALSE);
}
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
/***********************************************************************
* WTInfoW (WINTAB32.1020)
*/
UINT WINAPI WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
{
return WTInfoT(wCategory, nIndex, lpOutput, TRUE);
}
/***********************************************************************
......
......@@ -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 (*pWTInfoW)(UINT wCategory, UINT nIndex, LPVOID lpOutput) = NULL;
static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam);
......@@ -81,7 +81,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
pLoadTabletInfo = (void *)GetProcAddress(hx11drv, "LoadTabletInfo");
pAttachEventQueueToTablet = (void *)GetProcAddress(hx11drv, "AttachEventQueueToTablet");
pGetCurrentPacket = (void *)GetProcAddress(hx11drv, "GetCurrentPacket");
pWTInfoA = (void *)GetProcAddress(hx11drv, "WTInfoA");
pWTInfoW = (void *)GetProcAddress(hx11drv, "WTInfoW");
TABLET_Register();
hwndDefault = CreateWindowW(WC_TABLETCLASSNAME, name,
WS_POPUPWINDOW,0,0,0,0,0,0,hInstDLL,0);
......
......@@ -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 (*pWTInfoW)(UINT wCategory, UINT nIndex, LPVOID lpOutput);
extern HWND hwndDefault;
extern CRITICAL_SECTION csTablet;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment