Jacek Caban : winex11: Avoid using kernel32 functions in user driver.

Alexandre Julliard julliard at winehq.org
Wed May 4 16:14:45 CDT 2022


Module: wine
Branch: master
Commit: a34669b238b121313b6c3aecdcb1a1fbc231e8a6
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a34669b238b121313b6c3aecdcb1a1fbc231e8a6

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon May  2 20:00:27 2022 +0200

winex11: Avoid using kernel32 functions in user driver.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/wintab.c      |  6 +++---
 dlls/winex11.drv/x11drv_main.c |  3 ++-
 dlls/winex11.drv/xim.c         | 25 +++++++++++++------------
 dlls/winex11.drv/xrender.c     |  6 +++---
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index edd6fb8d271..44d9c7698aa 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -736,7 +736,7 @@ NTSTATUS x11drv_tablet_load_info( void *hwnd )
                         Button = (XButtonInfoPtr) any;
                         TRACE("    ButtonInput %d: [class %d|length %d|num_buttons %d]\n",
                                 class_loop, (int) Button->class, Button->length, Button->num_buttons);
-                        cursor.BTNNAMES = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*cchBuf);
+                        cursor.BTNNAMES = malloc( sizeof(WCHAR) * cchBuf );
                         for (i = 0; i < cursor.BUTTONS; i++)
                         {
                             /* FIXME - these names are probably incorrect */
@@ -744,14 +744,14 @@ NTSTATUS x11drv_tablet_load_info( void *hwnd )
                             while (cch > cchBuf - cchPos - 1) /* we want one extra byte for the last NUL */
                             {
                                 cchBuf *= 2;
-                                cursor.BTNNAMES = HeapReAlloc(GetProcessHeap(), 0, cursor.BTNNAMES, sizeof(WCHAR)*cchBuf);
+                                cursor.BTNNAMES = realloc( cursor.BTNNAMES, sizeof(WCHAR) * cchBuf );
                             }
 
                             strcpyW(cursor.BTNNAMES + cchPos, cursor.NAME);
                             cchPos += cch;
                         }
                         cursor.BTNNAMES[cchPos++] = 0;
-                        cursor.BTNNAMES = HeapReAlloc(GetProcessHeap(), 0, cursor.BTNNAMES, sizeof(WCHAR)*cchPos);
+                        cursor.BTNNAMES = realloc( cursor.BTNNAMES, sizeof(WCHAR)*cchPos );
                         cursor.cchBTNNAMES = cchPos;
                     }
                     break;
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index f05885c316a..5347bc7c1a5 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <sys/time.h>
 #include <unistd.h>
+#include <assert.h>
 #include <dlfcn.h>
 #include <X11/cursorfont.h>
 #include <X11/Xlib.h>
@@ -293,7 +294,7 @@ static int error_handler( Display *display, XErrorEvent *error_evt )
     {
         ERR( "X protocol error: serial=%ld, request_code=%d - breaking into debugger\n",
              error_evt->serial, error_evt->request_code );
-        DebugBreak();  /* force an entry in the debugger */
+        assert( 0 );
     }
     old_error_handler( display, error_evt );
     return 0;
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
index 81f420891ad..4b63a24cccf 100644
--- a/dlls/winex11.drv/xim.c
+++ b/dlls/winex11.drv/xim.c
@@ -72,13 +72,7 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset,
 
     if (byte_expansion + dwCompStringLength >= dwCompStringSize)
     {
-        if (CompositionString)
-            ptr_new = HeapReAlloc(GetProcessHeap(), 0, CompositionString,
-                                  dwCompStringSize + byte_expansion);
-        else
-            ptr_new = HeapAlloc(GetProcessHeap(), 0,
-                                dwCompStringSize + byte_expansion);
-
+        ptr_new = realloc( CompositionString, dwCompStringSize + byte_expansion );
         if (ptr_new == NULL)
         {
             ERR("Couldn't expand composition string buffer\n");
@@ -150,7 +144,7 @@ static void XIMPreEditDoneCallback(XIC ic, XPointer client_data, XPointer call_d
     TRACE("PreeditDoneCallback %p\n",ic);
     ximInComposeMode = FALSE;
     if (dwCompStringSize)
-        HeapFree(GetProcessHeap(), 0, CompositionString);
+        free( CompositionString );
     dwCompStringSize = 0;
     dwCompStringLength = 0;
     CompositionString = NULL;
@@ -464,17 +458,24 @@ XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
     XIC xic;
     XICCallback destroy = {(XPointer)data, X11DRV_DestroyIC};
     XICCallback P_StateNotifyCB, P_StartCB, P_DoneCB, P_DrawCB, P_CaretCB;
-    LANGID langid = PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale()));
+    LCID lcid;
     Window win = data->whole_window;
     XFontSet fontSet = x11drv_thread_data()->font_set;
 
     TRACE("xim = %p\n", xim);
 
+    lcid = NtCurrentTeb()->CurrentLocale;
+    if (!lcid) NtQueryDefaultLocale( TRUE, &lcid );
+
     /* use complex and slow XIC initialization method only for CJK */
-    if (langid != LANG_CHINESE &&
-        langid != LANG_JAPANESE &&
-        langid != LANG_KOREAN)
+    switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
     {
+    case LANG_CHINESE:
+    case LANG_JAPANESE:
+    case LANG_KOREAN:
+        break;
+
+    default:
         xic = XCreateIC(xim,
                         XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                         XNClientWindow, win,
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 2a694794397..33725338f60 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -774,7 +774,7 @@ static AA_Type aa_type_from_flags( UINT aa_flags )
 
 static UINT get_xft_aa_flags( const LOGFONTW *lf )
 {
-    char *value;
+    char *value, *p;
     UINT ret = 0;
 
     switch (lf->lfQuality)
@@ -785,8 +785,8 @@ static UINT get_xft_aa_flags( const LOGFONTW *lf )
     default:
         if (!(value = XGetDefault( gdi_display, "Xft", "antialias" ))) break;
         TRACE( "got antialias '%s'\n", value );
-        if (tolower(value[0]) == 'f' || tolower(value[0]) == 'n' ||
-            value[0] == '0' || !_strnicmp( value, "off", -1 ))
+        for (p = value; *p; p++) if ('A' <= *p && *p <= 'Z') *p += 'a' - 'A'; /* to lower */
+        if (value[0] == 'f' || value[0] == 'n' || value[0] == '0' || !strcmp( value, "off" ))
         {
             ret = GGO_BITMAP;
             break;




More information about the wine-cvs mailing list