[gtk/gtk-3-24] Force a window resize if the content view frame changes.



commit 3a959e984f558d763db03f6bee53cc5bb9470a26
Author: John Ralls <jralls ceridwen us>
Date:   Sun Mar 17 10:15:30 2019 -0700

    Force a window resize if the content view frame changes.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1029
    
    Should fix most if not all other cases where system-caused changes to
    the NSWindow result in the Gdk coordinates not mapping correctly to the
    AppKit coordinates.

 gdk/quartz/GdkQuartzView.c    | 1 +
 gdk/quartz/gdkwindow-quartz.c | 9 +++++++++
 2 files changed, 10 insertions(+)
---
diff --git a/gdk/quartz/GdkQuartzView.c b/gdk/quartz/GdkQuartzView.c
index 72e305c5c4..193fcc1d31 100644
--- a/gdk/quartz/GdkQuartzView.c
+++ b/gdk/quartz/GdkQuartzView.c
@@ -33,6 +33,7 @@
       markedRange = NSMakeRange (NSNotFound, 0);
       selectedRange = NSMakeRange (0, 0);
     }
+  [self setValue: @(YES) forKey: @"postsFrameChangedNotifications"];
 
   return self;
 }
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 66c4a140c4..5918fc5fc1 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -208,6 +208,11 @@ gdk_window_impl_quartz_finalize (GObject *object)
   if (impl->transient_for)
     g_object_unref (impl->transient_for);
 
+  if (impl->view)
+    [[NSNotificationCenter defaultCenter] removeObserver: impl->toplevel
+                                       name: @"NSViewFrameDidChangeNotification"
+                                     object: impl->view];
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -909,6 +914,10 @@ _gdk_quartz_display_create_window_impl (GdkDisplay    *display,
        impl->view = [[GdkQuartzView alloc] initWithFrame:content_rect];
        [impl->view setGdkWindow:window];
        [impl->toplevel setContentView:impl->view];
+        [[NSNotificationCenter defaultCenter] addObserver: impl->toplevel
+                                      selector: @selector (windowDidResize:)
+                                      name: @"NSViewFrameDidChangeNotification"
+                                      object: impl->view];
        [impl->view release];
       }
       break;


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