Commit 7d66affd authored by Richard Hult's avatar Richard Hult Committed by Richard Hult

Don't do anything while in fullscreen mode. (gdk_window_set_decorations):

2007-10-02  Richard Hult  <richard@imendio.com>

	* gdk/quartz/gdkwindow-quartz.c: (gdk_window_move),
	(gdk_window_resize): Don't do anything while in fullscreen mode.
	(gdk_window_set_decorations): Update the size of the window after
	showing/hiding the title bar so the size of the content area
	doesn't change.
	(gdk_window_get_decorations): NSBorderlessWindowMask is 0, so
	don't try to check it as a bit being set.
	(gdk_window_fullscreen), (gdk_window_unfullscreen): Implement.

svn path=/trunk/; revision=18875
parent 721eb57a
2007-10-02 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkwindow-quartz.c: (gdk_window_move),
(gdk_window_resize): Don't do anything while in fullscreen mode.
(gdk_window_set_decorations): Update the size of the window after
showing/hiding the title bar so the size of the content area
doesn't change.
(gdk_window_get_decorations): NSBorderlessWindowMask is 0, so
don't try to check it as a bit being set.
(gdk_window_fullscreen), (gdk_window_unfullscreen): Implement.
2007-10-02 Federico Mena Quintero <federico@novell.com>
Fix http://bugzilla.gnome.org/show_bug.cgi?id=455284 - In the file
......
......@@ -20,6 +20,7 @@
*/
#include <config.h>
#include <Carbon/Carbon.h>
#include "gdk.h"
#include "gdkprivate-quartz.h"
......@@ -1115,6 +1116,9 @@ gdk_window_move (GdkWindow *window,
{
g_return_if_fail (GDK_IS_WINDOW (window));
if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
return;
move_resize_window_internal (window, x, y, -1, -1);
}
......@@ -1125,6 +1129,9 @@ gdk_window_resize (GdkWindow *window,
{
g_return_if_fail (GDK_IS_WINDOW (window));
if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
return;
if (width < 1)
width = 1;
if (height < 1)
......@@ -2149,7 +2156,7 @@ gdk_window_set_decorations (GdkWindow *window,
GdkWMDecoration decorations)
{
GdkWindowImplQuartz *impl;
int style_mask;
int old_mask, new_mask;
NSView *old_view;
g_return_if_fail (GDK_IS_WINDOW (window));
......@@ -2162,31 +2169,52 @@ gdk_window_set_decorations (GdkWindow *window,
if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
{
style_mask = NSBorderlessWindowMask;
new_mask = NSBorderlessWindowMask;
}
else
{
/* FIXME: Honor other GTK_DECOR_* flags. */
style_mask = (NSTitledWindowMask | NSClosableWindowMask |
/* FIXME: Honor other GDK_DECOR_* flags. */
new_mask = (NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask);
}
GDK_QUARTZ_ALLOC_POOL;
old_mask = [impl->toplevel styleMask];
/* Note, there doesn't seem to be a way to change this without
* recreating the toplevel. There might be bad side-effects of doing
* that, but it seems alright.
*/
if ([impl->toplevel styleMask] != style_mask)
if (old_mask != new_mask)
{
NSRect rect;
old_view = [impl->toplevel contentView];
impl->toplevel = [impl->toplevel initWithContentRect:[impl->toplevel frame]
styleMask:style_mask
rect = [impl->toplevel frame];
/* Properly update the size of the window when the titlebar is
* added or removed.
*/
if (old_mask == NSBorderlessWindowMask &&
new_mask != NSBorderlessWindowMask)
{
rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask];
}
else if (old_mask != NSBorderlessWindowMask &&
new_mask == NSBorderlessWindowMask)
{
rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
}
impl->toplevel = [impl->toplevel initWithContentRect:rect
styleMask:new_mask
backing:NSBackingStoreBuffered
defer:NO];
[impl->toplevel setContentView:old_view];
[impl->toplevel setFrame:rect display:YES];
}
GDK_QUARTZ_RELEASE_POOL;
......@@ -2208,13 +2236,14 @@ gdk_window_get_decorations (GdkWindow *window,
if (decorations)
{
if ([impl->toplevel styleMask] & NSBorderlessWindowMask)
/* Borderless is 0, so we can't check it as a bit being set. */
if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
{
*decorations = 0;
}
else
{
/* FIXME: Honor the other GTK_DECOR_* flags. */
/* FIXME: Honor the other GDK_DECOR_* flags. */
*decorations = GDK_DECOR_ALL;
}
}
......@@ -2374,20 +2403,79 @@ gdk_window_deiconify (GdkWindow *window)
}
}
#define FULLSCREEN_DATA "fullscreen-data"
typedef struct
{
gint x, y;
gint width, height;
GdkWMDecoration decor;
} FullscreenSavedGeometry;
void
gdk_window_fullscreen (GdkWindow *window)
{
FullscreenSavedGeometry *geometry;
GdkWindowObject *private = (GdkWindowObject *) window;
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
NSRect frame;
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
/* FIXME: Implement */
geometry = g_new (FullscreenSavedGeometry, 1);
geometry->x = private->x;
geometry->y = private->y;
geometry->width = impl->width;
geometry->height = impl->height;
if (!gdk_window_get_decorations (window, &geometry->decor))
geometry->decor = GDK_DECOR_ALL;
g_object_set_data_full (G_OBJECT (window),
FULLSCREEN_DATA, geometry,
g_free);
HideMenuBar ();
gdk_window_set_decorations (window, 0);
frame = [[NSScreen mainScreen] frame];
move_resize_window_internal (window,
0, 0,
frame.size.width, frame.size.height);
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
}
void
gdk_window_unfullscreen (GdkWindow *window)
{
FullscreenSavedGeometry *geometry;
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
/* FIXME: Implement */
geometry = g_object_get_data (G_OBJECT (window), FULLSCREEN_DATA);
if (geometry)
{
ShowMenuBar ();
move_resize_window_internal (window,
geometry->x,
geometry->y,
geometry->width,
geometry->height);
gdk_window_set_decorations (window, geometry->decor);
g_object_set_data (G_OBJECT (window), FULLSCREEN_DATA, NULL);
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
}
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment