From 9a5219d78f0343ebb46d1d9ed14d011eb19e76fa Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 26 May 2021 18:43:57 -0400 Subject: [PATCH] Only Send NSWindowDidResizeNotification When Resizing, Not When Moving --- AppKit/X11.backend/X11Display.m | 11 ++++++++--- AppKit/X11.backend/X11Window.h | 4 +++- AppKit/X11.backend/X11Window.m | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/AppKit/X11.backend/X11Display.m b/AppKit/X11.backend/X11Display.m index 3a7e94ada..14e4ae778 100644 --- a/AppKit/X11.backend/X11Display.m +++ b/AppKit/X11.backend/X11Display.m @@ -1216,11 +1216,16 @@ - (void) postXEvent: (XEvent *) ev { NSLog(@"ReparentNotify"); break; - case ConfigureNotify: + case ConfigureNotify:; + // -[X11Window realFrame] is used instead of -[X11Window frame] because -[X11Window frame] is + // modified by -[X11Window setFrame], so if you resized using -[X11Window setFrame] it would only + // register as a window move + O2Rect oldFrame = [window realFrame]; [window frameChanged]; + O2Rect newFrame = [window realFrame]; [delegate platformWindow: window - frameChanged: [window frame] - didSize: YES]; + frameChanged: newFrame + didSize: !NSEqualSizes(newFrame.size, oldFrame.size)]; break; case ConfigureRequest: diff --git a/AppKit/X11.backend/X11Window.h b/AppKit/X11.backend/X11Window.h index b371fff5e..3780355a1 100644 --- a/AppKit/X11.backend/X11Window.h +++ b/AppKit/X11.backend/X11Window.h @@ -43,6 +43,7 @@ NSMutableDictionary *_deviceDictionary; O2Rect _frame; + O2Rect _realFrame; NSUInteger _styleMask; BOOL _mapped; CGPoint _lastMotionPos; @@ -54,7 +55,8 @@ + (void) removeDecorationForWindow: (Window) w onDisplay: (Display *) dpy; - (instancetype) initWithDelegate: (NSWindow *) delegate; -- (O2Rect) frame; +- (O2Rect) frame; // This frame is set by -[X11Window setFrame] and -[X11Window frameChanged] +- (O2Rect) realFrame; // This frame is only set by -[X11Window frameChanged] - (Visual *) visual; - (Drawable) drawable; - (NSPoint) transformPoint: (NSPoint) pos; diff --git a/AppKit/X11.backend/X11Window.m b/AppKit/X11.backend/X11Window.m index 7c0b6f22f..49a97653c 100644 --- a/AppKit/X11.backend/X11Window.m +++ b/AppKit/X11.backend/X11Window.m @@ -636,6 +636,10 @@ - (O2Rect) frame { return [self transformFrame: _frame]; } +- (O2Rect) realFrame { + return [self transformFrame: _realFrame]; +} + static int ignoreBadWindow(Display *display, XErrorEvent *errorEvent) { if (errorEvent->error_code == BadWindow) return 0; @@ -674,6 +678,7 @@ - (void) frameChanged { [self invalidateContextWithNewSize: rect.size]; _frame = rect; + _realFrame = _frame; } @finally { XSetErrorHandler(previousHandler); }