From c8d59dffb617e2bd5b3cf23300f9831bffd0bbf4 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 12 Oct 2020 17:17:34 -0700 Subject: [PATCH] macos: fix an issue where new windows created cocoa tabs To reproduce the problem, maximize wezterm, then press CMD-N. This commit tells the window not to use cocoa native tabs and instead really create a new window when we ask it to create a new window. closes: #254 --- docs/changelog.markdown | 4 ++++ window/src/os/macos/window.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/changelog.markdown b/docs/changelog.markdown index 2a71389dc..96e7d4122 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -40,6 +40,10 @@ brief notes about them may accumulate here. * Halved the memory usage requirements per Cell in the common case (saving 32 bytes per cell), which gives more headroom for users with large scrollback. +* macOS: Fix issue where new windows would open as Cocoa tabs + when wezterm was maximized. +* macOS: Fix issue where wezterm wouldn't adjust to DPI changes + when dragging across monitors or the screen resolution changed ### 20200909-002054-4c9af461 diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index dbdf12d0f..2129e6ce3 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -313,6 +313,9 @@ impl Window { ), ); + // Prevent Cocoa native tabs from being used + let _: () = msg_send![*window, setTabbingMode:2 /* NSWindowTabbingModeDisallowed */]; + window.setReleasedWhenClosed_(NO); // window.cascadeTopLeftFromPoint_(NSPoint::new(20.0, 20.0)); window.center(); @@ -956,6 +959,11 @@ impl WindowView { YES } + // Don't use Cocoa native window tabbing + extern "C" fn allow_automatic_tabbing(_this: &Object, _sel: Sel) -> BOOL { + NO + } + extern "C" fn window_will_close(this: &mut Object, _sel: Sel, _id: id) { if let Some(this) = Self::get_this(this) { // Advise the window of its impending death @@ -1335,6 +1343,11 @@ impl WindowView { Self::is_flipped as extern "C" fn(&Object, Sel) -> BOOL, ); + cls.add_method( + sel!(allowsAutomaticWindowTabbing), + Self::allow_automatic_tabbing as extern "C" fn(&Object, Sel) -> BOOL, + ); + cls.add_method( sel!(windowDidResize:), Self::did_resize as extern "C" fn(&mut Object, Sel, id),