Alexandre Julliard : user32: Treat the top-level message window as a desktop window.

Alexandre Julliard julliard at winehq.org
Wed Jun 25 16:43:49 CDT 2008


Module: wine
Branch: master
Commit: 782403085f98423250c9286f7104c0191eb27234
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=782403085f98423250c9286f7104c0191eb27234

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun 25 15:20:26 2008 +0200

user32: Treat the top-level message window as a desktop window.

---

 dlls/user32/dialog.c  |    2 +-
 dlls/user32/focus.c   |    1 +
 dlls/user32/message.c |   10 ++++----
 dlls/user32/win.c     |   53 ++++++++++++++++++++++++++++++++++++++----------
 dlls/user32/win.h     |    2 +
 dlls/user32/winpos.c  |    2 +-
 6 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index a9867c6..444a73d 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1085,7 +1085,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
     if (CallMsgFilterW( msg, MSGF_DIALOGBOX )) return TRUE;
 
     hwndDlg = WIN_GetFullHandle( hwndDlg );
-    if (hwndDlg == GetDesktopWindow()) return FALSE;
+    if (is_desktop_window(hwndDlg)) return FALSE;
     if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE;
 
     hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index 2eb1496..3253a87 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -264,6 +264,7 @@ HWND WINAPI SetFocus( HWND hwnd )
             if (style & (WS_MINIMIZE | WS_DISABLED)) return 0;
             parent = GetAncestor( hwndTop, GA_PARENT );
             if (!parent || parent == GetDesktopWindow()) break;
+            if (parent == get_hwnd_message_parent()) return 0;
             hwndTop = parent;
         }
 
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 19b3935..6588f8e 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -1281,21 +1281,21 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
     case WM_WINE_DESTROYWINDOW:
         return WIN_DestroyWindow( hwnd );
     case WM_WINE_SETWINDOWPOS:
-        if (hwnd == GetDesktopWindow()) return 0;
+        if (is_desktop_window( hwnd )) return 0;
         return USER_SetWindowPos( (WINDOWPOS *)lparam );
     case WM_WINE_SHOWWINDOW:
-        if (hwnd == GetDesktopWindow()) return 0;
+        if (is_desktop_window( hwnd )) return 0;
         return ShowWindow( hwnd, wparam );
     case WM_WINE_SETPARENT:
-        if (hwnd == GetDesktopWindow()) return 0;
+        if (is_desktop_window( hwnd )) return 0;
         return (LRESULT)SetParent( hwnd, (HWND)wparam );
     case WM_WINE_SETWINDOWLONG:
         return WIN_SetWindowLong( hwnd, (short)LOWORD(wparam), HIWORD(wparam), lparam, TRUE );
     case WM_WINE_ENABLEWINDOW:
-        if (hwnd == GetDesktopWindow()) return 0;
+        if (is_desktop_window( hwnd )) return 0;
         return EnableWindow( hwnd, wparam );
     case WM_WINE_SETACTIVEWINDOW:
-        if (hwnd == GetDesktopWindow()) return 0;
+        if (is_desktop_window( hwnd )) return 0;
         return (LRESULT)SetActiveWindow( (HWND)wparam );
     case WM_WINE_KEYBOARD_LL_HOOK:
     case WM_WINE_MOUSE_LL_HOOK:
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 3e65a2f..3ba4d76 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -362,7 +362,7 @@ static void get_server_window_text( HWND hwnd, LPWSTR text, INT count )
  *
  * Return the parent for HWND_MESSAGE windows.
  */
-static HWND get_hwnd_message_parent(void)
+HWND get_hwnd_message_parent(void)
 {
     struct user_thread_info *thread_info = get_user_thread_info();
 
@@ -371,6 +371,28 @@ static HWND get_hwnd_message_parent(void)
 }
 
 
