[gtk/wip/chergert/quartz4u] start on fullscreen and decorated state



commit f6ad9634f9249ccf5778c364509cfd73ffefe352
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 30 12:51:01 2020 -0700

    start on fullscreen and decorated state

 gdk/macos/GdkMacosWindow.c          | 25 +++++++++++++++++
 gdk/macos/GdkMacosWindow.h          |  1 +
 gdk/macos/gdkmacossurface-private.h | 55 +++++++++++++++++++------------------
 gdk/macos/gdkmacossurface.c         | 32 +++++++++++++++++++++
 gdk/macos/gdkmacostoplevelsurface.c |  4 +--
 5 files changed, 88 insertions(+), 29 deletions(-)
---
diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c
index 7ecd71c9bd..70b781c0b0 100644
--- a/gdk/macos/GdkMacosWindow.c
+++ b/gdk/macos/GdkMacosWindow.c
@@ -553,6 +553,17 @@
 
 -(void)setStyleMask:(NSWindowStyleMask)styleMask
 {
+  gboolean was_fullscreen;
+  gboolean is_fullscreen;
+
+  was_fullscreen = (([self styleMask] & NSWindowStyleMaskFullScreen) != 0);
+
+  [super setStyleMask:styleMask];
+
+  is_fullscreen = (([self styleMask] & NSWindowStyleMaskFullScreen) != 0);
+
+  if (was_fullscreen != is_fullscreen)
+    _gdk_macos_surface_update_fullscreen_state (self->gdkSurface);
 }
 
 -(NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
@@ -632,4 +643,18 @@
   self->gdkSurface = surface;
 }
 
+-(void)setDecorated:(BOOL)decorated
+{
+  NSWindowStyleMask style_mask = [self styleMask];
+
+  [self setHasShadow:decorated];
+
+  if (decorated)
+    style_mask |= NSWindowStyleMaskTitled;
+  else
+    style_mask &= ~NSWindowStyleMaskTitled;
+
+  [self setStyleMask:style_mask];
+}
+
 @end
diff --git a/gdk/macos/GdkMacosWindow.h b/gdk/macos/GdkMacosWindow.h
index 8cc15116f1..1c7277a1ff 100644
--- a/gdk/macos/GdkMacosWindow.h
+++ b/gdk/macos/GdkMacosWindow.h
@@ -58,5 +58,6 @@
 -(void)showAndMakeKey:(BOOL)makeKey;
 -(BOOL)trackManualMove;
 -(BOOL)trackManualResize;
+-(void)setDecorated:(BOOL)decorated;
 
 @end
diff --git a/gdk/macos/gdkmacossurface-private.h b/gdk/macos/gdkmacossurface-private.h
index adc4f4bd4b..2990b17db6 100644
--- a/gdk/macos/gdkmacossurface-private.h
+++ b/gdk/macos/gdkmacossurface-private.h
@@ -44,33 +44,34 @@ struct _GdkMacosSurfaceClass
   GdkSurfaceClass parent_class;
 };
 
