Repository: wezterm/wezterm (language: rust)

Issue:
disable rounded corners macos
Hi, I've seen discussion about making the macos build preserve the rounded corners when the title bar is disabled here: #1034, I'm assuming the squared corners were originally considered a bug?

Is it possible to restore the squared corners in macos via a setting? If not, I think it would be a good idea to extend the window decorations setting to include a corners option.


Discussion / hints:
Yeah, all the windows are rounded on macOS, so I considered it a bug. I'll accept a PR for something around this. I'm not super sure what the config should look like. Maybe add a `MACOS_SQUARE_CORNERS` to window decorations?
I think we can introduce `SQUARE_CORNER`. The existing flags `NONE`, `TITLE`, `RESIZE` and `TITLE | RESIZE` can be preserved, i.e., the rounded corner is the default. If users need the square corner, they can just append it to the corresponding flags. E.g., `NONE | SQUARE_CORNER`, `RESIZE | SQUARE_CORNER`, etc. 
An issue with just using `SQUARE_CORNER` is that it implies that not specifying it will give something other than square corners, but most systems only have square corners, and there is not a portable way to know or specify which should be used.

I think `MACOS_FORCE_SQUARE_CORNERS` is a more appropriately scoped name and effect.

Oh yes, exactly. `MACOS_FORCE_SQUARE_CORNERS` is proper flag. I second it. 
Another vote for `MACOS_FORCE_SQUARE_CORNERS` flag. Afraid I have zero Rust chops to help out though, sorry! 
FWIW, I think this is more a matter of figuring out how to get macos to disable rounded corners with OpenGL and Metal views.

These are relevant questions with no obvious answer:

* https://stackoverflow.com/questions/38986010/when-exactly-does-an-nswindow-get-rounded-corners
* https://stackoverflow.com/questions/47173374/how-to-get-square-lower-corners-in-an-nswindow

https://github.com/lukakerr/NSWindowStyles#6-vibrant-background-with-custom-border-radius-and-no-titlebar might be adaptable for this purpose by setting the corner radius to 0.

I don't have time to actually sit down and play with this; I just happened to be looking at `window_decorations` tonight as part of #2669 
Is there a way to made look wez like iterm? Without title bar but with close/expand buttons? Like this:

<img width="782" alt="image" src="https://user-images.githubusercontent.com/14233969/226553030-06875821-15bf-41e9-99b3-5edd72ef3a2a.png">

@karambaq not yet, but keep you eye on this PR:
* https://github.com/wez/wezterm/pull/2722
hey @wez any update on the corner radius setting?
Hey @wez, I was going to create an issue for this but noticed this one was asking exactly the same thing I was going to. Any plans to implement this at some point now? Is it a matter of difficulty or necessity?
the PR-welcome tag indicates that I'm happy to review a PR produced by someone in the community, but that I have no plans to work directly on this myself.

Fix patch:
diff --git a/wezterm-input-types/src/lib.rs b/wezterm-input-types/src/lib.rs
index b3298bad6aa..bf7cbfd4752 100644
--- a/wezterm-input-types/src/lib.rs
+++ b/wezterm-input-types/src/lib.rs
@@ -1976,6 +1976,7 @@ bitflags! {
         const MACOS_FORCE_DISABLE_SHADOW = 4;
         const MACOS_FORCE_ENABLE_SHADOW = 4|8;
         const INTEGRATED_BUTTONS = 16;
+        const MACOS_FORCE_SQUARE_CORNERS = 32;
     }
 }
 
@@ -1995,6 +1996,8 @@ impl Into<String> for &WindowDecorations {
             s.push("MACOS_FORCE_ENABLE_SHADOW");
         } else if self.contains(WindowDecorations::MACOS_FORCE_DISABLE_SHADOW) {
             s.push("MACOS_FORCE_DISABLE_SHADOW");
+        } else if self.contains(WindowDecorations::MACOS_FORCE_SQUARE_CORNERS) {
+            s.push("MACOS_FORCE_SQUARE_CORNERS");
         }
         if s.is_empty() {
             "NONE".to_string()
@@ -2020,6 +2023,8 @@ impl TryFrom<String> for WindowDecorations {
                 flags |= Self::MACOS_FORCE_DISABLE_SHADOW;
             } else if ele == "MACOS_FORCE_ENABLE_SHADOW" {
                 flags |= Self::MACOS_FORCE_ENABLE_SHADOW;
+            } else if ele == "MACOS_FORCE_SQUARE_CORNERS" {
+                flags |= Self::MACOS_FORCE_SQUARE_CORNERS;
             } else if ele == "INTEGRATED_BUTTONS" {
                 flags |= Self::INTEGRATED_BUTTONS;
             } else {
diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs
index 316968ccec0..187c6b99a5b 100644
--- a/window/src/os/macos/window.rs
+++ b/window/src/os/macos/window.rs
@@ -1375,6 +1375,11 @@ fn decoration_to_mask(
             | NSWindowStyleMask::NSClosableWindowMask
             | NSWindowStyleMask::NSMiniaturizableWindowMask
             | NSWindowStyleMask::NSResizableWindowMask
+    } else if decorations == WindowDecorations::MACOS_FORCE_SQUARE_CORNERS | WindowDecorations::RESIZE {
+        NSWindowStyleMask::NSClosableWindowMask
+            | NSWindowStyleMask::NSMiniaturizableWindowMask
+            | NSWindowStyleMask::NSResizableWindowMask
+            | NSWindowStyleMask::NSFullSizeContentViewWindowMask
     } else if decorations == WindowDecorations::RESIZE
         || decorations == WindowDecorations::INTEGRATED_BUTTONS
         || decorations == WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE
@@ -1393,6 +1398,10 @@ fn decoration_to_mask(
         NSWindowStyleMask::NSTitledWindowMask
             | NSWindowStyleMask::NSClosableWindowMask
             | NSWindowStyleMask::NSMiniaturizableWindowMask
+    } else if decorations == WindowDecorations::MACOS_FORCE_SQUARE_CORNERS {
+        NSWindowStyleMask::NSClosableWindowMask
+            | NSWindowStyleMask::NSMiniaturizableWindowMask
+            | NSWindowStyleMask::NSFullSizeContentViewWindowMask
     } else {
         NSWindowStyleMask::NSTitledWindowMask
             | NSWindowStyleMask::NSClosableWindowMask


Test patch: