]> code.delx.au - gnu-emacs/blobdiff - src/xfns.c
Merge from emacs--rel--22
[gnu-emacs] / src / xfns.c
index f2c8581484782195fc8f4cd027250151c325f54a..fe4d1c8335f7dda9aebb14fd1249761f41a13f61 100644 (file)
@@ -6,7 +6,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -73,8 +73,13 @@ Boston, MA 02110-1301, USA.  */
 #include <X11/Shell.h>
 
 #ifndef USE_MOTIF
+#ifdef HAVE_XAW3D
+#include <X11/Xaw3d/Paned.h>
+#include <X11/Xaw3d/Label.h>
+#else /* !HAVE_XAW3D */
 #include <X11/Xaw/Paned.h>
 #include <X11/Xaw/Label.h>
+#endif /* HAVE_XAW3D */
 #endif /* USE_MOTIF */
 
 #ifdef USG
@@ -275,7 +280,7 @@ check_x_display_info (object)
     }
   else if (INTEGERP (object))
     {
-      struct terminal *t = get_terminal (XINT (object), 1);
+      struct terminal *t = get_terminal (object, 1);
 
       if (t->type != output_x_window)
         error ("Terminal %d is not an X display", XINT (object));
@@ -1525,6 +1530,8 @@ x_set_scroll_bar_background (f, value, oldval)
 /* Encode Lisp string STRING as a text in a format appropriate for
    XICCC (X Inter Client Communication Conventions).
 
+   This can call Lisp code, so callers must GCPRO.
+
    If STRING contains only ASCII characters, do no conversion and
    return the string data of STRING.  Otherwise, encode the text by
    CODING_SYSTEM, and return a newly allocated memory area which
@@ -1572,7 +1579,11 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp, freep)
       && SYMBOLP (coding.pre_write_conversion)
       && !NILP (Ffboundp (coding.pre_write_conversion)))
     {
+      struct gcpro gcpro1;
+      /* We don't need to GCPRO string.  */
+      GCPRO1 (coding_system);
       string = run_pre_post_conversion_on_str (string, &coding, 1);
+      UNGCPRO;
       str = SDATA (string);
       chars = SCHARS (string);
       bytes = SBYTES (string);
@@ -1614,6 +1625,16 @@ x_set_name_internal (f, name)
        int bytes, stringp;
         int do_free_icon_value = 0, do_free_text_value = 0;
        Lisp_Object coding_system;
+#ifdef USE_GTK
+       Lisp_Object encoded_name;
+       struct gcpro gcpro1;
+
+       /* As ENCODE_UTF_8 may cause GC and relocation of string data,
+          we use it before x_encode_text that may return string data.  */
+       GCPRO1 (name);
+       encoded_name = ENCODE_UTF_8 (name);
+       UNGCPRO;
+#endif
 
        coding_system = Qcompound_text;
        /* Note: Encoding strategy
@@ -1654,7 +1675,7 @@ x_set_name_internal (f, name)
 
 #ifdef USE_GTK
         gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                              (char *) SDATA (ENCODE_UTF_8 (name)));
+                              (char *) SDATA (encoded_name));
 #else /* not USE_GTK */
        XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
 #endif /* not USE_GTK */
@@ -1757,15 +1778,7 @@ x_implicitly_set_name (f, arg, oldval)
 }
 \f
 /* 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.  */
 
 void
 x_set_title (f, name, old_name)
@@ -1840,9 +1853,9 @@ x_default_scroll_bar_color_parameter (f, alist, prop, xprop, xclass,
                                    build_string (foreground_p
                                                  ? "foreground"
                                                  : "background"),
-                                   empty_string,
+                                   empty_unibyte_string,
                                    build_string ("verticalScrollBar"),
-                                   empty_string);
+                                   empty_unibyte_string);
       if (!STRINGP (tem))
        {
          /* If nothing has been specified, scroll bars will use a
@@ -2853,7 +2866,9 @@ x_icon (f, parms)
      Lisp_Object parms;
 {
   Lisp_Object icon_x, icon_y;
+#if 0
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+#endif
 
   /* Set the position of the icon.  Note that twm groups all
      icons in an icon window.  */
@@ -3085,8 +3100,8 @@ This function is an internal primitive--use `make-frame' instead.  */)
   kb = &the_only_kboard;
 #endif
 
-  if (dpyinfo->terminal->deleted)
-    error ("Terminal is being deleted, can't create new frames on it");
+  if (!dpyinfo->terminal->name)
+    error ("Terminal is not live, can't create new frames on it");
 
   name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
   if (!STRINGP (name)
@@ -3509,6 +3524,7 @@ FRAME nil means use the selected frame.  */)
   x_catch_errors (dpy);
   XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                  RevertToParent, CurrentTime);
+  x_ewmh_activate_frame (f);
   x_uncatch_errors ();
   UNBLOCK_INPUT;
 
@@ -4679,8 +4695,8 @@ x_create_tip_frame (dpyinfo, parms, text)
 
   check_x ();
 
-  if (dpyinfo->terminal->deleted)
-    error ("Terminal is being deleted, can't create new frames on it");
+  if (!dpyinfo->terminal->name)
+    error ("Terminal is not live, can't create new frames on it");
 
   parms = Fcopy_alist (parms);
 
@@ -4923,6 +4939,26 @@ x_create_tip_frame (dpyinfo, parms, text)
     Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
                                            Qnil));
 
+  /* FIXME - can this be done in a similar way to normal frames?
+     http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg00641.html */
+
+  /* Set the `display-type' frame parameter before setting up faces. */
+  {
+    Lisp_Object disptype;
+
+    if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
+      disptype = intern ("mono");
+    else if (FRAME_X_DISPLAY_INFO (f)->visual->class == GrayScale
+             || FRAME_X_DISPLAY_INFO (f)->visual->class == StaticGray)
+      disptype = intern ("grayscale");
+    else
+      disptype = intern ("color");
+
+    if (NILP (Fframe_parameter (frame, Qdisplay_type)))
+      Fmodify_frame_parameters (frame, Fcons (Fcons (Qdisplay_type, disptype),
+                                              Qnil));
+  }
+
   /* Set up faces after all frame parameters are known.  This call
      also merges in face attributes specified for new frames.