Commit 72f54f03 authored by Alan Third's avatar Alan Third

Fix NS frame parameters (bug#39000)

* src/frame.c (make_frame): Use new system default setting.
* src/frame.h (enum ns_appearance_type): Add new system default
setting.
* src/nsfns.m (Fx_create_frame): Correctly handle Qunbound and support
system default appearance.
(syms_of_nsfns): Add Qlight.
* src/nsterm.h: New method definition.
* src/nsterm.m (ns_set_appearance): Correctly handle Qlight and use new
setAppearance method.
([EmacsView initFrameFromEmacs:]): Use new setAppearance method.
([EmacsWindow setAppearance]): New method.
* doc/lispref/frames.texi (Management Parameters): Document 'light'.
parent dd85664d
Pipeline #4510 passed with stage
in 54 minutes and 58 seconds
......@@ -2192,10 +2192,11 @@ it and see if it works.)
@vindex ns-appearance@r{, 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.
window-system window using the ``vibrant dark'' theme, and if set to
@code{light} use the ``aqua'' 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@r{, a frame parameter}
@item ns-transparent-titlebar
......
......@@ -904,7 +904,7 @@ make_frame (bool mini_p)
f->last_tool_bar_item = -1;
#endif
#ifdef NS_IMPL_COCOA
f->ns_appearance = ns_appearance_aqua;
f->ns_appearance = ns_appearance_system_default;
f->ns_transparent_titlebar = false;
#endif
#endif
......
......@@ -69,8 +69,9 @@ enum internal_border_part
#ifdef NS_IMPL_COCOA
enum ns_appearance_type
{
ns_appearance_aqua,
ns_appearance_vibrant_dark
ns_appearance_system_default,
ns_appearance_aqua,
ns_appearance_vibrant_dark
};
#endif
#endif /* HAVE_WINDOW_SYSTEM */
......
......@@ -1277,14 +1277,20 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
#ifdef NS_IMPL_COCOA
tem = gui_display_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);
if (EQ (tem, Qdark))
FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark;
else if (EQ (tem, Qlight))
FRAME_NS_APPEARANCE (f) = ns_appearance_aqua;
else
FRAME_NS_APPEARANCE (f) = ns_appearance_system_default;
store_frame_param (f, Qns_appearance,
(!NILP (tem) && !EQ (tem, Qunbound)) ? tem : Qnil);
tem = gui_display_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);
store_frame_param (f, Qns_transparent_titlebar,
FRAME_NS_TRANSPARENT_TITLEBAR (f) ? Qt : Qnil);
#endif
parent_frame = gui_display_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL,
......@@ -3141,6 +3147,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
DEFSYM (Qframe_title_format, "frame-title-format");
DEFSYM (Qicon_title_format, "icon-title-format");
DEFSYM (Qdark, "dark");
DEFSYM (Qlight, "light");
DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist,
doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames.
......
......@@ -471,6 +471,8 @@ typedef id instancetype;
{
NSPoint grabOffset;
}
- (void)setAppearance;
@end
......
......@@ -2025,17 +2025,13 @@ so some key presses (TAB) are swallowed by the system. */
return;
if (EQ (new_value, Qdark))
{
window.appearance = [NSAppearance
appearanceNamed: NSAppearanceNameVibrantDark];
FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark;
}
FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark;
else if (EQ (new_value, Qlight))
FRAME_NS_APPEARANCE (f) = ns_appearance_aqua;
else
{
window.appearance = [NSAppearance
appearanceNamed: NSAppearanceNameAqua];
FRAME_NS_APPEARANCE (f) = ns_appearance_aqua;
}
FRAME_NS_APPEARANCE (f) = ns_appearance_system_default;
[window setAppearance];
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */
}
......@@ -7469,16 +7465,8 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
if (! FRAME_UNDECORATED (f))
[self createToolbar: f];
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
#ifndef NSAppKitVersionNumber10_10
#define NSAppKitVersionNumber10_10 1343
#endif
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_10
&& FRAME_NS_APPEARANCE (f) != ns_appearance_aqua)
win.appearance = [NSAppearance
appearanceNamed: NSAppearanceNameVibrantDark];
#endif
[win setAppearance];
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
if ([win respondsToSelector: @selector(titlebarAppearsTransparent)])
......@@ -8728,6 +8716,32 @@ - (void)zoom:(id)sender
#endif
}
- (void)setAppearance
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
struct frame *f = ((EmacsView *)[self delegate])->emacsframe;
NSAppearance *appearance = nil;
NSTRACE ("[EmacsWindow setAppearance]");
#ifndef NSAppKitVersionNumber10_10
#define NSAppKitVersionNumber10_10 1343
#endif
if (NSAppKitVersionNumber < NSAppKitVersionNumber10_10)
return;
if (FRAME_NS_APPEARANCE (f) == ns_appearance_vibrant_dark)
appearance =
[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
else if (FRAME_NS_APPEARANCE (f) == ns_appearance_aqua)
appearance =
[NSAppearance appearanceNamed:NSAppearanceNameAqua];
[self setAppearance:appearance];
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */
}
- (void)setFrame:(NSRect)windowFrame
display:(BOOL)displayViews
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment