[gtk+/gtk-2-24-win32: 2/5] in window_at_pointer, ensure that we handle non-client areas correctly



commit b34ff7b3eafb553d26dd892dd110004bf31dd0eb
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Oct 19 16:15:17 2011 +0200

    in window_at_pointer, ensure that we handle non-client areas correctly
    
    We should not return a window if the pointer is in the non-client area,
    like the titlebar.

 gdk/win32/gdkwindow-win32.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index d895262..5eca45d 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -2581,6 +2581,16 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
         screen_to_client (hwnd, screen_pt, &client_pt);
         hwndc = ChildWindowFromPointEx (hwnd, client_pt, CWP_SKIPDISABLED  |
                                                          CWP_SKIPINVISIBLE);
+
+	/* Verify that we're really inside the client area of the window */
+	if (hwndc != hwnd)
+	  {
+	    GetClientRect (hwndc, &rect);
+	    screen_to_client (hwndc, screen_pt, &client_pt);
+	    if (!PtInRect (&rect, client_pt))
+	      hwndc = hwnd;
+	  }
+
       } while (hwndc != hwnd && (hwnd = hwndc, 1));
 
     }
@@ -2588,6 +2598,12 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
     {
       hwnd = WindowFromPoint (screen_pt);
 
+      /* Verify that we're really inside the client area of the window */
+      GetClientRect (hwnd, &rect);
+      screen_to_client (hwnd, screen_pt, &client_pt);
+      if (!PtInRect (&rect, client_pt))
+	hwnd = NULL;
+
       /* If we didn't hit any window at that point, return the desktop */
       if (hwnd == NULL)
         {
@@ -2603,13 +2619,10 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
 
   if (window && (win_x || win_y))
     {
-      screen_to_client (hwnd, screen_pt, &client_pt);
-      GetClientRect (hwnd, &rect);
-
       if (win_x)
-        *win_x = client_pt.x - rect.left;
+        *win_x = client_pt.x;
       if (win_y)
-        *win_y = client_pt.y - rect.top;
+        *win_y = client_pt.y;
     }
 
   GDK_NOTE (MISC, g_print ("_gdk_windowing_window_at_pointer: %+d%+d %p%s\n",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]