Skip to content

Commit

Permalink
Only Send NSWindowDidResizeNotification When Resizing, Not When Moving
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBrokenRail committed May 27, 2021
1 parent c9b4a96 commit 9a5219d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
11 changes: 8 additions & 3 deletions AppKit/X11.backend/X11Display.m
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion AppKit/X11.backend/X11Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

NSMutableDictionary *_deviceDictionary;
O2Rect _frame;
O2Rect _realFrame;
NSUInteger _styleMask;
BOOL _mapped;
CGPoint _lastMotionPos;
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions AppKit/X11.backend/X11Window.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -674,6 +678,7 @@ - (void) frameChanged {

[self invalidateContextWithNewSize: rect.size];
_frame = rect;
_realFrame = _frame;
} @finally {
XSetErrorHandler(previousHandler);
}
Expand Down

0 comments on commit 9a5219d

Please sign in to comment.