/[emacs]/emacs/src/xfns.c
ViewVC logotype

Diff of /emacs/src/xfns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.613 by jhd, Tue Aug 24 10:54:39 2004 UTC revision 1.614 by jhd, Thu Sep 2 16:15:47 2004 UTC
# Line 1560  x_encode_text (string, coding_system, se Line 1560  x_encode_text (string, coding_system, se
1560  }  }
1561    
1562    
1563  /* Change the name of frame F to NAME.  If NAME is nil, set F's name to  /* Set the WM name to NAME for frame F. Also set the icon name.
1564         x_id_name.     If the frame already has an icon name, use that, otherwise set the
1565       icon name to 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.  
1566    
1567     If EXPLICIT is zero, that indicates that Emacs redisplay code is  static void
1568         suggesting a new name, which lisp code should override; if  x_set_name_internal (f, name)
1569         F->explicit_name is set, ignore the new name; otherwise, set it.  */       FRAME_PTR f;
   
 void  
 x_set_name (f, name, explicit)  
      struct frame *f;  
1570       Lisp_Object name;       Lisp_Object name;
      int explicit;  
1571  {  {
   /* 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;  
   
1572    if (FRAME_X_WINDOW (f))    if (FRAME_X_WINDOW (f))
1573      {      {
1574        BLOCK_INPUT;        BLOCK_INPUT;
# Line 1622  x_set_name (f, name, explicit) Line 1576  x_set_name (f, name, explicit)
1576        {        {
1577          XTextProperty text, icon;          XTextProperty text, icon;
1578          int bytes, stringp;          int bytes, stringp;
1579            int do_free_icon_value = 0, do_free_text_value = 0;
1580          Lisp_Object coding_system;          Lisp_Object coding_system;
1581    
1582            coding_system = Qcompound_text;
1583          /* Note: Encoding strategy          /* Note: Encoding strategy
1584    
1585             We encode NAME by compound-text and use "COMPOUND-TEXT" in             We encode NAME by compound-text and use "COMPOUND-TEXT" in
# Line 1638  x_set_name (f, name, explicit) Line 1594  x_set_name (f, name, explicit)
1594             in the future which can encode all Unicode characters.             in the future which can encode all Unicode characters.
1595             But, for the moment, there's no way to know that the             But, for the moment, there's no way to know that the
1596             current window manager supports it or not.  */             current window manager supports it or not.  */
         coding_system = Qcompound_text;  
1597          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1598          text.encoding = (stringp ? XA_STRING          text.encoding = (stringp ? XA_STRING
1599                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1600          text.format = 8;          text.format = 8;
1601          text.nitems = bytes;          text.nitems = bytes;
1602    
1603            /* Check early, because ENCODE_UTF_8 below may GC and name may be
1604               relocated.  */
1605            do_free_text_value = text.value != SDATA (name);
1606    
1607          if (NILP (f->icon_name))          if (NILP (f->icon_name))
1608            {            {
1609              icon = text;              icon = text;
# Line 1658  x_set_name (f, name, explicit) Line 1617  x_set_name (f, name, explicit)
1617                               : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);                               : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1618              icon.format = 8;              icon.format = 8;
1619              icon.nitems = bytes;              icon.nitems = bytes;
1620                do_free_icon_value = icon.value != SDATA (f->icon_name);
1621            }            }
1622    
1623  #ifdef USE_GTK  #ifdef USE_GTK
1624          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1625                                SDATA (ENCODE_UTF_8 (name)));                                SDATA (ENCODE_UTF_8 (name)));
# Line 1668  x_set_name (f, name, explicit) Line 1629  x_set_name (f, name, explicit)
1629    
1630          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
1631    
1632          if (!NILP (f->icon_name)          if (do_free_icon_value)
             && icon.value != (unsigned char *) SDATA (f->icon_name))  
1633            xfree (icon.value);            xfree (icon.value);
1634          if (text.value != (unsigned char *) SDATA (name))          if (do_free_text_value)
1635            xfree (text.value);            xfree (text.value);
1636        }        }
1637  #else /* not HAVE_X11R4 */  #else /* not HAVE_X11R4 */
# Line 1684  x_set_name (f, name, explicit) Line 1644  x_set_name (f, name, explicit)
1644      }      }
1645  }  }
1646    
1647    /* Change the name of frame F to NAME.  If NAME is nil, set F's name to
1648           x_id_name.
1649    
1650       If EXPLICIT is non-zero, that indicates that lisp code is setting the
1651           name; if NAME is a string, set F's name to NAME and set
1652           F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1653    
1654       If EXPLICIT is zero, that indicates that Emacs redisplay code is
1655           suggesting a new name, which lisp code should override; if
1656           F->explicit_name is set, ignore the new name; otherwise, set it.  */
1657    
1658    void
1659    x_set_name (f, name, explicit)
1660         struct frame *f;
1661         Lisp_Object name;
1662         int explicit;
1663    {
1664      /* Make sure that requests from lisp code override requests from
1665         Emacs redisplay code.  */
1666      if (explicit)
1667        {
1668          /* If we're switching from explicit to implicit, we had better
1669             update the mode lines and thereby update the title.  */
1670          if (f->explicit_name && NILP (name))
1671            update_mode_lines = 1;
1672    
1673          f->explicit_name = ! NILP (name);
1674        }
1675      else if (f->explicit_name)
1676        return;
1677    
1678      /* If NAME is nil, set the name to the x_id_name.  */
1679      if (NILP (name))
1680        {
1681          /* Check for no change needed in this very common case
1682             before we do any consing.  */
1683          if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1684                       SDATA (f->name)))
1685            return;
1686          name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1687        }
1688      else
1689        CHECK_STRING (name);
1690    
1691      /* Don't change the name if it's already NAME.  */
1692      if (! NILP (Fstring_equal (name, f->name)))
1693        return;
1694    
1695      f->name = name;
1696    
1697      /* For setting the frame title, the title parameter should override
1698         the name parameter.  */
1699      if (! NILP (f->title))
1700        name = f->title;
1701    
1702      x_set_name_internal (f, name);
1703    }
1704    
1705  /* This function should be called when the user's lisp code has  /* This function should be called when the user's lisp code has
1706     specified a name for the frame; the name will override any set by the     specified a name for the frame; the name will override any set by the
1707     redisplay code.  */     redisplay code.  */
# Line 1735  x_set_title (f, name, old_name) Line 1753  x_set_title (f, name, old_name)
1753    else    else
1754      CHECK_STRING (name);      CHECK_STRING (name);
1755    
1756    if (FRAME_X_WINDOW (f))    x_set_name_internal (f, name);
     {  
       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;  
     }  
1757  }  }
1758    
1759  void  void

Legend:
Removed from v.1.613  
changed lines
  Added in v.1.614

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26