mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 16:10:48 +00:00
Merge pull request #54 from gnustep/randr
New feature: Main menu follows key window. Plus some multi-monitor fixes.
This commit is contained in:
commit
941dd311e0
4 changed files with 127 additions and 26 deletions
33
ChangeLog
33
ChangeLog
|
@ -1,3 +1,12 @@
|
|||
2020-02-23 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* Source/NSWindow.m
|
||||
(applicationDidChangeScreenParameters:): quit while loop after
|
||||
screen was found.
|
||||
(sendEvent:): use `_screen` ivar to get screen befor frame change.
|
||||
|
||||
* Source/NSMenu.m (windowDidChangeScreen:): join two if statements.
|
||||
|
||||
2020-02-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSXibLoading.h,
|
||||
|
@ -19,6 +28,30 @@
|
|||
* Source/NSApplication.m (_appIconInit): take into account main screen
|
||||
origin when placing application icon.
|
||||
|
||||
2020-02-13 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* Source/NSWindow.m (setFrame:display:): use _screeForFrame: here
|
||||
to prevent `_screen` reassign - it will be reassigned in
|
||||
sendEvent: (GSAppKitWindowMoved event) after call to [self screen].
|
||||
(setFrameFromString:): removed unused code because _screenForFrame:
|
||||
never returns `nil`. Do not reassign `_screen` here.
|
||||
|
||||
2020-02-12 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* Source/NSWindow.m (sendEvent:): set current screen to ivar and
|
||||
send WindowDidChangeScreen notification if window was moved to other
|
||||
screen.
|
||||
|
||||
* Source/NSScreen.m (mainScreen): returns screen of main menu if no
|
||||
key window exists. With this implementation default screen (screen at
|
||||
index 0 in screens array) should never be returned.
|
||||
|
||||
* Source/NSMenu.m (initWithTitle:): observe WindowDidBecomeKey and
|
||||
WindowDidChangeScreen notifications.
|
||||
(windowDidChangeScreen:): new method to handle observed notification
|
||||
added above. Moves menu to screen of key window for both cases: when
|
||||
key window moved to or activated on different screen.
|
||||
|
||||
2020-02-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSFontDescriptor.m: Correct key for encoding and decoding.
|
||||
|
|
|
@ -1803,6 +1803,23 @@ static BOOL menuBarVisible = YES;
|
|||
[[supermenu menuRepresentation] setHighlightedItemIndex: -1];
|
||||
supermenu->_attachedMenu = nil;
|
||||
}
|
||||
[nc addObserver: self
|
||||
selector: @selector(windowDidChangeScreen:)
|
||||
name: NSWindowDidBecomeKeyNotification
|
||||
object: nil];
|
||||
[nc addObserver: self
|
||||
selector: @selector(windowDidChangeScreen:)
|
||||
name: NSWindowDidChangeScreenNotification
|
||||
object: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[nc removeObserver: self
|
||||
name: NSWindowDidBecomeKeyNotification
|
||||
object: nil];
|
||||
[nc removeObserver: self
|
||||
name: NSWindowDidChangeScreenNotification
|
||||
object: nil];
|
||||
}
|
||||
[_view update];
|
||||
}
|
||||
|
@ -1850,6 +1867,18 @@ static BOOL menuBarVisible = YES;
|
|||
[[GSTheme theme] updateAllWindowsWithMenu: [NSApp mainMenu]];
|
||||
}
|
||||
[self _showTornOffMenuIfAny: notification];
|
||||
|
||||
if ([NSApp mainMenu] == self)
|
||||
{
|
||||
[nc addObserver: self
|
||||
selector: @selector(windowDidChangeScreen:)
|
||||
name: NSWindowDidBecomeKeyNotification
|
||||
object: nil];
|
||||
[nc addObserver: self
|
||||
selector: @selector(windowDidChangeScreen:)
|
||||
name: NSWindowDidChangeScreenNotification
|
||||
object: nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _showOnActivateApp: (NSNotification*)notification
|
||||
|
@ -1862,6 +1891,38 @@ static BOOL menuBarVisible = YES;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) windowDidChangeScreen: (NSNotification*)notification
|
||||
{
|
||||
NSWindow *window = [notification object];
|
||||
NSRect frame;
|
||||
NSRect oldScreenFrame;
|
||||
NSRect newScreenFrame;
|
||||
CGFloat yOffset;
|
||||
|
||||
if ([window isKindOfClass: [NSPanel class]]
|
||||
|| window == _aWindow
|
||||
|| [window isKeyWindow] == NO
|
||||
|| [_aWindow screen] == [window screen]
|
||||
|| [_aWindow isVisible] == NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
oldScreenFrame = [[_aWindow screen] frame];
|
||||
newScreenFrame = [[window screen] frame];
|
||||
frame = [_aWindow frame];
|
||||
|
||||
// Keep left offset fixed
|
||||
frame.origin.x += newScreenFrame.origin.x - oldScreenFrame.origin.x;
|
||||
|
||||
// Keep top offset fixed
|
||||
yOffset = NSMaxY(oldScreenFrame) - NSMaxY(frame);
|
||||
frame.origin.y = NSMaxY(newScreenFrame) - yOffset - frame.size.height;
|
||||
|
||||
// setFrame: changes _screen value.
|
||||
[self nestedSetFrameOrigin: frame.origin];
|
||||
}
|
||||
|
||||
- (BOOL) isTransient
|
||||
{
|
||||
return _menu.transient;
|
||||
|
|
|
@ -122,6 +122,11 @@ static NSMutableArray *screenArray = nil;
|
|||
NSWindow *keyWindow;
|
||||
|
||||
keyWindow = [NSApp keyWindow];
|
||||
if (keyWindow == nil)
|
||||
{
|
||||
keyWindow = [[NSApp mainMenu] window];
|
||||
}
|
||||
|
||||
if (keyWindow != nil)
|
||||
{
|
||||
return [keyWindow screen];
|
||||
|
|
|
@ -2249,12 +2249,13 @@ titleWithRepresentedFilename(NSString *representedFilename)
|
|||
{
|
||||
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]];
|
||||
frameRect = [self constrainFrameRect: frameRect
|
||||
toScreen: [self _screenForFrame: frameRect]];
|
||||
}
|
||||
|
||||
// If nothing changes, don't send it to the backend and don't redisplay
|
||||
|
@ -2721,7 +2722,10 @@ titleWithRepresentedFilename(NSString *representedFilename)
|
|||
while ((scr = [e nextObject]))
|
||||
{
|
||||
if ([scr screenNumber] == screenNumber)
|
||||
ASSIGN(_screen, scr);
|
||||
{
|
||||
ASSIGN(_screen, scr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Do not adjust frame for mini and appicon windows - it's a WM's job.
|
||||
|
@ -4170,16 +4174,27 @@ checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoi
|
|||
switch (sub)
|
||||
{
|
||||
case GSAppKitWindowMoved:
|
||||
_frame.origin.x = (CGFloat)[theEvent data1];
|
||||
_frame.origin.y = (CGFloat)[theEvent data2];
|
||||
NSDebugLLog(@"Moving", @"Move event: %d %@",
|
||||
(int)_windowNum, NSStringFromPoint(_frame.origin));
|
||||
if (_autosaveName != nil)
|
||||
{
|
||||
[self saveFrameUsingName: _autosaveName];
|
||||
}
|
||||
[nc postNotificationName: NSWindowDidMoveNotification
|
||||
object: self];
|
||||
{
|
||||
NSScreen *oldScreen;
|
||||
NSScreen *newScreen;
|
||||
oldScreen = _screen;
|
||||
_frame.origin.x = (CGFloat)[theEvent data1];
|
||||
_frame.origin.y = (CGFloat)[theEvent data2];
|
||||
newScreen = [self screen];
|
||||
NSDebugLLog(@"Moving", @"Move event: %d %@",
|
||||
(int)_windowNum, NSStringFromPoint(_frame.origin));
|
||||
if (_autosaveName != nil)
|
||||
{
|
||||
[self saveFrameUsingName: _autosaveName];
|
||||
}
|
||||
[nc postNotificationName: NSWindowDidMoveNotification
|
||||
object: self];
|
||||
if (newScreen != oldScreen)
|
||||
{
|
||||
[nc postNotificationName: NSWindowDidChangeScreenNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GSAppKitWindowResized:
|
||||
|
@ -4961,16 +4976,6 @@ current key view.<br />
|
|||
* the window could be placed (ie a rectangle excluding the dock).
|
||||
*/
|
||||
screen = [self _screenForFrame: fRect];
|
||||
|
||||
// Check whether a portion is showing somewhere...
|
||||
if (screen == nil)
|
||||
{
|
||||
// If the window doesn't show up on any screen then we need
|
||||
// to move it so it can be seen and assign it to the main
|
||||
// screen...
|
||||
screen = [NSScreen mainScreen];
|
||||
NSDebugLLog(@"NSWindow", @"%s: re-assigning to main screen\n", __PRETTY_FUNCTION__);
|
||||
}
|
||||
nRect = [screen visibleFrame];
|
||||
|
||||
/*
|
||||
|
@ -5022,9 +5027,6 @@ current key view.<br />
|
|||
}
|
||||
}
|
||||
|
||||
// Make sure we are using the new screen we are applying to...
|
||||
ASSIGN(_screen, screen);
|
||||
|
||||
/*
|
||||
* Set frame.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue