- (void)viewDidResize:(NSNotification *)notification
{
NSRect frame = [self frame];
- int oldw, oldh, neww, newh;
+ int neww, newh;
if (! FRAME_LIVE_P (emacsframe))
return;
+ NSTRACE ("[EmacsView viewDidResize]");
+
+ neww = (int)NSWidth (frame);
+ newh = (int)NSHeight (frame);
+ NSTRACE_SIZE ("New size", NSMakeSize (neww, newh));
+
#ifdef NS_DRAW_TO_BUFFER
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400
if ([self wantsUpdateLayer])
{
-#endif
CGFloat scale = [[self window] backingScaleFactor];
- oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale;
- oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale;
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400
- }
- else
- {
-#endif
-#endif /* NS_DRAW_TO_BUFFER */
-#if !defined (NS_DRAW_TO_BUFFER) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400
- oldw = FRAME_PIXEL_WIDTH (emacsframe);
- oldh = FRAME_PIXEL_HEIGHT (emacsframe);
-#endif
-#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400
- }
-#endif
-
- neww = (int)NSWidth (frame);
- newh = (int)NSHeight (frame);
+ int oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale;
+ int oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale;
- NSTRACE ("[EmacsView viewDidResize]");
+ NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
- /* Don't want to do anything when the view size hasn't changed. */
- if ((oldh == newh && oldw == neww))
- {
- NSTRACE_MSG ("No change");
- return;
+ /* Don't want to do anything when the view size hasn't changed. */
+ if ((oldh == newh && oldw == neww))
+ {
+ NSTRACE_MSG ("No change");
+ return;
+ }
}
+#endif
- NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
- NSTRACE_SIZE ("New size", NSMakeSize (neww, newh));
-
+ /* I'm not sure if it's safe to call this every time the view
+ changes size, as Emacs may already know about the change.
+ Unfortunately there doesn't seem to be a bullet-proof method of
+ determining whether we need to call it or not. */
change_frame_size (emacsframe,
FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww),
FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh),