emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/src/xfns.c [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/xfns.c [lexbind]
Date: Sat, 04 Sep 2004 05:39:58 -0400

Index: emacs/src/xfns.c
diff -c emacs/src/xfns.c:1.549.2.13 emacs/src/xfns.c:1.549.2.14
*** emacs/src/xfns.c:1.549.2.13 Sat Sep  4 09:26:27 2004
--- emacs/src/xfns.c    Sat Sep  4 09:28:16 2004
***************
*** 1560,1620 ****
  }
  
  
! /* Change the name of frame F to NAME.  If NAME is nil, set F's name to
!        x_id_name.
! 
!    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.  */
! 
! void
! x_set_name (f, name, explicit)
!      struct frame *f;
       Lisp_Object name;
-      int explicit;
  {
-   /* 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)
-     return;
- 
-   /* If NAME is nil, set the name to the x_id_name.  */
-   if (NILP (name))
-     {
-       /* Check for no change needed in this very common case
-        before we do any consing.  */
-       if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
-                  SDATA (f->name)))
-       return;
-       name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
-     }
-   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;
- 
-   /* For setting the frame title, the title parameter should override
-      the name parameter.  */
-   if (! NILP (f->title))
-     name = f->title;
- 
    if (FRAME_X_WINDOW (f))
      {
        BLOCK_INPUT;
--- 1560,1574 ----
  }
  
  
! /* Set the WM name to NAME for frame F. Also set the icon name.
!    If the frame already has an icon name, use that, otherwise set the
!    icon name to NAME.  */
  
! static void
! x_set_name_internal (f, name)
!      FRAME_PTR f;
       Lisp_Object name;
  {
    if (FRAME_X_WINDOW (f))
      {
        BLOCK_INPUT;
***************
*** 1622,1629 ****
--- 1576,1585 ----
        {
        XTextProperty text, icon;
        int bytes, stringp;
+         int do_free_icon_value = 0, do_free_text_value = 0;
        Lisp_Object coding_system;
  
+       coding_system = Qcompound_text;
        /* Note: Encoding strategy
  
           We encode NAME by compound-text and use "COMPOUND-TEXT" in
***************
*** 1638,1650 ****
           in the future which can encode all Unicode characters.
           But, for the moment, there's no way to know that the
           current window manager supports it or not.  */
-       coding_system = Qcompound_text;
        text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
        text.encoding = (stringp ? XA_STRING
                         : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
        text.format = 8;
        text.nitems = bytes;
  
        if (NILP (f->icon_name))
          {
            icon = text;
--- 1594,1609 ----
           in the future which can encode all Unicode characters.
           But, for the moment, there's no way to know that the
           current window manager supports it or not.  */
        text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
        text.encoding = (stringp ? XA_STRING
                         : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
        text.format = 8;
        text.nitems = bytes;
  
+         /* Check early, because ENCODE_UTF_8 below may GC and name may be
+            relocated.  */
+         do_free_text_value = text.value != SDATA (name);
+ 
        if (NILP (f->icon_name))
          {
            icon = text;
***************
*** 1658,1664 ****
--- 1617,1625 ----
                             : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
            icon.format = 8;
            icon.nitems = bytes;
+             do_free_icon_value = icon.value != SDATA (f->icon_name);
          }
+ 
  #ifdef USE_GTK
          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
                                SDATA (ENCODE_UTF_8 (name)));
***************
*** 1668,1677 ****
  
        XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
  
!       if (!NILP (f->icon_name)
!           && icon.value != (unsigned char *) SDATA (f->icon_name))
          xfree (icon.value);
!       if (text.value != (unsigned char *) SDATA (name))
          xfree (text.value);
        }
  #else /* not HAVE_X11R4 */
--- 1629,1637 ----
  
        XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
  
!       if (do_free_icon_value)
          xfree (icon.value);
!       if (do_free_text_value)
          xfree (text.value);
        }
  #else /* not HAVE_X11R4 */
***************
*** 1684,1689 ****
--- 1644,1707 ----
      }
  }
  
+ /* Change the name of frame F to NAME.  If NAME is nil, set F's name to
+        x_id_name.
+ 
+    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.  */
+ 
+ void
+ x_set_name (f, name, explicit)
+      struct frame *f;
+      Lisp_Object name;
+      int explicit;
+ {
+   /* 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)
+     return;
+ 
+   /* If NAME is nil, set the name to the x_id_name.  */
+   if (NILP (name))
+     {
+       /* Check for no change needed in this very common case
+        before we do any consing.  */
+       if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
+                  SDATA (f->name)))
+       return;
+       name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
+     }
+   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;
+ 
+   /* For setting the frame title, the title parameter should override
+      the name parameter.  */
+   if (! NILP (f->title))
+     name = f->title;
+ 
+   x_set_name_internal (f, name);
+ }
+ 
  /* This function should be called when the user's lisp code has
     specified a name for the frame; the name will override any set by the
     redisplay code.  */
***************
*** 1735,1796 ****
    else
      CHECK_STRING (name);
  
!   if (FRAME_X_WINDOW (f))
!     {
!       BLOCK_INPUT;
! #ifdef HAVE_X11R4
!       {
!       XTextProperty text, icon;
!       int bytes, stringp;
!       Lisp_Object coding_system;
! 
!       coding_system = Qcompound_text;
!       /* See the comment "Note: Encoding strategy" in x_set_name.  */
!       text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
!       text.encoding = (stringp ? XA_STRING
!                        : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
!       text.format = 8;
!       text.nitems = bytes;
! 
!       if (NILP (f->icon_name))
!         {
!           icon = text;
!         }
!       else
!         {
!           /* See the comment "Note: Encoding strategy" in x_set_name.  */
!           icon.value = x_encode_text (f->icon_name, coding_system, 0,
!                                       &bytes, &stringp);
!           icon.encoding = (stringp ? XA_STRING
!                            : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
!           icon.format = 8;
!           icon.nitems = bytes;
!         }
! 
! #ifdef USE_GTK
!         gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
!                               SDATA (ENCODE_UTF_8 (name)));
! #else /* not USE_GTK */
!       XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
! #endif /* not USE_GTK */
! 
!       XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
!                         &icon);
! 
!       if (!NILP (f->icon_name)
!           && icon.value != (unsigned char *) SDATA (f->icon_name))
!         xfree (icon.value);
!       if (text.value != (unsigned char *) SDATA (name))
!         xfree (text.value);
!       }
! #else /* not HAVE_X11R4 */
!       XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                   SDATA (name));
!       XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                 SDATA (name));
! #endif /* not HAVE_X11R4 */
!       UNBLOCK_INPUT;
!     }
  }
  
  void
--- 1753,1759 ----
    else
      CHECK_STRING (name);
  
!   x_set_name_internal (f, name);
  }
  
  void




reply via email to

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