[gtk+/gtk-2-24] quartz: delay emission of EnterNotify until window position is known



commit 860499ce90a6f184181f2e7249871e2514c83e00
Author: Kristian Rietveld <kris lanedo com>
Date:   Sun Jun 3 15:19:27 2012 +0200

    quartz: delay emission of EnterNotify until window position is known
    
    Beforehand, the check whether or not emission is necessary was done
    based on the "uninitialized" window position in the top left corner.
    We now wait until the window size is set for the first time, to avoid
    emitting EnterNotify when it is not necessary.

 gdk/quartz/GdkQuartzView.c   |    9 ---------
 gdk/quartz/GdkQuartzWindow.c |   22 ++++++++++++++++++++++
 gdk/quartz/GdkQuartzWindow.h |    1 +
 3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzView.c b/gdk/quartz/GdkQuartzView.c
index 2c897fb..5606b99 100644
--- a/gdk/quartz/GdkQuartzView.c
+++ b/gdk/quartz/GdkQuartzView.c
@@ -154,15 +154,6 @@
                                  owner:self
                               userData:nil
                           assumeInside:NO];
-
-  if (NSPointInRect ([[self window] convertScreenToBase:[NSEvent mouseLocation]], rect))
-    {
-      /* When a new window (and thus view) has been created, and the mouse
-       * is in the window area, we will not receive an NSMouseEntered
-       * event.  Therefore, we synthesize an enter notify event manually.
-       */
-      _gdk_quartz_events_send_enter_notify_event (gdk_window);
-    }
 }
 
 -(void)viewDidMoveToWindow
diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c
index f7593ba..06d11cf 100644
--- a/gdk/quartz/GdkQuartzWindow.c
+++ b/gdk/quartz/GdkQuartzWindow.c
@@ -142,6 +142,24 @@
   return inMove;
 }
 
+-(void)checkSendEnterNotify
+{
+  /* When a new window has been created, and the mouse
+   * is in the window area, we will not receive an NSMouseEntered
+   * event.  Therefore, we synthesize an enter notify event manually.
+   */
+  if (!initialPositionKnown)
+    {
+      initialPositionKnown = YES;
+
+      if (NSPointInRect ([NSEvent mouseLocation], [self frame]))
+        {
+          GdkWindow *window = [[self contentView] gdkWindow];
+          _gdk_quartz_events_send_enter_notify_event (window);
+        }
+    }
+}
+
 -(void)windowDidMove:(NSNotification *)aNotification
 {
   GdkWindow *window = [[self contentView] gdkWindow];
@@ -159,6 +177,8 @@
   event->configure.height = private->height;
 
   _gdk_event_queue_append (gdk_display_get_default (), event);
+
+  [self checkSendEnterNotify];
 }
 
 -(void)windowDidResize:(NSNotification *)aNotification
@@ -189,6 +209,8 @@
   event->configure.height = private->height;
 
   _gdk_event_queue_append (gdk_display_get_default (), event);
+
+  [self checkSendEnterNotify];
 }
 
 -(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag screen:(NSScreen *)screen
diff --git a/gdk/quartz/GdkQuartzWindow.h b/gdk/quartz/GdkQuartzWindow.h
index 974e572..9cdee6b 100644
--- a/gdk/quartz/GdkQuartzWindow.h
+++ b/gdk/quartz/GdkQuartzWindow.h
@@ -25,6 +25,7 @@
 @interface GdkQuartzWindow : NSWindow {
   BOOL    inMove;
   BOOL    inShowOrHide;
+  BOOL    initialPositionKnown;
 
   /* Manually triggered move/resize (not by the window manager) */
   BOOL    inManualMove;



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