From a93430ad56c234637b9e18823dd29396169067f0 Mon Sep 17 00:00:00 2001 From: Quentin Mathe Date: Sun, 7 Nov 2004 18:03:50 +0000 Subject: [PATCH] Improved the NSWindow positioning git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20306 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 +++++++++ Source/NSWindow.m | 63 +++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb417bbaf..3b2ec5d5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-11-07 Quentin Mathe + + * Source/NSWindow.m (-constrainFrameRect:toScreen:): Modified the method + to match the specification and the constraints used when the user + moves/resizes the window with the cursor. That makes possible to have + resizable windows which extends below the bottom of the screen as long + as you can move them up to take back the resize control on the screen. + (-setFrame:display:): Modified the method to remove the possibility to + have the window title bar positioned over the top of the screen when + using -gui window decorations. + 2004-11-06 08:34 Gregory John Casamento * Source/GSNibTemplates.m: Removed nibInstantiate. This method diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 0800d82bd..d4be72706 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1709,36 +1709,36 @@ many times. /* Move top edge of the window inside the screen */ difference = NSMaxY (frameRect) - NSMaxY (screenRect); - if (difference > 0) { frameRect.origin.y -= difference; } - else if (NSMinY (frameRect) < NSMinY (screenRect)) - { - float diff1 = NSMinY (frameRect) - NSMinY (screenRect); - /* move bottom inside the screen, but keep top inside screen */ - frameRect.origin.y -= MAX(difference, diff1); - difference = NSMaxY (frameRect) - NSMaxY (screenRect); - } - + /* If the window is resizable, resize it (if needed) so that the - bottom edge is on the screen too */ + bottom edge is on the screen or can be on the screen when the user moves + the window */ + difference = NSMaxY (screenRect) - NSMaxY (frameRect); if (_styleMask & NSResizableWindowMask) { - difference = screenRect.origin.y - frameRect.origin.y; - if (difference > 0) - { - frameRect.size.height -= difference; - frameRect.origin.y += difference; - } - /* Ensure that rewsizing doesn't makewindow smaller than minimum */ - difference = _minimumSize.height - frameRect.size.height; - if (difference > 0) - { - frameRect.size.height += difference; - frameRect.origin.y -= difference; - } + float difference2; + + difference2 = screenRect.origin.y - frameRect.origin.y; + difference2 -= difference; + // Take in account the space between the top of window and the top of the + // screen which can be used to move the bottom of the window on the screen + if (difference2 > 0) + { + frameRect.size.height -= difference2; + frameRect.origin.y += difference2; + } + + /* Ensure that resizing doesn't makewindow smaller than minimum */ + difference2 = _minimumSize.height - frameRect.size.height; + if (difference2 > 0) + { + frameRect.size.height += difference2; + frameRect.origin.y -= difference2; + } } return frameRect; @@ -1787,17 +1787,16 @@ many times. { frameRect.size.height = _minimumSize.height; } - + + /* Windows need to be constrained when displayed or resized - but only + titled windows are constrained */ + if (_styleMask & NSTitledWindowMask) + { + frameRect = [self constrainFrameRect: frameRect toScreen: [self screen]]; + } + if (NSEqualSizes(frameRect.size, _frame.size) == NO) { - /* Windows need to be constrained when displayed or resized - but only - titled windows are constrained */ - if (_styleMask & NSTitledWindowMask) - { - frameRect = [self constrainFrameRect: frameRect - toScreen: [self screen]]; - } - if ([_delegate respondsToSelector: @selector(windowWillResize:toSize:)]) { frameRect.size = [_delegate windowWillResize: self