diff options
| author | Alan Third | 2021-05-02 22:38:13 +0100 |
|---|---|---|
| committer | Alan Third | 2021-05-03 13:51:55 +0100 |
| commit | 4fdebc016c3b821fcd9556807dce3781fe6b6c41 (patch) | |
| tree | 053b13f11ade985e08986f9114d9a18c6690180e /src | |
| parent | 1dafab893652c42be807e9a44005413cb7915f81 (diff) | |
| download | emacs-4fdebc016c3b821fcd9556807dce3781fe6b6c41.tar.gz emacs-4fdebc016c3b821fcd9556807dce3781fe6b6c41.zip | |
Fix incorrect resizing behaviour on macOS (bug#48157, bug#48162)
* src/nsterm.m ([EmacsView viewDidResize:]): The drawing buffer can be
resized independently of Emacs's idea of the frame size.
Co-authored-by: martin rudalics <rudalics@gmx.at>
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 6e7ab1266ba..bb20886ab1d 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -7303,16 +7303,34 @@ not_in_argv (NSString *arg) | |||
| 7303 | 7303 | ||
| 7304 | NSTRACE ("[EmacsView viewDidResize]"); | 7304 | NSTRACE ("[EmacsView viewDidResize]"); |
| 7305 | 7305 | ||
| 7306 | #ifdef NS_DRAW_TO_BUFFER | ||
| 7307 | /* If the buffer size doesn't match the view's backing size, destroy | ||
| 7308 | the buffer and let it be recreated at the correct size later. */ | ||
| 7309 | if ([self wantsUpdateLayer] && surface) | ||
| 7310 | { | ||
| 7311 | NSRect surfaceRect = {{0, 0}, [surface getSize]}; | ||
| 7312 | NSRect frameRect = [[self window] convertRectToBacking:frame]; | ||
| 7313 | |||
| 7314 | if (!NSEqualRects (frameRect, surfaceRect)) | ||
| 7315 | { | ||
| 7316 | [surface release]; | ||
| 7317 | surface = nil; | ||
| 7318 | |||
| 7319 | [self setNeedsDisplay:YES]; | ||
| 7320 | } | ||
| 7321 | } | ||
| 7322 | #endif | ||
| 7323 | |||
| 7306 | neww = (int)NSWidth (frame); | 7324 | neww = (int)NSWidth (frame); |
| 7307 | newh = (int)NSHeight (frame); | 7325 | newh = (int)NSHeight (frame); |
| 7308 | oldw = FRAME_PIXEL_WIDTH (emacsframe); | 7326 | oldw = FRAME_PIXEL_WIDTH (emacsframe); |
| 7309 | oldh = FRAME_PIXEL_HEIGHT (emacsframe); | 7327 | oldh = FRAME_PIXEL_HEIGHT (emacsframe); |
| 7310 | 7328 | ||
| 7311 | /* Don't want to do anything when the view size hasn't changed. */ | 7329 | /* Don't want to do anything when the view size hasn't changed. */ |
| 7312 | if ((oldh == newh && oldw == neww) | 7330 | if (emacsframe->new_size_p |
| 7313 | || (emacsframe->new_size_p | 7331 | ? (newh == emacsframe->new_height |
| 7314 | && newh == emacsframe->new_height | 7332 | && neww == emacsframe->new_width) |
| 7315 | && neww == emacsframe->new_width)) | 7333 | : (oldh == newh && oldw == neww)) |
| 7316 | { | 7334 | { |
| 7317 | NSTRACE_MSG ("No change"); | 7335 | NSTRACE_MSG ("No change"); |
| 7318 | return; | 7336 | return; |
| @@ -7321,16 +7339,6 @@ not_in_argv (NSString *arg) | |||
| 7321 | NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); | 7339 | NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); |
| 7322 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); | 7340 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); |
| 7323 | 7341 | ||
| 7324 | #ifdef NS_DRAW_TO_BUFFER | ||
| 7325 | if ([self wantsUpdateLayer]) | ||
| 7326 | { | ||
| 7327 | [surface release]; | ||
| 7328 | surface = nil; | ||
| 7329 | |||
| 7330 | [self setNeedsDisplay:YES]; | ||
| 7331 | } | ||
| 7332 | #endif | ||
| 7333 | |||
| 7334 | change_frame_size (emacsframe, neww, newh, false, YES, false); | 7342 | change_frame_size (emacsframe, neww, newh, false, YES, false); |
| 7335 | 7343 | ||
| 7336 | SET_FRAME_GARBAGED (emacsframe); | 7344 | SET_FRAME_GARBAGED (emacsframe); |