From 60902756b0d794b16b9c1c67c4c40a3ac04d1c1b Mon Sep 17 00:00:00 2001 From: Anders Lindgren Date: Tue, 26 Jan 2016 13:51:59 +0100 Subject: [PATCH] Fixed NextStep fullscreen issue (bug#22468) When in fullscreen mode, `[screen visibleFrame]' sometimes includes, sometimes excludes the menu bar. This could cause a frame to be placed too low when in fullscreen mode. * src/nsterm.m (ns_menu_bar_should_be_hidden): Trace. (constrain_frame_rect): New parameter, isFullscreen, when true don't query the height of the menu bar. (ns_constrain_all_frames): Pass `false' (isFullscreen) to `constrain_frame_rect'. ([EmacsView initFrameFromEmacs:]): Trace. ([EmacsView isFullscreen]): Trace. ([EmacsWindow constrainFrameRect:toScreen:]): Pass fullscreen state to `constrain_frame_rect'. --- src/nsterm.m | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 19083ef21f..f77aadba67 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -637,10 +637,11 @@ ns_menu_bar_should_be_hidden (void) static CGFloat ns_menu_bar_height (NSScreen *screen) -/* The height of the menu bar, if visible. */ -{ - // NSTRACE ("ns_menu_bar_height"); +/* The height of the menu bar, if visible. + Note: Don't use this when fullscreen is enabled -- the screen + sometimes includes, sometimes excludes the menu bar area. */ +{ CGFloat res; if (ns_menu_bar_should_be_hidden()) @@ -660,7 +661,7 @@ ns_menu_bar_height (NSScreen *screen) } - // NSTRACE_MSG (NSTRACE_FMT_RETURN "%.0f", res); + NSTRACE ("ns_menu_bar_height " NSTRACE_FMT_RETURN " %.0f", res); return res; } @@ -714,7 +715,7 @@ ns_menu_bar_height (NSScreen *screen) // Result: Menu bar visible, frame placed immediately below the menu. // -static NSRect constrain_frame_rect(NSRect frameRect) +static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) { NSTRACE ("constrain_frame_rect(" NSTRACE_FMT_RECT ")", NSTRACE_ARG_RECT (frameRect)); @@ -746,7 +747,11 @@ static NSRect constrain_frame_rect(NSRect frameRect) { multiscreenRect = NSUnionRect (multiscreenRect, scrRect); - menu_bar_height = max(menu_bar_height, ns_menu_bar_height (s)); + if (!isFullscreen) + { + CGFloat screen_menu_bar_height = ns_menu_bar_height (s); + menu_bar_height = max(menu_bar_height, screen_menu_bar_height); + } } } @@ -840,7 +845,7 @@ ns_constrain_all_frames (void) if (![view isFullscreen]) { [[view window] - setFrame:constrain_frame_rect([[view window] frame]) + setFrame:constrain_frame_rect([[view window] frame], false) display:NO]; } } @@ -6650,7 +6655,7 @@ not_in_argv (NSString *arg) NSString *name; NSTRACE ("[EmacsView initFrameFromEmacs:]"); - NSTRACE_MSG ("cols:%d lines:%d\n", f->text_cols, f->text_lines); + NSTRACE_MSG ("cols:%d lines:%d", f->text_cols, f->text_lines); windowClosing = NO; processingCompose = NO; @@ -7099,14 +7104,25 @@ not_in_argv (NSString *arg) - (BOOL)isFullscreen { - NSTRACE ("[EmacsView isFullscreen]"); + BOOL res; - if (! fs_is_native) return nonfs_window != nil; + if (! fs_is_native) + { + res = (nonfs_window != nil); + } + else + { #ifdef HAVE_NATIVE_FS - return ([[self window] styleMask] & NSFullScreenWindowMask) != 0; + res = (([[self window] styleMask] & NSFullScreenWindowMask) != 0); #else - return NO; + res = NO; #endif + } + + NSTRACE ("[EmacsView isFullscreen] " NSTRACE_FMT_RETURN " %d", + (int) res); + + return res; } #ifdef HAVE_NATIVE_FS @@ -7772,7 +7788,8 @@ not_in_argv (NSString *arg) #endif #endif - return constrain_frame_rect(frameRect); + return constrain_frame_rect(frameRect, + [(EmacsView *)[self delegate] isFullscreen]); } -- 2.39.2