[gtk+/client-side-windows: 267/284] Get the right event window for non-grabbed windows too
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-windows: 267/284] Get the right event window for non-grabbed windows too
- Date: Thu, 2 Apr 2009 14:24:20 -0400 (EDT)
commit 53b3343d1bc2ab88f8b1242adea64221694da257
Author: Richard Hult <richard imendio com>
Date: Wed Feb 4 10:41:22 2009 +0100
Get the right event window for non-grabbed windows too
---
gdk/quartz/gdkevents-quartz.c | 65 ++++++++++++++++++++++++++++++++--------
1 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index ad30e4b..5b93ad5 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -418,6 +418,33 @@ _gdk_quartz_events_send_map_event (GdkWindow *window)
}
}
+static GdkWindow *
+find_toplevel_under_pointer (GdkDisplay *display,
+ NSPoint screen_point,
+ gint *x,
+ gint *y)
+{
+ GdkWindow *toplevel;
+
+ toplevel = display->pointer_info.toplevel_under_pointer;
+ if (toplevel)
+ {
+ GdkWindowObject *private;
+ NSWindow *nswindow;
+ NSPoint point;
+
+ private = (GdkWindowObject *)toplevel;
+ nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
+
+ point = [nswindow convertScreenToBase:screen_point];
+
+ *x = point.x;
+ *y = private->height - point.y;
+ }
+
+ return toplevel;
+}
+
/* This function finds the correct window to send an event to, taking
* into account grabs, event propagation, and event masks.
*/
@@ -492,20 +519,17 @@ find_window_for_ns_event (NSEvent *nsevent,
* reported with respect to the key window, which could be
* wrong.
*/
- if (display->pointer_info.toplevel_under_pointer)
- {
- GdkWindowObject *pointer_private;
- NSWindow *pointer_nswindow;
-
- toplevel = display->pointer_info.toplevel_under_pointer;
- pointer_private = (GdkWindowObject *)toplevel;
- pointer_nswindow = ((GdkWindowImplQuartz *)pointer_private->impl)->toplevel;
-
- point = [pointer_nswindow convertScreenToBase:screen_point];
+ GdkWindow *toplevel_under_pointer;
+ gint x_tmp, y_tmp;
- /* Note: x_root and y_root are already right. */
- *x = point.x;
- *y = pointer_private->height - point.y;
+ toplevel_under_pointer = find_toplevel_under_pointer (display,
+ screen_point,
+ &x_tmp, &y_tmp);
+ if (toplevel_under_pointer)
+ {
+ toplevel = toplevel_under_pointer;
+ *x = x_tmp;
+ *y = y_tmp;
}
return toplevel;
@@ -535,6 +559,8 @@ find_window_for_ns_event (NSEvent *nsevent,
else
{
/* The non-grabbed case. */
+ GdkWindow *toplevel_under_pointer;
+ gint x_tmp, y_tmp;
/* Ignore all events but mouse moved that might be on the title
* bar (above the content view). The reason is that otherwise
@@ -547,6 +573,19 @@ find_window_for_ns_event (NSEvent *nsevent,
/* FIXME: Also need to leave resize events to cocoa somehow? */
+ /* As for owner events, we need to use the toplevel under the
+ * pointer, not the window from the NSEvent.
+ */
+ toplevel_under_pointer = find_toplevel_under_pointer (display,
+ screen_point,
+ &x_tmp, &y_tmp);
+ if (toplevel_under_pointer)
+ {
+ toplevel = toplevel_under_pointer;
+ *x = x_tmp;
+ *y = y_tmp;
+ }
+
return toplevel;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]