Make IsWindowUnicode work in the case when window belongs to another processIsWindowUnicode work in the case when window belongs to another process. Take 3
Dmitry Timoshkov
dmitry at baikal.ru
Wed Jul 6 00:28:26 CDT 2005
Hello,
here is another attempt to make it work and minimize changes to
the server protocol as much as possible.
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 Jul 6 14:10:27 2005
@@ -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:
@@ -1987,11 +2010,18 @@ static LONG_PTR WIN_SetWindowLong( HWND
case DWLP_DLGPROC:
if ((wndPtr->cbWndExtra + sizeof(LONG_PTR) >= DWLP_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
{
+ WINDOWPROCTYPE old_type;
WNDPROC *ptr = (WNDPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
+ old_type = WINPROC_GetProcType( *ptr );
retval = (ULONG_PTR)WINPROC_GetProc( *ptr, type );
*ptr = 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;
}
/* fall through */
default:
@@ -2036,6 +2066,11 @@ static LONG_PTR WIN_SetWindowLong( HWND
req->flags = SET_WIN_INSTANCE;
req->instance = (void *)newval;
break;
+ case GWLP_WNDPROC:
+ case DWLP_DLGPROC:
+ 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;
@@ -2065,6 +2100,9 @@ static LONG_PTR WIN_SetWindowLong( HWND
case GWLP_HINSTANCE:
wndPtr->hInstance = (HINSTANCE)newval;
retval = (ULONG_PTR)reply->old_instance;
+ break;
+ case GWLP_WNDPROC:
+ case DWLP_DLGPROC:
break;
case GWLP_USERDATA:
wndPtr->userdata = newval;
diff -up cvs/hq/wine/server/protocol.def wine/server/protocol.def
--- cvs/hq/wine/server/protocol.def Tue Jun 21 16:40:09 2005
+++ wine/server/protocol.def Wed Jul 6 13:50:10 2005
@@ -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 Tue Jun 21 16:40:10 2005
+++ wine/server/trace.c Wed Jul 6 13:50:23 2005
@@ -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 Sat Jul 2 22:07:06 2005
+++ wine/server/window.c Wed Jul 6 13:54:37 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 */
@@ -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