quartz: implement maximized/unmaximized

Instead of using the default zoom behaviour use the internal
maximized state for selecting our own zoom target. This makes
zooming work for CSD windows where for some reason the
given default zoom target is the current window frame itself
resulting in a shadowless window of the same size.

While this makes the zoom button behave a bit different as expected
it makes things more consistent with other platforms and fixes CSD
zooming.
This commit is contained in:
Christoph Reiter 2015-07-20 09:05:52 +02:00 committed by Christoph Reiter
parent 61ce90a8e2
commit eb37fd22e7
3 changed files with 49 additions and 16 deletions

View File

@ -689,4 +689,43 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
return rect;
}
- (NSRect)windowWillUseStandardFrame:(NSWindow *)nsWindow
defaultFrame:(NSRect)newFrame
{
NSRect screenFrame = [[self screen] visibleFrame];
GdkWindow *window = [[self contentView] gdkWindow];
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
if (!maximized)
return screenFrame;
else
return lastUnmaximizedFrame;
}
- (BOOL)windowShouldZoom:(NSWindow *)nsWindow
toFrame:(NSRect)newFrame
{
GdkWindow *window = [[self contentView] gdkWindow];
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
if (maximized)
{
gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_MAXIMIZED,
0);
}
else
{
lastUnmaximizedFrame = [nsWindow frame];
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_MAXIMIZED);
}
return YES;
}
@end

View File

@ -32,6 +32,8 @@
NSPoint initialMoveLocation;
NSPoint initialResizeLocation;
NSRect initialResizeFrame;
NSRect lastUnmaximizedFrame;
}
-(BOOL)isInMove;

View File

@ -2477,56 +2477,48 @@ static void
gdk_quartz_window_maximize (GdkWindow *window)
{
GdkWindowImplQuartz *impl;
gboolean maximized;
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL (window))
return;
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
if (GDK_WINDOW_IS_MAPPED (window))
{
GDK_QUARTZ_ALLOC_POOL;
if (impl->toplevel && ![impl->toplevel isZoomed])
[impl->toplevel zoom:nil];
if (impl->toplevel && !maximized)
[impl->toplevel zoom:nil];
GDK_QUARTZ_RELEASE_POOL;
}
else
{
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_MAXIMIZED);
}
}
static void
gdk_quartz_window_unmaximize (GdkWindow *window)
{
GdkWindowImplQuartz *impl;
gboolean maximized;
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL (window))
return;
impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
if (GDK_WINDOW_IS_MAPPED (window))
{
GDK_QUARTZ_ALLOC_POOL;
if (impl->toplevel && [impl->toplevel isZoomed])
[impl->toplevel zoom:nil];
if (impl->toplevel && maximized)
[impl->toplevel zoom:nil];
GDK_QUARTZ_RELEASE_POOL;
}
else
{
gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_MAXIMIZED,
0);
}
}
static void