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

Dmitry Timoshkov dmitry at baikal.ru
Thu Jul 7 04:35:56 CDT 2005


Hello,

this time without DWLP_DLGPROC 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-07-07 18:26:29.000000000 +0900
@@ -1056,10 +1056,11 @@ static HWND WIN_CreateWindowEx( CREATEST
     SERVER_START_REQ( set_window_info )
     {
         req->handle    = hwnd;
-        req->flags     = SET_WIN_STYLE | SET_WIN_EXSTYLE | SET_WIN_INSTANCE;
+        req->flags     = SET_WIN_STYLE | SET_WIN_EXSTYLE | SET_WIN_INSTANCE | SET_WIN_UNICODE;
         req->style     = wndPtr->dwStyle;
         req->ex_style  = wndPtr->dwExStyle;
         req->instance  = (void *)wndPtr->hInstance;
+        req->is_unicode = (type == WIN_PROC_32W);
         req->extra_offset = -1;
         wine_server_call( req );
     }
@@ -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;
 }
 
@@ -1976,10 +1991,18 @@ static LONG_PTR WIN_SetWindowLong( HWND 
             return (ULONG_PTR)SetParent( hwnd, (HWND)newval );
         }
     case GWLP_WNDPROC:
+    {
+        WINDOWPROCTYPE old_type = WINPROC_GetProcType( wndPtr->winproc );
         retval = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, type );
         wndPtr->winproc = WINPROC_AllocProc( (WNDPROC)newval, type );
-        WIN_ReleasePtr( wndPtr );
-        return retval;
+        if (old_type == type)
+        {
+            WIN_ReleasePtr( wndPtr );
+            return retval;
+        }
+        /* update is_unicode flag on the server side */
+        break;
+    }
     case GWLP_ID:
     case GWLP_HINSTANCE:
     case GWLP_USERDATA:
@@ -2036,6 +2059,10 @@ static LONG_PTR WIN_SetWindowLong( HWND 
             req->flags = SET_WIN_INSTANCE;
             req->instance = (void *)newval;
             break;
+        case GWLP_WNDPROC:
+            req->flags = SET_WIN_UNICODE;
+            req->is_unicode = (type == WIN_PROC_32W);
+            break;
         case GWLP_USERDATA:
             req->flags = SET_WIN_USERDATA;
             req->user_data = (void *)newval;
@@ -2066,6 +2093,8 @@ static LONG_PTR WIN_SetWindowLong( HWND 
                 wndPtr->hInstance = (HINSTANCE)newval;
                 retval = (ULONG_PTR)reply->old_instance;
                 break;
+            case GWLP_WNDPROC:
+                break;
             case GWLP_USERDATA:
                 wndPtr->userdata = newval;
                 retval = (ULONG_PTR)reply->old_user_data;
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-07-07 18:15:45.000000000 +0900
@@ -1788,6 +1788,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
 
 
@@ -1799,6 +1800,7 @@ enum message_type
     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 */
     int            extra_offset;  /* offset to set in extra bytes */
     size_t         extra_size;    /* size to set in extra bytes */
@@ -1817,6 +1819,7 @@ enum message_type
 #define SET_WIN_INSTANCE  0x08
 #define SET_WIN_USERDATA  0x10
 #define SET_WIN_EXTRA     0x20
+#define SET_WIN_UNICODE   0x40
 
 
 /* Set the parent of a window */
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-07-07 18:16:00.000000000 +0900
@@ -2249,7 +2249,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 )
@@ -2260,6 +2261,7 @@ static void dump_set_window_info_request
     fprintf( stderr, " ex_style=%08x,", req->ex_style );
     fprintf( stderr, " id=%08x,", req->id );
     fprintf( stderr, " instance=%p,", req->instance );
+    fprintf( stderr, " is_unicode=%d,", req->is_unicode );
     fprintf( stderr, " user_data=%p,", req->user_data );
     fprintf( stderr, " extra_offset=%d,", req->extra_offset );
     fprintf( stderr, " extra_size=%d,", req->extra_size );
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-07-07 18:15:45.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 */
@@ -1393,6 +1394,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)
         {
@@ -1440,6 +1442,7 @@ DECL_HANDLER(set_window_info)
     if (req->flags & SET_WIN_EXSTYLE) win->ex_style = req->ex_style;
     if (req->flags & SET_WIN_ID) win->id = req->id;
     if (req->flags & SET_WIN_INSTANCE) win->instance = req->instance;
+    if (req->flags & SET_WIN_UNICODE) win->is_unicode = req->is_unicode;
     if (req->flags & SET_WIN_USERDATA) win->user_data = req->user_data;
     if (req->flags & SET_WIN_EXTRA) memcpy( win->extra_bytes + req->extra_offset,
                                             &req->extra_value, req->extra_size );






More information about the wine-patches mailing list