[gtk+] [quartz] Fix manual resizing of windows



commit 7e778aa033ad96a1a1ded0cd0780ce90befb4d9f
Author: Kristian Rietveld <kris lanedo com>
Date:   Sun Feb 19 16:08:26 2012 +0100

    [quartz] Fix manual resizing of windows
    
    In the Quartz backend, there are two methods by which windows are
    resized. The first method is fully handled by Quartz and does not appear
    in the event stream the application resizes. The second method is when
    we resize windows by ourselves. In OS X this happens when a GTK+ resize
    grip is used. This resize grip is larger than the Quartz resize grip.
    When the resize is started outside the "Quartz area", we have to handle
    it by ourselves.
    
    This patch fixes this manual window resizing by ignoring events while we
    are in the process of resizing (such that the events actually arrive at
    the sendEvent handler of GdkQuartzWindow where this resize is handled).
    When the resize has finished we break all grabs such that GDK is not
    stuck thinking the cursor is still in the resize window.

 gdk/quartz/GdkQuartzNSWindow.c |   10 ++++++++++
 gdk/quartz/GdkQuartzNSWindow.h |    1 +
 gdk/quartz/gdkevents-quartz.c  |    6 ++++++
 3 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c
index fafc2a8..76a759c 100644
--- a/gdk/quartz/GdkQuartzNSWindow.c
+++ b/gdk/quartz/GdkQuartzNSWindow.c
@@ -114,10 +114,15 @@
   switch ([event type])
     {
     case NSLeftMouseUp:
+    {
+      double time = ((double)[event timestamp]) * 1000.0;
+
+      _gdk_quartz_events_break_all_grabs (time);
       inManualMove = NO;
       inManualResize = NO;
       inMove = NO;
       break;
+    }
 
     case NSLeftMouseDragged:
       if ([self trackManualMove] || [self trackManualResize])
@@ -313,6 +318,11 @@
   return YES;
 }
 
+-(BOOL)isInManualResize
+{
+  return inManualResize;
+}
+
 -(void)beginManualMove
 {
   NSRect frame = [self frame];
diff --git a/gdk/quartz/GdkQuartzNSWindow.h b/gdk/quartz/GdkQuartzNSWindow.h
index df691ff..b456ff7 100644
--- a/gdk/quartz/GdkQuartzNSWindow.h
+++ b/gdk/quartz/GdkQuartzNSWindow.h
@@ -36,6 +36,7 @@
 -(BOOL)isInMove;
 -(void)beginManualMove;
 -(BOOL)trackManualMove;
+-(BOOL)isInManualResize;
 -(void)beginManualResize;
 -(BOOL)trackManualResize;
 -(void)showAndMakeKey:(BOOL)makeKey;
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 3cb249f..94064c0 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -1241,6 +1241,12 @@ gdk_event_translate (GdkEvent *event,
       return FALSE;
     }
 
+  /* Also when in a manual resize, we ignore events so that these are
+   * pushed to GdkQuartzWindow's sendEvent handler.
+   */
+  if ([(GdkQuartzWindow *)nswindow isInManualResize])
+    return FALSE;
+
   /* Find the right GDK window to send the event to, taking grabs and
    * event masks into consideration.
    */



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