summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hult <richard@imendio.com>2007-06-16 16:16:43 +0000
committerRichard Hult <rhult@src.gnome.org>2007-06-16 16:16:43 +0000
commit2902d87a22651c7d9e70cac2df90b09fbc6d65f9 (patch)
tree6c0485587518f095c949b9c5d783a5321b9ed0c9
parent4fd1fb4d9bc0ef2e3a18d7c60f99deb1d0c466a8 (diff)
downloadgdk-pixbuf-2902d87a22651c7d9e70cac2df90b09fbc6d65f9.tar.gz
Move the checks for no window or a non-GDK window from here...
2007-06-16 Richard Hult <richard@imendio.com> * gdk/quartz/gdkevents-quartz.c (find_mouse_window_for_ns_event): Move the checks for no window or a non-GDK window from here... (gdk_event_translate): ...to here. Reorder the code so that we detect the cases where we need to break grabs before bailing out. svn path=/trunk/; revision=18161
-rw-r--r--ChangeLog8
-rw-r--r--gdk/quartz/gdkevents-quartz.c53
2 files changed, 39 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index e8cc13742..e01716db3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2007-06-16 Richard Hult <richard@imendio.com>
+ * gdk/quartz/gdkevents-quartz.c (find_mouse_window_for_ns_event):
+ Move the checks for no window or a non-GDK window from here...
+ (gdk_event_translate): ...to here. Reorder the code so that we
+ detect the cases where we need to break grabs before bailing
+ out.
+
+2007-06-16 Richard Hult <richard@imendio.com>
+
* gdk/quartz/gdkevents-quartz.c (gdk_event_translate)
(break_all_grabs): Break out into a separate function.
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 6b4e67396..4d5aa49c3 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -1033,15 +1033,9 @@ find_window_for_ns_event (NSEvent *nsevent,
gint *x,
gint *y)
{
- NSWindow *nswindow = [nsevent window];
- NSEventType event_type = [nsevent type];
+ NSEventType event_type;
- if (!nswindow)
- return NULL;
-
- /* Window was not created by GDK so the event should be handled by Quartz. */
- if (![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
- return NULL;
+ event_type = [nsevent type];
/* Synthesize crossing events when moving between child
* windows. Toplevels are handled with NSMouseEntered and
@@ -1188,7 +1182,7 @@ find_window_for_ns_event (NSEvent *nsevent,
else
{
GdkWindowImplQuartz *impl;
-
+
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (event_toplevel)->impl);
y_tmp = impl->height - point.y;
}
@@ -1241,7 +1235,7 @@ find_window_for_ns_event (NSEvent *nsevent,
else
{
GdkWindowImplQuartz *impl;
-
+
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (event_toplevel)->impl);
y_tmp = impl->height - point.y;
}
@@ -1483,16 +1477,36 @@ _gdk_quartz_events_get_current_event_mask (void)
static gboolean
gdk_event_translate (NSEvent *nsevent)
{
+ NSWindow *nswindow;
GdkWindow *window;
GdkFilterReturn result;
GdkEvent *event;
int x, y;
- if (_gdk_default_filters)
+ /* There is no support for real desktop wide grabs, so we break
+ * grabs when the application loses focus (gets deactivated).
+ */
+ if ([nsevent type] == NSAppKitDefined)
{
- /* Apply global filters */
+ if ([nsevent subtype] == NSApplicationDeactivatedEventType)
+ break_all_grabs ();
+
+ /* This could potentially be used to break grabs when clicking
+ * on the title. The subtype 20 is undocumented so it's probably
+ * not a good idea: else if (subtype == 20) break_all_grabs ();
+ */
+ }
- GdkFilterReturn result = apply_filters (NULL, nsevent, _gdk_default_filters);
+ nswindow = [nsevent window];
+
+ /* Ignore events for no window or ones not created by GDK. */
+ if (!nswindow || ![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
+ return FALSE;
+
+ /* Apply any global filters. */
+ if (_gdk_default_filters)
+ {
+ result = apply_filters (NULL, nsevent, _gdk_default_filters);
/* If result is GDK_FILTER_CONTINUE, we continue as if nothing
* happened. If it is GDK_FILTER_REMOVE,
@@ -1502,20 +1516,15 @@ gdk_event_translate (NSEvent *nsevent)
return TRUE;
}
- /* Catch the case where the entire app loses focus, and break any grabs. */
- if ([nsevent type] == NSAppKitDefined)
- {
- if ([nsevent subtype] == NSApplicationDeactivatedEventType)
- break_all_grabs ();
- }
-
+ /* Find the right gdk window to send the event to, taking grabs and
+ * event masks into consideration.
+ */
window = find_window_for_ns_event (nsevent, &x, &y);
-
if (!window)
return FALSE;
+ /* Apply any window filters. */
result = apply_filters (window, nsevent, ((GdkWindowObject *) window)->filters);
-
if (result == GDK_FILTER_REMOVE)
return TRUE;