-GdkMacosSurface   *_gdk_macos_surface_new                (GdkMacosDisplay    *display,
-                                                          GdkSurfaceType      surface_type,
-                                                          GdkSurface         *parent,
-                                                          int                 x,
-                                                          int                 y,
-                                                          int                 width,
-                                                          int                 height);
-NSWindow          *_gdk_macos_surface_get_native         (GdkMacosSurface    *self);
-CGDirectDisplayID  _gdk_macos_surface_get_screen_id      (GdkMacosSurface    *self);
-const char        *_gdk_macos_surface_get_title          (GdkMacosSurface    *self);
-void               _gdk_macos_surface_set_title          (GdkMacosSurface    *self,
-                                                          const gchar        *title);
-void               _gdk_macos_surface_get_shadow         (GdkMacosSurface    *self,
-                                                          gint               *top,
-                                                          gint               *right,
-                                                          gint               *bottom,
-                                                          gint               *left);
-gboolean           _gdk_macos_surface_get_modal_hint     (GdkMacosSurface    *self);
-void               _gdk_macos_surface_set_modal_hint     (GdkMacosSurface    *self,
-                                                          gboolean            modal_hint);
-void               _gdk_macos_surface_set_geometry_hints (GdkMacosSurface    *self,
-                                                          const GdkGeometry  *geometry,
-                                                          GdkSurfaceHints     geom_mask);
-void               _gdk_macos_surface_resize             (GdkMacosSurface    *self,
-                                                          int                 width,
-                                                          int                 height,
-                                                          int                 scale);
+GdkMacosSurface   *_gdk_macos_surface_new                     (GdkMacosDisplay    *display,
+                                                               GdkSurfaceType      surface_type,
+                                                               GdkSurface         *parent,
+                                                               int                 x,
+                                                               int                 y,
+                                                               int                 width,
+                                                               int                 height);
+NSWindow          *_gdk_macos_surface_get_native              (GdkMacosSurface    *self);
+CGDirectDisplayID  _gdk_macos_surface_get_screen_id           (GdkMacosSurface    *self);
+const char        *_gdk_macos_surface_get_title               (GdkMacosSurface    *self);
+void               _gdk_macos_surface_set_title               (GdkMacosSurface    *self,
+                                                               const gchar        *title);
+void               _gdk_macos_surface_get_shadow              (GdkMacosSurface    *self,
+                                                               gint               *top,
+                                                               gint               *right,
+                                                               gint               *bottom,
+                                                               gint               *left);
+gboolean           _gdk_macos_surface_get_modal_hint          (GdkMacosSurface    *self);
+void               _gdk_macos_surface_set_modal_hint          (GdkMacosSurface    *self,
+                                                               gboolean            modal_hint);
+void               _gdk_macos_surface_set_geometry_hints      (GdkMacosSurface    *self,
+                                                               const GdkGeometry  *geometry,
+                                                               GdkSurfaceHints     geom_mask);
+void               _gdk_macos_surface_resize                  (GdkMacosSurface    *self,
+                                                               int                 width,
+                                                               int                 height,
+                                                               int                 scale);
+void               _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self);
 
 G_END_DECLS
 
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index eb64bf47be..71bd7f1691 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -62,6 +62,16 @@ enum {
 
 static GParamSpec *properties [LAST_PROP];
 
+static gboolean
+window_is_fullscreen (GdkMacosSurface *self)
+{
+  GdkMacosSurfacePrivate *priv = gdk_macos_surface_get_instance_private (self);
+
+  g_assert (GDK_IS_MACOS_SURFACE (self));
+
+  return ([priv->window styleMask] & NSWindowStyleMaskFullScreen) != 0;
+}
+
 static void
 gdk_macos_surface_set_input_region (GdkSurface     *surface,
                                     cairo_region_t *region)
@@ -378,3 +388,25 @@ _gdk_macos_surface_resize (GdkMacosSurface *self,
   frame_rect = [priv->window frameRectForContentRect:content_rect];
   [priv->window setFrame:frame_rect display:YES];
 }
+
+void
+_gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self)
+{
+  GdkSurfaceState state;
+  gboolean is_fullscreen;
+  gboolean was_fullscreen;
+
+  g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
+
+  state = GDK_SURFACE (self)->state;
+  is_fullscreen = window_is_fullscreen (self);
+  was_fullscreen = (state & GDK_SURFACE_STATE_FULLSCREEN) != 0;
+
+  if (is_fullscreen != was_fullscreen)
+    {
+      if (is_fullscreen)
+        gdk_synthesize_surface_state (GDK_SURFACE (self), 0, GDK_SURFACE_STATE_FULLSCREEN);
+      else
+        gdk_synthesize_surface_state (GDK_SURFACE (self), GDK_SURFACE_STATE_FULLSCREEN, 0);
+    }
+}
diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c
index a2085cddd3..2132d91b63 100644
--- a/gdk/macos/gdkmacostoplevelsurface.c
+++ b/gdk/macos/gdkmacostoplevelsurface.c
@@ -138,7 +138,7 @@ _gdk_macos_toplevel_surface_present (GdkToplevel       *toplevel,
     _gdk_macos_toplevel_surface_unfullscreen (self);
 
   /* Now present the window */
-  [window showAndMakeKey:YES];
+  [(GdkMacosWindow *)window showAndMakeKey:YES];
 
   return TRUE;
 }
@@ -209,7 +209,7 @@ _gdk_macos_toplevel_surface_set_decorated (GdkMacosToplevelSurface *self,
     {
       NSWindow *window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
       self->decorated = decorated;
-      [window setHasShadow:decorated ? YES : NO];
+      [(GdkMacosWindow *)window setDecorated:(BOOL)decorated];
     }
 }
 


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