diff options
| author | Alan Third | 2017-04-25 20:55:40 +0100 |
|---|---|---|
| committer | Alan Third | 2017-04-25 21:06:12 +0100 |
| commit | 603f634c8f5876613864c90e50585b5947be1667 (patch) | |
| tree | 5501c984e0e0001ecdf5570d1e87784800745182 /src | |
| parent | e4ddf394d0ca42b3958848800c98fed2215291f7 (diff) | |
| download | emacs-603f634c8f5876613864c90e50585b5947be1667.tar.gz emacs-603f634c8f5876613864c90e50585b5947be1667.zip | |
Fix some NS frame handling issues
* src/nsterm.m (FRAME_DECORATED_FLAGS, FRAME_UNDECORATED_FLAGS): New
defines intended to make things tidier.
(x_set_undecorated): Use the new defines.
(windowWillResize): Don't use new macOS 12+ only feature.
(initFrameFromEmacs): Use the new defines, and disable automatic
window tabbing feature in macOS 12.
(x_set_undecorated, x_set_parent_frame, x_set_no_accept_focus,
x_set_z_group): Add NSTRACE notices.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 8c5eb06641b..f5232d77dd7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -411,6 +411,23 @@ static CGPoint menu_mouse_point; | |||
| 411 | ns_send_appdefined (-1); \ | 411 | ns_send_appdefined (-1); \ |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | |||
| 415 | /* GNUstep always shows decorations if the window is resizable, | ||
| 416 | miniaturizable or closable, but Cocoa does strange things in native | ||
| 417 | fullscreen mode if you don't have at least resizable enabled. | ||
| 418 | |||
| 419 | These flags will be OR'd or XOR'd with the NSWindow's styleMask | ||
| 420 | property depending on what we're doing. */ | ||
| 421 | #ifdef NS_IMPL_COCOA | ||
| 422 | #define FRAME_DECORATED_FLAGS NSWindowStyleMaskTitled | ||
| 423 | #else | ||
| 424 | #define FRAME_DECORATED_FLAGS (NSWindowStyleMaskTitled \ | ||
| 425 | | NSWindowStyleMaskResizable \ | ||
| 426 | | NSWindowStyleMaskMiniaturizable \ | ||
| 427 | | NSWindowStyleMaskClosable) | ||
| 428 | #endif | ||
| 429 | #define FRAME_UNDECORATED_FLAGS NSWindowStyleMaskBorderless | ||
| 430 | |||
| 414 | /* TODO: get rid of need for these forward declarations */ | 431 | /* TODO: get rid of need for these forward declarations */ |
| 415 | static void ns_condemn_scroll_bars (struct frame *f); | 432 | static void ns_condemn_scroll_bars (struct frame *f); |
| 416 | static void ns_judge_scroll_bars (struct frame *f); | 433 | static void ns_judge_scroll_bars (struct frame *f); |
| @@ -1823,6 +1840,8 @@ x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value | |||
| 1823 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); | 1840 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); |
| 1824 | NSWindow *window = [view window]; | 1841 | NSWindow *window = [view window]; |
| 1825 | 1842 | ||
| 1843 | NSTRACE ("x_set_undecorated"); | ||
| 1844 | |||
| 1826 | if (!EQ (new_value, old_value)) | 1845 | if (!EQ (new_value, old_value)) |
| 1827 | { | 1846 | { |
| 1828 | block_input (); | 1847 | block_input (); |
| @@ -1830,12 +1849,8 @@ x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value | |||
| 1830 | if (NILP (new_value)) | 1849 | if (NILP (new_value)) |
| 1831 | { | 1850 | { |
| 1832 | FRAME_UNDECORATED (f) = false; | 1851 | FRAME_UNDECORATED (f) = false; |
| 1833 | [window setStyleMask: ((window.styleMask | 1852 | [window setStyleMask: ((window.styleMask | FRAME_DECORATED_FLAGS) |
| 1834 | | NSWindowStyleMaskTitled | 1853 | ^ FRAME_UNDECORATED_FLAGS)]; |
| 1835 | | NSWindowStyleMaskResizable | ||
| 1836 | | NSWindowStyleMaskMiniaturizable | ||
| 1837 | | NSWindowStyleMaskClosable) | ||
| 1838 | ^ NSWindowStyleMaskBorderless)]; | ||
| 1839 | 1854 | ||
| 1840 | [view createToolbar: f]; | 1855 | [view createToolbar: f]; |
| 1841 | } | 1856 | } |
| @@ -1845,11 +1860,8 @@ x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value | |||
| 1845 | /* Do I need to release the toolbar here? */ | 1860 | /* Do I need to release the toolbar here? */ |
| 1846 | 1861 | ||
| 1847 | FRAME_UNDECORATED (f) = true; | 1862 | FRAME_UNDECORATED (f) = true; |
| 1848 | [window setStyleMask: ((window.styleMask | NSWindowStyleMaskBorderless) | 1863 | [window setStyleMask: ((window.styleMask | FRAME_UNDECORATED_FLAGS) |
| 1849 | ^ (NSWindowStyleMaskTitled | 1864 | ^ FRAME_DECORATED_FLAGS)]; |
| 1850 | | NSWindowStyleMaskResizable | ||
| 1851 | | NSWindowStyleMaskMiniaturizable | ||
| 1852 | | NSWindowStyleMaskClosable))]; | ||
| 1853 | } | 1865 | } |
| 1854 | 1866 | ||
| 1855 | /* At this point it seems we don't have an active NSResponder, | 1867 | /* At this point it seems we don't have an active NSResponder, |
| @@ -1889,6 +1901,8 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu | |||
| 1889 | struct frame *p = NULL; | 1901 | struct frame *p = NULL; |
| 1890 | NSWindow *parent, *child; | 1902 | NSWindow *parent, *child; |
| 1891 | 1903 | ||
| 1904 | NSTRACE ("x_set_parent_frame"); | ||
| 1905 | |||
| 1892 | if (!NILP (new_value) | 1906 | if (!NILP (new_value) |
| 1893 | && (!FRAMEP (new_value) | 1907 | && (!FRAMEP (new_value) |
| 1894 | || !FRAME_LIVE_P (p = XFRAME (new_value)) | 1908 | || !FRAME_LIVE_P (p = XFRAME (new_value)) |
| @@ -1923,6 +1937,8 @@ x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object old_v | |||
| 1923 | * | 1937 | * |
| 1924 | * Some window managers may not honor this parameter. */ | 1938 | * Some window managers may not honor this parameter. */ |
| 1925 | { | 1939 | { |
| 1940 | NSTRACE ("x_set_no_accept_focus"); | ||
| 1941 | |||
| 1926 | if (!EQ (new_value, old_value)) | 1942 | if (!EQ (new_value, old_value)) |
| 1927 | FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value); | 1943 | FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value); |
| 1928 | } | 1944 | } |
| @@ -1941,6 +1957,8 @@ x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) | |||
| 1941 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); | 1957 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); |
| 1942 | NSWindow *window = [view window]; | 1958 | NSWindow *window = [view window]; |
| 1943 | 1959 | ||
| 1960 | NSTRACE ("x_set_z_group"); | ||
| 1961 | |||
| 1944 | if (NILP (new_value)) | 1962 | if (NILP (new_value)) |
| 1945 | { | 1963 | { |
| 1946 | window.level = NSNormalWindowLevel; | 1964 | window.level = NSNormalWindowLevel; |
| @@ -6647,7 +6665,7 @@ not_in_argv (NSString *arg) | |||
| 6647 | } | 6665 | } |
| 6648 | } | 6666 | } |
| 6649 | else if (fs_state == FULLSCREEN_NONE && ! maximizing_resize | 6667 | else if (fs_state == FULLSCREEN_NONE && ! maximizing_resize |
| 6650 | && [[self window] titleVisibility]) | 6668 | && [[self window] title] != NULL) |
| 6651 | { | 6669 | { |
| 6652 | char *size_title; | 6670 | char *size_title; |
| 6653 | NSWindow *window = [self window]; | 6671 | NSWindow *window = [self window]; |
| @@ -6918,11 +6936,14 @@ not_in_argv (NSString *arg) | |||
| 6918 | win = [[EmacsWindow alloc] | 6936 | win = [[EmacsWindow alloc] |
| 6919 | initWithContentRect: r | 6937 | initWithContentRect: r |
| 6920 | styleMask: (FRAME_UNDECORATED (f) | 6938 | styleMask: (FRAME_UNDECORATED (f) |
| 6921 | ? NSWindowStyleMaskBorderless | 6939 | ? FRAME_UNDECORATED_FLAGS |
| 6922 | : NSWindowStyleMaskTitled | 6940 | : FRAME_DECORATED_FLAGS |
| 6941 | #ifdef NS_IMPL_COCOA | ||
| 6923 | | NSWindowStyleMaskResizable | 6942 | | NSWindowStyleMaskResizable |
| 6924 | | NSWindowStyleMaskMiniaturizable | 6943 | | NSWindowStyleMaskMiniaturizable |
| 6925 | | NSWindowStyleMaskClosable) | 6944 | | NSWindowStyleMaskClosable |
| 6945 | #endif | ||
| 6946 | ) | ||
| 6926 | backing: NSBackingStoreBuffered | 6947 | backing: NSBackingStoreBuffered |
| 6927 | defer: YES]; | 6948 | defer: YES]; |
| 6928 | 6949 | ||
| @@ -7004,6 +7025,13 @@ not_in_argv (NSString *arg) | |||
| 7004 | [NSApp registerServicesMenuSendTypes: ns_send_types | 7025 | [NSApp registerServicesMenuSendTypes: ns_send_types |
| 7005 | returnTypes: nil]; | 7026 | returnTypes: nil]; |
| 7006 | 7027 | ||
| 7028 | /* macOS Sierra automatically enables tabbed windows. We can't | ||
| 7029 | allow this to be enabled until it's available on a Free system. | ||
| 7030 | Currently it only happens by accident and is buggy anyway. */ | ||
| 7031 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 | ||
| 7032 | [win setTabbingMode: NSWindowTabbingModeDisallowed]; | ||
| 7033 | #endif | ||
| 7034 | |||
| 7007 | ns_window_num++; | 7035 | ns_window_num++; |
| 7008 | return self; | 7036 | return self; |
| 7009 | } | 7037 | } |