Alexandre Julliard : user32: Use screen coordinates for hittest checking to handle RTL windows correctly .

Alexandre Julliard julliard at winehq.org
Fri Sep 24 11:43:45 CDT 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Sep 24 14:13:03 2010 +0200

user32: Use screen coordinates for hittest checking to handle RTL windows correctly.

---

 dlls/user32/nonclient.c |  100 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 68 insertions(+), 32 deletions(-)

diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c
index cc52f38..64c1186 100644
--- a/dlls/user32/nonclient.c
+++ b/dlls/user32/nonclient.c
@@ -527,8 +527,7 @@ LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt )
 
     TRACE("hwnd=%p pt=%d,%d\n", hwnd, pt.x, pt.y );
 
-    ScreenToClient( hwnd, &pt );
-    WIN_GetRectangles( hwnd, COORDS_CLIENT, &rect, &rcClient );
+    WIN_GetRectangles( hwnd, COORDS_SCREEN, &rect, &rcClient );
     if (!PtInRect( &rect, pt )) return HTNOWHERE;
 
     style = GetWindowLongW( hwnd, GWL_STYLE );
@@ -594,36 +593,81 @@ LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt )
         {
             BOOL min_or_max_box = (style & WS_MAXIMIZEBOX) ||
                                   (style & WS_MINIMIZEBOX);
-            /* Check system menu */
-            if ((style & WS_SYSMENU) && !(ex_style & WS_EX_TOOLWINDOW))
+            if (ex_style & WS_EX_LAYOUTRTL)
             {
-                if (NC_IconForWindow(hwnd)) rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
+                /* Check system menu */
+                if ((style & WS_SYSMENU) && !(ex_style & WS_EX_TOOLWINDOW) && NC_IconForWindow(hwnd))
+                {
+                    rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
+                    if (pt.x > rect.right) return HTSYSMENU;
+                }
+
+                /* Check close button */
+                if (style & WS_SYSMENU)
+                {
+                    rect.left += GetSystemMetrics(SM_CYCAPTION);
+                    if (pt.x < rect.left) return HTCLOSE;
+                }
+
+                /* Check maximize box */
+                /* In win95 there is automatically a Maximize button when there is a minimize one*/
+                if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
+                {
+                    rect.left += GetSystemMetrics(SM_CXSIZE);
+                    if (pt.x < rect.left) return HTMAXBUTTON;
+                }
+
+                /* Check minimize box */
+                if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
+                {
+                    rect.left += GetSystemMetrics(SM_CXSIZE);
+                    if (pt.x < rect.left) return HTMINBUTTON;
+                }
+            }
+            else
+            {
+                /* Check system menu */
+                if ((style & WS_SYSMENU) && !(ex_style & WS_EX_TOOLWINDOW) && NC_IconForWindow(hwnd))
+                {
+                    rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
+                    if (pt.x < rect.left) return HTSYSMENU;
+                }
+
+                /* Check close button */
+                if (style & WS_SYSMENU)
+                {
+                    rect.right -= GetSystemMetrics(SM_CYCAPTION);
+                    if (pt.x > rect.right) return HTCLOSE;
+                }
+
+                /* Check maximize box */
+                /* In win95 there is automatically a Maximize button when there is a minimize one*/
+                if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
+                {
+                    rect.right -= GetSystemMetrics(SM_CXSIZE);
+                    if (pt.x > rect.right) return HTMAXBUTTON;
+                }
+
+                /* Check minimize box */
+                if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
+                {
+                    rect.right -= GetSystemMetrics(SM_CXSIZE);
+                    if (pt.x > rect.right) return HTMINBUTTON;
+                }
             }
-            if (pt.x < rect.left) return HTSYSMENU;
-
-            /* Check close button */
-            if (style & WS_SYSMENU)
-                rect.right -= GetSystemMetrics(SM_CYCAPTION);
-            if (pt.x > rect.right) return HTCLOSE;
-
-            /* Check maximize box */
-            /* In win95 there is automatically a Maximize button when there is a minimize one*/
-            if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
-                rect.right -= GetSystemMetrics(SM_CXSIZE);
-            if (pt.x > rect.right) return HTMAXBUTTON;
-
-            /* Check minimize box */
-            /* In win95 there is automatically a Maximize button when there is a Maximize one*/
-            if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
-                rect.right -= GetSystemMetrics(SM_CXSIZE);
-
-            if (pt.x > rect.right) return HTMINBUTTON;
             return HTCAPTION;
         }
     }
 
+      /* Check menu bar */
+
+    if (HAS_MENU( hwnd, style ) && (pt.y < rcClient.top) &&
+        (pt.x >= rcClient.left) && (pt.x < rcClient.right))
+        return HTMENU;
+
       /* Check vertical scroll bar */
 
+    if (ex_style & WS_EX_LAYOUTRTL) ex_style ^= WS_EX_LEFTSCROLLBAR;
     if (style & WS_VSCROLL)
     {
         if((ex_style & WS_EX_LEFTSCROLLBAR) != 0)
@@ -649,14 +693,6 @@ LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt )
         }
     }
 
-      /* Check menu bar */
-
-    if (HAS_MENU( hwnd, style ))
-    {
-        if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rcClient.right))
-            return HTMENU;
-    }
-
     /* Has to return HTNOWHERE if nothing was found
        Could happen when a window has a customized non client area */
     return HTNOWHERE;




More information about the wine-cvs mailing list