diff options
| author | Jan Djärv | 2013-02-05 13:16:35 +0100 |
|---|---|---|
| committer | Jan Djärv | 2013-02-05 13:16:35 +0100 |
| commit | 6871e574da7938313bbfd519c17035a6805a2305 (patch) | |
| tree | 711e1106eb57c7e851f7432805e2688e3b3ad69a | |
| parent | ed746aa721aa5712249946b6061041563f7138f3 (diff) | |
| download | emacs-6871e574da7938313bbfd519c17035a6805a2305.tar.gz emacs-6871e574da7938313bbfd519c17035a6805a2305.zip | |
* lisp/cus-start.el (all): Add ns-use-native-fullscreen.
* src/nsmenu.m (update_frame_tool_bar): Check for negative tool bar
height.
* src/nsterm.h (HAVE_NATIVE_FS): Define if OSX => 10.7.
(EmacsView): Add fs_is_native, fsIsNative, isFullscreen and
updateCollectionBehaviour.
* src/nsterm.m (NEW_STYLE_FS): Remove.
(ns_last_use_native_fullscreen): New variable.
(x_make_frame_visible): Replace NEW_STYLE_FS with isFullscreen.
(x_set_window_size): Do not take title bar and tool bar into account
if isFullscreen returns YES.
(ns_fullscreen_hook): Replace NEW_STYLE_FS with isFullscreen.
(check_native_fs): New function.
(ns_select, ns_read_socket): Call check_native_fs if HAVE_NATIVE_FS.
(ns_term_init): Remove NEW_STYLE_FS.
(updateFrameSize:, windowWillResize:toSize:): Only adjust for title bar
and tool bar if isFullscreen returns NO.
(windowDidResize:): Replace NEW_STYLE_FS with fsIsNative.
(initFrameFromEmacs:): Initialize fs_is_native. Replace NEW_STYLE_FS
with HAVE_NATIVE_FS.
(window:willUseFullScreenPresentationOptions:): New method.
(windowDidEnterFullScreen:): Replace NEW_STYLE_FS with fsIsNative.
Hide toolbar if not enabled.
(windowDidExitFullScreen:): Call updateCollectionBehaviour.
Restore tool bar if enabled, hide it otherwise (Bug#13444).
(fsIsNative, isFullscreen, updateCollectionBehaviour): New methods.
(toggleFullScreen:): If fs_is_native, call toggleFullScreen on
window. Do no set FRAME_EXTERNAL_TOOL_BAR (f) to 0.
Check FRAME_EXTERNAL_TOOL_BAR (f) before restoring
FRAME_TOOLBAR_HEIGHT (f). Call updateFrameSize when going non-fs.
(syms_of_nsterm): Add ns-use-native-fullscreen.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/cus-start.el | 1 | ||||
| -rw-r--r-- | src/ChangeLog | 35 | ||||
| -rw-r--r-- | src/nsmenu.m | 2 | ||||
| -rw-r--r-- | src/nsterm.h | 11 | ||||
| -rw-r--r-- | src/nsterm.m | 241 |
6 files changed, 221 insertions, 73 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9fbc0e747fc..538206ae9d0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-02-05 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * cus-start.el (all): Add ns-use-native-fullscreen. | ||
| 4 | |||
| 1 | 2013-02-05 Glenn Morris <rgm@gnu.org> | 5 | 2013-02-05 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * profiler.el (profiler-report-mode-map): Add a restart menu entry. | 7 | * profiler.el (profiler-report-mode-map): Add a restart menu entry. |
diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 62e91fafcbf..2bc47426332 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el | |||
| @@ -398,6 +398,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of | |||
| 398 | (const super)) "23.1") | 398 | (const super)) "23.1") |
| 399 | (ns-antialias-text ns boolean "23.1") | 399 | (ns-antialias-text ns boolean "23.1") |
| 400 | (ns-auto-hide-menu-bar ns boolean "24.0") | 400 | (ns-auto-hide-menu-bar ns boolean "24.0") |
| 401 | (ns-use-native-fullscreen ns boolean "24.4") | ||
| 401 | ;; process.c | 402 | ;; process.c |
| 402 | (delete-exited-processes processes-basics boolean) | 403 | (delete-exited-processes processes-basics boolean) |
| 403 | ;; syntax.c | 404 | ;; syntax.c |
diff --git a/src/ChangeLog b/src/ChangeLog index cbfeadc04a3..dc0ae082ae9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,38 @@ | |||
| 1 | 2013-02-05 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsmenu.m (update_frame_tool_bar): Check for negative tool bar | ||
| 4 | height. | ||
| 5 | |||
| 6 | * nsterm.h (HAVE_NATIVE_FS): Define if OSX => 10.7. | ||
| 7 | (EmacsView): Add fs_is_native, fsIsNative, isFullscreen and | ||
| 8 | updateCollectionBehaviour. | ||
| 9 | |||
| 10 | * nsterm.m (NEW_STYLE_FS): Remove. | ||
| 11 | (ns_last_use_native_fullscreen): New variable. | ||
| 12 | (x_make_frame_visible): Replace NEW_STYLE_FS with isFullscreen. | ||
| 13 | (x_set_window_size): Do not take title bar and tool bar into account | ||
| 14 | if isFullscreen returns YES. | ||
| 15 | (ns_fullscreen_hook): Replace NEW_STYLE_FS with isFullscreen. | ||
| 16 | (check_native_fs): New function. | ||
| 17 | (ns_select, ns_read_socket): Call check_native_fs if HAVE_NATIVE_FS. | ||
| 18 | (ns_term_init): Remove NEW_STYLE_FS. | ||
| 19 | (updateFrameSize:, windowWillResize:toSize:): Only adjust for title bar | ||
| 20 | and tool bar if isFullscreen returns NO. | ||
| 21 | (windowDidResize:): Replace NEW_STYLE_FS with fsIsNative. | ||
| 22 | (initFrameFromEmacs:): Initialize fs_is_native. Replace NEW_STYLE_FS | ||
| 23 | with HAVE_NATIVE_FS. | ||
| 24 | (window:willUseFullScreenPresentationOptions:): New method. | ||
| 25 | (windowDidEnterFullScreen:): Replace NEW_STYLE_FS with fsIsNative. | ||
| 26 | Hide toolbar if not enabled (Bug#13444). | ||
| 27 | (windowDidExitFullScreen:): Call updateCollectionBehaviour. | ||
| 28 | Restore tool bar if enabled, hide it otherwise (Bug#13444). | ||
| 29 | (fsIsNative, isFullscreen, updateCollectionBehaviour): New methods. | ||
| 30 | (toggleFullScreen:): If fs_is_native, call toggleFullScreen on | ||
| 31 | window. Do no set FRAME_EXTERNAL_TOOL_BAR (f) to 0. | ||
| 32 | Check FRAME_EXTERNAL_TOOL_BAR (f) before restoring | ||
| 33 | FRAME_TOOLBAR_HEIGHT (f). Call updateFrameSize when going non-fs. | ||
| 34 | (syms_of_nsterm): Add ns-use-native-fullscreen. | ||
| 35 | |||
| 1 | 2013-02-04 Paul Eggert <eggert@cs.ucla.edu> | 36 | 2013-02-04 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 37 | ||
| 3 | * fileio.c (Qchoose_write_coding_system): Now static. | 38 | * fileio.c (Qchoose_write_coding_system): Now static. |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 6899e3575f5..22ff4dd0b53 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1110,6 +1110,8 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1110 | FRAME_TOOLBAR_HEIGHT (f) = | 1110 | FRAME_TOOLBAR_HEIGHT (f) = |
| 1111 | NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) | 1111 | NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) |
| 1112 | - FRAME_NS_TITLEBAR_HEIGHT (f); | 1112 | - FRAME_NS_TITLEBAR_HEIGHT (f); |
| 1113 | if (FRAME_TOOLBAR_HEIGHT (f) < 0) // happens if frame is fullscreen. | ||
| 1114 | FRAME_TOOLBAR_HEIGHT (f) = 0; | ||
| 1113 | unblock_input (); | 1115 | unblock_input (); |
| 1114 | } | 1116 | } |
| 1115 | 1117 | ||
diff --git a/src/nsterm.h b/src/nsterm.h index 0cf4aa60d08..41dbaf3c0f7 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -42,6 +42,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 42 | #ifndef MAC_OS_X_VERSION_10_8 | 42 | #ifndef MAC_OS_X_VERSION_10_8 |
| 43 | #define MAC_OS_X_VERSION_10_8 1080 | 43 | #define MAC_OS_X_VERSION_10_8 1080 |
| 44 | #endif | 44 | #endif |
| 45 | |||
| 46 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 | ||
| 47 | #define HAVE_NATIVE_FS | ||
| 48 | #endif | ||
| 49 | |||
| 45 | #endif /* NS_IMPL_COCOA */ | 50 | #endif /* NS_IMPL_COCOA */ |
| 46 | 51 | ||
| 47 | #ifdef __OBJC__ | 52 | #ifdef __OBJC__ |
| @@ -88,6 +93,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 88 | int tibar_height, tobar_height, bwidth; | 93 | int tibar_height, tobar_height, bwidth; |
| 89 | int maximized_width, maximized_height; | 94 | int maximized_width, maximized_height; |
| 90 | NSWindow *nonfs_window; | 95 | NSWindow *nonfs_window; |
| 96 | BOOL fs_is_native; | ||
| 91 | @public | 97 | @public |
| 92 | struct frame *emacsframe; | 98 | struct frame *emacsframe; |
| 93 | int rows, cols; | 99 | int rows, cols; |
| @@ -115,6 +121,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 115 | - (void) handleFS; | 121 | - (void) handleFS; |
| 116 | - (void) setFSValue: (int)value; | 122 | - (void) setFSValue: (int)value; |
| 117 | - (void) toggleFullScreen: (id) sender; | 123 | - (void) toggleFullScreen: (id) sender; |
| 124 | - (BOOL) fsIsNative; | ||
| 125 | - (BOOL) isFullscreen; | ||
| 126 | #ifdef HAVE_NATIVE_FS | ||
| 127 | - (void) updateCollectionBehaviour; | ||
| 128 | #endif | ||
| 118 | 129 | ||
| 119 | #ifdef NS_IMPL_GNUSTEP | 130 | #ifdef NS_IMPL_GNUSTEP |
| 120 | /* Not declared, but useful. */ | 131 | /* Not declared, but useful. */ |
diff --git a/src/nsterm.m b/src/nsterm.m index 3544cfd79a0..1f09e031592 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -69,11 +69,6 @@ int term_trace_num = 0; | |||
| 69 | #define NSTRACE(x) | 69 | #define NSTRACE(x) |
| 70 | #endif | 70 | #endif |
| 71 | 71 | ||
| 72 | #if defined (NS_IMPL_COCOA) && \ | ||
| 73 | MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 | ||
| 74 | #define NEW_STYLE_FS | ||
| 75 | #endif | ||
| 76 | |||
| 77 | extern NSString *NSMenuDidBeginTrackingNotification; | 72 | extern NSString *NSMenuDidBeginTrackingNotification; |
| 78 | 73 | ||
| 79 | /* ========================================================================== | 74 | /* ========================================================================== |
| @@ -224,6 +219,7 @@ static int n_emacs_events_pending = 0; | |||
| 224 | static NSMutableArray *ns_pending_files, *ns_pending_service_names, | 219 | static NSMutableArray *ns_pending_files, *ns_pending_service_names, |
| 225 | *ns_pending_service_args; | 220 | *ns_pending_service_args; |
| 226 | static BOOL ns_do_open_file = NO; | 221 | static BOOL ns_do_open_file = NO; |
| 222 | static BOOL ns_last_use_native_fullscreen; | ||
| 227 | 223 | ||
| 228 | static struct { | 224 | static struct { |
| 229 | struct input_event *q; | 225 | struct input_event *q; |
| @@ -1094,13 +1090,12 @@ x_make_frame_visible (struct frame *f) | |||
| 1094 | SET_FRAME_VISIBLE (f, 1); | 1090 | SET_FRAME_VISIBLE (f, 1); |
| 1095 | ns_raise_frame (f); | 1091 | ns_raise_frame (f); |
| 1096 | 1092 | ||
| 1097 | #ifdef NEW_STYLE_FS | ||
| 1098 | /* Making a new frame from a fullscreen frame will make the new frame | 1093 | /* Making a new frame from a fullscreen frame will make the new frame |
| 1099 | fullscreen also. So skip handleFS as this will print an error. */ | 1094 | fullscreen also. So skip handleFS as this will print an error. */ |
| 1100 | if (f->want_fullscreen == FULLSCREEN_BOTH | 1095 | if ([view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH |
| 1101 | && ([[view window] styleMask] & NSFullScreenWindowMask) != 0) | 1096 | && [view isFullscreen]) |
| 1102 | return; | 1097 | return; |
| 1103 | #endif | 1098 | |
| 1104 | if (f->want_fullscreen != FULLSCREEN_NONE) | 1099 | if (f->want_fullscreen != FULLSCREEN_NONE) |
| 1105 | { | 1100 | { |
| 1106 | block_input (); | 1101 | block_input (); |
| @@ -1292,7 +1287,7 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) | |||
| 1292 | pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); | 1287 | pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); |
| 1293 | 1288 | ||
| 1294 | /* If we have a toolbar, take its height into account. */ | 1289 | /* If we have a toolbar, take its height into account. */ |
| 1295 | if (tb) | 1290 | if (tb && ! [view isFullscreen]) |
| 1296 | /* NOTE: previously this would generate wrong result if toolbar not | 1291 | /* NOTE: previously this would generate wrong result if toolbar not |
| 1297 | yet displayed and fixing toolbar_height=32 helped, but | 1292 | yet displayed and fixing toolbar_height=32 helped, but |
| 1298 | now (200903) seems no longer needed */ | 1293 | now (200903) seems no longer needed */ |
| @@ -1303,8 +1298,10 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) | |||
| 1303 | FRAME_TOOLBAR_HEIGHT (f) = 0; | 1298 | FRAME_TOOLBAR_HEIGHT (f) = 0; |
| 1304 | 1299 | ||
| 1305 | wr.size.width = pixelwidth + f->border_width; | 1300 | wr.size.width = pixelwidth + f->border_width; |
| 1306 | wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f) | 1301 | wr.size.height = pixelheight; |
| 1307 | + FRAME_TOOLBAR_HEIGHT (f); | 1302 | if (! [view isFullscreen]) |
| 1303 | wr.size.height += FRAME_NS_TITLEBAR_HEIGHT (f) | ||
| 1304 | + FRAME_TOOLBAR_HEIGHT (f); | ||
| 1308 | 1305 | ||
| 1309 | /* Do not try to constrain to this screen. We may have multiple | 1306 | /* Do not try to constrain to this screen. We may have multiple |
| 1310 | screens, and want Emacs to span those. Constraining to screen | 1307 | screens, and want Emacs to span those. Constraining to screen |
| @@ -1355,8 +1352,7 @@ ns_fullscreen_hook (FRAME_PTR f) | |||
| 1355 | if (!FRAME_VISIBLE_P (f)) | 1352 | if (!FRAME_VISIBLE_P (f)) |
| 1356 | return; | 1353 | return; |
| 1357 | 1354 | ||
| 1358 | #ifndef NEW_STYLE_FS | 1355 | if (! [view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH) |
| 1359 | if (f->want_fullscreen == FULLSCREEN_BOTH) | ||
| 1360 | { | 1356 | { |
| 1361 | /* Old style fs don't initiate correctly if created from | 1357 | /* Old style fs don't initiate correctly if created from |
| 1362 | init/default-frame alist, so use a timer (not nice...). | 1358 | init/default-frame alist, so use a timer (not nice...). |
| @@ -1366,7 +1362,6 @@ ns_fullscreen_hook (FRAME_PTR f) | |||
| 1366 | userInfo: nil repeats: NO]; | 1362 | userInfo: nil repeats: NO]; |
| 1367 | return; | 1363 | return; |
| 1368 | } | 1364 | } |
| 1369 | #endif | ||
| 1370 | 1365 | ||
| 1371 | block_input (); | 1366 | block_input (); |
| 1372 | [view handleFS]; | 1367 | [view handleFS]; |
| @@ -3369,6 +3364,30 @@ ns_send_appdefined (int value) | |||
| 3369 | } | 3364 | } |
| 3370 | } | 3365 | } |
| 3371 | 3366 | ||
| 3367 | #ifdef HAVE_NATIVE_FS | ||
| 3368 | static void | ||
| 3369 | check_native_fs () | ||
| 3370 | { | ||
| 3371 | Lisp_Object frame, tail; | ||
| 3372 | |||
| 3373 | if (ns_last_use_native_fullscreen == ns_use_native_fullscreen) | ||
| 3374 | return; | ||
| 3375 | |||
| 3376 | ns_last_use_native_fullscreen = ns_use_native_fullscreen; | ||
| 3377 | |||
| 3378 | /* Clear the mouse-moved flag for every frame on this display. */ | ||
| 3379 | FOR_EACH_FRAME (tail, frame) | ||
| 3380 | { | ||
| 3381 | struct frame *f = XFRAME (frame); | ||
| 3382 | if (FRAME_NS_P (f)) | ||
| 3383 | { | ||
| 3384 | EmacsView *view = FRAME_NS_VIEW (f); | ||
| 3385 | [view updateCollectionBehaviour]; | ||
| 3386 | } | ||
| 3387 | } | ||
| 3388 | } | ||
| 3389 | #endif | ||
| 3390 | |||
| 3372 | static int | 3391 | static int |
| 3373 | ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) | 3392 | ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) |
| 3374 | /* -------------------------------------------------------------------------- | 3393 | /* -------------------------------------------------------------------------- |
| @@ -3382,6 +3401,10 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) | |||
| 3382 | 3401 | ||
| 3383 | /* NSTRACE (ns_read_socket); */ | 3402 | /* NSTRACE (ns_read_socket); */ |
| 3384 | 3403 | ||
| 3404 | #ifdef HAVE_NATIVE_FS | ||
| 3405 | check_native_fs (); | ||
| 3406 | #endif | ||
| 3407 | |||
| 3385 | if ([NSApp modalWindow] != nil) | 3408 | if ([NSApp modalWindow] != nil) |
| 3386 | return -1; | 3409 | return -1; |
| 3387 | 3410 | ||
| @@ -3459,6 +3482,10 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, | |||
| 3459 | 3482 | ||
| 3460 | /* NSTRACE (ns_select); */ | 3483 | /* NSTRACE (ns_select); */ |
| 3461 | 3484 | ||
| 3485 | #ifdef HAVE_NATIVE_FS | ||
| 3486 | check_native_fs (); | ||
| 3487 | #endif | ||
| 3488 | |||
| 3462 | if (hold_event_q.nr > 0) | 3489 | if (hold_event_q.nr > 0) |
| 3463 | { | 3490 | { |
| 3464 | /* We already have events pending. */ | 3491 | /* We already have events pending. */ |
| @@ -4238,11 +4265,9 @@ ns_term_init (Lisp_Object display_name) | |||
| 4238 | NSColorPboardType, | 4265 | NSColorPboardType, |
| 4239 | NSFontPboardType, nil] retain]; | 4266 | NSFontPboardType, nil] retain]; |
| 4240 | 4267 | ||
| 4241 | #ifndef NEW_STYLE_FS | ||
| 4242 | /* If fullscreen is in init/default-frame-alist, focus isn't set | 4268 | /* If fullscreen is in init/default-frame-alist, focus isn't set |
| 4243 | right for fullscreen windows, so set this. */ | 4269 | right for fullscreen windows, so set this. */ |
| 4244 | [NSApp activateIgnoringOtherApps:YES]; | 4270 | [NSApp activateIgnoringOtherApps:YES]; |
| 4245 | #endif | ||
| 4246 | 4271 | ||
| 4247 | [NSApp run]; | 4272 | [NSApp run]; |
| 4248 | ns_do_open_file = YES; | 4273 | ns_do_open_file = YES; |
| @@ -5391,10 +5416,10 @@ not_in_argv (NSString *arg) | |||
| 5391 | { | 5416 | { |
| 5392 | NSWindow *window = [self window]; | 5417 | NSWindow *window = [self window]; |
| 5393 | NSRect wr = [window frame]; | 5418 | NSRect wr = [window frame]; |
| 5394 | #ifdef NS_IMPL_GNUSTEP | ||
| 5395 | int extra = 3; | ||
| 5396 | #else | ||
| 5397 | int extra = 0; | 5419 | int extra = 0; |
| 5420 | int gsextra = 0; | ||
| 5421 | #ifdef NS_IMPL_GNUSTEP | ||
| 5422 | gsextra = 3; | ||
| 5398 | #endif | 5423 | #endif |
| 5399 | 5424 | ||
| 5400 | int oldc = cols, oldr = rows; | 5425 | int oldc = cols, oldr = rows; |
| @@ -5402,23 +5427,24 @@ not_in_argv (NSString *arg) | |||
| 5402 | oldh = FRAME_PIXEL_HEIGHT (emacsframe); | 5427 | oldh = FRAME_PIXEL_HEIGHT (emacsframe); |
| 5403 | int neww, newh; | 5428 | int neww, newh; |
| 5404 | 5429 | ||
| 5405 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, wr.size.width + extra); | 5430 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, wr.size.width + gsextra); |
| 5406 | 5431 | ||
| 5407 | if (cols < MINWIDTH) | 5432 | if (cols < MINWIDTH) |
| 5408 | cols = MINWIDTH; | 5433 | cols = MINWIDTH; |
| 5409 | 5434 | ||
| 5410 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES | 5435 | if (! [self isFullscreen]) |
| 5411 | (emacsframe, wr.size.height | 5436 | { |
| 5412 | - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + extra | 5437 | extra = FRAME_NS_TITLEBAR_HEIGHT (emacsframe) |
| 5413 | - FRAME_TOOLBAR_HEIGHT (emacsframe)); | 5438 | + FRAME_TOOLBAR_HEIGHT (emacsframe) - gsextra; |
| 5439 | } | ||
| 5440 | |||
| 5441 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, wr.size.height - extra); | ||
| 5414 | 5442 | ||
| 5415 | if (rows < MINHEIGHT) | 5443 | if (rows < MINHEIGHT) |
| 5416 | rows = MINHEIGHT; | 5444 | rows = MINHEIGHT; |
| 5417 | 5445 | ||
| 5418 | neww = (int)wr.size.width - emacsframe->border_width; | 5446 | neww = (int)wr.size.width - emacsframe->border_width; |
| 5419 | newh = ((int)wr.size.height | 5447 | newh = (int)wr.size.height - extra; |
| 5420 | - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) | ||
| 5421 | - FRAME_TOOLBAR_HEIGHT (emacsframe)); | ||
| 5422 | 5448 | ||
| 5423 | if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) | 5449 | if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) |
| 5424 | { | 5450 | { |
| @@ -5436,6 +5462,12 @@ not_in_argv (NSString *arg) | |||
| 5436 | - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize | 5462 | - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize |
| 5437 | /* normalize frame to gridded text size */ | 5463 | /* normalize frame to gridded text size */ |
| 5438 | { | 5464 | { |
| 5465 | int extra = 0; | ||
| 5466 | int gsextra = 0; | ||
| 5467 | #ifdef NS_IMPL_GNUSTEP | ||
| 5468 | gsextra = 3; | ||
| 5469 | #endif | ||
| 5470 | |||
| 5439 | NSTRACE (windowWillResize); | 5471 | NSTRACE (windowWillResize); |
| 5440 | /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ | 5472 | /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ |
| 5441 | 5473 | ||
| @@ -5453,22 +5485,12 @@ not_in_argv (NSString *arg) | |||
| 5453 | maximized_width = maximized_height = -1; | 5485 | maximized_width = maximized_height = -1; |
| 5454 | 5486 | ||
| 5455 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, | 5487 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, |
| 5456 | #ifdef NS_IMPL_GNUSTEP | 5488 | frameSize.width + gsextra); |
| 5457 | frameSize.width + 3); | ||
| 5458 | #else | ||
| 5459 | frameSize.width); | ||
| 5460 | #endif | ||
| 5461 | if (cols < MINWIDTH) | 5489 | if (cols < MINWIDTH) |
| 5462 | cols = MINWIDTH; | 5490 | cols = MINWIDTH; |
| 5463 | 5491 | ||
| 5464 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, frameSize.height | 5492 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, |
| 5465 | #ifdef NS_IMPL_GNUSTEP | 5493 | frameSize.height - extra); |
| 5466 | - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + 3 | ||
| 5467 | - FRAME_TOOLBAR_HEIGHT (emacsframe)); | ||
| 5468 | #else | ||
| 5469 | - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) | ||
| 5470 | - FRAME_TOOLBAR_HEIGHT (emacsframe)); | ||
| 5471 | #endif | ||
| 5472 | if (rows < MINHEIGHT) | 5494 | if (rows < MINHEIGHT) |
| 5473 | rows = MINHEIGHT; | 5495 | rows = MINHEIGHT; |
| 5474 | #ifdef NS_IMPL_COCOA | 5496 | #ifdef NS_IMPL_COCOA |
| @@ -5511,12 +5533,13 @@ not_in_argv (NSString *arg) | |||
| 5511 | 5533 | ||
| 5512 | - (void)windowDidResize: (NSNotification *)notification | 5534 | - (void)windowDidResize: (NSNotification *)notification |
| 5513 | { | 5535 | { |
| 5514 | 5536 | if (! [self fsIsNative]) | |
| 5515 | #if !defined (NEW_STYLE_FS) && ! defined (NS_IMPL_GNUSTEP) | 5537 | { |
| 5516 | NSWindow *theWindow = [notification object]; | 5538 | NSWindow *theWindow = [notification object]; |
| 5517 | /* We can get notification on the non-FS window when in fullscreen mode. */ | 5539 | /* We can get notification on the non-FS window when in |
| 5518 | if ([self window] != theWindow) return; | 5540 | fullscreen mode. */ |
| 5519 | #endif | 5541 | if ([self window] != theWindow) return; |
| 5542 | } | ||
| 5520 | 5543 | ||
| 5521 | #ifdef NS_IMPL_GNUSTEP | 5544 | #ifdef NS_IMPL_GNUSTEP |
| 5522 | NSWindow *theWindow = [notification object]; | 5545 | NSWindow *theWindow = [notification object]; |
| @@ -5632,6 +5655,11 @@ not_in_argv (NSString *arg) | |||
| 5632 | scrollbarsNeedingUpdate = 0; | 5655 | scrollbarsNeedingUpdate = 0; |
| 5633 | fs_state = FULLSCREEN_NONE; | 5656 | fs_state = FULLSCREEN_NONE; |
| 5634 | fs_before_fs = next_maximized = -1; | 5657 | fs_before_fs = next_maximized = -1; |
| 5658 | #ifdef HAVE_NATIVE_FS | ||
| 5659 | fs_is_native = ns_use_native_fullscreen; | ||
| 5660 | #else | ||
| 5661 | fs_is_native = NO; | ||
| 5662 | #endif | ||
| 5635 | maximized_width = maximized_height = -1; | 5663 | maximized_width = maximized_height = -1; |
| 5636 | nonfs_window = nil; | 5664 | nonfs_window = nil; |
| 5637 | 5665 | ||
| @@ -5658,7 +5686,7 @@ not_in_argv (NSString *arg) | |||
| 5658 | backing: NSBackingStoreBuffered | 5686 | backing: NSBackingStoreBuffered |
| 5659 | defer: YES]; | 5687 | defer: YES]; |
| 5660 | 5688 | ||
| 5661 | #ifdef NEW_STYLE_FS | 5689 | #ifdef HAVE_NATIVE_FS |
| 5662 | [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; | 5690 | [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; |
| 5663 | #endif | 5691 | #endif |
| 5664 | 5692 | ||
| @@ -5867,6 +5895,15 @@ not_in_argv (NSString *arg) | |||
| 5867 | } | 5895 | } |
| 5868 | } | 5896 | } |
| 5869 | 5897 | ||
| 5898 | #ifdef HAVE_NATIVE_FS | ||
| 5899 | - (NSApplicationPresentationOptions)window:(NSWindow *)window | ||
| 5900 | willUseFullScreenPresentationOptions: | ||
| 5901 | (NSApplicationPresentationOptions)proposedOptions | ||
| 5902 | { | ||
| 5903 | return proposedOptions|NSApplicationPresentationAutoHideToolbar; | ||
| 5904 | } | ||
| 5905 | #endif | ||
| 5906 | |||
| 5870 | - (void)windowWillEnterFullScreen:(NSNotification *)notification | 5907 | - (void)windowWillEnterFullScreen:(NSNotification *)notification |
| 5871 | { | 5908 | { |
| 5872 | fs_before_fs = fs_state; | 5909 | fs_before_fs = fs_state; |
| @@ -5875,17 +5912,13 @@ not_in_argv (NSString *arg) | |||
| 5875 | - (void)windowDidEnterFullScreen:(NSNotification *)notification | 5912 | - (void)windowDidEnterFullScreen:(NSNotification *)notification |
| 5876 | { | 5913 | { |
| 5877 | [self setFSValue: FULLSCREEN_BOTH]; | 5914 | [self setFSValue: FULLSCREEN_BOTH]; |
| 5878 | #ifdef NEW_STYLE_FS | 5915 | if (! [self fsIsNative]) |
| 5879 | // Fix bad background. | ||
| 5880 | if ([toolbar isVisible]) | ||
| 5881 | { | 5916 | { |
| 5882 | [toolbar setVisible:NO]; | 5917 | [self windowDidBecomeKey:notification]; |
| 5883 | [toolbar setVisible:YES]; | 5918 | [nonfs_window orderOut:self]; |
| 5884 | } | 5919 | } |
| 5885 | #else | 5920 | else if (! FRAME_EXTERNAL_TOOL_BAR (emacsframe)) |
| 5886 | [self windowDidBecomeKey:notification]; | 5921 | [toolbar setVisible:NO]; |
| 5887 | [nonfs_window orderOut:self]; | ||
| 5888 | #endif | ||
| 5889 | } | 5922 | } |
| 5890 | 5923 | ||
| 5891 | - (void)windowWillExitFullScreen:(NSNotification *)notification | 5924 | - (void)windowWillExitFullScreen:(NSNotification *)notification |
| @@ -5898,24 +5931,76 @@ not_in_argv (NSString *arg) | |||
| 5898 | { | 5931 | { |
| 5899 | [self setFSValue: fs_before_fs]; | 5932 | [self setFSValue: fs_before_fs]; |
| 5900 | fs_before_fs = -1; | 5933 | fs_before_fs = -1; |
| 5934 | [self updateCollectionBehaviour]; | ||
| 5935 | if (FRAME_EXTERNAL_TOOL_BAR (emacsframe)) | ||
| 5936 | { | ||
| 5937 | [toolbar setVisible:YES]; | ||
| 5938 | update_frame_tool_bar (emacsframe); | ||
| 5939 | [self updateFrameSize:YES]; | ||
| 5940 | [[self window] display]; | ||
| 5941 | } | ||
| 5942 | else | ||
| 5943 | [toolbar setVisible:NO]; | ||
| 5944 | |||
| 5901 | if (next_maximized != -1) | 5945 | if (next_maximized != -1) |
| 5902 | [[self window] performZoom:self]; | 5946 | [[self window] performZoom:self]; |
| 5903 | } | 5947 | } |
| 5904 | 5948 | ||
| 5905 | - (void)toggleFullScreen: (id)sender | 5949 | - (BOOL)fsIsNative |
| 5906 | { | 5950 | { |
| 5907 | #ifdef NEW_STYLE_FS | 5951 | return fs_is_native; |
| 5908 | [[self window] toggleFullScreen:sender]; | 5952 | } |
| 5953 | |||
| 5954 | - (BOOL)isFullscreen | ||
| 5955 | { | ||
| 5956 | if (! fs_is_native) return nonfs_window != nil; | ||
| 5957 | #ifdef HAVE_NATIVE_FS | ||
| 5958 | return ([[self window] styleMask] & NSFullScreenWindowMask) != 0; | ||
| 5909 | #else | 5959 | #else |
| 5910 | NSWindow *w = [self window], *fw; | 5960 | return NO; |
| 5911 | BOOL onFirstScreen = [[w screen] | 5961 | #endif |
| 5912 | isEqual:[[NSScreen screens] objectAtIndex:0]]; | 5962 | } |
| 5913 | struct frame *f = emacsframe; | 5963 | |
| 5964 | #ifdef HAVE_NATIVE_FS | ||
| 5965 | - (void)updateCollectionBehaviour | ||
| 5966 | { | ||
| 5967 | if (! [self isFullscreen]) | ||
| 5968 | { | ||
| 5969 | NSWindow *win = [self window]; | ||
| 5970 | NSWindowCollectionBehavior b = [win collectionBehavior]; | ||
| 5971 | if (ns_use_native_fullscreen) | ||
| 5972 | b |= NSWindowCollectionBehaviorFullScreenPrimary; | ||
| 5973 | else | ||
| 5974 | b &= ~NSWindowCollectionBehaviorFullScreenPrimary; | ||
| 5975 | |||
| 5976 | [win setCollectionBehavior: b]; | ||
| 5977 | fs_is_native = ns_use_native_fullscreen; | ||
| 5978 | } | ||
| 5979 | } | ||
| 5980 | #endif | ||
| 5981 | |||
| 5982 | - (void)toggleFullScreen: (id)sender | ||
| 5983 | { | ||
| 5984 | NSWindow *w, *fw; | ||
| 5985 | BOOL onFirstScreen; | ||
| 5986 | struct frame *f; | ||
| 5914 | NSSize sz; | 5987 | NSSize sz; |
| 5915 | NSRect r, wr = [w frame]; | 5988 | NSRect r, wr; |
| 5916 | NSColor *col = ns_lookup_indexed_color (NS_FACE_BACKGROUND | 5989 | NSColor *col; |
| 5917 | (FRAME_DEFAULT_FACE (f)), | 5990 | |
| 5918 | f); | 5991 | if (fs_is_native) |
| 5992 | { | ||
| 5993 | [[self window] toggleFullScreen:sender]; | ||
| 5994 | return; | ||
| 5995 | } | ||
| 5996 | |||
| 5997 | w = [self window]; | ||
| 5998 | onFirstScreen = [[w screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; | ||
| 5999 | f = emacsframe; | ||
| 6000 | wr = [w frame]; | ||
| 6001 | col = ns_lookup_indexed_color (NS_FACE_BACKGROUND | ||
| 6002 | (FRAME_DEFAULT_FACE (f)), | ||
| 6003 | f); | ||
| 5919 | 6004 | ||
| 5920 | sz.width = FRAME_COLUMN_WIDTH (f); | 6005 | sz.width = FRAME_COLUMN_WIDTH (f); |
| 5921 | sz.height = FRAME_LINE_HEIGHT (f); | 6006 | sz.height = FRAME_LINE_HEIGHT (f); |
| @@ -5958,7 +6043,6 @@ not_in_argv (NSString *arg) | |||
| 5958 | FRAME_NS_TITLEBAR_HEIGHT (f) = 0; | 6043 | FRAME_NS_TITLEBAR_HEIGHT (f) = 0; |
| 5959 | tobar_height = FRAME_TOOLBAR_HEIGHT (f); | 6044 | tobar_height = FRAME_TOOLBAR_HEIGHT (f); |
| 5960 | FRAME_TOOLBAR_HEIGHT (f) = 0; | 6045 | FRAME_TOOLBAR_HEIGHT (f) = 0; |
| 5961 | FRAME_EXTERNAL_TOOL_BAR (f) = 0; | ||
| 5962 | 6046 | ||
| 5963 | nonfs_window = w; | 6047 | nonfs_window = w; |
| 5964 | 6048 | ||
| @@ -5995,17 +6079,16 @@ not_in_argv (NSString *arg) | |||
| 5995 | 6079 | ||
| 5996 | f->border_width = bwidth; | 6080 | f->border_width = bwidth; |
| 5997 | FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height; | 6081 | FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height; |
| 5998 | FRAME_TOOLBAR_HEIGHT (f) = tobar_height; | 6082 | if (FRAME_EXTERNAL_TOOL_BAR (f)) |
| 5999 | if (tobar_height) | 6083 | FRAME_TOOLBAR_HEIGHT (f) = tobar_height; |
| 6000 | FRAME_EXTERNAL_TOOL_BAR (f) = 1; | ||
| 6001 | 6084 | ||
| 6002 | [self windowWillExitFullScreen:nil]; | 6085 | [self windowWillExitFullScreen:nil]; |
| 6003 | [fw setFrame: [w frame] display:YES animate:YES]; | 6086 | [fw setFrame: [w frame] display:YES animate:YES]; |
| 6004 | [fw close]; | 6087 | [fw close]; |
| 6005 | [w makeKeyAndOrderFront:NSApp]; | 6088 | [w makeKeyAndOrderFront:NSApp]; |
| 6006 | [self windowDidExitFullScreen:nil]; | 6089 | [self windowDidExitFullScreen:nil]; |
| 6090 | [self updateFrameSize:YES]; | ||
| 6007 | } | 6091 | } |
| 6008 | #endif | ||
| 6009 | } | 6092 | } |
| 6010 | 6093 | ||
| 6011 | - (void)handleFS | 6094 | - (void)handleFS |
| @@ -7159,6 +7242,18 @@ allowing it to be used at a lower level for accented character entry."); | |||
| 7159 | Only works on OSX 10.6 or later. */); | 7242 | Only works on OSX 10.6 or later. */); |
| 7160 | ns_auto_hide_menu_bar = Qnil; | 7243 | ns_auto_hide_menu_bar = Qnil; |
| 7161 | 7244 | ||
| 7245 | DEFVAR_BOOL ("ns-use-native-fullscreen", ns_use_native_fullscreen, | ||
| 7246 | doc: /*Non-nil means to use native fullscreen on OSX >= 10.7. | ||
| 7247 | Nil means use fullscreen the old (< 10.7) way. The old way works better with | ||
| 7248 | multiple monitors, but lacks tool bar. This variable is ignored on OSX < 10.7. | ||
| 7249 | Default is t for OSX >= 10.7, nil otherwise. */); | ||
| 7250 | #ifdef HAVE_NATIVE_FS | ||
| 7251 | ns_use_native_fullscreen = YES; | ||
| 7252 | #else | ||
| 7253 | ns_use_native_fullscreen = NO; | ||
| 7254 | #endif | ||
| 7255 | ns_last_use_native_fullscreen = ns_use_native_fullscreen; | ||
| 7256 | |||
| 7162 | /* TODO: move to common code */ | 7257 | /* TODO: move to common code */ |
| 7163 | DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, | 7258 | DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, |
| 7164 | doc: /* Which toolkit scroll bars Emacs uses, if any. | 7259 | doc: /* Which toolkit scroll bars Emacs uses, if any. |