* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars @ 2017-08-05 17:26 James Nguyen 2017-08-06 0:14 ` Alan Third [not found] ` <handler.27973.D27973.15035160789583.notifdone@debbugs.gnu.org> 0 siblings, 2 replies; 20+ messages in thread From: James Nguyen @ 2017-08-05 17:26 UTC (permalink / raw) To: 27973 Wondering if we can support transparent titlebars in the OSX build of Emacs? It looks something like this. https://cloud.githubusercontent.com/assets/3277054/24304360/623a5ae2-10b9-11e7-8442-f8705580374e.png ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars 2017-08-05 17:26 bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars James Nguyen @ 2017-08-06 0:14 ` Alan Third 2017-08-06 0:19 ` James Nguyen [not found] ` <handler.27973.D27973.15035160789583.notifdone@debbugs.gnu.org> 1 sibling, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-06 0:14 UTC (permalink / raw) To: James Nguyen; +Cc: 27973 On Sat, Aug 05, 2017 at 10:26:37AM -0700, James Nguyen wrote: > Wondering if we can support transparent titlebars in the OSX build of > Emacs? > > It looks something like this. > > https://cloud.githubusercontent.com/assets/3277054/24304360/623a5ae2-10b9-11e7-8442-f8705580374e.png Hi, I’m not sure what I’m looking at in this screenshot. Is it just that the titlebar will show the background or windows underneath? The documentation for titlebarAppearsTransparent (https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) says It only makes sense to set this property to YES when NSFullSizeContentViewWindowMask is also set. which I believe merges the toolbar and titlebar. Is that what you’re thinking of? -- Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars 2017-08-06 0:14 ` Alan Third @ 2017-08-06 0:19 ` James Nguyen 2017-08-06 0:25 ` Alan Third 0 siblings, 1 reply; 20+ messages in thread From: James Nguyen @ 2017-08-06 0:19 UTC (permalink / raw) To: Alan Third; +Cc: 27973 Alan Third <alan@idiocy.org> writes: Hi Alan, Here's a comparison. https://www.dropbox.com/s/i4xw5mq82f5g3wc/Screenshot%202017-08-05%2017.16.20.png?dl=0 The title bar (that holds the red/yellow/green buttons) is the same color as the rest of the window. Normally it is silver. > On Sat, Aug 05, 2017 at 10:26:37AM -0700, James Nguyen wrote: >> Wondering if we can support transparent titlebars in the OSX build of >> Emacs? >> >> It looks something like this. >> >> https://cloud.githubusercontent.com/assets/3277054/24304360/623a5ae2-10b9-11e7-8442-f8705580374e.png > > Hi, I’m not sure what I’m looking at in this screenshot. Is it just > that the titlebar will show the background or windows underneath? > > The documentation for titlebarAppearsTransparent > (https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) > says > > It only makes sense to set this property to YES when > NSFullSizeContentViewWindowMask > is also set. > > which I believe merges the toolbar and titlebar. Is that what you’re > thinking of? > -- > Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars 2017-08-06 0:19 ` James Nguyen @ 2017-08-06 0:25 ` Alan Third 2017-08-06 0:39 ` James Nguyen 0 siblings, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-06 0:25 UTC (permalink / raw) To: James Nguyen; +Cc: 27973 On Sat, Aug 05, 2017 at 05:19:46PM -0700, James Nguyen wrote: > Here's a comparison. > > https://www.dropbox.com/s/i4xw5mq82f5g3wc/Screenshot%202017-08-05%2017.16.20.png?dl=0 > > The title bar (that holds the red/yellow/green buttons) is the same > color as the rest of the window. Normally it is silver. Oh, I get you. That’s quite nifty. Out of interest, what happens if you turn the toolbar on? Is it reasonable, or does it need something else done with it? -- Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars 2017-08-06 0:25 ` Alan Third @ 2017-08-06 0:39 ` James Nguyen 2017-08-06 13:12 ` Alan Third 0 siblings, 1 reply; 20+ messages in thread From: James Nguyen @ 2017-08-06 0:39 UTC (permalink / raw) To: Alan Third; +Cc: 27973 Alan Third <alan@idiocy.org> writes: It looks reasonable to me, the toolbar is also transparent. https://www.dropbox.com/s/tiy36twyut6uw73/Screenshot%202017-08-05%2017.31.42.png?dl=0 The frame color isn't adjustable since I'm setting up the colors at Emac's compile time so using a dark theme results in dark font in the title bar instead of a light one. https://www.dropbox.com/s/kasebe8a8srffyu/Screenshot%202017-08-05%2017.35.31.png?dl=0 (Can ignore the white line, taking a screenshot causes it to go white momentarily, but it's a black line normally.) > On Sat, Aug 05, 2017 at 05:19:46PM -0700, James Nguyen wrote: >> Here's a comparison. >> >> https://www.dropbox.com/s/i4xw5mq82f5g3wc/Screenshot%202017-08-05%2017.16.20.png?dl=0 >> >> The title bar (that holds the red/yellow/green buttons) is the same >> color as the rest of the window. Normally it is silver. > > Oh, I get you. That’s quite nifty. > > Out of interest, what happens if you turn the toolbar on? Is it > reasonable, or does it need something else done with it? > -- > Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars 2017-08-06 0:39 ` James Nguyen @ 2017-08-06 13:12 ` Alan Third 2017-08-06 15:41 ` James Nguyen 0 siblings, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-06 13:12 UTC (permalink / raw) To: James Nguyen; +Cc: 27973 On Sat, Aug 05, 2017 at 05:39:03PM -0700, James Nguyen wrote: > It looks reasonable to me, the toolbar is also transparent. > > https://www.dropbox.com/s/tiy36twyut6uw73/Screenshot%202017-08-05%2017.31.42.png?dl=0 > > The frame color isn't adjustable since I'm setting up the colors at > Emac's compile time so using a dark theme results in dark font in the > title bar instead of a light one. It seems to me there are at least two things we want here: 1. Setting transparency of UI elements. Possibly with an option to use ‘unified’ toolbars and titlebars. 2. Setting the NSAppearance theme. After messing about with NSAppearance I’ve discovered this is the solution to one of my bugbears: if you set it to dark then the scrollbars are no longer white, which always looks stupid with a dark Emacs theme. I’m not sure how these settings should be implemented, though. I think they’d be best as frame parameters, but none of the existing frame parameters are system dependent like these, so I don’t know if doing it that way would upset anyone. Alternatively we just make them variables which affect any subsequently created frames. -- Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars 2017-08-06 13:12 ` Alan Third @ 2017-08-06 15:41 ` James Nguyen 2017-08-13 13:11 ` bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) Alan Third 0 siblings, 1 reply; 20+ messages in thread From: James Nguyen @ 2017-08-06 15:41 UTC (permalink / raw) To: Alan Third; +Cc: 27973 Alan Third <alan@idiocy.org> writes: It'd be great if the current frame can be updated programatically. I think many use a 'theme-changer' that changes themes from light to dark or vice versa and would want ther rest of the UI to match after. > On Sat, Aug 05, 2017 at 05:39:03PM -0700, James Nguyen wrote: >> It looks reasonable to me, the toolbar is also transparent. >> >> https://www.dropbox.com/s/tiy36twyut6uw73/Screenshot%202017-08-05%2017.31.42.png?dl=0 >> >> The frame color isn't adjustable since I'm setting up the colors at >> Emac's compile time so using a dark theme results in dark font in the >> title bar instead of a light one. > > It seems to me there are at least two things we want here: > > 1. Setting transparency of UI elements. Possibly with an option to > use ‘unified’ toolbars and titlebars. > > 2. Setting the NSAppearance theme. > > After messing about with NSAppearance I’ve discovered this is the > solution to one of my bugbears: if you set it to dark then the > scrollbars are no longer white, which always looks stupid with a dark > Emacs theme. > > I’m not sure how these settings should be implemented, though. I think > they’d be best as frame parameters, but none of the existing frame > parameters are system dependent like these, so I don’t know if doing > it that way would upset anyone. > > Alternatively we just make them variables which affect any > subsequently created frames. > -- > Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-06 15:41 ` James Nguyen @ 2017-08-13 13:11 ` Alan Third 2017-08-13 14:38 ` Eli Zaretskii 0 siblings, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-13 13:11 UTC (permalink / raw) To: James Nguyen; +Cc: 27973 * src/frame.c (make_frame, frame_parms, syms_of_frame) [NS_IMPL_COCOA]: Add ns-appearance and ns-transparent-titlebar options. * src/frame.h (ns_appearance_type) [NS_IMPL_COCOA]: Add enum to represent NSAppearance options. (struct frame) [NS_IMPL_COCOA]: Add ns_appearance and ns_transparent_titlebar frame parameters. * src/nsfns.m (ns_frame_parm_handlers) [NS_IMPL_COCOA]: Add ns_set_appearance and ns_set_transparent_titlebar handlers. (Sx_create_frame): Handle ns-appearance and ns-transparent-titlebar frame parameters. (Qdark): Add new symbol for use with ns-appearance. * src/nsterm.h (ns_set_appearance, ns_set_transparent_titlebar) [NS_IMPL_COCOA]: Add prototypes. * src/nsterm.m (ns_set_appearance, ns_set_transparent_titlebar) [NS_IMPL_COCOA]: New functions. (initFrameFromEmacs) [NS_IMPL_COCOA]: Handle ns-appearance and ns-transparent-titlebar frame parameters. --- src/frame.c | 12 +++++++++++ src/frame.h | 18 ++++++++++++++++ src/nsfns.m | 15 ++++++++++++++ src/nsterm.h | 7 +++++++ src/nsterm.m | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+) diff --git a/src/frame.c b/src/frame.c index 1e5e4bbdb4..5099f75be4 100644 --- a/src/frame.c +++ b/src/frame.c @@ -834,6 +834,10 @@ make_frame (bool mini_p) #if ! defined (USE_GTK) && ! defined (HAVE_NS) f->last_tool_bar_item = -1; #endif +#ifdef NS_IMPL_COCOA + f->ns_appearance = ns_appearance_aqua; + f->ns_transparent_titlebar = false; +#endif #endif root_window = make_window (); @@ -3520,6 +3524,10 @@ static const struct frame_parm_table frame_parms[] = {"z-group", SYMBOL_INDEX (Qz_group)}, {"override-redirect", SYMBOL_INDEX (Qoverride_redirect)}, {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs)}, +#ifdef NS_IMPL_COCOA + {"ns-appearance", SYMBOL_INDEX (Qns_appearance)}, + {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar)}, +#endif }; #ifdef HAVE_WINDOW_SYSTEM @@ -5646,6 +5654,10 @@ syms_of_frame (void) #ifdef HAVE_NS DEFSYM (Qns_parse_geometry, "ns-parse-geometry"); #endif +#ifdef NS_IMPL_COCOA + DEFSYM (Qns_appearance, "ns-appearance"); + DEFSYM (Qns_transparent_titlebar, "ns-transparent-titlebar"); +#endif DEFSYM (Qalpha, "alpha"); DEFSYM (Qauto_lower, "auto-lower"); diff --git a/src/frame.h b/src/frame.h index 154dc9a3bb..4b7e448b54 100644 --- a/src/frame.h +++ b/src/frame.h @@ -65,6 +65,14 @@ enum internal_border_part INTERNAL_BORDER_BOTTOM_EDGE, INTERNAL_BORDER_BOTTOM_LEFT_CORNER, }; + +#ifdef NS_IMPL_COCOA +enum ns_appearance_type + { + ns_appearance_aqua, + ns_appearance_vibrant_dark + }; +#endif #endif /* HAVE_WINDOW_SYSTEM */ /* The structure representing a frame. */ @@ -563,6 +571,12 @@ struct frame /* All display backends seem to need these two pixel values. */ unsigned long background_pixel; unsigned long foreground_pixel; + +#ifdef NS_IMPL_COCOA + /* NSAppearance theme used on this frame. */ + enum ns_appearance_type ns_appearance; + bool_bf ns_transparent_titlebar; +#endif }; /* Most code should use these functions to set Lisp fields in struct frame. */ @@ -953,6 +967,10 @@ default_pixels_per_inch_y (void) #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \ ((f)->z_group == z_group_above_suspended) #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below) +#ifdef NS_IMPL_COCOA +#define FRAME_NS_APPEARANCE(f) ((f)->ns_appearance) +#define FRAME_NS_TRANSPARENT_TITLEBAR(f) ((f)->ns_transparent_titlebar) +#endif #else /* not HAVE_WINDOW_SYSTEM */ #define FRAME_UNDECORATED(f) ((void) (f), 0) #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0) diff --git a/src/nsfns.m b/src/nsfns.m index 36748cebb8..8d48737054 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -985,6 +985,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side x_set_z_group, /* x_set_z_group */ 0, /* x_set_override_redirect */ x_set_no_special_glyphs, +#ifdef NS_IMPL_COCOA + ns_set_appearance, + ns_set_transparent_titlebar, +#endif }; @@ -1277,6 +1281,16 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound); store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil); + tem = x_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, RES_TYPE_SYMBOL); + FRAME_NS_APPEARANCE (f) = EQ (tem, Qdark) + ? ns_appearance_vibrant_dark : ns_appearance_aqua; + store_frame_param (f, Qns_appearance, tem); + + tem = x_get_arg (dpyinfo, parms, Qns_transparent_titlebar, + NULL, NULL, RES_TYPE_BOOLEAN); + FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (tem) && !EQ (tem, Qunbound); + store_frame_param (f, Qns_transparent_titlebar, tem); + parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL, RES_TYPE_SYMBOL); /* Accept parent-frame iff parent-id was not specified. */ @@ -3239,6 +3253,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename DEFSYM (Qfontsize, "fontsize"); DEFSYM (Qframe_title_format, "frame-title-format"); DEFSYM (Qicon_title_format, "icon-title-format"); + DEFSYM (Qdark, "dark"); DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist, doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames. diff --git a/src/nsterm.h b/src/nsterm.h index 67c0d42ac1..2adf28b8b0 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1234,6 +1234,13 @@ extern void x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object old_value); extern void x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value); +#ifdef NS_IMPL_COCOA +extern void ns_set_appearance (struct frame *f, Lisp_Object new_value, + Lisp_Object old_value); +extern void ns_set_transparent_titlebar (struct frame *f, + Lisp_Object new_value, + Lisp_Object old_value); +#endif extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timespec *timeout, sigset_t *sigmask); diff --git a/src/nsterm.m b/src/nsterm.m index 36d906a7ce..cc41e3a0dc 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2025,6 +2025,58 @@ so some key presses (TAB) are swallowed by the system. */ error ("Invalid z-group specification"); } +#ifdef NS_IMPL_COCOA +void +ns_set_appearance (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + + NSTRACE ("ns_set_appearance"); + +#ifndef NSAppKitVersionNumber10_9 +#define NSAppKitVersionNumber10_9 1265 +#endif + + if (NSAppKitVersionNumber < NSAppKitVersionNumber10_9) + return; + + if (EQ (new_value, Qdark)) + { + window.appearance = [NSAppearance + appearanceNamed: NSAppearanceNameVibrantDark]; + FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; + } + else + { + window.appearance = [NSAppearance + appearanceNamed: NSAppearanceNameAqua]; + FRAME_NS_APPEARANCE (f) = ns_appearance_aqua; + } +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 */ +} + +void +ns_set_transparent_titlebar (struct frame *f, Lisp_Object new_value, + Lisp_Object old_value) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + + NSTRACE ("ns_set_transparent_titlebar"); + + if ([window respondsToSelector: @selector(titlebarAppearsTransparent)] + && !EQ (new_value, old_value)) + { + window.titlebarAppearsTransparent = !NILP (new_value); + FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (new_value); + } +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */ +} +#endif /* NS_IMPL_COCOA */ + static void ns_fullscreen_hook (struct frame *f) { @@ -7051,6 +7103,22 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f if (! FRAME_UNDECORATED (f)) [self createToolbar: f]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 +#ifndef NSAppKitVersionNumber10_9 +#define NSAppKitVersionNumber10_9 1265 +#endif + + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_9 + && FRAME_NS_APPEARANCE (f) != ns_appearance_aqua) + win.appearance = [NSAppearance + appearanceNamed: NSAppearanceNameVibrantDark]; +#endif + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 + if ([win respondsToSelector: @selector(titlebarAppearsTransparent)]) + win.titlebarAppearsTransparent = FRAME_NS_TRANSPARENT_TITLEBAR (f); +#endif + tem = f->icon_name; if (!NILP (tem)) [win setMiniwindowTitle: -- 2.12.0 -- Alan Third ^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-13 13:11 ` bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) Alan Third @ 2017-08-13 14:38 ` Eli Zaretskii 2017-08-13 15:10 ` Alan Third 2017-08-20 13:42 ` Alan Third 0 siblings, 2 replies; 20+ messages in thread From: Eli Zaretskii @ 2017-08-13 14:38 UTC (permalink / raw) To: Alan Third; +Cc: james, 27973 > Date: Sun, 13 Aug 2017 14:11:10 +0100 > From: Alan Third <alan@idiocy.org> > Cc: 27973@debbugs.gnu.org > > * src/frame.c (make_frame, frame_parms, syms_of_frame) > [NS_IMPL_COCOA]: Add ns-appearance and ns-transparent-titlebar > options. This should be mentioned in the documentation somewhere, I think. Including how to use it to solve whatever problems we have with themes on NS. > * src/frame.h (ns_appearance_type) [NS_IMPL_COCOA]: Add enum to > represent NSAppearance options. > (struct frame) [NS_IMPL_COCOA]: Add ns_appearance and > ns_transparent_titlebar frame parameters. > * src/nsfns.m (ns_frame_parm_handlers) [NS_IMPL_COCOA]: Add > ns_set_appearance and ns_set_transparent_titlebar handlers. > (Sx_create_frame): Handle ns-appearance and ns-transparent-titlebar > frame parameters. Is the transparency thing, or its equivalent, supported on GNU/Linux? Thanks. ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-13 14:38 ` Eli Zaretskii @ 2017-08-13 15:10 ` Alan Third 2017-08-20 13:42 ` Alan Third 1 sibling, 0 replies; 20+ messages in thread From: Alan Third @ 2017-08-13 15:10 UTC (permalink / raw) To: Eli Zaretskii; +Cc: james, 27973 On Sun, Aug 13, 2017 at 05:38:37PM +0300, Eli Zaretskii wrote: > > Date: Sun, 13 Aug 2017 14:11:10 +0100 > > From: Alan Third <alan@idiocy.org> > > Cc: 27973@debbugs.gnu.org > > > > * src/frame.c (make_frame, frame_parms, syms_of_frame) > > [NS_IMPL_COCOA]: Add ns-appearance and ns-transparent-titlebar > > options. > > This should be mentioned in the documentation somewhere, I think. > Including how to use it to solve whatever problems we have with themes > on NS. Ah yes, I knew there was something else I needed to do. :) > Is the transparency thing, or its equivalent, supported on GNU/Linux? I’m not sure, because it’s roughly equivalent to changing a window manager and/or GTK theme. On macOS the theme of the window decorations is set by a combination of system‐wide settings and application specific settings. -- Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-13 14:38 ` Eli Zaretskii 2017-08-13 15:10 ` Alan Third @ 2017-08-20 13:42 ` Alan Third 2017-08-20 14:45 ` Eli Zaretskii 1 sibling, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-20 13:42 UTC (permalink / raw) To: Eli Zaretskii; +Cc: james, 27973 * src/frame.c (make_frame, frame_parms, syms_of_frame) [NS_IMPL_COCOA]: Add ns-appearance and ns-transparent-titlebar options. * src/frame.h (ns_appearance_type) [NS_IMPL_COCOA]: Add enum to represent NSAppearance options. (struct frame) [NS_IMPL_COCOA]: Add ns_appearance and ns_transparent_titlebar frame parameters. * src/nsfns.m (ns_frame_parm_handlers) [NS_IMPL_COCOA]: Add ns_set_appearance and ns_set_transparent_titlebar handlers. (Sx_create_frame): Handle ns-appearance and ns-transparent-titlebar frame parameters. (Qdark): Add new symbol for use with ns-appearance. * src/nsterm.h (ns_set_appearance, ns_set_transparent_titlebar) [NS_IMPL_COCOA]: Add prototypes. * src/nsterm.m (ns_set_appearance, ns_set_transparent_titlebar) [NS_IMPL_COCOA]: New functions. (initFrameFromEmacs) [NS_IMPL_COCOA]: Handle ns-appearance and ns-transparent-titlebar frame parameters. * doc/lispref/frames.texi (Window Management Parameters): Document ns-apperance and ns-transparent-titlebar. --- doc/lispref/frames.texi | 14 ++++++++++ src/frame.c | 12 +++++++++ src/frame.h | 18 +++++++++++++ src/nsfns.m | 17 +++++++++++++ src/nsterm.h | 7 +++++ src/nsterm.m | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+) diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index b430f7c6fa..1552d8f27e 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2125,6 +2125,20 @@ Management Parameters application's window. (It is not certain this will be implemented; try it and see if it works.) @end ignore + +@vindex ns-appearance, a frame parameter +@item ns-appearance +Only available on macOS, if set to @code{dark} draw this frame's +window-system window using the `vibrant dark' theme, otherwise use the +system default. The `vibrant dark' theme can be used to set the +toolbar and scrollbars to a dark appearance when using an Emacs theme +with a dark background. + +@vindex ns-transparent-titlebar, a frame parameter +@item ns-transparent-titlebar +Only available on macOS, if non-@code{nil}, set the titlebar and +toolbar to be `transparent'. This effectively sets the background +color of both to match the Emacs background color. @end table diff --git a/src/frame.c b/src/frame.c index 1e5e4bbdb4..5099f75be4 100644 --- a/src/frame.c +++ b/src/frame.c @@ -834,6 +834,10 @@ make_frame (bool mini_p) #if ! defined (USE_GTK) && ! defined (HAVE_NS) f->last_tool_bar_item = -1; #endif +#ifdef NS_IMPL_COCOA + f->ns_appearance = ns_appearance_aqua; + f->ns_transparent_titlebar = false; +#endif #endif root_window = make_window (); @@ -3520,6 +3524,10 @@ static const struct frame_parm_table frame_parms[] = {"z-group", SYMBOL_INDEX (Qz_group)}, {"override-redirect", SYMBOL_INDEX (Qoverride_redirect)}, {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs)}, +#ifdef NS_IMPL_COCOA + {"ns-appearance", SYMBOL_INDEX (Qns_appearance)}, + {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar)}, +#endif }; #ifdef HAVE_WINDOW_SYSTEM @@ -5646,6 +5654,10 @@ syms_of_frame (void) #ifdef HAVE_NS DEFSYM (Qns_parse_geometry, "ns-parse-geometry"); #endif +#ifdef NS_IMPL_COCOA + DEFSYM (Qns_appearance, "ns-appearance"); + DEFSYM (Qns_transparent_titlebar, "ns-transparent-titlebar"); +#endif DEFSYM (Qalpha, "alpha"); DEFSYM (Qauto_lower, "auto-lower"); diff --git a/src/frame.h b/src/frame.h index 154dc9a3bb..4b7e448b54 100644 --- a/src/frame.h +++ b/src/frame.h @@ -65,6 +65,14 @@ enum internal_border_part INTERNAL_BORDER_BOTTOM_EDGE, INTERNAL_BORDER_BOTTOM_LEFT_CORNER, }; + +#ifdef NS_IMPL_COCOA +enum ns_appearance_type + { + ns_appearance_aqua, + ns_appearance_vibrant_dark + }; +#endif #endif /* HAVE_WINDOW_SYSTEM */ /* The structure representing a frame. */ @@ -563,6 +571,12 @@ struct frame /* All display backends seem to need these two pixel values. */ unsigned long background_pixel; unsigned long foreground_pixel; + +#ifdef NS_IMPL_COCOA + /* NSAppearance theme used on this frame. */ + enum ns_appearance_type ns_appearance; + bool_bf ns_transparent_titlebar; +#endif }; /* Most code should use these functions to set Lisp fields in struct frame. */ @@ -953,6 +967,10 @@ default_pixels_per_inch_y (void) #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \ ((f)->z_group == z_group_above_suspended) #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below) +#ifdef NS_IMPL_COCOA +#define FRAME_NS_APPEARANCE(f) ((f)->ns_appearance) +#define FRAME_NS_TRANSPARENT_TITLEBAR(f) ((f)->ns_transparent_titlebar) +#endif #else /* not HAVE_WINDOW_SYSTEM */ #define FRAME_UNDECORATED(f) ((void) (f), 0) #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0) diff --git a/src/nsfns.m b/src/nsfns.m index e19e4e2641..b00441eb79 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -985,6 +985,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side x_set_z_group, /* x_set_z_group */ 0, /* x_set_override_redirect */ x_set_no_special_glyphs, +#ifdef NS_IMPL_COCOA + ns_set_appearance, + ns_set_transparent_titlebar, +#endif }; @@ -1277,6 +1281,18 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound); store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil); +#ifdef NS_IMPL_COCOA + tem = x_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, RES_TYPE_SYMBOL); + FRAME_NS_APPEARANCE (f) = EQ (tem, Qdark) + ? ns_appearance_vibrant_dark : ns_appearance_aqua; + store_frame_param (f, Qns_appearance, tem); + + tem = x_get_arg (dpyinfo, parms, Qns_transparent_titlebar, + NULL, NULL, RES_TYPE_BOOLEAN); + FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (tem) && !EQ (tem, Qunbound); + store_frame_param (f, Qns_transparent_titlebar, tem); +#endif + parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL, RES_TYPE_SYMBOL); /* Accept parent-frame iff parent-id was not specified. */ @@ -3248,6 +3264,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename DEFSYM (Qfontsize, "fontsize"); DEFSYM (Qframe_title_format, "frame-title-format"); DEFSYM (Qicon_title_format, "icon-title-format"); + DEFSYM (Qdark, "dark"); DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist, doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames. diff --git a/src/nsterm.h b/src/nsterm.h index 0ac8043e26..65b7a0347a 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1210,6 +1210,13 @@ extern void x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object old_value); extern void x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value); +#ifdef NS_IMPL_COCOA +extern void ns_set_appearance (struct frame *f, Lisp_Object new_value, + Lisp_Object old_value); +extern void ns_set_transparent_titlebar (struct frame *f, + Lisp_Object new_value, + Lisp_Object old_value); +#endif extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timespec *timeout, sigset_t *sigmask); diff --git a/src/nsterm.m b/src/nsterm.m index 95092b29c8..22f8efd6b9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2036,6 +2036,58 @@ so some key presses (TAB) are swallowed by the system. */ error ("Invalid z-group specification"); } +#ifdef NS_IMPL_COCOA +void +ns_set_appearance (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + + NSTRACE ("ns_set_appearance"); + +#ifndef NSAppKitVersionNumber10_9 +#define NSAppKitVersionNumber10_9 1265 +#endif + + if (NSAppKitVersionNumber < NSAppKitVersionNumber10_9) + return; + + if (EQ (new_value, Qdark)) + { + window.appearance = [NSAppearance + appearanceNamed: NSAppearanceNameVibrantDark]; + FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; + } + else + { + window.appearance = [NSAppearance + appearanceNamed: NSAppearanceNameAqua]; + FRAME_NS_APPEARANCE (f) = ns_appearance_aqua; + } +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 */ +} + +void +ns_set_transparent_titlebar (struct frame *f, Lisp_Object new_value, + Lisp_Object old_value) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + + NSTRACE ("ns_set_transparent_titlebar"); + + if ([window respondsToSelector: @selector(titlebarAppearsTransparent)] + && !EQ (new_value, old_value)) + { + window.titlebarAppearsTransparent = !NILP (new_value); + FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (new_value); + } +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */ +} +#endif /* NS_IMPL_COCOA */ + static void ns_fullscreen_hook (struct frame *f) { @@ -7083,6 +7135,22 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f if (! FRAME_UNDECORATED (f)) [self createToolbar: f]; +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 +#ifndef NSAppKitVersionNumber10_9 +#define NSAppKitVersionNumber10_9 1265 +#endif + + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_9 + && FRAME_NS_APPEARANCE (f) != ns_appearance_aqua) + win.appearance = [NSAppearance + appearanceNamed: NSAppearanceNameVibrantDark]; +#endif + +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 + if ([win respondsToSelector: @selector(titlebarAppearsTransparent)]) + win.titlebarAppearsTransparent = FRAME_NS_TRANSPARENT_TITLEBAR (f); +#endif + tem = f->icon_name; if (!NILP (tem)) [win setMiniwindowTitle: -- Documentation updated as requested. -- Alan Third ^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-20 13:42 ` Alan Third @ 2017-08-20 14:45 ` Eli Zaretskii 2017-08-20 15:20 ` Alan Third 2017-08-20 18:18 ` James Nguyen 0 siblings, 2 replies; 20+ messages in thread From: Eli Zaretskii @ 2017-08-20 14:45 UTC (permalink / raw) To: Alan Third; +Cc: james, 27973 > Date: Sun, 20 Aug 2017 14:42:01 +0100 > From: Alan Third <alan@idiocy.org> > Cc: james@jojojames.com, 27973@debbugs.gnu.org > > +@vindex ns-appearance, a frame parameter > +@item ns-appearance > +Only available on macOS, if set to @code{dark} draw this frame's > +window-system window using the `vibrant dark' theme, otherwise use the ^^^^^^^^^^^^^^ Please quote ``like this'' in Texinfo sources, this produces a much better output. Alternatively, you could use @samp{vibrant dark} instead. > +@vindex ns-transparent-titlebar, a frame parameter > +@item ns-transparent-titlebar > +Only available on macOS, if non-@code{nil}, set the titlebar and > +toolbar to be `transparent'. This effectively sets the background ^^^^^^^^^^^^^ I don't think you need any quoting here, as "transparent" is used here in its literal sense, right? Thanks. ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-20 14:45 ` Eli Zaretskii @ 2017-08-20 15:20 ` Alan Third 2017-08-20 18:18 ` James Nguyen 1 sibling, 0 replies; 20+ messages in thread From: Alan Third @ 2017-08-20 15:20 UTC (permalink / raw) To: Eli Zaretskii; +Cc: james, 27973 On Sun, Aug 20, 2017 at 05:45:24PM +0300, Eli Zaretskii wrote: > > Date: Sun, 20 Aug 2017 14:42:01 +0100 > > From: Alan Third <alan@idiocy.org> > > Cc: james@jojojames.com, 27973@debbugs.gnu.org > > > > +@vindex ns-appearance, a frame parameter > > +@item ns-appearance > > +Only available on macOS, if set to @code{dark} draw this frame's > > +window-system window using the `vibrant dark' theme, otherwise use the > ^^^^^^^^^^^^^^ > Please quote ``like this'' in Texinfo sources, this produces a much > better output. Alternatively, you could use @samp{vibrant dark} instead. > > > +@vindex ns-transparent-titlebar, a frame parameter > > +@item ns-transparent-titlebar > > +Only available on macOS, if non-@code{nil}, set the titlebar and > > +toolbar to be `transparent'. This effectively sets the background > ^^^^^^^^^^^^^ > I don't think you need any quoting here, as "transparent" is used here > in its literal sense, right? Both changes made locally. Thanks. -- Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-20 14:45 ` Eli Zaretskii 2017-08-20 15:20 ` Alan Third @ 2017-08-20 18:18 ` James Nguyen 2017-08-23 19:21 ` Alan Third 1 sibling, 1 reply; 20+ messages in thread From: James Nguyen @ 2017-08-20 18:18 UTC (permalink / raw) To: Eli Zaretskii, Alan Third; +Cc: 27973 Eli Zaretskii <eliz@gnu.org> writes: With a short trial of the patch, it is working well for me. Thanks Alan! >> Date: Sun, 20 Aug 2017 14:42:01 +0100 >> From: Alan Third <alan@idiocy.org> >> Cc: james@jojojames.com, 27973@debbugs.gnu.org >> >> +@vindex ns-appearance, a frame parameter >> +@item ns-appearance >> +Only available on macOS, if set to @code{dark} draw this frame's >> +window-system window using the `vibrant dark' theme, otherwise use the > ^^^^^^^^^^^^^^ > Please quote ``like this'' in Texinfo sources, this produces a much > better output. Alternatively, you could use @samp{vibrant dark} instead. > >> +@vindex ns-transparent-titlebar, a frame parameter >> +@item ns-transparent-titlebar >> +Only available on macOS, if non-@code{nil}, set the titlebar and >> +toolbar to be `transparent'. This effectively sets the background > ^^^^^^^^^^^^^ > I don't think you need any quoting here, as "transparent" is used here > in its literal sense, right? > > Thanks. ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-20 18:18 ` James Nguyen @ 2017-08-23 19:21 ` Alan Third 2017-08-24 1:28 ` James Nguyen 0 siblings, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-23 19:21 UTC (permalink / raw) To: James Nguyen; +Cc: 27973-done Pushed to master. -- Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) 2017-08-23 19:21 ` Alan Third @ 2017-08-24 1:28 ` James Nguyen 0 siblings, 0 replies; 20+ messages in thread From: James Nguyen @ 2017-08-24 1:28 UTC (permalink / raw) To: Alan Third; +Cc: 27973-done Alan Third <alan@idiocy.org> writes: Thanks Alan! > Pushed to master. > -- > Alan Third ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <handler.27973.D27973.15035160789583.notifdone@debbugs.gnu.org>]
* bug#27973: closed (Re: [PATCH] Add ability to change macOS WM theme (bug#27973)) [not found] ` <handler.27973.D27973.15035160789583.notifdone@debbugs.gnu.org> @ 2017-08-24 9:21 ` Charles A. Roelli 2017-08-24 21:01 ` Alan Third 0 siblings, 1 reply; 20+ messages in thread From: Charles A. Roelli @ 2017-08-24 9:21 UTC (permalink / raw) To: 27973, alan; +Cc: james > commit 7baa50eca28ff21497b058fa22656bbb4a447d87 > Author: Alan Third <alan@idiocy.org> > Date: Sun Aug 20 21:14:47 2017 +0100 > > Add ability to change macOS WM theme (bug#27973) Should we also add a NEWS entry for this? Otherwise people may not be aware of the new functionality when 26.1 is released. ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: closed (Re: [PATCH] Add ability to change macOS WM theme (bug#27973)) 2017-08-24 9:21 ` bug#27973: closed (Re: [PATCH] Add ability to change macOS WM theme (bug#27973)) Charles A. Roelli @ 2017-08-24 21:01 ` Alan Third 2017-08-25 0:58 ` Glenn Morris 0 siblings, 1 reply; 20+ messages in thread From: Alan Third @ 2017-08-24 21:01 UTC (permalink / raw) To: Charles A. Roelli; +Cc: james, 27973 [-- Attachment #1: Type: text/plain, Size: 480 bytes --] On Thu, Aug 24, 2017 at 11:21:23AM +0200, Charles A. Roelli wrote: > > commit 7baa50eca28ff21497b058fa22656bbb4a447d87 > > Author: Alan Third <alan@idiocy.org> > > Date: Sun Aug 20 21:14:47 2017 +0100 > > > > Add ability to change macOS WM theme (bug#27973) > > Should we also add a NEWS entry for this? Otherwise people may not be > aware of the new functionality when 26.1 is released. I’ve never done NEWS changes before. Something like the attached? -- Alan Third [-- Attachment #2: 0001-Add-news-entry-about-new-macOS-frame-parameters-bug-.patch --] [-- Type: text/plain, Size: 876 bytes --] From 2b90b722ebfcbdf3da425bb6de437e3021761f97 Mon Sep 17 00:00:00 2001 From: Alan Third <alan@idiocy.org> Date: Thu, 24 Aug 2017 21:59:33 +0100 Subject: [PATCH] Add news entry about new macOS frame parameters (bug#27973) * etc/NEWS: Add entry about ns-appearance and ns-transparent-titlebar. --- etc/NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 09390333ae..c5ab7b3673 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1531,6 +1531,10 @@ handle fitting a frame to its buffer individually. 'drag-with-mode-line', 'snap-width', 'top-visible' and 'bottom-visible' allow to drag and resize frames with the mouse. ++++ +**** 'ns-appearance' and 'ns-transparent-titlebar' change the +appearance of frame decorations on macOS 10.9+. + *** The new function 'frame-list-z-order' returns a list of all frames in Z (stacking) order. -- 2.12.0 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#27973: closed (Re: [PATCH] Add ability to change macOS WM theme (bug#27973)) 2017-08-24 21:01 ` Alan Third @ 2017-08-25 0:58 ` Glenn Morris 2017-08-27 7:11 ` Charles A. Roelli 0 siblings, 1 reply; 20+ messages in thread From: Glenn Morris @ 2017-08-25 0:58 UTC (permalink / raw) To: Alan Third; +Cc: Charles A. Roelli, james, 27973 There's a separate section of NEWS for Non-Free OS changes. ^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#27973: closed (Re: [PATCH] Add ability to change macOS WM theme (bug#27973)) 2017-08-25 0:58 ` Glenn Morris @ 2017-08-27 7:11 ` Charles A. Roelli 0 siblings, 0 replies; 20+ messages in thread From: Charles A. Roelli @ 2017-08-27 7:11 UTC (permalink / raw) To: Glenn Morris; +Cc: alan, james, 27973 > Date: Thu, 24 Aug 2017 22:01:05 +0100 > From: Alan Third <alan@idiocy.org> > > On Thu, Aug 24, 2017 at 11:21:23AM +0200, Charles A. Roelli wrote: > > > commit 7baa50eca28ff21497b058fa22656bbb4a447d87 > > > Author: Alan Third <alan@idiocy.org> > > > Date: Sun Aug 20 21:14:47 2017 +0100 > > > > > > Add ability to change macOS WM theme (bug#27973) > > > > Should we also add a NEWS entry for this? Otherwise people may not be > > aware of the new functionality when 26.1 is released. > > I’ve never done NEWS changes before. Something like the attached? The text looks fine to me. But as Glenn suggested, it would probably best fit with the Non-Free OS changes section. ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2017-08-27 7:11 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-08-05 17:26 bug#27973: 26.0.50; Feature Request - OSX - Transparent Titlebars James Nguyen 2017-08-06 0:14 ` Alan Third 2017-08-06 0:19 ` James Nguyen 2017-08-06 0:25 ` Alan Third 2017-08-06 0:39 ` James Nguyen 2017-08-06 13:12 ` Alan Third 2017-08-06 15:41 ` James Nguyen 2017-08-13 13:11 ` bug#27973: [PATCH] Add ability to change macOS WM theme (bug#27973) Alan Third 2017-08-13 14:38 ` Eli Zaretskii 2017-08-13 15:10 ` Alan Third 2017-08-20 13:42 ` Alan Third 2017-08-20 14:45 ` Eli Zaretskii 2017-08-20 15:20 ` Alan Third 2017-08-20 18:18 ` James Nguyen 2017-08-23 19:21 ` Alan Third 2017-08-24 1:28 ` James Nguyen [not found] ` <handler.27973.D27973.15035160789583.notifdone@debbugs.gnu.org> 2017-08-24 9:21 ` bug#27973: closed (Re: [PATCH] Add ability to change macOS WM theme (bug#27973)) Charles A. Roelli 2017-08-24 21:01 ` Alan Third 2017-08-25 0:58 ` Glenn Morris 2017-08-27 7:11 ` Charles A. Roelli
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.