diff options
| author | Alan Third | 2020-01-07 14:19:01 +0000 |
|---|---|---|
| committer | Alan Third | 2020-01-07 18:33:14 +0000 |
| commit | 72f54f035dc74a01c1ab5ff444752a994d852490 (patch) | |
| tree | fc80598e1e93bc19d22110c1400bdf49cc8ff29a | |
| parent | dd85664d23e29363fe08f8cbbf2b96472ac60fc1 (diff) | |
| download | emacs-72f54f035dc74a01c1ab5ff444752a994d852490.tar.gz emacs-72f54f035dc74a01c1ab5ff444752a994d852490.zip | |
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'.
| -rw-r--r-- | doc/lispref/frames.texi | 9 | ||||
| -rw-r--r-- | src/frame.c | 2 | ||||
| -rw-r--r-- | src/frame.h | 5 | ||||
| -rw-r--r-- | src/nsfns.m | 15 | ||||
| -rw-r--r-- | src/nsterm.h | 2 | ||||
| -rw-r--r-- | src/nsterm.m | 52 |
6 files changed, 55 insertions, 30 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 05038c6f52b..9bd8bedc660 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi | |||
| @@ -2192,10 +2192,11 @@ it and see if it works.) | |||
| 2192 | @vindex ns-appearance@r{, a frame parameter} | 2192 | @vindex ns-appearance@r{, a frame parameter} |
| 2193 | @item ns-appearance | 2193 | @item ns-appearance |
| 2194 | Only available on macOS, if set to @code{dark} draw this frame's | 2194 | Only available on macOS, if set to @code{dark} draw this frame's |
| 2195 | window-system window using the ``vibrant dark'' theme, otherwise use | 2195 | window-system window using the ``vibrant dark'' theme, and if set to |
| 2196 | the system default. The ``vibrant dark'' theme can be used to set the | 2196 | @code{light} use the ``aqua'' theme, otherwise use the system default. |
| 2197 | toolbar and scrollbars to a dark appearance when using an Emacs theme | 2197 | The ``vibrant dark'' theme can be used to set the toolbar and |
| 2198 | with a dark background. | 2198 | scrollbars to a dark appearance when using an Emacs theme with a dark |
| 2199 | background. | ||
| 2199 | 2200 | ||
| 2200 | @vindex ns-transparent-titlebar@r{, a frame parameter} | 2201 | @vindex ns-transparent-titlebar@r{, a frame parameter} |
| 2201 | @item ns-transparent-titlebar | 2202 | @item ns-transparent-titlebar |
diff --git a/src/frame.c b/src/frame.c index 88d6f22fc0a..51fc78ab703 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -904,7 +904,7 @@ make_frame (bool mini_p) | |||
| 904 | f->last_tool_bar_item = -1; | 904 | f->last_tool_bar_item = -1; |
| 905 | #endif | 905 | #endif |
| 906 | #ifdef NS_IMPL_COCOA | 906 | #ifdef NS_IMPL_COCOA |
| 907 | f->ns_appearance = ns_appearance_aqua; | 907 | f->ns_appearance = ns_appearance_system_default; |
| 908 | f->ns_transparent_titlebar = false; | 908 | f->ns_transparent_titlebar = false; |
| 909 | #endif | 909 | #endif |
| 910 | #endif | 910 | #endif |
diff --git a/src/frame.h b/src/frame.h index 6ab690c0ff5..68dc0ce3649 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -69,8 +69,9 @@ enum internal_border_part | |||
| 69 | #ifdef NS_IMPL_COCOA | 69 | #ifdef NS_IMPL_COCOA |
| 70 | enum ns_appearance_type | 70 | enum ns_appearance_type |
| 71 | { | 71 | { |
| 72 | ns_appearance_aqua, | 72 | ns_appearance_system_default, |
| 73 | ns_appearance_vibrant_dark | 73 | ns_appearance_aqua, |
| 74 | ns_appearance_vibrant_dark | ||
| 74 | }; | 75 | }; |
| 75 | #endif | 76 | #endif |
| 76 | #endif /* HAVE_WINDOW_SYSTEM */ | 77 | #endif /* HAVE_WINDOW_SYSTEM */ |
diff --git a/src/nsfns.m b/src/nsfns.m index 4d47a90a720..f2857c022ee 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -1277,14 +1277,20 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, | |||
| 1277 | #ifdef NS_IMPL_COCOA | 1277 | #ifdef NS_IMPL_COCOA |
| 1278 | tem = gui_display_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, | 1278 | tem = gui_display_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, |
| 1279 | RES_TYPE_SYMBOL); | 1279 | RES_TYPE_SYMBOL); |
| 1280 | FRAME_NS_APPEARANCE (f) = EQ (tem, Qdark) | 1280 | if (EQ (tem, Qdark)) |
| 1281 | ? ns_appearance_vibrant_dark : ns_appearance_aqua; | 1281 | FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; |
| 1282 | store_frame_param (f, Qns_appearance, tem); | 1282 | else if (EQ (tem, Qlight)) |
| 1283 | FRAME_NS_APPEARANCE (f) = ns_appearance_aqua; | ||
| 1284 | else | ||
| 1285 | FRAME_NS_APPEARANCE (f) = ns_appearance_system_default; | ||
| 1286 | store_frame_param (f, Qns_appearance, | ||
| 1287 | (!NILP (tem) && !EQ (tem, Qunbound)) ? tem : Qnil); | ||
| 1283 | 1288 | ||
| 1284 | tem = gui_display_get_arg (dpyinfo, parms, Qns_transparent_titlebar, | 1289 | tem = gui_display_get_arg (dpyinfo, parms, Qns_transparent_titlebar, |
| 1285 | NULL, NULL, RES_TYPE_BOOLEAN); | 1290 | NULL, NULL, RES_TYPE_BOOLEAN); |
| 1286 | FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (tem) && !EQ (tem, Qunbound); | 1291 | FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (tem) && !EQ (tem, Qunbound); |
| 1287 | store_frame_param (f, Qns_transparent_titlebar, tem); | 1292 | store_frame_param (f, Qns_transparent_titlebar, |
| 1293 | FRAME_NS_TRANSPARENT_TITLEBAR (f) ? Qt : Qnil); | ||
| 1288 | #endif | 1294 | #endif |
| 1289 | 1295 | ||
| 1290 | parent_frame = gui_display_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL, | 1296 | parent_frame = gui_display_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL, |
| @@ -3141,6 +3147,7 @@ syms_of_nsfns (void) | |||
| 3141 | DEFSYM (Qframe_title_format, "frame-title-format"); | 3147 | DEFSYM (Qframe_title_format, "frame-title-format"); |
| 3142 | DEFSYM (Qicon_title_format, "icon-title-format"); | 3148 | DEFSYM (Qicon_title_format, "icon-title-format"); |
| 3143 | DEFSYM (Qdark, "dark"); | 3149 | DEFSYM (Qdark, "dark"); |
| 3150 | DEFSYM (Qlight, "light"); | ||
| 3144 | 3151 | ||
| 3145 | DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist, | 3152 | DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist, |
| 3146 | doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames. | 3153 | doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames. |
diff --git a/src/nsterm.h b/src/nsterm.h index fb9ac1b462c..8baa65f5783 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -471,6 +471,8 @@ typedef id instancetype; | |||
| 471 | { | 471 | { |
| 472 | NSPoint grabOffset; | 472 | NSPoint grabOffset; |
| 473 | } | 473 | } |
| 474 | |||
| 475 | - (void)setAppearance; | ||
| 474 | @end | 476 | @end |
| 475 | 477 | ||
| 476 | 478 | ||
diff --git a/src/nsterm.m b/src/nsterm.m index 2b6be86db82..57573ef8d7e 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -2025,17 +2025,13 @@ ns_set_appearance (struct frame *f, Lisp_Object new_value, Lisp_Object old_value | |||
| 2025 | return; | 2025 | return; |
| 2026 | 2026 | ||
| 2027 | if (EQ (new_value, Qdark)) | 2027 | if (EQ (new_value, Qdark)) |
| 2028 | { | 2028 | FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; |
| 2029 | window.appearance = [NSAppearance | 2029 | else if (EQ (new_value, Qlight)) |
| 2030 | appearanceNamed: NSAppearanceNameVibrantDark]; | 2030 | FRAME_NS_APPEARANCE (f) = ns_appearance_aqua; |
| 2031 | FRAME_NS_APPEARANCE (f) = ns_appearance_vibrant_dark; | ||
| 2032 | } | ||
| 2033 | else | 2031 | else |
| 2034 | { | 2032 | FRAME_NS_APPEARANCE (f) = ns_appearance_system_default; |
| 2035 | window.appearance = [NSAppearance | 2033 | |
| 2036 | appearanceNamed: NSAppearanceNameAqua]; | 2034 | [window setAppearance]; |
| 2037 | FRAME_NS_APPEARANCE (f) = ns_appearance_aqua; | ||
| 2038 | } | ||
| 2039 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */ | 2035 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */ |
| 2040 | } | 2036 | } |
| 2041 | 2037 | ||
| @@ -7469,16 +7465,8 @@ not_in_argv (NSString *arg) | |||
| 7469 | if (! FRAME_UNDECORATED (f)) | 7465 | if (! FRAME_UNDECORATED (f)) |
| 7470 | [self createToolbar: f]; | 7466 | [self createToolbar: f]; |
| 7471 | 7467 | ||
| 7472 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 | ||
| 7473 | #ifndef NSAppKitVersionNumber10_10 | ||
| 7474 | #define NSAppKitVersionNumber10_10 1343 | ||
| 7475 | #endif | ||
| 7476 | 7468 | ||
| 7477 | if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_10 | 7469 | [win setAppearance]; |
| 7478 | && FRAME_NS_APPEARANCE (f) != ns_appearance_aqua) | ||
| 7479 | win.appearance = [NSAppearance | ||
| 7480 | appearanceNamed: NSAppearanceNameVibrantDark]; | ||
| 7481 | #endif | ||
| 7482 | 7470 | ||
| 7483 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 | 7471 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
| 7484 | if ([win respondsToSelector: @selector(titlebarAppearsTransparent)]) | 7472 | if ([win respondsToSelector: @selector(titlebarAppearsTransparent)]) |
| @@ -8728,6 +8716,32 @@ not_in_argv (NSString *arg) | |||
| 8728 | #endif | 8716 | #endif |
| 8729 | } | 8717 | } |
| 8730 | 8718 | ||
| 8719 | - (void)setAppearance | ||
| 8720 | { | ||
| 8721 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 | ||
| 8722 | struct frame *f = ((EmacsView *)[self delegate])->emacsframe; | ||
| 8723 | NSAppearance *appearance = nil; | ||
| 8724 | |||
| 8725 | NSTRACE ("[EmacsWindow setAppearance]"); | ||
| 8726 | |||
| 8727 | #ifndef NSAppKitVersionNumber10_10 | ||
| 8728 | #define NSAppKitVersionNumber10_10 1343 | ||
| 8729 | #endif | ||
| 8730 | |||
| 8731 | if (NSAppKitVersionNumber < NSAppKitVersionNumber10_10) | ||
| 8732 | return; | ||
| 8733 | |||
| 8734 | if (FRAME_NS_APPEARANCE (f) == ns_appearance_vibrant_dark) | ||
| 8735 | appearance = | ||
| 8736 | [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; | ||
| 8737 | else if (FRAME_NS_APPEARANCE (f) == ns_appearance_aqua) | ||
| 8738 | appearance = | ||
| 8739 | [NSAppearance appearanceNamed:NSAppearanceNameAqua]; | ||
| 8740 | |||
| 8741 | [self setAppearance:appearance]; | ||
| 8742 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 */ | ||
| 8743 | } | ||
| 8744 | |||
| 8731 | - (void)setFrame:(NSRect)windowFrame | 8745 | - (void)setFrame:(NSRect)windowFrame |
| 8732 | display:(BOOL)displayViews | 8746 | display:(BOOL)displayViews |
| 8733 | { | 8747 | { |