homebrew-emacs-plus icon indicating copy to clipboard operation
homebrew-emacs-plus copied to clipboard

Rounded corners when no title bar

Open rougier opened this issue 3 years ago • 8 comments

When using the no title bar option, I noticed that the frame does not have rounded corners anymore. After trying to understand why it was the case, I think the mask of the window should be something like NSWindowStyleMaskFullSizeContentView and the NSWindowTitleVisibility should be set to hidden. However, I'm not sure how this should be combined the the current no-title-bar patch.

Relevant links:

  • https://github.com/lukakerr/NSWindowStyles
  • https://stackoverflow.com/questions/35944792/window-title-bar-appears-transparent-issue-not-really-transparent
  • https://gitlab.com/gnachman/iterm2/-/issues/7143

rougier avatar Mar 07 '21 09:03 rougier

Hey @rougier

Nice investigation. You are totally right that the reason is NSWindowStyles used by this patch.

However, I'm not sure how this should be combined the the current no-title-bar patch.

Ineeded. I don't like this patch for not being composable nor configurable. Ideally this patch should not change NSWindowStyle, but instead provide a variable controlling NSWindowStyle and this variable should be configurable from init.el.

d12frosted avatar Mar 08 '21 16:03 d12frosted

That would be awesome (and well beyond my knowledge of Apple internals)

rougier avatar Mar 08 '21 16:03 rougier

I agree with not combining it with the current no-title-bar behavior out of pure self-interest. I use this patch with a tiling window manager, and it would bug me to see my desktop through the space left by rounded corners. I could see someone else curating a desktop that is meant to show through the rounded corners, but that's not me. So long as the behavior of the --no-title-bar flag in brew remains unchanged, I'm happy, and I'd be fine with needing to use a different flag, but having the default just change would be slightly annoying to me. I'd still be fine with it, just very low-key annoyed.

winmillwill avatar Mar 16 '21 23:03 winmillwill

Maybe there could be an additional flag --with-round-corners or --no-round-corners.

rougier avatar Mar 17 '21 05:03 rougier

I'm using this patch, without title bar and keep the rounded corners, works very well:

diff --git a/src/nsterm.m b/src/nsterm.m
index aa29c13eb2..6cec091b8e 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -434,6 +434,7 @@ - (NSColor *)colorUsingDefaultColorSpace
 /* These flags will be OR'd or XOR'd with the NSWindow's styleMask
    property depending on what we're doing.  */
 #define FRAME_DECORATED_FLAGS (NSWindowStyleMaskTitled              \
+                               | NSFullSizeContentViewWindowMask    \
                                | NSWindowStyleMaskResizable         \
                                | NSWindowStyleMaskMiniaturizable    \
                                | NSWindowStyleMaskClosable)
@@ -8342,6 +8343,12 @@ - (instancetype) initWithEmacsFrame:(struct frame *)f
 #endif
     }
 
+  [self setTitlebarAppearsTransparent:YES];
+  [self setTitleVisibility:NSWindowTitleHidden];
+  [[self standardWindowButton:NSWindowCloseButton] setHidden:YES];
+  [[self standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
+  [[self standardWindowButton:NSWindowZoomButton] setHidden:YES];
+
   return self;
 }

cxa avatar Nov 10 '21 11:11 cxa

@cxa is there a way to apply this patch to emacs-plus?

gf3 avatar Nov 15 '21 17:11 gf3

@cxa is there a way to apply this patch to emacs-plus?

You can clone my fork and run ./build 28 --with-no-titlebar-alt. (since I only tested on Emacs 28)

cxa avatar Nov 16 '21 00:11 cxa

@cxa works like a charm! thanks

Screenshot

gf3 avatar Nov 20 '21 01:11 gf3

For someone who needs no titlebar with rounded corners for 29, you can check out my fork: https://github.com/cxa/homebrew-emacs-plus/blob/master/Formula/emacs-plus%4029.rb

cxa avatar Sep 29 '22 06:09 cxa

I second @rougier's suggestion of two flags, out of self interest... now that Yabai defaults to rounded window borders. EDIT apologies looks like @brorbw beat me to it.

drummachineshavenosoul avatar Oct 02 '22 21:10 drummachineshavenosoul

Im a bit opposed to two flags. Since all alle macOS apps more or less have rounded corners I think it should be the default. Thats just my two cents

brorbw avatar Oct 03 '22 08:10 brorbw

I think for Emacs 28 we should have two options as changing from rectangle to round is a breaking change. So a pair of --with-no-title-bar and --with-no-title-bar-rounded sounds good to me. For Emacs 29 we will have only one option, --with-no-title-bar-rounded as the rectangle is available without any patches - it's just a matter of configuration.

I invite everyone interested in it to join #511 to share your opinion on naming. I am definitely bad at it (just take a look at the repository name :sweat_smile: ).

d12frosted avatar Oct 03 '22 08:10 d12frosted

Thanks to @brorbw , emacs-plus@28 now has the option --with-no-titlebar-and-round-corners that uses patch by @cxa. Soon it will be added to emacs-plus@29.

CC @rougier

P.S. @cxa and @brorbw what I've noticed, unlike --with-no-titlebar, --with-no-titlebar-and-round-corners doesn't disable tool-bar. That means, unless user modifies configurations, tool-bar overlays buffer content.

d12frosted avatar Oct 05 '22 05:10 d12frosted

@d12frosted I got a little confused by that because I have not disabled the toolbar in my config. So I did some digging and indeed found this inside doom

(setq menu-bar-mode nil
      tool-bar-mode nil
      scroll-bar-mode nil)

brorbw avatar Oct 05 '22 11:10 brorbw

@brorbw removed it in #514. So even with 'stock' Emacs configurations you get no visual bugs.

d12frosted avatar Oct 05 '22 14:10 d12frosted

Added support of rounded corners to Emacs 29 in #516. I am going to merge it tomorrow, unless someone has objections or suggestions.

Instead of compilation options, all you have to do is to add the following line to your early-init.el:

(add-to-list 'default-frame-alist '(undecorated-round . t))

Make sure that you don't have undecorated option as they are mutually exclusive.

early-init.el
decorated
undecorated with square corners (undecorated . t)
undecorated with round corners (undecorated-round . t)

d12frosted avatar Oct 08 '22 16:10 d12frosted

@d12frosted I am using (add-to-list 'default-frame-alist '(undecorated . t)) but (add-to-list 'default-frame-alist '(fullscreen . maximized)) stopped working with it.

I usually made the emacs frame maximised to the screen.

ankitsharma07 avatar Oct 08 '22 17:10 ankitsharma07

@ankitsharma07 is it on #516 or from master?

d12frosted avatar Oct 08 '22 17:10 d12frosted

Solution for Emacs 29 is also in the master, so closing this FR. Let me know if you think there is something else to do.

d12frosted avatar Oct 10 '22 11:10 d12frosted

Nice, now I can drop my fork.

cxa avatar Oct 10 '22 11:10 cxa