Merge pull request #56 from gnustep/randr

Window placement fix on screen change
This commit is contained in:
Sergii Stoian 2020-03-06 01:34:44 +02:00 committed by GitHub
commit a655fe1192
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 15 deletions

View file

@ -1,8 +1,22 @@
2020-03-05 Sergii Stoian <stoyan255@gmail.com>
* Source/NSWindow.m (_applyFrame:): new helper method to do actual
resizing.
(setFrame:display:): use _applyFrame method.
(applicationDidChangeScreenParameters:): Use _applyFrame: because our
origin in OpenStep coordinates might be unchanged and `setFrame:display:`
has check for it.
2020-02-28 Sergii Stoian <stoyan255@gmail.com> 2020-02-28 Sergii Stoian <stoyan255@gmail.com>
* Source/NSWindow.m (center): always center window on main screen - * Source/NSWindow.m (center): always center window on main screen -
monitor where user expects to see window. monitor where user expects to see window.
2020-02-26 Sergii Stoian <stoyan255@gmail.com>
* Source/NSWindow.m (sendEvent:): removed usage of extra local variables
in GSAppKitWindowMoved code block.
2020-02-23 Sergii Stoian <stoyan255@gmail.com> 2020-02-23 Sergii Stoian <stoyan255@gmail.com>
* Source/NSWindow.m * Source/NSWindow.m

View file

@ -2227,6 +2227,20 @@ titleWithRepresentedFilename(NSString *representedFilename)
[self setFrame: r display: YES]; [self setFrame: r display: YES];
} }
- (void) _applyFrame: (NSRect )frameRect
{
if (_windowNum)
{
[GSServerForWindow(self) placewindow: frameRect : _windowNum];
}
else
{
_frame = frameRect;
frameRect.origin = NSZeroPoint;
[_wv setFrame: frameRect];
}
}
- (void) setFrame: (NSRect)frameRect display: (BOOL)flag - (void) setFrame: (NSRect)frameRect display: (BOOL)flag
{ {
if (_maximumSize.width > 0 && frameRect.size.width > _maximumSize.width) if (_maximumSize.width > 0 && frameRect.size.width > _maximumSize.width)
@ -2265,14 +2279,7 @@ titleWithRepresentedFilename(NSString *representedFilename)
* Now we can tell the graphics context to do the actual resizing. * Now we can tell the graphics context to do the actual resizing.
* We will recieve an event to tell us when the resize is done. * We will recieve an event to tell us when the resize is done.
*/ */
if (_windowNum) [self _applyFrame: frameRect];
[GSServerForWindow(self) placewindow: frameRect : _windowNum];
else
{
_frame = frameRect;
frameRect.origin = NSZeroPoint;
[_wv setFrame: frameRect];
}
if (flag) if (flag)
[self display]; [self display];
@ -2495,7 +2502,7 @@ titleWithRepresentedFilename(NSString *representedFilename)
} }
- (void) update - (void) update
{ {
[nc postNotificationName: NSWindowDidUpdateNotification object: self]; [nc postNotificationName: NSWindowDidUpdateNotification object: self];
} }
@ -2737,7 +2744,13 @@ titleWithRepresentedFilename(NSString *representedFilename)
newFrame.origin.y += newScreenFrame.size.height - oldScreenFrame.size.height; newFrame.origin.y += newScreenFrame.size.height - oldScreenFrame.size.height;
// Screen X origin change. Screen width change shouldn't affect our frame. // Screen X origin change. Screen width change shouldn't affect our frame.
newFrame.origin.x += newScreenFrame.origin.x - oldScreenFrame.origin.x; newFrame.origin.x += newScreenFrame.origin.x - oldScreenFrame.origin.x;
[self setFrame: newFrame display: NO];
/* Call backend's `placewindow::` directly because our origin in OpenStep
coordinates might be unchanged and `setFrame:display:` has check
for it. */
[self _applyFrame: newFrame];
[self display];
if (_autosaveName != nil) if (_autosaveName != nil)
{ {
[self saveFrameUsingName: _autosaveName]; [self saveFrameUsingName: _autosaveName];
@ -4171,12 +4184,10 @@ checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoi
{ {
case GSAppKitWindowMoved: case GSAppKitWindowMoved:
{ {
NSScreen *oldScreen; NSScreen *oldScreen = _screen;
NSScreen *newScreen;
oldScreen = _screen;
_frame.origin.x = (CGFloat)[theEvent data1]; _frame.origin.x = (CGFloat)[theEvent data1];
_frame.origin.y = (CGFloat)[theEvent data2]; _frame.origin.y = (CGFloat)[theEvent data2];
newScreen = [self screen];
NSDebugLLog(@"Moving", @"Move event: %d %@", NSDebugLLog(@"Moving", @"Move event: %d %@",
(int)_windowNum, NSStringFromPoint(_frame.origin)); (int)_windowNum, NSStringFromPoint(_frame.origin));
if (_autosaveName != nil) if (_autosaveName != nil)
@ -4185,7 +4196,7 @@ checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoi
} }
[nc postNotificationName: NSWindowDidMoveNotification [nc postNotificationName: NSWindowDidMoveNotification
object: self]; object: self];
if (newScreen != oldScreen) if ([self screen] != oldScreen)
{ {
[nc postNotificationName: NSWindowDidChangeScreenNotification [nc postNotificationName: NSWindowDidChangeScreenNotification
object: self]; object: self];