bug-gnustep
[Top][All Lists]
Advanced

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

Fix: NSWindow, constrainFrameRect


From: Georg Fleischmann
Subject: Fix: NSWindow, constrainFrameRect
Date: Wed, 9 Oct 2002 17:01:28 GMT

Hi,

here is a little fix for NSWindow's constrain method.
The patch brings the window back inside screen, if the window has dropped  
through the bottom of the screen (window top < screen).
Without the patch only windows with the top above the top of the screen are  
moved into the screen.

Georg



2002-08-30  Georg Fleischmann
        * gui/Source/NSWindow.m [-constrainFrameRect]:
          move window inside screen, if window top is below screen



*** gui/Source/NSWindow.m.old   Sun Oct  6 19:27:30 2002
--- gui/Source/NSWindow.m       Wed Oct  9 18:57:44 2002
***************
*** 1508,1514 ****
  - (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: screen
  {
    NSRect screenRect = [screen frame];
!   float difference;

    /* Move top edge of the window inside the screen */
    difference = NSMaxY (frameRect) - NSMaxY (screenRect);
--- 1508,1514 ----
  - (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: screen
  {
    NSRect screenRect = [screen frame];
!   float difference, diff1;

    /* Move top edge of the window inside the screen */
    difference = NSMaxY (frameRect) - NSMaxY (screenRect);
***************
*** 1517,1523 ****
      {
        frameRect.origin.y -= difference;
      }
!
    /* If the window is resizable, resize it (if needed) so that the
       bottom edge is on the screen too */
    if (_styleMask & NSResizableWindowMask)
--- 1517,1530 ----
      {
        frameRect.origin.y -= difference;
      }
!   else if (NSMaxY (frameRect) < NSMinY (screenRect))
!     {
!       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 */
    if (_styleMask & NSResizableWindowMask)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]