mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 03:00:47 +00:00
* Source/GSTitleView.m (mouseDown:): add additional sanity checks
for NSScreen, NSWindow values.
This commit is contained in:
parent
75cbfce281
commit
deec9c5932
1 changed files with 29 additions and 18 deletions
|
@ -239,22 +239,30 @@
|
||||||
NSDate *theDistantFuture = [NSDate distantFuture];
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
||||||
NSPoint startWindowOrigin;
|
NSPoint startWindowOrigin;
|
||||||
NSPoint endWindowOrigin;
|
NSPoint endWindowOrigin;
|
||||||
CGFloat leftLimit;
|
NSRect screenFrame = NSZeroRect;
|
||||||
CGFloat topLimit;
|
CGFloat leftLimit = -1.0;
|
||||||
CGFloat rightLimit;
|
CGFloat topLimit = -1.0 ;
|
||||||
CGFloat bottomLimit;
|
CGFloat rightLimit = -1.0;
|
||||||
|
CGFloat bottomLimit = 0.0;
|
||||||
|
|
||||||
NSDebugLLog (@"NSMenu", @"Mouse down in title!");
|
NSDebugLLog (@"NSMenu", @"Mouse down in title!");
|
||||||
|
|
||||||
// Define move constrains for menu
|
// Define move constrains for menu
|
||||||
if (_ownedByMenu)
|
if (_ownedByMenu)
|
||||||
{
|
{
|
||||||
NSRect screenFrame = [[_window screen] frame];
|
NSRect windowFrame;
|
||||||
leftLimit = screenFrame.origin.x;
|
NSScreen *screen;
|
||||||
topLimit = NSMaxY(screenFrame) - [_window frame].size.height;
|
|
||||||
rightLimit = NSMaxX(screenFrame) - [_window frame].size.width;
|
if (_window && (screen = [_window screen]))
|
||||||
bottomLimit = screenFrame.origin.y -
|
{
|
||||||
([_window frame].size.height - [self frame].size.height);
|
windowFrame = [_window frame];
|
||||||
|
screenFrame = [screen frame];
|
||||||
|
leftLimit = screenFrame.origin.x;
|
||||||
|
topLimit = NSMaxY(screenFrame) - windowFrame.size.height;
|
||||||
|
rightLimit = NSMaxX(screenFrame) - windowFrame.size.width;
|
||||||
|
bottomLimit = screenFrame.origin.y -
|
||||||
|
(windowFrame.size.height - [self frame].size.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember start position of window
|
// Remember start position of window
|
||||||
|
@ -291,15 +299,18 @@
|
||||||
origin.y += (location.y - lastLocation.y);
|
origin.y += (location.y - lastLocation.y);
|
||||||
if (_ownedByMenu)
|
if (_ownedByMenu)
|
||||||
{
|
{
|
||||||
if (origin.x <= leftLimit)
|
if (screenFrame.size.width > 0 && screenFrame.size.height > 0)
|
||||||
origin.x = leftLimit;
|
{
|
||||||
else if (origin.x >= rightLimit)
|
if (origin.x <= leftLimit)
|
||||||
origin.x = rightLimit;
|
origin.x = leftLimit;
|
||||||
|
else if (origin.x >= rightLimit)
|
||||||
|
origin.x = rightLimit;
|
||||||
|
|
||||||
if (origin.y >= topLimit)
|
if (origin.y >= topLimit)
|
||||||
origin.y = topLimit;
|
origin.y = topLimit;
|
||||||
else if (origin.y <= bottomLimit)
|
else if (origin.y <= bottomLimit)
|
||||||
origin.y = bottomLimit;
|
origin.y = bottomLimit;
|
||||||
|
}
|
||||||
|
|
||||||
[_owner nestedSetFrameOrigin: origin];
|
[_owner nestedSetFrameOrigin: origin];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue