/[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.590.2.6 by miles, Fri Aug 27 07:00:34 2004 UTC revision 1.590.2.7 by miles, Sat Sep 4 09:14:28 2004 UTC
# Line 1540  x_encode_text (string, coding_system, se Line 1540  x_encode_text (string, coding_system, se
1540  }  }
1541    
1542    
1543  /* 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.
1544         x_id_name.     If the frame already has an icon name, use that, otherwise set the
1545       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.  
1546    
1547     If EXPLICIT is zero, that indicates that Emacs redisplay code is  static void
1548         suggesting a new name, which lisp code should override; if  x_set_name_internal (f, name)
1549         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;  
1550       Lisp_Object name;       Lisp_Object name;
      int explicit;  
1551  {  {
   /* 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;  
   
1552    if (FRAME_X_WINDOW (f))    if (FRAME_X_WINDOW (f))
1553      {      {
1554        BLOCK_INPUT;        BLOCK_INPUT;
# Line 1602  x_set_name (f, name, explicit) Line 1556  x_set_name (f, name, explicit)
1556        {        {
1557          XTextProperty text, icon;          XTextProperty text, icon;
1558          int bytes, stringp;          int bytes, stringp;
1559            int do_free_icon_value = 0, do_free_text_value = 0;
1560          Lisp_Object coding_system;          Lisp_Object coding_system;
1561    
1562            coding_system = Qcompound_text;
1563          /* Note: Encoding strategy          /* Note: Encoding strategy
1564    
1565             We encode NAME by compound-text and use "COMPOUND-TEXT" in             We encode NAME by compound-text and use "COMPOUND-TEXT" in
# Line 1618  x_set_name (f, name, explicit) Line 1574  x_set_name (f, name, explicit)
1574             in the future which can encode all Unicode characters.             in the future which can encode all Unicode characters.
1575             But, for the moment, there's no way to know that the             But, for the moment, there's no way to know that the
1576             current window manager supports it or not.  */             current window manager supports it or not.  */
         coding_system = Qcompound_text;  
1577          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1578          text.encoding = (stringp ? XA_STRING          text.encoding = (stringp ? XA_STRING
1579                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1580          text.format = 8;          text.format = 8;
1581          text.nitems = bytes;          text.nitems = bytes;
1582    
1583            /* Check early, because ENCODE_UTF_8 below may GC and name may be
1584               relocated.  */
1585            do_free_text_value = text.value != SDATA (name);
1586    
1587          if (NILP (f->icon_name))          if (NILP (f->icon_name))
1588            {            {
1589              icon = text;              icon = text;
# Line 1638  x_set_name (f, name, explicit) Line 1597  x_set_name (f, name, explicit)
1597                               : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);                               : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1598              icon.format = 8;              icon.format = 8;
1599              icon.nitems = bytes;              icon.nitems = bytes;
1600                do_free_icon_value = icon.value != SDATA (f->icon_name);
1601            }            }
1602    
1603  #ifdef USE_GTK  #ifdef USE_GTK
1604          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1605                                SDATA (ENCODE_UTF_8 (name)));                                SDATA (ENCODE_UTF_8 (name)));
# Line 1648  x_set_name (f, name, explicit) Line 1609  x_set_name (f, name, explicit)
1609    
1610          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
1611    
1612          if (!NILP (f->icon_name)          if (do_free_icon_value)
             && icon.value != (unsigned char *) SDATA (f->icon_name))  
1613            xfree (icon.value);            xfree (icon.value);
1614          if (text.value != (unsigned char *) SDATA (name))          if (do_free_text_value)
1615            xfree (text.value);            xfree (text.value);
1616        }        }
1617  #else /* not HAVE_X11R4 */  #else /* not HAVE_X11R4 */
# Line 1664  x_set_name (f, name, explicit) Line 1624  x_set_name (f, name, explicit)
1624      }      }
1625  }  }
1626    
1627    /* Change the name of frame F to NAME.  If NAME is nil, set F's name to
1628           x_id_name.
1629    
1630       If EXPLICIT is non-zero, that indicates that lisp code is setting the
1631           name; if NAME is a string, set F's name to NAME and set
1632           F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1633    
1634       If EXPLICIT is zero, that indicates that Emacs redisplay code is
1635           suggesting a new name, which lisp code should override; if
1636           F->explicit_name is set, ignore the new name; otherwise, set it.  */
1637    
1638    void
1639    x_set_name (f, name, explicit)
1640         struct frame *f;
1641         Lisp_Object name;
1642         int explicit;
1643    {
1644      /* Make sure that requests from lisp code override requests from
1645         Emacs redisplay code.  */
1646      if (explicit)
1647        {
1648          /* If we're switching from explicit to implicit, we had better
1649             update the mode lines and thereby update the title.  */
1650          if (f->explicit_name && NILP (name))
1651            update_mode_lines = 1;
1652    
1653          f->explicit_name = ! NILP (name);
1654        }
1655      else if (f->explicit_name)
1656        return;
1657    
1658      /* If NAME is nil, set the name to the x_id_name.  */
1659      if (NILP (name))
1660        {
1661          /* Check for no change needed in this very common case
1662             before we do any consing.  */
1663          if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1664                       SDATA (f->name)))
1665            return;
1666          name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1667        }
1668      else
1669        CHECK_STRING (name);
1670    
1671      /* Don't change the name if it's already NAME.  */
1672      if (! NILP (Fstring_equal (name, f->name)))
1673        return;
1674    
1675      f->name = name;
1676    
1677      /* For setting the frame title, the title parameter should override
1678         the name parameter.  */
1679      if (! NILP (f->title))
1680        name = f->title;
1681    
1682      x_set_name_internal (f, name);
1683    }
1684    
1685  /* This function should be called when the user's lisp code has  /* This function should be called when the user's lisp code has
1686     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
1687     redisplay code.  */     redisplay code.  */
# Line 1715  x_set_title (f, name, old_name) Line 1733  x_set_title (f, name, old_name)
1733    else    else
1734      CHECK_STRING (name);      CHECK_STRING (name);
1735    
1736    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;  
     }  
1737  }  }
1738    
1739  void  void

Legend:
Removed from v.1.590.2.6  
changed lines
  Added in v.1.590.2.7

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