Commit 603f634c authored by Alan Third's avatar Alan Third
Browse files

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.
parent e4ddf394
......@@ -411,6 +411,23 @@ - (NSColor *)colorUsingDefaultColorSpace
ns_send_appdefined (-1); \
}
/* GNUstep always shows decorations if the window is resizable,
miniaturizable or closable, but Cocoa does strange things in native
fullscreen mode if you don't have at least resizable enabled.
These flags will be OR'd or XOR'd with the NSWindow's styleMask
property depending on what we're doing. */
#ifdef NS_IMPL_COCOA
#define FRAME_DECORATED_FLAGS NSWindowStyleMaskTitled
#else
#define FRAME_DECORATED_FLAGS (NSWindowStyleMaskTitled \
| NSWindowStyleMaskResizable \
| NSWindowStyleMaskMiniaturizable \
| NSWindowStyleMaskClosable)
#endif
#define FRAME_UNDECORATED_FLAGS NSWindowStyleMaskBorderless
/* TODO: get rid of need for these forward declarations */
static void ns_condemn_scroll_bars (struct frame *f);
static void ns_judge_scroll_bars (struct frame *f);
......@@ -1823,6 +1840,8 @@ -(void)remove
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
NSWindow *window = [view window];
NSTRACE ("x_set_undecorated");
if (!EQ (new_value, old_value))
{
block_input ();
......@@ -1830,12 +1849,8 @@ -(void)remove
if (NILP (new_value))
{
FRAME_UNDECORATED (f) = false;
[window setStyleMask: ((window.styleMask
| NSWindowStyleMaskTitled
| NSWindowStyleMaskResizable
| NSWindowStyleMaskMiniaturizable
| NSWindowStyleMaskClosable)
^ NSWindowStyleMaskBorderless)];
[window setStyleMask: ((window.styleMask | FRAME_DECORATED_FLAGS)
^ FRAME_UNDECORATED_FLAGS)];
[view createToolbar: f];
}
......@@ -1845,11 +1860,8 @@ -(void)remove
/* Do I need to release the toolbar here? */
FRAME_UNDECORATED (f) = true;
[window setStyleMask: ((window.styleMask | NSWindowStyleMaskBorderless)
^ (NSWindowStyleMaskTitled
| NSWindowStyleMaskResizable
| NSWindowStyleMaskMiniaturizable
| NSWindowStyleMaskClosable))];
[window setStyleMask: ((window.styleMask | FRAME_UNDECORATED_FLAGS)
^ FRAME_DECORATED_FLAGS)];
}
/* At this point it seems we don't have an active NSResponder,
......@@ -1889,6 +1901,8 @@ so some key presses (TAB) are swallowed by the system. */
struct frame *p = NULL;
NSWindow *parent, *child;
NSTRACE ("x_set_parent_frame");
if (!NILP (new_value)
&& (!FRAMEP (new_value)
|| !FRAME_LIVE_P (p = XFRAME (new_value))
......@@ -1923,6 +1937,8 @@ so some key presses (TAB) are swallowed by the system. */
*
* Some window managers may not honor this parameter. */
{
NSTRACE ("x_set_no_accept_focus");
if (!EQ (new_value, old_value))
FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value);
}
......@@ -1941,6 +1957,8 @@ so some key presses (TAB) are swallowed by the system. */
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
NSWindow *window = [view window];
NSTRACE ("x_set_z_group");
if (NILP (new_value))
{
window.level = NSNormalWindowLevel;
......@@ -6647,7 +6665,7 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
}
}
else if (fs_state == FULLSCREEN_NONE && ! maximizing_resize
&& [[self window] titleVisibility])
&& [[self window] title] != NULL)
{
char *size_title;
NSWindow *window = [self window];
......@@ -6918,11 +6936,14 @@ This avoids an extra clear and redraw (flicker) at frame creation. */
win = [[EmacsWindow alloc]
initWithContentRect: r
styleMask: (FRAME_UNDECORATED (f)
? NSWindowStyleMaskBorderless
: NSWindowStyleMaskTitled
? FRAME_UNDECORATED_FLAGS
: FRAME_DECORATED_FLAGS
#ifdef NS_IMPL_COCOA
| NSWindowStyleMaskResizable
| NSWindowStyleMaskMiniaturizable
| NSWindowStyleMaskClosable)
| NSWindowStyleMaskClosable
#endif
)
backing: NSBackingStoreBuffered
defer: YES];
......@@ -7004,6 +7025,13 @@ This avoids an extra clear and redraw (flicker) at frame creation. */
[NSApp registerServicesMenuSendTypes: ns_send_types
returnTypes: nil];
/* macOS Sierra automatically enables tabbed windows. We can't
allow this to be enabled until it's available on a Free system.
Currently it only happens by accident and is buggy anyway. */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
[win setTabbingMode: NSWindowTabbingModeDisallowed];
#endif
ns_window_num++;
return self;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment