# HG changeset patch # User Adrian Robert # Date 1253309113 0 # Node ID ec8c2bbf049e01724e5d43cb4f340b71cbf87687 # Parent 4adac4895f0f9d2d5a20c83578ec30e80eb6e529 * nsterm.m (EmacsView-windowShouldZoom:): Set frame left_pos, top_pos and don't update the NSWindow itself. (EmacsView-windowWillUseStandardFrame:defaultFrame:): Improve state detection and store user rect ourselves. (Bug #3581) diff -r 4adac4895f0f -r ec8c2bbf049e src/nsterm.m --- a/src/nsterm.m Fri Sep 18 21:16:28 2009 +0000 +++ b/src/nsterm.m Fri Sep 18 21:25:13 2009 +0000 @@ -1089,6 +1089,7 @@ if (xoff < 100) f->left_pos = 100; /* don't overlap menu */ #endif + if (view != nil && (screen = [[view window] screen])) [[view window] setFrameTopLeftPoint: NSMakePoint (SCREENMAXBOUND (f->left_pos), @@ -5191,7 +5192,6 @@ NSWindow *win = [self window]; NSRect r = [win frame]; NSScreen *screen = [win screen]; - NSRect sr = [screen frame]; NSTRACE (windowDidMove); @@ -5199,21 +5199,24 @@ return; if (screen != nil) { - emacsframe->left_pos = r.origin.x; /* - sr.origin.x; */ - emacsframe->top_pos = sr.size.height - - (r.origin.y + r.size.height); /* + sr.origin.y; */ + emacsframe->left_pos = r.origin.x; + emacsframe->top_pos = + [screen frame].size.height - (r.origin.y + r.size.height); } } -#ifdef NS_IMPL_COCOA -/* if we don't do this manually, the window will resize but not move */ + +/* Called AFTER method below, but before our windowWillResize call there leads + to windowDidResize -> x_set_window_size. Update emacs' notion of frame + location so set_window_size moves the frame. */ - (BOOL)windowShouldZoom: (NSWindow *)sender toFrame: (NSRect)newFrame { NSTRACE (windowShouldZoom); - [[self window] setFrame: newFrame display: NO]; + emacsframe->left_pos = (int)newFrame.origin.x; + emacsframe->top_pos = [[sender screen] frame].size.height + - (newFrame.origin.y+newFrame.size.height); return YES; } -#endif /* Override to do something slightly nonstandard, but nice. First click on @@ -5223,16 +5226,27 @@ defaultFrame:(NSRect)defaultFrame { NSRect result = [sender frame]; + static NSRect ns_userRect = { 0, 0, 0, 0 }; + NSTRACE (windowWillUseStandardFrame); - if (result.size.height == defaultFrame.size.height) { - result = defaultFrame; - } else { - result.size.height = defaultFrame.size.height; - result.origin.y = defaultFrame.origin.y; - } - - /* A windowWillResize does not get generated on Tiger or Leopard. */ + if (abs (defaultFrame.size.height - result.size.height) + > FRAME_LINE_HEIGHT (emacsframe)) + { + /* first click */ + ns_userRect = result; + result.size.height = defaultFrame.size.height; + result.origin.y = defaultFrame.origin.y; + } + else + { + if (abs (defaultFrame.size.width - result.size.width) + > FRAME_COLUMN_WIDTH (emacsframe)) + result = defaultFrame; /* second click */ + else + result = ns_userRect.size.height ? ns_userRect : result; /* restore */ + } + [self windowWillResize: sender toSize: result.size]; return result; }