[gtk/wip/chergert/macos-fix-fullscreen] macos: allow windows to enter fullscreen




commit 592436503cadbdf52f5012c8a93bb99d7d1fa36a
Author: Christian Hergert <christian hergert me>
Date:   Fri Feb 18 01:52:48 2022 -0800

    macos: allow windows to enter fullscreen
    
    This fixes GTK's NSWindow for toplevels so that they are allowed to enter
    fullscreen. We were already handlign the state transitions from the
    setStyleMask: halper, but we didn't previously tell the window we are
    allowed to transition into that.
    
    There is a bit of a mismatch here in that GTK doesn't have any such flag
    that determines if a window is "allowed" by policy to enter fullscreen
    since window managers on Linux are free to do that at will.

 gdk/macos/GdkMacosWindow.c          | 16 ++++++++++++++++
 gdk/macos/gdkmacostoplevelsurface.c |  3 +++
 2 files changed, 19 insertions(+)
---
diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c
index a30d1b71a1..deea0477f7 100644
--- a/gdk/macos/GdkMacosWindow.c
+++ b/gdk/macos/GdkMacosWindow.c
@@ -804,12 +804,28 @@ typedef NSString *CALayerContentsGravity;
   lastUnfullscreenFrame = [self frame];
 }
 
+-(void)windowDidEnterFullScreen:(NSNotification *)aNotification
+{
+  initialPositionKnown = NO;
+  [self checkSendEnterNotify];
+}
+
 -(void)windowWillExitFullScreen:(NSNotification *)aNotification
 {
   [self setFrame:lastUnfullscreenFrame display:YES];
 }
 
 -(void)windowDidExitFullScreen:(NSNotification *)aNotification
+{
+  initialPositionKnown = NO;
+  [self checkSendEnterNotify];
+}
+
+-(void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
+{
+}
+
+-(void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
 {
 }
 
diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c
index 17b1cec708..a14644fceb 100644
--- a/gdk/macos/gdkmacostoplevelsurface.c
+++ b/gdk/macos/gdkmacostoplevelsurface.c
@@ -646,6 +646,9 @@ _gdk_macos_toplevel_surface_new (GdkMacosDisplay *display,
                                                  defer:NO
                                                 screen:screen];
 
+  /* Allow NSWindow to go fullscreen */
+  [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+
   self = g_object_new (GDK_TYPE_MACOS_TOPLEVEL_SURFACE,
                        "display", display,
                        "frame-clock", frame_clock,


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