diff options
| author | Alan Third | 2020-04-18 16:22:06 +0100 |
|---|---|---|
| committer | Alan Third | 2020-05-03 17:14:48 +0100 |
| commit | 2c306146d2a4a12b291ab81ed4ff2968a9ba22e6 (patch) | |
| tree | 0a8e28b7508211555e6899ff46d4fa207f990e10 /src | |
| parent | 22bff6e87b5f1e0d11f582e0639ca44d3d229f47 (diff) | |
| download | emacs-2c306146d2a4a12b291ab81ed4ff2968a9ba22e6.tar.gz emacs-2c306146d2a4a12b291ab81ed4ff2968a9ba22e6.zip | |
Fix initial frame resizing issue on NS (bug#40200)
* src/nsterm.m ([EmacsView viewDidResize:]): Don't try to determine
the old size when not drawing to the buffer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index a8f7540ea20..19531389545 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -7335,48 +7335,39 @@ not_in_argv (NSString *arg) | |||
| 7335 | - (void)viewDidResize:(NSNotification *)notification | 7335 | - (void)viewDidResize:(NSNotification *)notification |
| 7336 | { | 7336 | { |
| 7337 | NSRect frame = [self frame]; | 7337 | NSRect frame = [self frame]; |
| 7338 | int oldw, oldh, neww, newh; | 7338 | int neww, newh; |
| 7339 | 7339 | ||
| 7340 | if (! FRAME_LIVE_P (emacsframe)) | 7340 | if (! FRAME_LIVE_P (emacsframe)) |
| 7341 | return; | 7341 | return; |
| 7342 | 7342 | ||
| 7343 | NSTRACE ("[EmacsView viewDidResize]"); | ||
| 7344 | |||
| 7345 | neww = (int)NSWidth (frame); | ||
| 7346 | newh = (int)NSHeight (frame); | ||
| 7347 | NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); | ||
| 7348 | |||
| 7343 | #ifdef NS_DRAW_TO_BUFFER | 7349 | #ifdef NS_DRAW_TO_BUFFER |
| 7344 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 | ||
| 7345 | if ([self wantsUpdateLayer]) | 7350 | if ([self wantsUpdateLayer]) |
| 7346 | { | 7351 | { |
| 7347 | #endif | ||
| 7348 | CGFloat scale = [[self window] backingScaleFactor]; | 7352 | CGFloat scale = [[self window] backingScaleFactor]; |
| 7349 | oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale; | 7353 | int oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale; |
| 7350 | oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale; | 7354 | int oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale; |
| 7351 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 | ||
| 7352 | } | ||
| 7353 | else | ||
| 7354 | { | ||
| 7355 | #endif | ||
| 7356 | #endif /* NS_DRAW_TO_BUFFER */ | ||
| 7357 | #if !defined (NS_DRAW_TO_BUFFER) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400 | ||
| 7358 | oldw = FRAME_PIXEL_WIDTH (emacsframe); | ||
| 7359 | oldh = FRAME_PIXEL_HEIGHT (emacsframe); | ||
| 7360 | #endif | ||
| 7361 | #if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 | ||
| 7362 | } | ||
| 7363 | #endif | ||
| 7364 | |||
| 7365 | neww = (int)NSWidth (frame); | ||
| 7366 | newh = (int)NSHeight (frame); | ||
| 7367 | 7355 | ||
| 7368 | NSTRACE ("[EmacsView viewDidResize]"); | 7356 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); |
| 7369 | 7357 | ||
| 7370 | /* Don't want to do anything when the view size hasn't changed. */ | 7358 | /* Don't want to do anything when the view size hasn't changed. */ |
| 7371 | if ((oldh == newh && oldw == neww)) | 7359 | if ((oldh == newh && oldw == neww)) |
| 7372 | { | 7360 | { |
| 7373 | NSTRACE_MSG ("No change"); | 7361 | NSTRACE_MSG ("No change"); |
| 7374 | return; | 7362 | return; |
| 7363 | } | ||
| 7375 | } | 7364 | } |
| 7365 | #endif | ||
| 7376 | 7366 | ||
| 7377 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); | 7367 | /* I'm not sure if it's safe to call this every time the view |
| 7378 | NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); | 7368 | changes size, as Emacs may already know about the change. |
| 7379 | 7369 | Unfortunately there doesn't seem to be a bullet-proof method of | |
| 7370 | determining whether we need to call it or not. */ | ||
| 7380 | change_frame_size (emacsframe, | 7371 | change_frame_size (emacsframe, |
| 7381 | FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww), | 7372 | FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww), |
| 7382 | FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh), | 7373 | FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh), |