summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2009-09-25 17:23:54 +0200
committerKristian Rietveld <kris@gtk.org>2009-09-25 18:51:54 +0200
commitcdec2caaf3571dbaf0ccd52aab6a111b1bcb1307 (patch)
tree32e63e8e4e4010fffabe92ec6160b8490f6b1c3d
parent3bcf8b39fb7651cbdeaf356cbe829799cc0b1ed0 (diff)
downloadgtk+-cdec2caaf3571dbaf0ccd52aab6a111b1bcb1307.tar.gz
Send a motion-notify when a (new) main window became active
This motion-notify even will make sure that things like highlights are set up correctly now that the window has become active.
-rw-r--r--gdk/quartz/gdkwindow-quartz.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index bbff7fb90e..019201969e 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -747,13 +747,76 @@ _gdk_quartz_window_find_child (GdkWindow *window,
return NULL;
}
+
+static void
+generate_motion_event (GdkWindow *window)
+{
+ NSPoint point;
+ NSPoint screen_point;
+ NSWindow *nswindow;
+ GdkQuartzView *view;
+ GdkWindowObject *private;
+ GdkEvent *event;
+ gint x, y, x_root, y_root;
+ gdouble xx, yy;
+ GList *node;
+ GdkWindow *pointer_window;
+
+ event = gdk_event_new (GDK_MOTION_NOTIFY);
+ event->any.window = NULL;
+ event->any.send_event = TRUE;
+
+ private = (GdkWindowObject *)window;
+ nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
+ view = (GdkQuartzView *)[nswindow contentView];
+
+ screen_point = [NSEvent mouseLocation];
+
+ x_root = screen_point.x;
+ y_root = _gdk_quartz_window_get_inverted_screen_y (screen_point.y);
+
+ point = [nswindow convertScreenToBase:screen_point];
+
+ x = point.x;
+ y = private->height - point.y;
+
+ pointer_window = _gdk_window_find_descendant_at (window, x, y,
+ &xx, &yy);
+
+ event->any.type = GDK_MOTION_NOTIFY;
+ event->motion.window = window;
+ event->motion.time = GDK_CURRENT_TIME;
+ event->motion.x = x;
+ event->motion.y = y;
+ event->motion.x_root = x_root;
+ event->motion.y_root = y_root;
+ /* FIXME event->axes */
+ event->motion.state = 0;
+ event->motion.is_hint = FALSE;
+ event->motion.device = _gdk_display->core_pointer;
+
+ if (event->any.window)
+ g_object_ref (event->any.window);
+
+ node = _gdk_event_queue_append (gdk_display_get_default (), event);
+ _gdk_windowing_got_event (gdk_display_get_default (), node, event, 0);
+}
+
void
_gdk_quartz_window_did_become_main (GdkWindow *window)
{
main_window_stack = g_slist_remove (main_window_stack, window);
if (GDK_WINDOW_OBJECT (window)->window_type != GDK_WINDOW_TEMP)
- main_window_stack = g_slist_prepend (main_window_stack, window);
+ {
+ main_window_stack = g_slist_prepend (main_window_stack, window);
+
+ /* We just became the active window, send a motion-notify
+ * event so things like highlights get set up correctly.
+ * This motion-notify is sent to the key window.
+ */
+ generate_motion_event (window);
+ }
clear_toplevel_order ();
}