diff options
| author | Jan Djärv | 2012-10-06 19:31:11 +0200 |
|---|---|---|
| committer | Jan Djärv | 2012-10-06 19:31:11 +0200 |
| commit | 04fafa467506fe9ca9b77d9cdc3f8e25cb8fd5d3 (patch) | |
| tree | b979881a01a83b9faf1fe22765e068617a04a2c8 /src | |
| parent | d39109c3e111bf2403f6e636ff1273f2701683e7 (diff) | |
| download | emacs-04fafa467506fe9ca9b77d9cdc3f8e25cb8fd5d3.tar.gz emacs-04fafa467506fe9ca9b77d9cdc3f8e25cb8fd5d3.zip | |
Handle fullscreen parameter in initial/defult-frame-alist for NS.
* nsfns.m (Fx_create_frame): Call x_default_parameter with
fullscreen/Fullscreen.
* nsterm.h (EmacsView): Rename tbar_height to tibar_height.
tobar_height is new.
* nsterm.m (x_make_frame_visible): Check for fullscreen.
(ns_fullscreen_hook): Activate old style fullscreen with a timer.
(ns_term_init): Set activateIgnoringOtherApps if old style fullscreen.
(windowDidResize:): Check for correct window if old style fullscreen.
Capitalize word in comment. Remove incorrect comment.
(initFrameFromEmacs:): tbar_height renamed tibar_height.
(windowDidEnterFullScreen:): Toggle toolbar for fullscreen to fix
error in drawing background.
(toggleFullScreen:): Remove comment. Rearrange calls.
Set toolbar values to zero, save old height in tobar_height.
Restore tool bar height when leaving fullscreen.
(canBecomeMainWindow): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 21 | ||||
| -rw-r--r-- | src/nsfns.m | 2 | ||||
| -rw-r--r-- | src/nsterm.h | 3 | ||||
| -rw-r--r-- | src/nsterm.m | 87 |
4 files changed, 94 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 956e78e6c7e..b960837eaab 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2012-10-06 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsfns.m (Fx_create_frame): Call x_default_parameter with | ||
| 4 | fullscreen/Fullscreen. | ||
| 5 | |||
| 6 | * nsterm.h (EmacsView): Rename tbar_height to tibar_height. | ||
| 7 | tobar_height is new. | ||
| 8 | |||
| 9 | * nsterm.m (x_make_frame_visible): Check for fullscreen. | ||
| 10 | (ns_fullscreen_hook): Activate old style fullscreen with a timer. | ||
| 11 | (ns_term_init): Set activateIgnoringOtherApps if old style fullscreen. | ||
| 12 | (windowDidResize:): Check for correct window if old style fullscreen. | ||
| 13 | Capitalize word in comment. Remove incorrect comment. | ||
| 14 | (initFrameFromEmacs:): tbar_height renamed tibar_height. | ||
| 15 | (windowDidEnterFullScreen:): Toggle toolbar for fullscreen to fix | ||
| 16 | error in drawing background. | ||
| 17 | (toggleFullScreen:): Remove comment. Rearrange calls. | ||
| 18 | Set toolbar values to zero, save old height in tobar_height. | ||
| 19 | Restore tool bar height when leaving fullscreen. | ||
| 20 | (canBecomeMainWindow): New function. | ||
| 21 | |||
| 1 | 2012-10-06 Paul Eggert <eggert@cs.ucla.edu> | 22 | 2012-10-06 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 23 | ||
| 3 | * keyboard.c (read_char): Remove unnecessary 'volatile's and label. | 24 | * keyboard.c (read_char): Remove unnecessary 'volatile's and label. |
diff --git a/src/nsfns.m b/src/nsfns.m index 1efadf0cb98..f22198401e0 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -1346,6 +1346,8 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1346 | RES_TYPE_NUMBER); | 1346 | RES_TYPE_NUMBER); |
| 1347 | x_default_parameter (f, parms, Qalpha, Qnil, | 1347 | x_default_parameter (f, parms, Qalpha, Qnil, |
| 1348 | "alpha", "Alpha", RES_TYPE_NUMBER); | 1348 | "alpha", "Alpha", RES_TYPE_NUMBER); |
| 1349 | x_default_parameter (f, parms, Qfullscreen, Qnil, | ||
| 1350 | "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); | ||
| 1349 | 1351 | ||
| 1350 | width = FRAME_COLS (f); | 1352 | width = FRAME_COLS (f); |
| 1351 | height = FRAME_LINES (f); | 1353 | height = FRAME_LINES (f); |
diff --git a/src/nsterm.h b/src/nsterm.h index f06e0cb0f7f..f1cd7458bdc 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -86,7 +86,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 86 | BOOL windowClosing; | 86 | BOOL windowClosing; |
| 87 | NSString *workingText; | 87 | NSString *workingText; |
| 88 | BOOL processingCompose; | 88 | BOOL processingCompose; |
| 89 | int fs_state, fs_before_fs, next_maximized, tbar_height, bwidth; | 89 | int fs_state, fs_before_fs, next_maximized; |
| 90 | int tibar_height, tobar_height, bwidth; | ||
| 90 | int maximized_width, maximized_height; | 91 | int maximized_width, maximized_height; |
| 91 | NSWindow *nonfs_window; | 92 | NSWindow *nonfs_window; |
| 92 | @public | 93 | @public |
diff --git a/src/nsterm.m b/src/nsterm.m index 2df0e1a1ad5..0d0be9281ee 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1068,8 +1068,23 @@ x_make_frame_visible (struct frame *f) | |||
| 1068 | if this ends up the case again, comment this out again. */ | 1068 | if this ends up the case again, comment this out again. */ |
| 1069 | if (!FRAME_VISIBLE_P (f)) | 1069 | if (!FRAME_VISIBLE_P (f)) |
| 1070 | { | 1070 | { |
| 1071 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); | ||
| 1071 | f->async_visible = 1; | 1072 | f->async_visible = 1; |
| 1072 | ns_raise_frame (f); | 1073 | ns_raise_frame (f); |
| 1074 | |||
| 1075 | #ifdef NEW_STYLE_FS | ||
| 1076 | /* Making a new frame from a fullscreen frame will make the new frame | ||
| 1077 | fullscreen also. So skip handleFS as this will print an error. */ | ||
| 1078 | if (f->want_fullscreen == FULLSCREEN_BOTH | ||
| 1079 | && ([[view window] styleMask] & NSFullScreenWindowMask) != 0) | ||
| 1080 | return; | ||
| 1081 | #endif | ||
| 1082 | if (f->want_fullscreen != FULLSCREEN_NONE) | ||
| 1083 | { | ||
| 1084 | block_input (); | ||
| 1085 | [view handleFS]; | ||
| 1086 | unblock_input (); | ||
| 1087 | } | ||
| 1073 | } | 1088 | } |
| 1074 | } | 1089 | } |
| 1075 | 1090 | ||
| @@ -1317,6 +1332,18 @@ ns_fullscreen_hook (FRAME_PTR f) | |||
| 1317 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); | 1332 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); |
| 1318 | 1333 | ||
| 1319 | if (! f->async_visible) return; | 1334 | if (! f->async_visible) return; |
| 1335 | #ifndef NEW_STYLE_FS | ||
| 1336 | if (f->want_fullscreen == FULLSCREEN_BOTH) | ||
| 1337 | { | ||
| 1338 | /* Old style fs don't initiate correctly if created from | ||
| 1339 | init/default-frame alist, so use a timer (not nice...). | ||
| 1340 | */ | ||
| 1341 | [NSTimer scheduledTimerWithTimeInterval: 0.5 target: view | ||
| 1342 | selector: @selector (handleFS) | ||
| 1343 | userInfo: nil repeats: NO]; | ||
| 1344 | return; | ||
| 1345 | } | ||
| 1346 | #endif | ||
| 1320 | 1347 | ||
| 1321 | block_input (); | 1348 | block_input (); |
| 1322 | [view handleFS]; | 1349 | [view handleFS]; |
| @@ -4210,6 +4237,11 @@ ns_term_init (Lisp_Object display_name) | |||
| 4210 | NSColorPboardType, | 4237 | NSColorPboardType, |
| 4211 | NSFontPboardType, nil] retain]; | 4238 | NSFontPboardType, nil] retain]; |
| 4212 | 4239 | ||
| 4240 | #ifndef NEW_STYLE_FS | ||
| 4241 | /* If fullscreen is in init/default-frame-alist, focus isn't set | ||
| 4242 | right for fullscreen windows, so set this. */ | ||
| 4243 | [NSApp activateIgnoringOtherApps:YES]; | ||
| 4244 | #endif | ||
| 4213 | 4245 | ||
| 4214 | [NSApp run]; | 4246 | [NSApp run]; |
| 4215 | ns_do_open_file = YES; | 4247 | ns_do_open_file = YES; |
| @@ -5505,10 +5537,17 @@ not_in_argv (NSString *arg) | |||
| 5505 | 5537 | ||
| 5506 | - (void)windowDidResize: (NSNotification *)notification | 5538 | - (void)windowDidResize: (NSNotification *)notification |
| 5507 | { | 5539 | { |
| 5540 | |||
| 5541 | #if !defined (NEW_STYLE_FS) && ! defined (NS_IMPL_GNUSTEP) | ||
| 5542 | NSWindow *theWindow = [notification object]; | ||
| 5543 | /* We can get notification on the non-FS window when in fullscreen mode. */ | ||
| 5544 | if ([self window] != theWindow) return; | ||
| 5545 | #endif | ||
| 5546 | |||
| 5508 | #ifdef NS_IMPL_GNUSTEP | 5547 | #ifdef NS_IMPL_GNUSTEP |
| 5509 | NSWindow *theWindow = [notification object]; | 5548 | NSWindow *theWindow = [notification object]; |
| 5510 | 5549 | ||
| 5511 | /* in GNUstep, at least currently, it's possible to get a didResize | 5550 | /* In GNUstep, at least currently, it's possible to get a didResize |
| 5512 | without getting a willResize.. therefore we need to act as if we got | 5551 | without getting a willResize.. therefore we need to act as if we got |
| 5513 | the willResize now */ | 5552 | the willResize now */ |
| 5514 | NSSize sz = [theWindow frame].size; | 5553 | NSSize sz = [theWindow frame].size; |
| @@ -5526,10 +5565,6 @@ not_in_argv (NSString *arg) | |||
| 5526 | } | 5565 | } |
| 5527 | #endif /* NS_IMPL_COCOA */ | 5566 | #endif /* NS_IMPL_COCOA */ |
| 5528 | 5567 | ||
| 5529 | /* Avoid loop under GNUstep due to call at beginning of this function. | ||
| 5530 | (x_set_window_size causes a resize which causes | ||
| 5531 | a "windowDidResize" which calls x_set_window_size). */ | ||
| 5532 | #ifndef NS_IMPL_GNUSTEP | ||
| 5533 | if (cols > 0 && rows > 0) | 5568 | if (cols > 0 && rows > 0) |
| 5534 | { | 5569 | { |
| 5535 | if (ns_in_resize) | 5570 | if (ns_in_resize) |
| @@ -5539,7 +5574,6 @@ not_in_argv (NSString *arg) | |||
| 5539 | [self updateFrameSize: YES]; | 5574 | [self updateFrameSize: YES]; |
| 5540 | } | 5575 | } |
| 5541 | } | 5576 | } |
| 5542 | #endif | ||
| 5543 | 5577 | ||
| 5544 | ns_send_appdefined (-1); | 5578 | ns_send_appdefined (-1); |
| 5545 | } | 5579 | } |
| @@ -5661,7 +5695,7 @@ not_in_argv (NSString *arg) | |||
| 5661 | 5695 | ||
| 5662 | wr = [win frame]; | 5696 | wr = [win frame]; |
| 5663 | bwidth = f->border_width = wr.size.width - r.size.width; | 5697 | bwidth = f->border_width = wr.size.width - r.size.width; |
| 5664 | tbar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height; | 5698 | tibar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height; |
| 5665 | 5699 | ||
| 5666 | [win setAcceptsMouseMovedEvents: YES]; | 5700 | [win setAcceptsMouseMovedEvents: YES]; |
| 5667 | [win setDelegate: self]; | 5701 | [win setDelegate: self]; |
| @@ -5870,8 +5904,16 @@ not_in_argv (NSString *arg) | |||
| 5870 | - (void)windowDidEnterFullScreen:(NSNotification *)notification | 5904 | - (void)windowDidEnterFullScreen:(NSNotification *)notification |
| 5871 | { | 5905 | { |
| 5872 | [self setFSValue: FULLSCREEN_BOTH]; | 5906 | [self setFSValue: FULLSCREEN_BOTH]; |
| 5873 | #ifndef NEW_STYLE_FS | 5907 | #ifdef NEW_STYLE_FS |
| 5908 | // Fix bad background. | ||
| 5909 | if ([toolbar isVisible]) | ||
| 5910 | { | ||
| 5911 | [toolbar setVisible:NO]; | ||
| 5912 | [toolbar setVisible:YES]; | ||
| 5913 | } | ||
| 5914 | #else | ||
| 5874 | [self windowDidBecomeKey:notification]; | 5915 | [self windowDidBecomeKey:notification]; |
| 5916 | [nonfs_window orderOut:self]; | ||
| 5875 | #endif | 5917 | #endif |
| 5876 | } | 5918 | } |
| 5877 | 5919 | ||
| @@ -5891,11 +5933,6 @@ not_in_argv (NSString *arg) | |||
| 5891 | 5933 | ||
| 5892 | - (void)toggleFullScreen: (id)sender | 5934 | - (void)toggleFullScreen: (id)sender |
| 5893 | { | 5935 | { |
| 5894 | /* Bugs remain: | ||
| 5895 | 1) Having fullscreen in initial/default frame alist. | ||
| 5896 | 2) Fullscreen in default frame alist only applied to first frame. | ||
| 5897 | */ | ||
| 5898 | |||
| 5899 | #ifdef NEW_STYLE_FS | 5936 | #ifdef NEW_STYLE_FS |
| 5900 | [[self window] toggleFullScreen:sender]; | 5937 | [[self window] toggleFullScreen:sender]; |
| 5901 | #else | 5938 | #else |
| @@ -5904,7 +5941,7 @@ not_in_argv (NSString *arg) | |||
| 5904 | isEqual:[[NSScreen screens] objectAtIndex:0]]; | 5941 | isEqual:[[NSScreen screens] objectAtIndex:0]]; |
| 5905 | struct frame *f = emacsframe; | 5942 | struct frame *f = emacsframe; |
| 5906 | NSSize sz; | 5943 | NSSize sz; |
| 5907 | NSRect r; | 5944 | NSRect r, wr = [w frame]; |
| 5908 | NSColor *col = ns_lookup_indexed_color (NS_FACE_BACKGROUND | 5945 | NSColor *col = ns_lookup_indexed_color (NS_FACE_BACKGROUND |
| 5909 | (FRAME_DEFAULT_FACE (f)), | 5946 | (FRAME_DEFAULT_FACE (f)), |
| 5910 | f); | 5947 | f); |
| @@ -5930,7 +5967,7 @@ not_in_argv (NSString *arg) | |||
| 5930 | } | 5967 | } |
| 5931 | 5968 | ||
| 5932 | fw = [[EmacsFSWindow alloc] | 5969 | fw = [[EmacsFSWindow alloc] |
| 5933 | initWithContentRect:[w contentRectForFrameRect:[w frame]] | 5970 | initWithContentRect:[w contentRectForFrameRect:wr] |
| 5934 | styleMask:NSBorderlessWindowMask | 5971 | styleMask:NSBorderlessWindowMask |
| 5935 | backing:NSBackingStoreBuffered | 5972 | backing:NSBackingStoreBuffered |
| 5936 | defer:YES | 5973 | defer:YES |
| @@ -5938,9 +5975,7 @@ not_in_argv (NSString *arg) | |||
| 5938 | 5975 | ||
| 5939 | [fw setContentView:[w contentView]]; | 5976 | [fw setContentView:[w contentView]]; |
| 5940 | [fw setTitle:[w title]]; | 5977 | [fw setTitle:[w title]]; |
| 5941 | [fw makeKeyAndOrderFront:NSApp]; | ||
| 5942 | [fw setDelegate:self]; | 5978 | [fw setDelegate:self]; |
| 5943 | [fw makeFirstResponder:self]; | ||
| 5944 | [fw setAcceptsMouseMovedEvents: YES]; | 5979 | [fw setAcceptsMouseMovedEvents: YES]; |
| 5945 | [fw useOptimizedDrawing: YES]; | 5980 | [fw useOptimizedDrawing: YES]; |
| 5946 | [fw setResizeIncrements: sz]; | 5981 | [fw setResizeIncrements: sz]; |
| @@ -5950,18 +5985,26 @@ not_in_argv (NSString *arg) | |||
| 5950 | 5985 | ||
| 5951 | f->border_width = 0; | 5986 | f->border_width = 0; |
| 5952 | FRAME_NS_TITLEBAR_HEIGHT (f) = 0; | 5987 | FRAME_NS_TITLEBAR_HEIGHT (f) = 0; |
| 5988 | tobar_height = FRAME_TOOLBAR_HEIGHT (f); | ||
| 5989 | FRAME_TOOLBAR_HEIGHT (f) = 0; | ||
| 5990 | FRAME_EXTERNAL_TOOL_BAR (f) = 0; | ||
| 5953 | 5991 | ||
| 5954 | nonfs_window = w; | 5992 | nonfs_window = w; |
| 5993 | |||
| 5955 | [self windowWillEnterFullScreen:nil]; | 5994 | [self windowWillEnterFullScreen:nil]; |
| 5995 | [fw makeKeyAndOrderFront:NSApp]; | ||
| 5996 | [fw makeFirstResponder:self]; | ||
| 5956 | [w orderOut:self]; | 5997 | [w orderOut:self]; |
| 5957 | r = [fw frameRectForContentRect:[[fw screen] frame]]; | 5998 | r = [fw frameRectForContentRect:[[fw screen] frame]]; |
| 5958 | [fw setFrame: r display:YES animate:YES]; | 5999 | [fw setFrame: r display:YES animate:YES]; |
| 5959 | [self windowDidEnterFullScreen:nil]; | 6000 | [self windowDidEnterFullScreen:nil]; |
| 6001 | [fw display]; | ||
| 5960 | } | 6002 | } |
| 5961 | else | 6003 | else |
| 5962 | { | 6004 | { |
| 5963 | fw = w; | 6005 | fw = w; |
| 5964 | w = nonfs_window; | 6006 | w = nonfs_window; |
| 6007 | nonfs_window = nil; | ||
| 5965 | 6008 | ||
| 5966 | if (onFirstScreen) | 6009 | if (onFirstScreen) |
| 5967 | { | 6010 | { |
| @@ -5980,7 +6023,10 @@ not_in_argv (NSString *arg) | |||
| 5980 | [w setOpaque: NO]; | 6023 | [w setOpaque: NO]; |
| 5981 | 6024 | ||
| 5982 | f->border_width = bwidth; | 6025 | f->border_width = bwidth; |
| 5983 | FRAME_NS_TITLEBAR_HEIGHT (f) = tbar_height; | 6026 | FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height; |
| 6027 | FRAME_TOOLBAR_HEIGHT (f) = tobar_height; | ||
| 6028 | if (tobar_height) | ||
| 6029 | FRAME_EXTERNAL_TOOL_BAR (f) = 1; | ||
| 5984 | 6030 | ||
| 5985 | [self windowWillExitFullScreen:nil]; | 6031 | [self windowWillExitFullScreen:nil]; |
| 5986 | [fw setFrame: [w frame] display:YES animate:YES]; | 6032 | [fw setFrame: [w frame] display:YES animate:YES]; |
| @@ -6553,6 +6599,11 @@ not_in_argv (NSString *arg) | |||
| 6553 | return YES; | 6599 | return YES; |
| 6554 | } | 6600 | } |
| 6555 | 6601 | ||
| 6602 | - (BOOL)canBecomeMainWindow | ||
| 6603 | { | ||
| 6604 | return YES; | ||
| 6605 | } | ||
| 6606 | |||
| 6556 | @end | 6607 | @end |
| 6557 | 6608 | ||
| 6558 | /* ========================================================================== | 6609 | /* ========================================================================== |