]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix NS frame parameters (bug#39000)
authorAlan Third <alan@idiocy.org>
Tue, 7 Jan 2020 14:19:01 +0000 (14:19 +0000)
committerAlan Third <alan@idiocy.org>
Tue, 7 Jan 2020 18:33:14 +0000 (18:33 +0000)
* 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'.

doc/lispref/frames.texi
src/frame.c
src/frame.h
src/nsfns.m
src/nsterm.h
src/nsterm.m

index 05038c6f52bc56afdf98eed3ed6fc8d577a412bf..9bd8bedc660ea4bc4da26f472b5fa9a6a4153fd9 100644 (file)
@@ -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
index 88d6f22fc0a5c50e187b1617da9eb218f44c7f85..51fc78ab7030d5430aa855919d1331cedbc23171 100644 (file)
@@ -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
index 6ab690c0ff52932899bbcf4fe6538a59c66066b2..68dc0ce3649edfd51752596b5d220154fb763dee 100644 (file)
@@ -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 */
index 4d47a90a720c0b0cc1aaa1b98c77f1e2e28e3512..f2857c022ee4eeb2e19928b0d9e8ce9afe92368b 100644 (file)
@@ -1277,14 +1277,20 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 #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 @@ syms_of_nsfns (void)
   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.
index fb9ac1b462c41f2401a740e1861eab4d2adbc64a..8baa65f5783dd8f05b0ad945f9f4a8595b5e2ef9 100644 (file)
@@ -471,6 +471,8 @@ typedef id instancetype;
 {
   NSPoint grabOffset;
 }
+
+- (void)setAppearance;
 @end
 
 
index 2b6be86db82f994091a02c0cc7f806d3da15ae71..57573ef8d7ed7ab04d3965a12126d464772b432b 100644 (file)
@@ -2025,17 +2025,13 @@ ns_set_appearance (struct frame *f, Lisp_Object new_value, Lisp_Object old_value
     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 @@ not_in_argv (NSString *arg)
   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 @@ not_in_argv (NSString *arg)
 #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
 {