emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102724: Encode frame title and icon


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102724: Encode frame title and icon name before setting.
Date: Thu, 30 Dec 2010 12:30:55 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102724
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Thu 2010-12-30 12:30:55 +0100
message:
  Encode frame title and icon name before setting.
  
  * coding.h (ENCODE_UTF_8): Remove "Used by ..." comment.
  
  * nsfns.m (ns_set_name_iconic): Remove.
  (ns_set_name_internal): New function.
  (Vicon_title_format): Extern declare.
  (ns_set_name): Call ns_set_name_internal.
  (x_explicitly_set_name): Remove call to ns_set_name_iconic.
  (x_implicitly_set_name): Ditto.
  (x_set_title): Remove commet about EXPLICIT.  Call ns_set_name_internal.
  (ns_set_name_as_filename): Encode name with ENCODE_UTF_8 (Bug#7517).
modified:
  src/ChangeLog
  src/coding.h
  src/nsfns.m
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-12-29 11:16:44 +0000
+++ b/src/ChangeLog     2010-12-30 11:30:55 +0000
@@ -1,3 +1,16 @@
+2010-12-30  Jan Djärv  <address@hidden>
+
+       * coding.h (ENCODE_UTF_8): Remove "Used by ..." comment.
+
+       * nsfns.m (ns_set_name_iconic): Remove.
+       (ns_set_name_internal): New function (Bug#7517).
+       (Vicon_title_format): Extern declare.
+       (ns_set_name): Call ns_set_name_internal.
+       (x_explicitly_set_name): Remove call to ns_set_name_iconic.
+       (x_implicitly_set_name): Ditto.
+       (x_set_title): Remove commet about EXPLICIT.  Call ns_set_name_internal.
+       (ns_set_name_as_filename): Encode name with ENCODE_UTF_8 (Bug#7517).
+
 2010-12-29  Štěpán Němec  <address@hidden>  (tiny change)
 
        * window.c (syms_of_window): Add missing defsubr for

=== modified file 'src/coding.h'
--- a/src/coding.h      2010-10-08 10:14:47 +0000
+++ b/src/coding.h      2010-12-30 11:30:55 +0000
@@ -686,8 +686,7 @@
    ? code_convert_string_norecord (str, Vlocale_coding_system, 0)         \
    : str)
 
-/* Used by the gtk menu code.  Note that this encodes utf-8, not
-   utf-8-emacs, so it's not a no-op.  */
+/* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op.  */
 #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
 
 /* Extern declarations.  */

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2010-11-14 19:58:24 +0000
+++ b/src/nsfns.m       2010-12-30 11:30:55 +0000
@@ -82,7 +82,7 @@
 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
 extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
 extern Lisp_Object Qnone;
-extern Lisp_Object Vframe_title_format;
+extern Lisp_Object Vframe_title_format, Vicon_title_format;
 
 /* The below are defined in frame.c.  */
 
@@ -473,55 +473,37 @@
         [NSString stringWithUTF8String: SDATA (arg)]];
 }
 
-
 static void
-ns_set_name_iconic (struct frame *f, Lisp_Object name, int explicit)
+ns_set_name_internal (FRAME_PTR f, Lisp_Object name)
 {
+  struct gcpro gcpro1;
+  Lisp_Object encoded_name, encoded_icon_name;
+  NSString *str;
   NSView *view = FRAME_NS_VIEW (f);
-  NSTRACE (ns_set_name_iconic);
-
-  if (ns_in_resize)
-    return;
-
-  /* Make sure that requests from lisp code override requests from
-     Emacs redisplay code.  */
-  if (explicit)
-    {
-      /* If we're switching from explicit to implicit, we had better
-         update the mode lines and thereby update the title.  */
-      if (f->explicit_name && NILP (name))
-        update_mode_lines = 1;
-
-      f->explicit_name = ! NILP (name);
-    }
-  else if (f->explicit_name)
-    name = f->name;
-
-  /* title overrides explicit name */
-  if (! NILP (f->title))
-    name = f->title;
-
-  /* icon_name overrides title and explicit name */
-  if (! NILP (f->icon_name))
-    name = f->icon_name;
-
-  if (NILP (name))
-    name = build_string([ns_app_name UTF8String]);
+
+  GCPRO1 (name);
+  encoded_name = ENCODE_UTF_8 (name);
+  UNGCPRO;
+
+  str = [NSString stringWithUTF8String: SDATA (encoded_name)];
+
+  /* Don't change the name if it's already NAME.  */
+  if (! [[[view window] title] isEqualToString: str])
+    [[view window] setTitle: str];
+
+  if (!STRINGP (f->icon_name))
+    encoded_icon_name = encoded_name;
   else
-    CHECK_STRING (name);
-
-  /* Don't change the name if it's already NAME.  */
+    encoded_icon_name = ENCODE_UTF_8 (f->icon_name);    
+
+  str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)];
+
   if ([[view window] miniwindowTitle] &&
-      ([[[view window] miniwindowTitle]
-             isEqualToString: [NSString stringWithUTF8String:
-                                           SDATA (name)]]))
-    return;
+      ! [[[view window] miniwindowTitle] isEqualToString: str])
+    [[view window] setMiniwindowTitle: str];
 
