mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 14:10:37 +00:00
While shifting a menu on screen that is partially off screen, correctly
handle the cases where the menu is off screen on the top and the left side of the screen, respectively. This fixes bug #31415. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31038 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
519f920b8c
commit
b623ba6665
3 changed files with 28 additions and 8 deletions
|
@ -2047,25 +2047,36 @@ static BOOL menuBarVisible = YES;
|
|||
NSRect screenRect = [[theWindow screen] visibleFrame];
|
||||
NSPoint vector = {0.0, 0.0};
|
||||
BOOL moveIt = NO;
|
||||
NSPoint location = [theWindow mouseLocationOutsideOfEventStream];
|
||||
NSPoint pointerLoc = [theWindow convertBaseToScreen: location];
|
||||
|
||||
// Why forget about moving the main menu? If the main menu was partially
|
||||
// shifted off screen while tracking one of its submenus, it should be
|
||||
// possible to shift it back on screen again.
|
||||
#if 0
|
||||
// If we are the main menu forget about moving.
|
||||
if ([self isEqual: [NSApp mainMenu]] && !_menu.transient)
|
||||
return;
|
||||
#endif
|
||||
|
||||
// 1 - determine the amount we need to shift in the y direction.
|
||||
if (NSMinY (frameRect) < 0)
|
||||
if (pointerLoc.y <= 1 && NSMinY (frameRect) < 0)
|
||||
{
|
||||
vector.y = MIN (SHIFT_DELTA, -NSMinY (frameRect));
|
||||
moveIt = YES;
|
||||
}
|
||||
else if (NSMaxY (frameRect) > NSMaxY (screenRect))
|
||||
/* Note: pointerLoc.y may be greater than NSMaxY(screenRect) if we have a
|
||||
horizontal menu bar at the top of the screen (Macintosh interface style) */
|
||||
// FIXME Don't move the horizontal menu bar downward in this case!
|
||||
else if (pointerLoc.y >= NSMaxY(screenRect) &&
|
||||
NSMaxY (frameRect) > NSMaxY (screenRect))
|
||||
{
|
||||
vector.y = -MIN (SHIFT_DELTA, NSMaxY (frameRect) - NSMaxY (screenRect));
|
||||
moveIt = YES;
|
||||
}
|
||||
|
||||
// 2 - determine the amount we need to shift in the x direction.
|
||||
if (NSMinX (frameRect) < 0)
|
||||
if (pointerLoc.x == 0 && NSMinX (frameRect) < 0)
|
||||
{
|
||||
vector.x = MIN (SHIFT_DELTA, -NSMinX (frameRect));
|
||||
moveIt = YES;
|
||||
|
@ -2073,7 +2084,8 @@ static BOOL menuBarVisible = YES;
|
|||
// Note the -3. This is done so the menu, after shifting completely
|
||||
// has some spare room on the right hand side. This is needed otherwise
|
||||
// the user can never access submenus of this menu.
|
||||
else if (NSMaxX (frameRect) > NSMaxX (screenRect) - 3)
|
||||
else if (pointerLoc.x == NSMaxX(screenRect) - 1 &&
|
||||
NSMaxX (frameRect) > NSMaxX (screenRect) - 3)
|
||||
{
|
||||
vector.x
|
||||
= -MIN (SHIFT_DELTA, NSMaxX (frameRect) - NSMaxX (screenRect) + 3);
|
||||
|
@ -2087,7 +2099,7 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
if (_menu.horizontal)
|
||||
{
|
||||
masterLocation = [[self window] frame].origin;
|
||||
masterLocation = frameRect.origin;
|
||||
destinationPoint.x = masterLocation.x + vector.x;
|
||||
destinationPoint.y = masterLocation.y + vector.y;
|
||||
[self nestedSetFrameOrigin: destinationPoint];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue