diff options
| author | Anders Lindgren | 2015-10-28 12:06:39 +0100 |
|---|---|---|
| committer | Anders Lindgren | 2015-10-28 12:06:39 +0100 |
| commit | 590449f3d87f8f43eb0a852233e8945ecbe1c6aa (patch) | |
| tree | 7c3c96ae80d72318be524f475ea7a84e98870166 /src | |
| parent | 934bfb933f4981b2edaa208186e2f8781ab6cb9f (diff) | |
| download | emacs-590449f3d87f8f43eb0a852233e8945ecbe1c6aa.tar.gz emacs-590449f3d87f8f43eb0a852233e8945ecbe1c6aa.zip | |
Fix incorrect NextStep tool-bar-mode -- wrong number of rows in frame.
* nsterm.h (struct ns_output): New flag, in_animation.
* nsfns.m (Fx_create_frame): Initialize in_animation flag.
* nsmenu.m (free_frame_tool_bar, update_frame_tool_bar): Set
in_animation flag around call to "setVisible". Set new tool bar
height before call to setVisible.
* nsterm.m (x_set_window_size): Don't call [view setRow:
andColumns:] as this fools the subsequent call to updateFrameSize
from performing the real resize.
(windowDidResize): Don't update anything when in_animation is
non-zero.
Trace output.
* nsmenu.m (free_frame_tool_bar, update_frame_tool_bar)
(EmacsToolbar):
* nsterm.m (x_set_window_size, updateFrameSize)
([EmacsView setRows: andColumns:])
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsfns.m | 2 | ||||
| -rw-r--r-- | src/nsmenu.m | 37 | ||||
| -rw-r--r-- | src/nsterm.h | 10 | ||||
| -rw-r--r-- | src/nsterm.m | 27 |
4 files changed, 70 insertions, 6 deletions
diff --git a/src/nsfns.m b/src/nsfns.m index 1ed3e23cba5..c24344436ad 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -1298,6 +1298,8 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1298 | = [NSCursor arrowCursor]; | 1298 | = [NSCursor arrowCursor]; |
| 1299 | f->output_data.ns->current_pointer = f->output_data.ns->text_cursor; | 1299 | f->output_data.ns->current_pointer = f->output_data.ns->text_cursor; |
| 1300 | 1300 | ||
| 1301 | f->output_data.ns->in_animation = NO; | ||
| 1302 | |||
| 1301 | [[EmacsView alloc] initFrameFromEmacs: f]; | 1303 | [[EmacsView alloc] initFrameFromEmacs: f]; |
| 1302 | 1304 | ||
| 1303 | x_icon (f, parms); | 1305 | x_icon (f, parms); |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 2ef12234960..ddc5dc20a82 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -998,10 +998,20 @@ free_frame_tool_bar (struct frame *f) | |||
| 998 | -------------------------------------------------------------------------- */ | 998 | -------------------------------------------------------------------------- */ |
| 999 | { | 999 | { |
| 1000 | EmacsView *view = FRAME_NS_VIEW (f); | 1000 | EmacsView *view = FRAME_NS_VIEW (f); |
| 1001 | |||
| 1002 | NSTRACE ("free_frame_tool_bar"); | ||
| 1003 | |||
| 1001 | block_input (); | 1004 | block_input (); |
| 1002 | view->wait_for_tool_bar = NO; | 1005 | view->wait_for_tool_bar = NO; |
| 1003 | [[view toolbar] setVisible: NO]; | 1006 | |
| 1004 | FRAME_TOOLBAR_HEIGHT (f) = 0; | 1007 | FRAME_TOOLBAR_HEIGHT (f) = 0; |
| 1008 | |||
| 1009 | /* Note: This trigger an animation, which calls windowDidResize | ||
| 1010 | repeatedly. */ | ||
| 1011 | f->output_data.ns->in_animation = 1; | ||
| 1012 | [[view toolbar] setVisible: NO]; | ||
| 1013 | f->output_data.ns->in_animation = 0; | ||
| 1014 | |||
| 1005 | unblock_input (); | 1015 | unblock_input (); |
| 1006 | } | 1016 | } |
| 1007 | 1017 | ||
| @@ -1017,6 +1027,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1017 | EmacsToolbar *toolbar = [view toolbar]; | 1027 | EmacsToolbar *toolbar = [view toolbar]; |
| 1018 | int oldh; | 1028 | int oldh; |
| 1019 | 1029 | ||
| 1030 | NSTRACE ("update_frame_tool_bar"); | ||
| 1031 | |||
| 1020 | if (view == nil || toolbar == nil) return; | 1032 | if (view == nil || toolbar == nil) return; |
| 1021 | block_input (); | 1033 | block_input (); |
| 1022 | 1034 | ||
| @@ -1096,7 +1108,11 @@ update_frame_tool_bar (struct frame *f) | |||
| 1096 | } | 1108 | } |
| 1097 | 1109 | ||
| 1098 | if (![toolbar isVisible]) | 1110 | if (![toolbar isVisible]) |
| 1111 | { | ||
| 1112 | f->output_data.ns->in_animation = 1; | ||
| 1099 | [toolbar setVisible: YES]; | 1113 | [toolbar setVisible: YES]; |
| 1114 | f->output_data.ns->in_animation = 0; | ||
| 1115 | } | ||
| 1100 | 1116 | ||
| 1101 | #ifdef NS_IMPL_COCOA | 1117 | #ifdef NS_IMPL_COCOA |
| 1102 | if ([toolbar changed]) | 1118 | if ([toolbar changed]) |
| @@ -1150,6 +1166,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1150 | 1166 | ||
| 1151 | - initForView: (EmacsView *)view withIdentifier: (NSString *)identifier | 1167 | - initForView: (EmacsView *)view withIdentifier: (NSString *)identifier |
| 1152 | { | 1168 | { |
| 1169 | NSTRACE ("[EmacsToolbar initForView: withIdentifier:]"); | ||
| 1170 | |||
| 1153 | self = [super initWithIdentifier: identifier]; | 1171 | self = [super initWithIdentifier: identifier]; |
| 1154 | emacsView = view; | 1172 | emacsView = view; |
| 1155 | [self setDisplayMode: NSToolbarDisplayModeIconOnly]; | 1173 | [self setDisplayMode: NSToolbarDisplayModeIconOnly]; |
| @@ -1164,6 +1182,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1164 | 1182 | ||
| 1165 | - (void)dealloc | 1183 | - (void)dealloc |
| 1166 | { | 1184 | { |
| 1185 | NSTRACE ("[EmacsToolbar dealloc]"); | ||
| 1186 | |||
| 1167 | [prevIdentifiers release]; | 1187 | [prevIdentifiers release]; |
| 1168 | [activeIdentifiers release]; | 1188 | [activeIdentifiers release]; |
| 1169 | [identifierToItem release]; | 1189 | [identifierToItem release]; |
| @@ -1172,6 +1192,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1172 | 1192 | ||
| 1173 | - (void) clearActive | 1193 | - (void) clearActive |
| 1174 | { | 1194 | { |
| 1195 | NSTRACE ("[EmacsToolbar clearActive]"); | ||
| 1196 | |||
| 1175 | [prevIdentifiers release]; | 1197 | [prevIdentifiers release]; |
| 1176 | prevIdentifiers = [activeIdentifiers copy]; | 1198 | prevIdentifiers = [activeIdentifiers copy]; |
| 1177 | [activeIdentifiers removeAllObjects]; | 1199 | [activeIdentifiers removeAllObjects]; |
| @@ -1181,6 +1203,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1181 | 1203 | ||
| 1182 | - (void) clearAll | 1204 | - (void) clearAll |
| 1183 | { | 1205 | { |
| 1206 | NSTRACE ("[EmacsToolbar clearAll]"); | ||
| 1207 | |||
| 1184 | [self clearActive]; | 1208 | [self clearActive]; |
| 1185 | while ([[self items] count] > 0) | 1209 | while ([[self items] count] > 0) |
| 1186 | [self removeItemAtIndex: 0]; | 1210 | [self removeItemAtIndex: 0]; |
| @@ -1188,6 +1212,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1188 | 1212 | ||
| 1189 | - (BOOL) changed | 1213 | - (BOOL) changed |
| 1190 | { | 1214 | { |
| 1215 | NSTRACE ("[EmacsToolbar changed]"); | ||
| 1216 | |||
| 1191 | return [activeIdentifiers isEqualToArray: prevIdentifiers] && | 1217 | return [activeIdentifiers isEqualToArray: prevIdentifiers] && |
| 1192 | enablement == prevEnablement ? NO : YES; | 1218 | enablement == prevEnablement ? NO : YES; |
| 1193 | } | 1219 | } |
| @@ -1198,6 +1224,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1198 | helpText: (const char *)help | 1224 | helpText: (const char *)help |
| 1199 | enabled: (BOOL)enabled | 1225 | enabled: (BOOL)enabled |
| 1200 | { | 1226 | { |
| 1227 | NSTRACE ("[EmacsToolbar addDisplayItemWithImage: ...]"); | ||
| 1228 | |||
| 1201 | /* 1) come up w/identifier */ | 1229 | /* 1) come up w/identifier */ |
| 1202 | NSString *identifier | 1230 | NSString *identifier |
| 1203 | = [NSString stringWithFormat: @"%lu", (unsigned long)[img hash]]; | 1231 | = [NSString stringWithFormat: @"%lu", (unsigned long)[img hash]]; |
| @@ -1231,6 +1259,7 @@ update_frame_tool_bar (struct frame *f) | |||
| 1231 | all items to enabled state (for some reason). */ | 1259 | all items to enabled state (for some reason). */ |
| 1232 | - (void)validateVisibleItems | 1260 | - (void)validateVisibleItems |
| 1233 | { | 1261 | { |
| 1262 | NSTRACE ("[EmacsToolbar validateVisibleItems]"); | ||
| 1234 | } | 1263 | } |
| 1235 | 1264 | ||
| 1236 | 1265 | ||
| @@ -1240,12 +1269,16 @@ update_frame_tool_bar (struct frame *f) | |||
| 1240 | itemForItemIdentifier: (NSString *)itemIdentifier | 1269 | itemForItemIdentifier: (NSString *)itemIdentifier |
| 1241 | willBeInsertedIntoToolbar: (BOOL)flag | 1270 | willBeInsertedIntoToolbar: (BOOL)flag |
| 1242 | { | 1271 | { |
| 1272 | NSTRACE ("[EmacsToolbar toolbar: ...]"); | ||
| 1273 | |||
| 1243 | /* look up NSToolbarItem by identifier and return... */ | 1274 | /* look up NSToolbarItem by identifier and return... */ |
| 1244 | return [identifierToItem objectForKey: itemIdentifier]; | 1275 | return [identifierToItem objectForKey: itemIdentifier]; |
| 1245 | } | 1276 | } |
| 1246 | 1277 | ||
| 1247 | - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar | 1278 | - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar |
| 1248 | { | 1279 | { |
| 1280 | NSTRACE ("[EmacsToolbar toolbarDefaultItemIdentifiers:]"); | ||
| 1281 | |||
| 1249 | /* return entire set.. */ | 1282 | /* return entire set.. */ |
| 1250 | return activeIdentifiers; | 1283 | return activeIdentifiers; |
| 1251 | } | 1284 | } |
| @@ -1253,6 +1286,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1253 | /* for configuration palette (not yet supported) */ | 1286 | /* for configuration palette (not yet supported) */ |
| 1254 | - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar | 1287 | - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar |
| 1255 | { | 1288 | { |
| 1289 | NSTRACE ("[EmacsToolbar toolbarAllowedItemIdentifiers:]"); | ||
| 1290 | |||
| 1256 | /* return entire set... */ | 1291 | /* return entire set... */ |
| 1257 | return activeIdentifiers; | 1292 | return activeIdentifiers; |
| 1258 | //return [identifierToItem allKeys]; | 1293 | //return [identifierToItem allKeys]; |
diff --git a/src/nsterm.h b/src/nsterm.h index 8d52dc642ed..3fb8cfc9cd8 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -65,9 +65,12 @@ typedef float EmacsCGFloat; | |||
| 65 | 65 | ||
| 66 | ========================================================================== */ | 66 | ========================================================================== */ |
| 67 | 67 | ||
| 68 | /* Uncomment the following line to enable trace. */ | 68 | /* Uncomment the following line to enable trace. |
| 69 | 69 | ||
| 70 | /* #define NSTRACE_ENABLED 1 */ | 70 | Hint: keep the trailing whitespace -- the version control system |
| 71 | will reject accidental commits. */ | ||
| 72 | |||
| 73 | /* #define NSTRACE_ENABLED 1 */ | ||
| 71 | 74 | ||
| 72 | 75 | ||
| 73 | /* Print a call tree containing all annotated functions. | 76 | /* Print a call tree containing all annotated functions. |
| @@ -913,6 +916,9 @@ struct ns_output | |||
| 913 | 916 | ||
| 914 | /* Non-zero if we are zooming (maximizing) the frame. */ | 917 | /* Non-zero if we are zooming (maximizing) the frame. */ |
| 915 | int zooming; | 918 | int zooming; |
| 919 | |||
| 920 | /* Non-zero if we are doing an animation, e.g. toggling the tool bar. */ | ||
| 921 | int in_animation; | ||
| 916 | }; | 922 | }; |
| 917 | 923 | ||
| 918 | /* this dummy decl needed to support TTYs */ | 924 | /* this dummy decl needed to support TTYs */ |
diff --git a/src/nsterm.m b/src/nsterm.m index e5eb8caaef3..ba205f53f4b 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1497,7 +1497,7 @@ x_set_window_size (struct frame *f, | |||
| 1497 | if (view == nil) | 1497 | if (view == nil) |
| 1498 | return; | 1498 | return; |
| 1499 | 1499 | ||
| 1500 | NSTRACE_RECT ("input", wr); | 1500 | NSTRACE_RECT ("current", wr); |
| 1501 | 1501 | ||
| 1502 | /*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x %d\n", width, height, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));*/ | 1502 | /*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x %d\n", width, height, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));*/ |
| 1503 | 1503 | ||
| @@ -1559,7 +1559,6 @@ x_set_window_size (struct frame *f, | |||
| 1559 | make_number (FRAME_NS_TITLEBAR_HEIGHT (f)), | 1559 | make_number (FRAME_NS_TITLEBAR_HEIGHT (f)), |
| 1560 | make_number (FRAME_TOOLBAR_HEIGHT (f)))); | 1560 | make_number (FRAME_TOOLBAR_HEIGHT (f)))); |
| 1561 | 1561 | ||
| 1562 | [view setRows: rows andColumns: cols]; | ||
| 1563 | NSTRACE_RECT ("setFrame", wr); | 1562 | NSTRACE_RECT ("setFrame", wr); |
| 1564 | [window setFrame: wr display: YES]; | 1563 | [window setFrame: wr display: YES]; |
| 1565 | 1564 | ||
| @@ -6142,6 +6141,8 @@ not_in_argv (NSString *arg) | |||
| 6142 | NSTRACE ("updateFrameSize"); | 6141 | NSTRACE ("updateFrameSize"); |
| 6143 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); | 6142 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); |
| 6144 | NSTRACE_RECT ("Original frame", wr); | 6143 | NSTRACE_RECT ("Original frame", wr); |
| 6144 | NSTRACE_MSG ("Original columns: %d", cols); | ||
| 6145 | NSTRACE_MSG ("Original rows: %d", rows); | ||
| 6145 | 6146 | ||
| 6146 | if (! [self isFullscreen]) | 6147 | if (! [self isFullscreen]) |
| 6147 | { | 6148 | { |
| @@ -6158,13 +6159,19 @@ not_in_argv (NSString *arg) | |||
| 6158 | if (wait_for_tool_bar) | 6159 | if (wait_for_tool_bar) |
| 6159 | { | 6160 | { |
| 6160 | if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0) | 6161 | if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0) |
| 6161 | return; | 6162 | { |
| 6163 | NSTRACE_MSG ("Waiting for toolbar"); | ||
| 6164 | return; | ||
| 6165 | } | ||
| 6162 | wait_for_tool_bar = NO; | 6166 | wait_for_tool_bar = NO; |
| 6163 | } | 6167 | } |
| 6164 | 6168 | ||
| 6165 | neww = (int)wr.size.width - emacsframe->border_width; | 6169 | neww = (int)wr.size.width - emacsframe->border_width; |
| 6166 | newh = (int)wr.size.height - extra; | 6170 | newh = (int)wr.size.height - extra; |
| 6167 | 6171 | ||
| 6172 | NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); | ||
| 6173 | NSTRACE_MSG ("tool_bar_height: %d", emacsframe->tool_bar_height); | ||
| 6174 | |||
| 6168 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, neww); | 6175 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, neww); |
| 6169 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, newh); | 6176 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, newh); |
| 6170 | 6177 | ||
| @@ -6174,6 +6181,9 @@ not_in_argv (NSString *arg) | |||
| 6174 | if (rows < MINHEIGHT) | 6181 | if (rows < MINHEIGHT) |
| 6175 | rows = MINHEIGHT; | 6182 | rows = MINHEIGHT; |
| 6176 | 6183 | ||
| 6184 | NSTRACE_MSG ("New columns: %d", cols); | ||
| 6185 | NSTRACE_MSG ("New rows: %d", rows); | ||
| 6186 | |||
| 6177 | if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) | 6187 | if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) |
| 6178 | { | 6188 | { |
| 6179 | NSView *view = FRAME_NS_VIEW (emacsframe); | 6189 | NSView *view = FRAME_NS_VIEW (emacsframe); |
| @@ -6191,6 +6201,10 @@ not_in_argv (NSString *arg) | |||
| 6191 | [view setFrame: wr]; | 6201 | [view setFrame: wr]; |
| 6192 | [self windowDidMove:nil]; // Update top/left. | 6202 | [self windowDidMove:nil]; // Update top/left. |
| 6193 | } | 6203 | } |
| 6204 | else | ||
| 6205 | { | ||
| 6206 | NSTRACE_MSG ("No change"); | ||
| 6207 | } | ||
| 6194 | } | 6208 | } |
| 6195 | 6209 | ||
| 6196 | - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize | 6210 | - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize |
| @@ -6299,6 +6313,12 @@ not_in_argv (NSString *arg) | |||
| 6299 | { | 6313 | { |
| 6300 | NSTRACE ("windowDidResize"); | 6314 | NSTRACE ("windowDidResize"); |
| 6301 | 6315 | ||
| 6316 | if (emacsframe->output_data.ns->in_animation) | ||
| 6317 | { | ||
| 6318 | NSTRACE_MSG ("Ignored (in animation)"); | ||
| 6319 | return; | ||
| 6320 | } | ||
| 6321 | |||
| 6302 | if (! [self fsIsNative]) | 6322 | if (! [self fsIsNative]) |
| 6303 | { | 6323 | { |
| 6304 | NSWindow *theWindow = [notification object]; | 6324 | NSWindow *theWindow = [notification object]; |
| @@ -7396,6 +7416,7 @@ not_in_argv (NSString *arg) | |||
| 7396 | 7416 | ||
| 7397 | - (void) setRows: (int) r andColumns: (int) c | 7417 | - (void) setRows: (int) r andColumns: (int) c |
| 7398 | { | 7418 | { |
| 7419 | NSTRACE ("[EmacsView setRows:%d andColumns:%d]", r, c); | ||
| 7399 | rows = r; | 7420 | rows = r; |
| 7400 | cols = c; | 7421 | cols = c; |
| 7401 | } | 7422 | } |