diff options
author | Jesse van den Kieboom <jessevdk@gmail.com> | 2014-08-23 16:04:46 +0200 |
---|---|---|
committer | Jesse van den Kieboom <jessevdk@gmail.com> | 2014-08-25 12:52:47 +0200 |
commit | ec17a649aed65fb0a27d6cf10ab097a5f310dfc6 (patch) | |
tree | 037c52f6311e5a8f875cb95d8954425943a77d5c /gdk/quartz | |
parent | 907dae414a733f0beccb121d751365fd9128dd8e (diff) | |
download | gtk+-ec17a649aed65fb0a27d6cf10ab097a5f310dfc6.tar.gz |
gdkwindow-quartz: Support native fullscreen mode
This implements native fullscreen mode on OS X >= 10.7. This patch
adds tracking of the fullscreen mode if externally modified, as well
as toggling the native fullscreen mode of the window as needed.
Diffstat (limited to 'gdk/quartz')
-rw-r--r-- | gdk/quartz/GdkQuartzNSWindow.c | 15 | ||||
-rw-r--r-- | gdk/quartz/GdkQuartzNSWindow.h | 1 | ||||
-rw-r--r-- | gdk/quartz/gdkprivate-quartz.h | 2 | ||||
-rw-r--r-- | gdk/quartz/gdkwindow-quartz.c | 71 |
4 files changed, 86 insertions, 3 deletions
diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index 8ab09ebea7..6bc05a4c4d 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -654,4 +654,19 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender) _gdk_quartz_drag_source_context = NULL; } +- (void)setStyleMask:(NSUInteger)styleMask +{ + gboolean was_fullscreen; + gboolean is_fullscreen; + + was_fullscreen = (([self styleMask] & NSFullScreenWindowMask) != 0); + + [super setStyleMask:styleMask]; + + is_fullscreen = (([self styleMask] & NSFullScreenWindowMask) != 0); + + if (was_fullscreen != is_fullscreen) + _gdk_quartz_window_update_fullscreen_state ([[self contentView] gdkWindow]); +} + @end diff --git a/gdk/quartz/GdkQuartzNSWindow.h b/gdk/quartz/GdkQuartzNSWindow.h index e60232a91d..80b910cffc 100644 --- a/gdk/quartz/GdkQuartzNSWindow.h +++ b/gdk/quartz/GdkQuartzNSWindow.h @@ -42,6 +42,7 @@ -(BOOL)trackManualResize; -(void)showAndMakeKey:(BOOL)makeKey; -(void)hide; +-(void)setStyleMask:(NSUInteger)styleMask; @end diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index 365dcbb187..5d2fcc1517 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -216,7 +216,7 @@ void _gdk_quartz_window_debug_highlight (GdkWindow *window, gint number); void _gdk_quartz_window_update_position (GdkWindow *window); - +void _gdk_quartz_window_update_fullscreen_state (GdkWindow *window); /* Window methods - testing */ void _gdk_quartz_window_sync_rendering (GdkWindow *window); diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index b3cc8dedce..d5a9923b49 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -29,6 +29,7 @@ #include "gdkquartzcursor.h" #include <Carbon/Carbon.h> +#include <AvailabilityMacros.h> #include <sys/time.h> #include <cairo-quartz.h> @@ -43,6 +44,10 @@ static GSList *main_window_stack; void _gdk_quartz_window_flush (GdkWindowImplQuartz *window_impl); +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window); +#endif + #define FULLSCREEN_DATA "fullscreen-data" typedef struct @@ -56,8 +61,6 @@ typedef struct static void update_toplevel_order (void); static void clear_toplevel_order (void); -static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window); - #define WINDOW_IS_TOPLEVEL(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ @@ -1170,8 +1173,10 @@ gdk_window_quartz_hide (GdkWindow *window) GdkWindowImplQuartz *impl; /* Make sure we're not stuck in fullscreen mode. */ +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER if (get_fullscreen_geometry (window)) SetSystemUIMode (kUIModeNormal, 0); +#endif check_grab_unmap (window); @@ -2635,6 +2640,66 @@ gdk_quartz_window_deiconify (GdkWindow *window) } } +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER + +static gboolean +window_is_fullscreen (GdkWindow *window) +{ + GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl); + + return ([impl->toplevel styleMask] & NSFullScreenWindowMask) != 0; +} + +static void +gdk_quartz_window_fullscreen (GdkWindow *window) +{ + GdkWindowImplQuartz *impl; + + if (GDK_WINDOW_DESTROYED (window) || + !WINDOW_IS_TOPLEVEL (window)) + return; + + impl = GDK_WINDOW_IMPL_QUARTZ (window->impl); + + if (!window_is_fullscreen (window)) + [impl->toplevel toggleFullScreen:nil]; +} + +static void +gdk_quartz_window_unfullscreen (GdkWindow *window) +{ + GdkWindowImplQuartz *impl; + + if (GDK_WINDOW_DESTROYED (window) || + !WINDOW_IS_TOPLEVEL (window)) + return; + + impl = GDK_WINDOW_IMPL_QUARTZ (window->impl); + + if (window_is_fullscreen (window)) + [impl->toplevel toggleFullScreen:nil]; +} + +void +_gdk_quartz_window_update_fullscreen_state (GdkWindow *window) +{ + gboolean is_fullscreen; + gboolean was_fullscreen; + + is_fullscreen = window_is_fullscreen (window); + was_fullscreen = (gdk_window_get_state (window) & GDK_WINDOW_STATE_FULLSCREEN) != 0; + + if (is_fullscreen != was_fullscreen) + { + if (is_fullscreen) + gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN); + else + gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0); + } +} + +#else + static FullscreenSavedGeometry * get_fullscreen_geometry (GdkWindow *window) { @@ -2718,6 +2783,8 @@ gdk_quartz_window_unfullscreen (GdkWindow *window) } } +#endif + static void gdk_quartz_window_set_keep_above (GdkWindow *window, gboolean setting) |