mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:10:48 +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
660c9414bb
commit
85c794ab22
3 changed files with 28 additions and 8 deletions
|
@ -1,3 +1,10 @@
|
|||
2010-07-26 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSMenuView.m (-trackWithEvent:):
|
||||
* Source/NSMenu.m (-shiftOnScreen): Correctly handle the cases
|
||||
where a menu is partially off screen on the top and the left side
|
||||
of the screen, respectively. This fixes bug #30439.
|
||||
|
||||
2010-07-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSInputManager.m: Use NSDeleteCharacter for the backspace key.
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -1473,14 +1473,15 @@ static NSMapTable *viewInfo = 0;
|
|||
if ([_attachedMenu isPartlyOffScreen])
|
||||
{
|
||||
NSPoint pointerLoc = [_window convertBaseToScreen: location];
|
||||
NSRect screenFrame = [[_window screen] visibleFrame];
|
||||
/*
|
||||
* The +/-1 in the y - direction is because the flipping
|
||||
* between X-coordinates and GNUstep coordinates let the
|
||||
* GNUstep screen coordinates start with 1.
|
||||
*/
|
||||
if (pointerLoc.x == 0 || pointerLoc.y == 1
|
||||
|| pointerLoc.x == [[_window screen] frame].size.width - 1
|
||||
|| pointerLoc.y == [[_window screen] frame].size.height)
|
||||
|| pointerLoc.x == screenFrame.size.width - 1
|
||||
|| pointerLoc.y == screenFrame.size.height)
|
||||
[_attachedMenu shiftOnScreen];
|
||||
}
|
||||
|
||||
|
@ -1520,7 +1521,7 @@ static NSMapTable *viewInfo = 0;
|
|||
= [_window convertBaseToScreen: location];
|
||||
|
||||
/*
|
||||
* 3a - Check if moved into one of the ancester menus.
|
||||
* 3a - Check if moved into one of the ancestor menus.
|
||||
* This is tricky, there are a few possibilities:
|
||||
* We are a transient attached menu of a
|
||||
* non-transient menu
|
||||
|
|
Loading…
Reference in a new issue