diff options
| author | Andrii Kolomoiets | 2020-03-10 10:14:59 +0200 |
|---|---|---|
| committer | Alan Third | 2020-03-12 23:16:41 +0000 |
| commit | bbc48b263485c26c6823eabdbbd7e9af62178e34 (patch) | |
| tree | 38e2a564d3b598edb04b6f737061a1df074f2d33 /src | |
| parent | 3db5a51384d80306b3279c2c0ceaf48e18e49474 (diff) | |
| download | emacs-bbc48b263485c26c6823eabdbbd7e9af62178e34.tar.gz emacs-bbc48b263485c26c6823eabdbbd7e9af62178e34.zip | |
Fix NS child frame in native fullscreen (bug#36672)
* lisp/frame.el (toggle-frame-fullscreen): Don't sleep on cocoa.
Fullscreen animation waiting is moved to src/nsterm.m.
* src/nsterm.h (EmacsView): Add in_fullscreen_transition,
inFullScreenTransition, waitFullScreenTransition.
(NSWindowCollectionBehaviorFullScreenAuxiliary): New define.
* src/nsterm.m (ns_make_frame_visible): Wait for fullscreen animation.
(ns_set_parent_frame): Set frame collection behavior; make child frames
non-fullscreen; make non-child frames fullscreen if parent was fullscreen.
([EmacsView initFrameFromEmacs]): Set in_fullscreen_transition; set frame
collection behavior according to parent frame.
([EmacsView windowDidMove]): Remove code by commenting with "fixme".
([EmacsView windowWillEnterFullScreen], [EmacsView windowDidEnterFullScreen])
([EmacsView windowWillExitFullScreen], [EmacsView windowDidExitFullScreen]):
Set in_fullscreen_transition.
([EmacsView inFullScreenTransition], [EmacsView waitFullScreenTransition]):
New methods.
([EmacsView updateCollectionBehavior]): Set collection behavior according to
parent frame.
([EmacsView toggleFullScreen]): Wait for fullscreen animation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.h | 4 | ||||
| -rw-r--r-- | src/nsterm.m | 107 |
2 files changed, 99 insertions, 12 deletions
diff --git a/src/nsterm.h b/src/nsterm.h index db966e1581b..8396a542f77 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -433,6 +433,7 @@ typedef id instancetype; | |||
| 433 | int maximized_width, maximized_height; | 433 | int maximized_width, maximized_height; |
| 434 | NSWindow *nonfs_window; | 434 | NSWindow *nonfs_window; |
| 435 | BOOL fs_is_native; | 435 | BOOL fs_is_native; |
| 436 | BOOL in_fullscreen_transition; | ||
| 436 | #ifdef NS_DRAW_TO_BUFFER | 437 | #ifdef NS_DRAW_TO_BUFFER |
| 437 | CGContextRef drawingBuffer; | 438 | CGContextRef drawingBuffer; |
| 438 | #endif | 439 | #endif |
| @@ -467,6 +468,8 @@ typedef id instancetype; | |||
| 467 | - (void) toggleFullScreen: (id) sender; | 468 | - (void) toggleFullScreen: (id) sender; |
| 468 | - (BOOL) fsIsNative; | 469 | - (BOOL) fsIsNative; |
| 469 | - (BOOL) isFullscreen; | 470 | - (BOOL) isFullscreen; |
| 471 | - (BOOL) inFullScreenTransition; | ||
| 472 | - (void) waitFullScreenTransition; | ||
| 470 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | 473 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 |
| 471 | - (void) updateCollectionBehavior; | 474 | - (void) updateCollectionBehavior; |
| 472 | #endif | 475 | #endif |
| @@ -1286,6 +1289,7 @@ extern char gnustep_base_version[]; /* version tracking */ | |||
| 1286 | #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_7) | 1289 | #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_7) |
| 1287 | #define NSFullScreenWindowMask (1 << 14) | 1290 | #define NSFullScreenWindowMask (1 << 14) |
| 1288 | #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7) | 1291 | #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7) |
| 1292 | #define NSWindowCollectionBehaviorFullScreenAuxiliary (1 << 8) | ||
| 1289 | #define NSApplicationPresentationFullScreen (1 << 10) | 1293 | #define NSApplicationPresentationFullScreen (1 << 10) |
| 1290 | #define NSApplicationPresentationAutoHideToolbar (1 << 11) | 1294 | #define NSApplicationPresentationAutoHideToolbar (1 << 11) |
| 1291 | #define NSAppKitVersionNumber10_7 1138 | 1295 | #define NSAppKitVersionNumber10_7 1138 |
diff --git a/src/nsterm.m b/src/nsterm.m index 851a5617d7b..96a7fdc0184 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1571,9 +1571,12 @@ ns_make_frame_visible (struct frame *f) | |||
| 1571 | 1571 | ||
| 1572 | /* Making a new frame from a fullscreen frame will make the new frame | 1572 | /* Making a new frame from a fullscreen frame will make the new frame |
| 1573 | fullscreen also. So skip handleFS as this will print an error. */ | 1573 | fullscreen also. So skip handleFS as this will print an error. */ |
| 1574 | if ([view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH | 1574 | if ([view fsIsNative] && [view isFullscreen]) |
| 1575 | && [view isFullscreen]) | 1575 | { |
| 1576 | return; | 1576 | // maybe it is not necessary to wait |
| 1577 | [view waitFullScreenTransition]; | ||
| 1578 | return; | ||
| 1579 | } | ||
| 1577 | 1580 | ||
| 1578 | if (f->want_fullscreen != FULLSCREEN_NONE) | 1581 | if (f->want_fullscreen != FULLSCREEN_NONE) |
| 1579 | { | 1582 | { |
| @@ -1959,8 +1962,16 @@ ns_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_val | |||
| 1959 | block_input (); | 1962 | block_input (); |
| 1960 | child = [FRAME_NS_VIEW (f) window]; | 1963 | child = [FRAME_NS_VIEW (f) window]; |
| 1961 | 1964 | ||
| 1965 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | ||
| 1966 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); | ||
| 1967 | #endif | ||
| 1968 | |||
| 1962 | if ([child parentWindow] != nil) | 1969 | if ([child parentWindow] != nil) |
| 1963 | { | 1970 | { |
| 1971 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | ||
| 1972 | parent = [child parentWindow]; | ||
| 1973 | #endif | ||
| 1974 | |||
| 1964 | [[child parentWindow] removeChildWindow:child]; | 1975 | [[child parentWindow] removeChildWindow:child]; |
| 1965 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 | 1976 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
| 1966 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 | 1977 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 |
| @@ -1968,10 +1979,38 @@ ns_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_val | |||
| 1968 | #endif | 1979 | #endif |
| 1969 | [child setAccessibilitySubrole:NSAccessibilityStandardWindowSubrole]; | 1980 | [child setAccessibilitySubrole:NSAccessibilityStandardWindowSubrole]; |
| 1970 | #endif | 1981 | #endif |
| 1982 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | ||
| 1983 | if (NILP (new_value)) | ||
| 1984 | { | ||
| 1985 | NSTRACE ("child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary"); | ||
| 1986 | [child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; | ||
| 1987 | // if current parent in fullscreen and no new parent make child fullscreen | ||
| 1988 | while (parent) { | ||
| 1989 | if (([parent styleMask] & NSWindowStyleMaskFullScreen) != 0) | ||
| 1990 | { | ||
| 1991 | [view toggleFullScreen:child]; | ||
| 1992 | break; | ||
| 1993 | } | ||
| 1994 | // check all parents | ||
| 1995 | parent = [parent parentWindow]; | ||
| 1996 | } | ||
| 1997 | } | ||
| 1998 | #endif | ||
| 1971 | } | 1999 | } |
| 1972 | 2000 | ||
| 1973 | if (!NILP (new_value)) | 2001 | if (!NILP (new_value)) |
| 1974 | { | 2002 | { |
| 2003 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | ||
| 2004 | // child frame must not be in fullscreen | ||
| 2005 | if ([view fsIsNative] && [view isFullscreen]) | ||
| 2006 | { | ||
| 2007 | // in case child is going fullscreen | ||
| 2008 | [view waitFullScreenTransition]; | ||
| 2009 | [view toggleFullScreen:child]; | ||
| 2010 | } | ||
| 2011 | NSTRACE ("child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary"); | ||
| 2012 | [child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary]; | ||
| 2013 | #endif | ||
| 1975 | parent = [FRAME_NS_VIEW (p) window]; | 2014 | parent = [FRAME_NS_VIEW (p) window]; |
| 1976 | 2015 | ||
| 1977 | [parent addChildWindow: child | 2016 | [parent addChildWindow: child |
| @@ -7398,6 +7437,7 @@ not_in_argv (NSString *arg) | |||
| 7398 | #endif | 7437 | #endif |
| 7399 | fs_is_native = ns_use_native_fullscreen; | 7438 | fs_is_native = ns_use_native_fullscreen; |
| 7400 | #endif | 7439 | #endif |
| 7440 | in_fullscreen_transition = NO; | ||
| 7401 | 7441 | ||
| 7402 | maximized_width = maximized_height = -1; | 7442 | maximized_width = maximized_height = -1; |
| 7403 | nonfs_window = nil; | 7443 | nonfs_window = nil; |
| @@ -7431,7 +7471,10 @@ not_in_argv (NSString *arg) | |||
| 7431 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | 7471 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 |
| 7432 | if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7) | 7472 | if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7) |
| 7433 | #endif | 7473 | #endif |
| 7434 | [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; | 7474 | if (FRAME_PARENT_FRAME (f)) |
| 7475 | [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary]; | ||
| 7476 | else | ||
| 7477 | [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; | ||
| 7435 | #endif | 7478 | #endif |
| 7436 | 7479 | ||
| 7437 | wr = [win frame]; | 7480 | wr = [win frame]; |
| @@ -7554,11 +7597,12 @@ not_in_argv (NSString *arg) | |||
| 7554 | emacsframe->top_pos = | 7597 | emacsframe->top_pos = |
| 7555 | NS_PARENT_WINDOW_TOP_POS (emacsframe) - (r.origin.y + r.size.height); | 7598 | NS_PARENT_WINDOW_TOP_POS (emacsframe) - (r.origin.y + r.size.height); |
| 7556 | 7599 | ||
| 7557 | if (emacs_event) | 7600 | // FIXME: after event part below didExitFullScreen is not received |
| 7558 | { | 7601 | // if (emacs_event) |
| 7559 | emacs_event->kind = MOVE_FRAME_EVENT; | 7602 | // { |
| 7560 | EV_TRAILER ((id)nil); | 7603 | // emacs_event->kind = MOVE_FRAME_EVENT; |
| 7561 | } | 7604 | // EV_TRAILER ((id)nil); |
| 7605 | // } | ||
| 7562 | } | 7606 | } |
| 7563 | } | 7607 | } |
| 7564 | 7608 | ||
| @@ -7758,6 +7802,7 @@ not_in_argv (NSString *arg) | |||
| 7758 | - (void)windowWillEnterFullScreen:(NSNotification *)notification | 7802 | - (void)windowWillEnterFullScreen:(NSNotification *)notification |
| 7759 | { | 7803 | { |
| 7760 | NSTRACE ("[EmacsView windowWillEnterFullScreen:]"); | 7804 | NSTRACE ("[EmacsView windowWillEnterFullScreen:]"); |
| 7805 | in_fullscreen_transition = YES; | ||
| 7761 | [self windowWillEnterFullScreen]; | 7806 | [self windowWillEnterFullScreen]; |
| 7762 | } | 7807 | } |
| 7763 | - (void)windowWillEnterFullScreen /* provided for direct calls */ | 7808 | - (void)windowWillEnterFullScreen /* provided for direct calls */ |
| @@ -7770,6 +7815,7 @@ not_in_argv (NSString *arg) | |||
| 7770 | { | 7815 | { |
| 7771 | NSTRACE ("[EmacsView windowDidEnterFullScreen:]"); | 7816 | NSTRACE ("[EmacsView windowDidEnterFullScreen:]"); |
| 7772 | [self windowDidEnterFullScreen]; | 7817 | [self windowDidEnterFullScreen]; |
| 7818 | in_fullscreen_transition = NO; | ||
| 7773 | } | 7819 | } |
| 7774 | 7820 | ||
| 7775 | - (void)windowDidEnterFullScreen /* provided for direct calls */ | 7821 | - (void)windowDidEnterFullScreen /* provided for direct calls */ |
| @@ -7808,6 +7854,7 @@ not_in_argv (NSString *arg) | |||
| 7808 | - (void)windowWillExitFullScreen:(NSNotification *)notification | 7854 | - (void)windowWillExitFullScreen:(NSNotification *)notification |
| 7809 | { | 7855 | { |
| 7810 | NSTRACE ("[EmacsView windowWillExitFullScreen:]"); | 7856 | NSTRACE ("[EmacsView windowWillExitFullScreen:]"); |
| 7857 | in_fullscreen_transition = YES; | ||
| 7811 | [self windowWillExitFullScreen]; | 7858 | [self windowWillExitFullScreen]; |
| 7812 | } | 7859 | } |
| 7813 | 7860 | ||
| @@ -7827,6 +7874,7 @@ not_in_argv (NSString *arg) | |||
| 7827 | { | 7874 | { |
| 7828 | NSTRACE ("[EmacsView windowDidExitFullScreen:]"); | 7875 | NSTRACE ("[EmacsView windowDidExitFullScreen:]"); |
| 7829 | [self windowDidExitFullScreen]; | 7876 | [self windowDidExitFullScreen]; |
| 7877 | in_fullscreen_transition = NO; | ||
| 7830 | } | 7878 | } |
| 7831 | 7879 | ||
| 7832 | - (void)windowDidExitFullScreen /* provided for direct calls */ | 7880 | - (void)windowDidExitFullScreen /* provided for direct calls */ |
| @@ -7856,6 +7904,22 @@ not_in_argv (NSString *arg) | |||
| 7856 | [[self window] performZoom:self]; | 7904 | [[self window] performZoom:self]; |
| 7857 | } | 7905 | } |
| 7858 | 7906 | ||
| 7907 | - (BOOL)inFullScreenTransition | ||
| 7908 | { | ||
| 7909 | return in_fullscreen_transition; | ||
| 7910 | } | ||
| 7911 | |||
| 7912 | - (void)waitFullScreenTransition | ||
| 7913 | { | ||
| 7914 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | ||
| 7915 | while ([self inFullScreenTransition]) | ||
| 7916 | { | ||
| 7917 | NSTRACE ("wait for fullscreen"); | ||
| 7918 | wait_reading_process_output (0, 300000000, 0, 1, Qnil, NULL, 0); | ||
| 7919 | } | ||
| 7920 | #endif | ||
| 7921 | } | ||
| 7922 | |||
| 7859 | - (BOOL)fsIsNative | 7923 | - (BOOL)fsIsNative |
| 7860 | { | 7924 | { |
| 7861 | return fs_is_native; | 7925 | return fs_is_native; |
| @@ -7894,9 +7958,22 @@ not_in_argv (NSString *arg) | |||
| 7894 | NSWindow *win = [self window]; | 7958 | NSWindow *win = [self window]; |
| 7895 | NSWindowCollectionBehavior b = [win collectionBehavior]; | 7959 | NSWindowCollectionBehavior b = [win collectionBehavior]; |
| 7896 | if (ns_use_native_fullscreen) | 7960 | if (ns_use_native_fullscreen) |
| 7897 | b |= NSWindowCollectionBehaviorFullScreenPrimary; | 7961 | { |
| 7962 | if ([win parentWindow]) | ||
| 7963 | { | ||
| 7964 | b &= ~NSWindowCollectionBehaviorFullScreenPrimary; | ||
| 7965 | b |= NSWindowCollectionBehaviorFullScreenAuxiliary; | ||
| 7966 | } | ||
| 7967 | else | ||
| 7968 | { | ||
| 7969 | b |= NSWindowCollectionBehaviorFullScreenPrimary; | ||
| 7970 | b &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; | ||
| 7971 | } | ||
| 7972 | } | ||
| 7898 | else | 7973 | else |
| 7899 | b &= ~NSWindowCollectionBehaviorFullScreenPrimary; | 7974 | { |
| 7975 | b &= ~NSWindowCollectionBehaviorFullScreenPrimary; | ||
| 7976 | } | ||
| 7900 | 7977 | ||
| 7901 | [win setCollectionBehavior: b]; | 7978 | [win setCollectionBehavior: b]; |
| 7902 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | 7979 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 |
| @@ -7922,8 +7999,14 @@ not_in_argv (NSString *arg) | |||
| 7922 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | 7999 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 |
| 7923 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | 8000 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 |
| 7924 | if ([[self window] respondsToSelector: @selector(toggleFullScreen:)]) | 8001 | if ([[self window] respondsToSelector: @selector(toggleFullScreen:)]) |
| 8002 | { | ||
| 8003 | #endif | ||
| 8004 | [[self window] toggleFullScreen:sender]; | ||
| 8005 | // wait for fullscreen animation complete (bug#28496) | ||
| 8006 | [self waitFullScreenTransition]; | ||
| 8007 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | ||
| 8008 | } | ||
| 7925 | #endif | 8009 | #endif |
| 7926 | [[self window] toggleFullScreen:sender]; | ||
| 7927 | #endif | 8010 | #endif |
| 7928 | return; | 8011 | return; |
| 7929 | } | 8012 | } |