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
#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 ();
{"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
#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");
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. */
/* 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. */
#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)
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
};
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. */
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.
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);
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)
{
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: