(x_window) [! USE_X_TOOLKIT]: Initialize wm_hints.icon_pixmap.
[bpt/emacs.git] / src / xfns.c
index 32270bc..aa90a93 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions for the X window system.
-   Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation.
+   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996 Free Software Foundation.
 
 This file is part of GNU Emacs.
 
@@ -44,7 +44,7 @@ extern void abort ();
 /* On some systems, the character-composition stuff is broken in X11R5.  */
 #if defined (HAVE_X11R5) && ! defined (HAVE_X11R6)
 #ifdef X11R5_INHIBIT_I18N
-#undef HAVE_X_I18N
+#define X_I18N_INHIBITED
 #endif
 #endif
 
@@ -831,9 +831,19 @@ x_set_frame_parameters (f, alist)
 
   /* Don't die if just one of these was set.  */
   if (EQ (width, Qunbound))
-    XSETINT (width, FRAME_WIDTH (f));
+    {
+      if (FRAME_NEW_WIDTH (f))
+       XSETINT (width, FRAME_NEW_WIDTH (f));
+      else
+       XSETINT (width, FRAME_WIDTH (f));
+    }
   if (EQ (height, Qunbound))
-    XSETINT (height, FRAME_HEIGHT (f));
+    {
+      if (FRAME_NEW_HEIGHT (f))
+       XSETINT (height, FRAME_NEW_HEIGHT (f));
+      else
+       XSETINT (height, FRAME_HEIGHT (f));
+    }
 
   /* Don't set these parameters unless they've been explicitly
      specified.  The window might be mapped or resized while we're in
@@ -851,7 +861,8 @@ x_set_frame_parameters (f, alist)
     XSETFRAME (frame, f);
 
     if ((NUMBERP (width) && XINT (width) != FRAME_WIDTH (f))
-       || (NUMBERP (height) && XINT (height) != FRAME_HEIGHT (f)))
+       || (NUMBERP (height) && XINT (height) != FRAME_HEIGHT (f))
+       || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
       Fset_frame_size (frame, width, height);
 
     if ((!NILP (left) || !NILP (top))
@@ -956,7 +967,7 @@ x_real_positions (f, xptr, yptr)
       XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window,
                  &f->output_data.x->parent_desc,
                  &tmp_children, &tmp_nchildren);
-      XFree (tmp_children);
+      XFree ((char *) tmp_children);
 
       win_x = win_y = 0;
 
@@ -1111,8 +1122,16 @@ defined_color (f, color, color_def, alloc)
                              * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
              if (trial_delta < nearest_delta) 
                {
-                 nearest = x;
-                 nearest_delta = trial_delta;
+                 XColor temp;
+                 temp.red = cells[x].red;
+                 temp.green = cells[x].green;
+                 temp.blue = cells[x].blue;
+                 status = XAllocColor (display, screen_colormap, &temp);
+                 if (status)
+                   {
+                     nearest = x;
+                     nearest_delta = trial_delta;
+                   }
                }
            }
          color_def->red = cells[nearest].red;
@@ -2648,6 +2667,7 @@ x_window (f, window_prompting, minibuffer_only)
   XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
 
 #ifdef HAVE_X_I18N
+#ifndef X_I18N_INHIBITED
   { 
     XIM xim;
     XIC xic = NULL;
@@ -2663,11 +2683,19 @@ x_window (f, window_prompting, minibuffer_only)
                         NULL);
 
        if (xic == 0)
-         XCloseIM (xim);
+         {
+           XCloseIM (xim);
+           xim = NULL;
+         }
       }
+    FRAME_XIM (f) = xim;
     FRAME_XIC (f) = xic;
   }
-#endif
+#else /* X_I18N_INHIBITED */
+  FRAME_XIM (f) = 0;
+  FRAME_XIC (f) = 0;
+#endif /* X_I18N_INHIBITED */
+#endif /* HAVE_X_I18N */
 
   f->output_data.x->wm_hints.input = True;
   f->output_data.x->wm_hints.flags |= InputHint;
@@ -2761,6 +2789,7 @@ x_window (f)
                     FRAME_X_DISPLAY_INFO (f)->visual,
                     attribute_mask, &attributes);
 #ifdef HAVE_X_I18N
+#ifndef X_I18N_INHIBITED
   { 
     XIM xim;
     XIC xic = NULL;
@@ -2776,12 +2805,20 @@ x_window (f)
                         NULL);
 
        if (!xic)
-         XCloseIM (xim);
+         {
+           XCloseIM (xim);
+           xim = NULL;
+         }
       }
 
+    FRAME_XIM (f) = xim;
     FRAME_XIC (f) = xic;
   }
-#endif
+#else /* X_I18N_INHIBITED */
+  FRAME_XIM (f) = 0;
+  FRAME_XIC (f) = 0;
+#endif /* X_I18N_INHIBITED */
+#endif /* HAVE_X_I18N */
 
   validate_x_resource_name ();
 
@@ -2802,6 +2839,7 @@ x_window (f)
   f->output_data.x->wm_hints.flags |= InputHint;
   XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
               &f->output_data.x->wm_hints);
+  f->output_data.x->wm_hints.icon_pixmap = None;
 
   /* Request "save yourself" and "delete window" commands from wm.  */
   {
@@ -3150,7 +3188,7 @@ This function is an internal primitive--use `make-frame' instead.")
   x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
                       "bufferPredicate", "BufferPredicate", symbol);
   x_default_parameter (f, parms, Qtitle, Qnil,
-                      "title", "Title", symbol);
+                      "title", "Title", string);
 
   f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
   window_prompting = x_figure_window_size (f, parms);
@@ -3359,10 +3397,15 @@ even if they match PATTERN and FACE.")
        {
          XFontStruct *thisinfo;
 
-          thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f),
+         x_catch_errors (FRAME_X_DISPLAY (f));
+
+         thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f),
                                     XSTRING (XCONS (tem)->car)->data);
 
-          if (thisinfo && same_size_fonts (thisinfo, size_ref))
+         x_check_errors (FRAME_X_DISPLAY (f), "XLoadQueryFont failure: %s");
+         x_uncatch_errors (FRAME_X_DISPLAY (f));
+
+         if (thisinfo && same_size_fonts (thisinfo, size_ref))
            newlist = Fcons (XCONS (tem)->car, newlist);
 
          if (thisinfo != 0)
@@ -3376,6 +3419,8 @@ even if they match PATTERN and FACE.")
 
   BLOCK_INPUT;
 
+  x_catch_errors (FRAME_X_DISPLAY (f));
+
   /* Solaris 2.3 has a bug in XListFontsWithInfo.  */
 #ifndef BROKEN_XLISTFONTSWITHINFO
   if (size_ref)
@@ -3391,6 +3436,9 @@ even if they match PATTERN and FACE.")
                        2000, /* maxnames */
                        &num_fonts); /* count_return */
 
+  x_check_errors (FRAME_X_DISPLAY (f), "XListFonts failure: %s");
+  x_uncatch_errors (FRAME_X_DISPLAY (f));
+
   UNBLOCK_INPUT;
 
   list = Qnil;
@@ -3423,10 +3471,22 @@ even if they match PATTERN and FACE.")
              XFontStruct *thisinfo;
 
              BLOCK_INPUT;
+
+             x_catch_errors (FRAME_X_DISPLAY (f));
              thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f), names[i]);
+             x_check_errors (FRAME_X_DISPLAY (f),
+                             "XLoadQueryFont failure: %s");
+             x_uncatch_errors (FRAME_X_DISPLAY (f));
+
              UNBLOCK_INPUT;
 
              keeper = thisinfo && same_size_fonts (thisinfo, size_ref);
+             BLOCK_INPUT;
+             if (thisinfo && ! keeper)
+               XFreeFont (FRAME_X_DISPLAY (f), thisinfo);
+             else if (thisinfo)
+               XFreeFontInfo (NULL, thisinfo, 1);
+             UNBLOCK_INPUT;
 #else
              keeper = same_size_fonts (&info[i], size_ref);
 #endif