gtk+ r19639 - in branches/gtk-2-12: . gdk/quartz



Author: rhult
Date: Sun Feb 24 17:59:01 2008
New Revision: 19639
URL: http://svn.gnome.org/viewvc/gtk+?rev=19639&view=rev

Log:
2008-02-24  Richard Hult  <richard imendio com>

	Merged from trunk:

	* gdk/quartz/gdkprivate-quartz.h:
	* gdk/quartz/gdkeventloop-quartz.c: (got_fd_activity), (poll_func):
	Use the subtype field for the custom event that is used to wake up
	the mainloop so we can have other custom event types.

	* gdk/quartz/gdkevents-quartz.c:
	(_gdk_quartz_events_trigger_crossing_events):
	* gdk/quartz/gdkwindow-quartz.c: (show_window_internal): Create
	crossing events after showing a window if necessary, to work
	around problems with the tracking rect API.


Modified:
   branches/gtk-2-12/ChangeLog
   branches/gtk-2-12/gdk/quartz/gdkeventloop-quartz.c
   branches/gtk-2-12/gdk/quartz/gdkevents-quartz.c
   branches/gtk-2-12/gdk/quartz/gdkprivate-quartz.h
   branches/gtk-2-12/gdk/quartz/gdkwindow-quartz.c

Modified: branches/gtk-2-12/gdk/quartz/gdkeventloop-quartz.c
==============================================================================
--- branches/gtk-2-12/gdk/quartz/gdkeventloop-quartz.c	(original)
+++ branches/gtk-2-12/gdk/quartz/gdkeventloop-quartz.c	Sun Feb 24 17:59:01 2008
@@ -139,7 +139,7 @@
 	                    timestamp: 0
 	                 windowNumber: 0
 	                      context: nil
-	                      subtype: 0
+                              subtype: GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP
 	                        data1: 0 
 	                        data2: 0];
 
@@ -253,7 +253,8 @@
   
   if (event)
     {
-      if ([event type] == NSApplicationDefined)
+      if ([event type] == NSApplicationDefined &&
+          [event subtype] == GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP)
         {
           pthread_mutex_lock (&pollfd_mutex);
 

Modified: branches/gtk-2-12/gdk/quartz/gdkevents-quartz.c
==============================================================================
--- branches/gtk-2-12/gdk/quartz/gdkevents-quartz.c	(original)
+++ branches/gtk-2-12/gdk/quartz/gdkevents-quartz.c	Sun Feb 24 17:59:01 2008
@@ -1079,6 +1079,64 @@
   return mouse_window;
 }
 
+/* Trigger crossing events if necessary. This is used when showing a new
+ * window, since the tracking rect API doesn't work reliably when a window
+ * shows up under the mouse cursor. It's done by finding the topmost window
+ * under the mouse pointer and synthesizing crossing events into that
+ * window.
+ */
+void
+_gdk_quartz_events_trigger_crossing_events (void)
+{
+  NSPoint point;
+  gint x; 
+  gint y;
+  GdkWindow *mouse_window;
+  GdkWindowImplQuartz *impl;
+  NSUInteger flags = 0;
+  NSTimeInterval timestamp = 0;
+  NSEvent *current_event;
+  NSEvent *nsevent;
+
+  point = [NSEvent mouseLocation];
+  x = point.x;
+  y = _gdk_quartz_window_get_inverted_screen_y (point.y);
+
+  mouse_window = _gdk_quartz_window_find_child (_gdk_root, x, y);
+  if (mouse_window == _gdk_root)
+    return;
+
+  /* NSMouseEntered always happens on the toplevel. */
+  mouse_window = gdk_window_get_toplevel (mouse_window);
+
+  get_converted_window_coordinates (_gdk_root,
+                                    x, y,
+                                    mouse_window,
+                                    &x, &y);
+
+  impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (mouse_window)->impl);
+
+  /* Fix up the event to be less fake if possible. */
+  current_event = [NSApp currentEvent];
+  if (current_event)
+    {
+      flags = [current_event modifierFlags];
+      timestamp = [current_event timestamp];
+    }
+
+  nsevent = [NSEvent otherEventWithType:NSApplicationDefined
+                               location:NSMakePoint(x, impl->height - y)
+                          modifierFlags:flags
+                              timestamp:timestamp
+                           windowNumber:[impl->toplevel windowNumber]
+                                context:nil
+                                subtype:GDK_QUARTZ_EVENT_SUBTYPE_FAKE_CROSSING
+                                  data1:0
+                                  data2:0];
+
+  synthesize_crossing_events (mouse_window, GDK_CROSSING_NORMAL, nsevent, x, y);
+}
+
 /* Synthesizes crossing events if necessary, based on the passed in
  * NSEvent. Uses NSMouseEntered and NSMouseExisted for toplevels and
  * the mouse moved/dragged events for child windows, to see if the

Modified: branches/gtk-2-12/gdk/quartz/gdkprivate-quartz.h
==============================================================================
--- branches/gtk-2-12/gdk/quartz/gdkprivate-quartz.h	(original)
+++ branches/gtk-2-12/gdk/quartz/gdkprivate-quartz.h	Sun Feb 24 17:59:01 2008
@@ -146,6 +146,11 @@
 void       _gdk_quartz_window_did_resign_main       (GdkWindow *window);
 
 /* Events */
+typedef enum {
+  GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP,
+  GDK_QUARTZ_EVENT_SUBTYPE_FAKE_CROSSING
+} GdkQuartzEventSubType;
+
 void         _gdk_quartz_events_update_focus_window    (GdkWindow *new_window,
                                                         gboolean   got_focus);
 GdkWindow *  _gdk_quartz_events_get_mouse_window       (gboolean   consider_grabs);
@@ -153,6 +158,7 @@
 void         _gdk_quartz_events_update_cursor          (GdkWindow *window);
 void         _gdk_quartz_events_send_map_events        (GdkWindow *window);
 GdkEventMask _gdk_quartz_events_get_current_event_mask (void);
+void         _gdk_quartz_events_trigger_crossing_events(void);
 
 extern GdkWindow *_gdk_quartz_keyboard_grab_window;
 extern GdkWindow *_gdk_quartz_pointer_grab_window;

Modified: branches/gtk-2-12/gdk/quartz/gdkwindow-quartz.c
==============================================================================
--- branches/gtk-2-12/gdk/quartz/gdkwindow-quartz.c	(original)
+++ branches/gtk-2-12/gdk/quartz/gdkwindow-quartz.c	Sun Feb 24 17:59:01 2008
@@ -1006,6 +1006,9 @@
   if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for))
     _gdk_quartz_window_attach_to_parent (window);
 
+  if (impl->toplevel)
+    _gdk_quartz_events_trigger_crossing_events ();
+
   GDK_QUARTZ_RELEASE_POOL;
 }
 
@@ -1103,9 +1106,6 @@
 
   if (impl->toplevel) 
     {
-      NSRect content_rect;
-      NSRect frame_rect;
-
      /* Update main window. */
       main_window_stack = g_slist_remove (main_window_stack, window);
       if ([NSApp mainWindow] == impl->toplevel)



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