diff options
author | Alexander Larsson <alexl@redhat.com> | 2011-10-19 16:15:17 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2011-11-10 17:40:53 +0100 |
commit | 321acc3286289b94322b3799d993fd8781b3a306 (patch) | |
tree | 18ac3fa50d3cdda07964ba057b188e116b3877e8 /gdk/win32/gdkdevice-win32.c | |
parent | f0f7c07f4d5e47a7f63e51ce0d7539321a253ec7 (diff) | |
download | gtk+-321acc3286289b94322b3799d993fd8781b3a306.tar.gz |
win32: 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.
Diffstat (limited to 'gdk/win32/gdkdevice-win32.c')
-rw-r--r-- | gdk/win32/gdkdevice-win32.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c index 27bf807979..09ec36a150 100644 --- a/gdk/win32/gdkdevice-win32.c +++ b/gdk/win32/gdkdevice-win32.c @@ -384,6 +384,16 @@ gdk_device_win32_window_at_position (GdkDevice *device, 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)); } @@ -391,6 +401,12 @@ gdk_device_win32_window_at_position (GdkDevice *device, { 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) { @@ -406,13 +422,10 @@ gdk_device_win32_window_at_position (GdkDevice *device, 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; } return window; |