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

Dmitry Timoshkov dmitry at baikal.ru
Thu Jun 30 02:23:58 CDT 2005


Hello,

this time re-diff'ed against current CVS and with protocol.def changes.

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	2005-06-28 17:49:55.000000000 +0900
+++ wine/dlls/user/win.c	2005-06-30 15:57:08.000000000 +0900
@@ -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/server/protocol.def wine/server/protocol.def
--- cvs/hq/wine/server/protocol.def	2005-06-21 16:40:09.000000000 +0900
+++ wine/server/protocol.def	2005-06-30 16:03:33.000000000 +0900
@@ -1756,6 +1756,7 @@ enum message_type
     user_handle_t  owner;       /* owner window */
     atom_t         atom;        /* class atom */
     void*          instance;    /* module instance */
+    int            is_unicode;  /* ANSI or unicode */
 @REPLY
     user_handle_t  handle;      /* created window */
     int            extra;       /* number of extra bytes */
@@ -1788,6 +1789,7 @@ enum message_type
     process_id_t   pid;         /* process owning the window */
     thread_id_t    tid;         /* thread owning the window */
     atom_t         atom;        /* class atom */
+    int            is_unicode;  /* ANSI or unicode */
 @END
 
 
diff -up cvs/hq/wine/server/trace.c wine/server/trace.c
--- cvs/hq/wine/server/trace.c	2005-06-21 16:40:10.000000000 +0900
+++ wine/server/trace.c	2005-06-30 16:03:50.000000000 +0900
@@ -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	2005-06-29 15:33:45.000000000 +0900
+++ wine/server/window.c	2005-06-30 15:58:07.000000000 +0900
@@ -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 */
@@ -326,7 +327,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;
@@ -354,6 +355,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;
@@ -1305,7 +1307,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;
             current->desktop_users--;
             top_window->thread = NULL;  /* no thread owns the desktop */
             top_window->style  = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
@@ -1325,7 +1327,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;
@@ -1393,6 +1395,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