-  [[view window] setMiniwindowTitle:
-        [NSString stringWithUTF8String: SDATA (name)]];
 }
 
-
 static void
 ns_set_name (struct frame *f, Lisp_Object name, int explicit)
 {
@@ -547,6 +529,12 @@
 
   if (NILP (name))
     name = build_string([ns_app_name UTF8String]);
+  else
+    CHECK_STRING (name);
+
+  /* Don't change the name if it's already NAME.  */
+  if (! NILP (Fstring_equal (name, f->name)))
+    return;
 
   f->name = name;
 
@@ -554,17 +542,7 @@
   if (! NILP (f->title))
     name = f->title;
 
-  CHECK_STRING (name);
-
-  view = FRAME_NS_VIEW (f);
-
-  /* Don't change the name if it's already NAME.  */
-  if ([[[view window] title]
-            isEqualToString: [NSString stringWithUTF8String:
-                                          SDATA (name)]])
-    return;
-  [[view window] setTitle: [NSString stringWithUTF8String:
-                                        SDATA (name)]];
+  ns_set_name_internal (f, name);
 }
 
 
@@ -575,7 +553,6 @@
 x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
 {
   NSTRACE (x_explicitly_set_name);
-  ns_set_name_iconic (f, arg, 1);
   ns_set_name (f, arg, 1);
 }
 
@@ -587,9 +564,10 @@
 x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
 {
   NSTRACE (x_implicitly_set_name);
-  if (FRAME_ICONIFIED_P (f))
-    ns_set_name_iconic (f, arg, 0);
-  else if (FRAME_NS_P (f) && EQ (Vframe_title_format, Qt))
+
+  /* Deal with NS specific format t.  */
+  if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (Vicon_title_format, Qt))
+                         || EQ (Vframe_title_format, Qt)))
     ns_set_name_as_filename (f);
   else
     ns_set_name (f, arg, 0);
@@ -597,15 +575,8 @@
 
 
 /* Change the title of frame F to NAME.
-   If NAME is nil, use the frame name as the title.
-
-   If EXPLICIT is non-zero, that indicates that lisp code is setting the
-   name; if NAME is a string, set F's name to NAME and set
-   F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
-
-   If EXPLICIT is zero, that indicates that Emacs redisplay code is
-   suggesting a new name, which lisp code should override; if
-   F->explicit_name is set, ignore the new name; otherwise, set it.  */
+   If NAME is nil, use the frame name as the title.  */
+
 static void
 x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
 {
@@ -617,6 +588,13 @@
   update_mode_lines = 1;
 
   f->title = name;
+
+  if (NILP (name))
+    name = f->name;
+  else
+    CHECK_STRING (name);
+
+  ns_set_name_internal (f, name);
 }
 
 
@@ -628,6 +606,8 @@
   Lisp_Object buf = XWINDOW (f->selected_window)->buffer;
   const char *title;
   NSAutoreleasePool *pool;
+  struct gcpro gcpro1;
+  Lisp_Object encoded_name;
   NSTRACE (ns_set_name_as_filename);
 
   if (f->explicit_name || ! NILP (f->title) || ns_in_resize)
@@ -636,7 +616,7 @@
   BLOCK_INPUT;
   pool = [[NSAutoreleasePool alloc] init];
   name = XBUFFER (buf)->filename;
-  if (NILP (name) || FRAME_ICONIFIED_P (f)) name =XBUFFER (buf)->name;
+  if (NILP (name) || FRAME_ICONIFIED_P (f)) name = XBUFFER (buf)->name;
 
   if (FRAME_ICONIFIED_P (f) && !NILP (f->icon_name))
     name = f->icon_name;
@@ -646,12 +626,16 @@
   else
     CHECK_STRING (name);
 
+  GCPRO1 (name);
+  encoded_name = ENCODE_UTF_8 (name);
+  UNGCPRO;
+
   view = FRAME_NS_VIEW (f);
 
   title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String]
                                 : [[[view window] title] UTF8String];
 
-  if (title && (! strcmp (title, SDATA (name))))
+  if (title && (! strcmp (title, SDATA (encoded_name))))
     {
       [pool release];
       UNBLOCK_INPUT;
@@ -664,7 +648,7 @@
       /* work around a bug observed on 10.3 where
          setTitleWithRepresentedFilename does not clear out previous state
          if given filename does not exist */
-      NSString *str = [NSString stringWithUTF8String: SDATA (name)];
+      NSString *str = [NSString stringWithUTF8String: SDATA (encoded_name)];
       if (![[NSFileManager defaultManager] fileExistsAtPath: str])
         {
           [[view window] setTitleWithRepresentedFilename: @""];
@@ -676,14 +660,14 @@
         }
 #else
       [[view window] setTitleWithRepresentedFilename:
-                         [NSString stringWithUTF8String: SDATA (name)]];
+                         [NSString stringWithUTF8String: SDATA 
(encoded_name)]];
 #endif
       f->name = name;
     }
   else
     {
       [[view window] setMiniwindowTitle:
-            [NSString stringWithUTF8String: SDATA (name)]];
+            [NSString stringWithUTF8String: SDATA (encoded_name)]];
     }
   [pool release];
   UNBLOCK_INPUT;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]