]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove NS special handling of 'frame-title-format'
authorAlan Third <alan@idiocy.org>
Sun, 11 Feb 2018 11:34:49 +0000 (11:34 +0000)
committerAlan Third <alan@idiocy.org>
Sun, 11 Feb 2018 20:54:28 +0000 (20:54 +0000)
* lisp/term/ns-win.el (frame-title-format, icon-title-format): Change
default format to just the filename.
* src/nsfns.m (ns-use-proxy-icon): New variable.
(ns_set_name_as_filename): Remove function.
(x_implicitly_set_name): Get rid of special handling of
frame-title-format.
* src/nsterm.h (ns_set_represented_filename): Use new definition.
* src/nsterm.m (ns_set_represented_filename): Move some of the logic
from ns_set_name_as_filename into this function.

etc/NEWS
lisp/term/ns-win.el
src/nsfns.m
src/nsterm.h
src/nsterm.m

index 8fed15af5b2be3094f6752f448be756c39d8c0de..005f177a27f19957c1d88d71c0c4c3ec66f00747 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -289,6 +289,11 @@ Previously it was supported only in the Cygwin-w32 build.
 ** Emacs now handles key combinations involving the macOS "command"
 and "option" modifier keys more correctly.
 
+** The special handling of `frame-title-format' on NS where setting it
+to `t' would enable the macOS proxy icon has been replaced with a
+separate variable, `ns-use-proxy-icon'. `frame-title-format' will now
+work as on other platforms.
+
 \f
 ----------------------------------------------------------------------
 This file is part of GNU Emacs.
index f8da1b2196597a960081a186830a96f416540325..4673af300145c89639c2d36ca9ec284e704d3cdc 100644 (file)
@@ -809,8 +809,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
 
 
 ;; Set some options to be as Nextstep-like as possible.
-(setq frame-title-format t
-      icon-title-format t)
+(setq frame-title-format "%b"
+      icon-title-format "%b")
 
 
 (defvar ns-initialized nil
index 0f60bb8107f8ec8e4ad44726fa921bd862235830..bbb6644ce032fd2ef334439a707fbf23b8045a5b 100644 (file)
@@ -61,7 +61,6 @@ static int as_status;
 static ptrdiff_t image_cache_refcount;
 
 static struct ns_display_info *ns_display_info_for_name (Lisp_Object);
-static void ns_set_name_as_filename (struct frame *);
 
 /* ==========================================================================
 
@@ -483,17 +482,10 @@ x_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   NSTRACE ("x_implicitly_set_name");
 
-  Lisp_Object frame_title = buffer_local_value
-    (Qframe_title_format, XWINDOW (f->selected_window)->contents);
-  Lisp_Object icon_title = buffer_local_value
-    (Qicon_title_format, XWINDOW (f->selected_window)->contents);
+  if (! NILP (ns_use_proxy_icon))
+    ns_set_represented_filename (f);
 
-  /* Deal with NS specific format t.  */
-  if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (icon_title, Qt))
-                         || EQ (frame_title, Qt)))
-    ns_set_name_as_filename (f);
-  else
-    ns_set_name (f, arg, 0);
+  ns_set_name (f, arg, 0);
 }
 
 
@@ -520,78 +512,6 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
   ns_set_name_internal (f, name);
 }
 
-
-static void
-ns_set_name_as_filename (struct frame *f)
-{
-  NSView *view;
-  Lisp_Object name, filename;
-  Lisp_Object buf = XWINDOW (f->selected_window)->contents;
-  const char *title;
-  NSAutoreleasePool *pool;
-  Lisp_Object encoded_name, encoded_filename;
-  NSString *str;
-  NSTRACE ("ns_set_name_as_filename");
-
-  if (f->explicit_name || ! NILP (f->title))
-    return;
-
-  block_input ();
-  pool = [[NSAutoreleasePool alloc] init];
-  filename = BVAR (XBUFFER (buf), filename);
-  name = BVAR (XBUFFER (buf), name);
-
-  if (NILP (name))
-    {
-      if (! NILP (filename))
-        name = Ffile_name_nondirectory (filename);
-      else
-        name = build_string ([ns_app_name UTF8String]);
-    }
-
-  encoded_name = ENCODE_UTF_8 (name);
-
-  view = FRAME_NS_VIEW (f);
-
-  title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String]
-                                : [[[view window] title] UTF8String];
-
-  if (title && (! strcmp (title, SSDATA (encoded_name))))
-    {
-      [pool release];
-      unblock_input ();
-      return;
-    }
-
-  str = [NSString stringWithUTF8String: SSDATA (encoded_name)];
-  if (str == nil) str = @"Bad coding";
-
-  if (FRAME_ICONIFIED_P (f))
-    [[view window] setMiniwindowTitle: str];
-  else
-    {
-      NSString *fstr;
-
-      if (! NILP (filename))
-        {
-          encoded_filename = ENCODE_UTF_8 (filename);
-
-          fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)];
-          if (fstr == nil) fstr = @"";
-        }
-      else
-        fstr = @"";
-
-      ns_set_represented_filename (fstr, f);
-      [[view window] setTitle: str];
-      fset_name (f, name);
-    }
-
-  [pool release];
-  unblock_input ();
-}
-
-
 void
 ns_set_doc_edited (void)
 {
@@ -3311,6 +3231,11 @@ be used as the image of the icon representing the frame.  */);
                doc: /* Toolkit version for NS Windowing.  */);
   Vns_version_string = ns_appkit_version_str ();
 
+  DEFVAR_BOOL ("ns-use-proxy-icon", ns_use_proxy_icon,
+               doc: /* When non-nil display a proxy icon in the titlebar.
+Default is t.  */);
+  ns_use_proxy_icon = Qt;
+
   defsubr (&Sns_read_file_name);
   defsubr (&Sns_get_resource);
   defsubr (&Sns_set_resource);
index cc4c6d5e910dd3493fc9a30fb99306d94a20e98c..8b985930ecb3791b9b508c0c9f8f0347f9a11ad6 100644 (file)
@@ -1237,7 +1237,7 @@ extern void ns_finish_events (void);
 #ifdef __OBJC__
 /* Needed in nsfns.m.  */
 extern void
-ns_set_represented_filename (NSString *fstr, struct frame *f);
+ns_set_represented_filename (struct frame *f);
 
 #endif
 
index b7f5a32c098b0fb65720a9e1ee7a301fb37099bc..56a1e01ba183c5831ba9948138e77999f45a9d2a 100644 (file)
@@ -444,10 +444,38 @@ static void ns_judge_scroll_bars (struct frame *f);
    ========================================================================== */
 
 void
-ns_set_represented_filename (NSString *fstr, struct frame *f)
+ns_set_represented_filename (struct frame *f)
 {
+  NSView *view;
+  Lisp_Object filename, encoded_filename;
+  Lisp_Object buf = XWINDOW (f->selected_window)->contents;
+  NSAutoreleasePool *pool;
+  NSString *fstr;
+
+  NSTRACE ("ns_set_represented_filename");
+
+  if (f->explicit_name || ! NILP (f->title))
+    return;
+
+  block_input ();
+  pool = [[NSAutoreleasePool alloc] init];
+  filename = BVAR (XBUFFER (buf), filename);
+
+  if (! NILP (filename))
+    {
+      encoded_filename = ENCODE_UTF_8 (filename);
+
+      fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)];
+      if (fstr == nil) fstr = @"";
+    }
+  else
+    fstr = @"";
+
   represented_filename = [fstr retain];
   represented_frame = f;
+
+  [pool release];
+  unblock_input ();
 }
 
 void