+/*******************************************************************
+ *           is_desktop_window
+ *
+ * Check if window is the desktop or the HWND_MESSAGE top parent.
+ */
+BOOL is_desktop_window( HWND hwnd )
+{
+    struct user_thread_info *thread_info = get_user_thread_info();
+
+    if (!hwnd) return FALSE;
+    if (hwnd == thread_info->top_window) return TRUE;
+    if (hwnd == thread_info->msg_window) return TRUE;
+
+    if (!HIWORD(hwnd) || HIWORD(hwnd) == 0xffff)
+    {
+        if (LOWORD(thread_info->top_window) == LOWORD(hwnd)) return TRUE;
+        if (LOWORD(thread_info->msg_window) == LOWORD(hwnd)) return TRUE;
+    }
+    return FALSE;
+}
+
+
 /***********************************************************************
  *           WIN_GetPtr
  *
@@ -393,11 +415,7 @@ WND *WIN_GetPtr( HWND hwnd )
             return ptr;
         ptr = NULL;
     }
-    else if (index == USER_HANDLE_TO_INDEX(GetDesktopWindow()))
-    {
-        if (hwnd == GetDesktopWindow() || !HIWORD(hwnd) || HIWORD(hwnd) == 0xffff) ptr = WND_DESKTOP;
-        else ptr = NULL;
-    }
+    else if (is_desktop_window( hwnd )) ptr = WND_DESKTOP;
     else ptr = WND_OTHER_PROCESS;
     USER_Unlock();
     return ptr;
@@ -454,7 +472,11 @@ HWND WIN_Handle32( HWND16 hwnd16 )
 
     if (!(ptr = WIN_GetPtr( hwnd ))) return hwnd;
 
-    if (ptr == WND_DESKTOP) return GetDesktopWindow();
+    if (ptr == WND_DESKTOP)
+    {
+        if (LOWORD(hwnd) == LOWORD(GetDesktopWindow())) return GetDesktopWindow();
+        else return get_hwnd_message_parent();
+    }
 
     if (ptr != WND_OTHER_PROCESS)
     {
@@ -569,8 +591,16 @@ BOOL WIN_GetRectangles( HWND hwnd, RECT *rectWindow, RECT *rectClient )
     {
         RECT rect;
         rect.left = rect.top = 0;
-        rect.right  = GetSystemMetrics(SM_CXSCREEN);
-        rect.bottom = GetSystemMetrics(SM_CYSCREEN);
+        if (hwnd == get_hwnd_message_parent())
+        {
+            rect.right  = 100;
+            rect.bottom = 100;
+        }
+        else
+        {
+            rect.right  = GetSystemMetrics(SM_CXSCREEN);
+            rect.bottom = GetSystemMetrics(SM_CYSCREEN);
+        }
         if (rectWindow) *rectWindow = rect;
         if (rectClient) *rectClient = rect;
     }
@@ -1431,7 +1461,7 @@ BOOL WINAPI DestroyWindow( HWND hwnd )
 {
     BOOL is_child;
 
-    if (!(hwnd = WIN_IsCurrentThread( hwnd )) || (hwnd == GetDesktopWindow()))
+    if (!(hwnd = WIN_IsCurrentThread( hwnd )) || is_desktop_window( hwnd ))
     {
         SetLastError( ERROR_ACCESS_DENIED );
         return FALSE;
@@ -2609,7 +2639,8 @@ HWND WINAPI GetAncestor( HWND hwnd, UINT type )
         break;
 
     case GA_ROOTOWNER:
-        if ((ret = WIN_GetFullHandle( hwnd )) == GetDesktopWindow()) return 0;
+        if (is_desktop_window( hwnd )) return 0;
+        ret = WIN_GetFullHandle( hwnd );
         for (;;)
         {
             HWND parent = GetParent( ret );
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index 5e7a67e..bc024f4 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -76,6 +76,8 @@ typedef struct tagWND
 #define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0080 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */
 
   /* Window functions */
+extern HWND get_hwnd_message_parent(void) DECLSPEC_HIDDEN;
+extern BOOL is_desktop_window( HWND hwnd ) DECLSPEC_HIDDEN;
 extern WND *WIN_GetPtr( HWND hwnd ) DECLSPEC_HIDDEN;
 extern HWND WIN_Handle32( HWND16 hwnd16 ) DECLSPEC_HIDDEN;
 extern HWND WIN_IsCurrentProcess( HWND hwnd ) DECLSPEC_HIDDEN;
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index aeea354..7398152 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -2100,7 +2100,7 @@ HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
           hdwp, hwnd, hwndAfter, x, y, cx, cy, flags);
 
     hwnd = WIN_GetFullHandle( hwnd );
-    if (hwnd == GetDesktopWindow()) return 0;
+    if (is_desktop_window( hwnd )) return 0;
 
     if (!(pDWP = USER_HEAP_LIN_ADDR( hdwp ))) return 0;
 




More information about the wine-cvs mailing list