Make IsWindowUnicode work in the case when window belongs to another process

Dmitry Timoshkov dmitry at baikal.ru
Wed Jun 29 10:39:51 CDT 2005


Hello,

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Make IsWindowUnicode work in the case when window belongs
    to another process.

diff -up cvs/hq/wine/dlls/user/win.c wine/dlls/user/win.c
--- cvs/hq/wine/dlls/user/win.c	Tue Jun 28 17:49:55 2005
+++ wine/dlls/user/win.c	Wed Jun 29 23:47:14 2005
@@ -79,6 +79,7 @@ static WND *create_window_handle( HWND p
         req->owner    = owner;
         req->atom     = atom;
         req->instance = instance;
+        req->is_unicode = type == WIN_PROC_32W;
         if (!wine_server_call_err( req ))
         {
             handle = reply->handle;
@@ -1658,12 +1659,26 @@ BOOL WINAPI IsWindowEnabled(HWND hWnd)
 BOOL WINAPI IsWindowUnicode( HWND hwnd )
 {
     WND * wndPtr;
-    BOOL retvalue;
+    BOOL retvalue = FALSE;
+
+    if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
 
-    if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE;
     if (wndPtr == WND_DESKTOP) return TRUE;
-    retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W);
-    WIN_ReleasePtr( wndPtr );
+
+    if (wndPtr != WND_OTHER_PROCESS)
+    {
+        retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W);
+        WIN_ReleasePtr( wndPtr );
+    }
+    else
+    {
+        SERVER_START_REQ( get_window_info )
+        {
+            req->handle = hwnd;
+            if (!wine_server_call_err( req )) retvalue = reply->is_unicode;
+        }
+        SERVER_END_REQ;
+    }
     return retvalue;
 }
 
diff -up cvs/hq/wine/include/wine/server_protocol.h wine/include/wine/server_protocol.h
--- cvs/hq/wine/include/wine/server_protocol.h	Tue Jun 21 16:40:08 2005
+++ wine/include/wine/server_protocol.h	Wed Jun 29 23:37:39 2005
@@ -2480,6 +2480,7 @@ struct create_window_request
     user_handle_t  owner;
     atom_t         atom;
     void*          instance;
+    int            is_unicode;
 };
 struct create_window_reply
 {
@@ -2531,6 +2532,7 @@ struct get_window_info_reply
     process_id_t   pid;
     thread_id_t    tid;
     atom_t         atom;
+    int            is_unicode;
 };
 
 
diff -up cvs/hq/wine/server/trace.c wine/server/trace.c
--- cvs/hq/wine/server/trace.c	Tue Jun 21 16:40:10 2005
+++ wine/server/trace.c	Wed Jun 29 23:37:39 2005
@@ -2211,7 +2211,8 @@ static void dump_create_window_request( 
     fprintf( stderr, " parent=%p,", req->parent );
     fprintf( stderr, " owner=%p,", req->owner );
     fprintf( stderr, " atom=%04x,", req->atom );
-    fprintf( stderr, " instance=%p", req->instance );
+    fprintf( stderr, " instance=%p,", req->instance );
+    fprintf( stderr, " is_unicode=%d", req->is_unicode );
 }
 
 static void dump_create_window_reply( const struct create_window_reply *req )
@@ -2249,7 +2250,8 @@ static void dump_get_window_info_reply( 
     fprintf( stderr, " last_active=%p,", req->last_active );
     fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " tid=%04x,", req->tid );
-    fprintf( stderr, " atom=%04x", req->atom );
+    fprintf( stderr, " atom=%04x,", req->atom );
+    fprintf( stderr, " is_unicode=%d", req->is_unicode );
 }
 
 static void dump_set_window_info_request( const struct set_window_info_request *req )
diff -up cvs/hq/wine/server/window.c wine/server/window.c
--- cvs/hq/wine/server/window.c	Wed Jun  1 11:16:45 2005
+++ wine/server/window.c	Wed Jun 29 23:49:48 2005
@@ -73,6 +73,7 @@ struct window
     unsigned int     ex_style;        /* window extended style */
     unsigned int     id;              /* window id */
     void*            instance;        /* creator instance */
+    int              is_unicode;      /* ANSI or unicode */
     void*            user_data;       /* user-specific data */
     WCHAR           *text;            /* window caption text */
     unsigned int     paint_flags;     /* various painting flags */
@@ -324,7 +325,7 @@ static void destroy_window( struct windo
 
 /* create a new window structure (note: the window is not linked in the window tree) */
 static struct window *create_window( struct window *parent, struct window *owner,
-                                     atom_t atom, void *instance )
+                                     atom_t atom, void *instance, int is_unicode )
 {
     int extra_bytes;
     struct window *win;
@@ -352,6 +353,7 @@ static struct window *create_window( str
     win->ex_style       = 0;
     win->id             = 0;
     win->instance       = NULL;
+    win->is_unicode     = is_unicode;
     win->user_data      = NULL;
     win->text           = NULL;
     win->paint_flags    = 0;
@@ -1302,7 +1304,7 @@ DECL_HANDLER(create_window)
     {
         if (!top_window)
         {
-            if (!(top_window = create_window( NULL, NULL, req->atom, req->instance ))) return;
+            if (!(top_window = create_window( NULL, NULL, req->atom, req->instance, req->is_unicode ))) return;
             top_window->thread = NULL;  /* no thread owns the desktop */
             top_window->style  = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
         }
@@ -1321,7 +1323,7 @@ DECL_HANDLER(create_window)
             set_error( STATUS_ACCESS_DENIED );
             return;
         }
-        if (!(win = create_window( parent, owner, req->atom, req->instance ))) return;
+        if (!(win = create_window( parent, owner, req->atom, req->instance, req->is_unicode ))) return;
     }
     reply->handle    = win->handle;
     reply->extra     = win->nb_extra_bytes;
@@ -1389,6 +1391,7 @@ DECL_HANDLER(get_window_info)
     {
         reply->full_handle = win->handle;
         reply->last_active = win->handle;
+        reply->is_unicode = win->is_unicode;
         if (get_user_object( win->last_active, USER_WINDOW )) reply->last_active = win->last_active;
         if (win->thread)
         {






More information about the wine-patches mailing list