]> code.delx.au - gnu-emacs/blobdiff - src/xfns.c
(union Lisp_Object): Give a more precise type for `type'.
[gnu-emacs] / src / xfns.c
index 68002e458c50665c597cd0d97ce5e5f2ed61b68c..cecffb1c222741816a58796a7eb66d449f8b3b31 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions for the X window system.
-   Copyright (C) 1989, 92, 93, 94, 95, 96, 1997, 1998, 1999, 2000, 2001
+   Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 01, 02, 03
      Free Software Foundation.
 
 This file is part of GNU Emacs.
@@ -125,6 +125,14 @@ static Lisp_Object Vmotif_version_string;
 
 #endif /* USE_X_TOOLKIT */
 
+#ifdef USE_GTK
+
+/* GTK+ version info */
+
+static Lisp_Object Vgtk_version_string;
+
+#endif /* USE_GTK */
+
 #ifdef HAVE_X11R4
 #define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
 #else
@@ -139,15 +147,6 @@ int gray_bitmap_width = gray_width;
 int gray_bitmap_height = gray_height;
 char *gray_bitmap_bits = gray_bits;
 
-/* The name we're using in resource queries.  Most often "emacs".  */
-
-Lisp_Object Vx_resource_name;
-
-/* The application class we're using in resource queries.
-   Normally "Emacs".  */
-
-Lisp_Object Vx_resource_class;
-
 /* Non-zero means we're allowed to display an hourglass cursor.  */
 
 int display_hourglass_p;
@@ -187,55 +186,17 @@ Lisp_Object Vx_bitmap_file_path;
 
 Lisp_Object Vx_pixel_size_width_font_regexp;
 
-Lisp_Object Qauto_raise;
-Lisp_Object Qauto_lower;
-Lisp_Object Qborder_color;
-Lisp_Object Qborder_width;
-extern Lisp_Object Qbox;
-Lisp_Object Qcursor_color;
-Lisp_Object Qcursor_type;
-Lisp_Object Qgeometry;
-Lisp_Object Qicon_left;
-Lisp_Object Qicon_top;
-Lisp_Object Qicon_type;
-Lisp_Object Qicon_name;
-Lisp_Object Qinternal_border_width;
-Lisp_Object Qleft;
-Lisp_Object Qright;
-Lisp_Object Qmouse_color;
 Lisp_Object Qnone;
-Lisp_Object Qouter_window_id;
-Lisp_Object Qparent_id;
-Lisp_Object Qscroll_bar_width;
 Lisp_Object Qsuppress_icon;
-extern Lisp_Object Qtop;
 Lisp_Object Qundefined_color;
-Lisp_Object Qvertical_scroll_bars;
-Lisp_Object Qvisibility;
-Lisp_Object Qwindow_id;
-Lisp_Object Qx_frame_parameter;
-Lisp_Object Qx_resource_name;
-Lisp_Object Quser_position;
-Lisp_Object Quser_size;
-extern Lisp_Object Qdisplay;
-Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
-Lisp_Object Qscreen_gamma, Qline_spacing, Qcenter;
+Lisp_Object Qcenter;
 Lisp_Object Qcompound_text, Qcancel_timer;
-Lisp_Object Qwait_for_wm;
-Lisp_Object Qfullscreen;
-Lisp_Object Qfullwidth;
-Lisp_Object Qfullheight;
-Lisp_Object Qfullboth;
-
-/* The below are defined in frame.c.  */
 
-extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
-extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
-extern Lisp_Object Qtool_bar_lines;
+/* In dispnew.c */
 
 extern Lisp_Object Vwindow_system_version;
 
-Lisp_Object Qface_set_after_frame_default;
+/* The below are defined in frame.c.  */
 
 #if GLYPH_DEBUG
 int image_cache_refcount, dpyinfo_refcount;
@@ -283,7 +244,7 @@ check_x_frame (frame)
    nil stands for the selected frame--or, if that is not an X frame,
    the first X display on the list.  */
 
-static struct x_display_info *
+struct x_display_info *
 check_x_display_info (frame)
      Lisp_Object frame;
 {
@@ -347,7 +308,7 @@ x_window_to_frame (dpyinfo, wdesc)
 #ifdef USE_GTK
       if (f->output_data.x->edit_widget)
       {
-        GtkWidget *gwdesc = xg_win_to_widget (wdesc);
+        GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
         struct x_output *x = f->output_data.x;
         if (gwdesc != 0 && gwdesc == x->edit_widget)
           return f;
@@ -391,7 +352,7 @@ x_any_window_to_frame (dpyinfo, wdesc)
          else if (x->widget)
            {
 #ifdef USE_GTK
-              GtkWidget *gwdesc = xg_win_to_widget (wdesc);
+              GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
               if (gwdesc != 0
                   && (gwdesc == x->widget
                       || gwdesc == x->edit_widget
@@ -443,7 +404,7 @@ x_non_menubar_window_to_frame (dpyinfo, wdesc)
       else if (x->widget)
        {
 #ifdef USE_GTK
-          GtkWidget *gwdesc = xg_win_to_widget (wdesc);
+          GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
           if (gwdesc != 0
               && (gwdesc == x->widget
                   || gwdesc == x->edit_widget
@@ -487,7 +448,7 @@ x_menubar_window_to_frame (dpyinfo, wdesc)
 #ifdef USE_GTK
       if (x->menubar_widget)
         {
-          GtkWidget *gwdesc = xg_win_to_widget (wdesc);
+          GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
           int found = 0;
 
           BLOCK_INPUT;
@@ -533,7 +494,7 @@ x_top_window_to_frame (dpyinfo, wdesc)
        {
          /* This frame matches if the window is its topmost widget.  */
 #ifdef USE_GTK
-          GtkWidget *gwdesc = xg_win_to_widget (wdesc);
+          GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
           if (gwdesc == x->widget)
             return f;
 #else
@@ -597,6 +558,14 @@ x_bitmap_pixmap (f, id)
   return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
 }
 
+int
+x_bitmap_mask (f, id)
+     FRAME_PTR f;
+     int id;
+{
+  return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask;
+}
+
 
 /* Allocate a new bitmap record.  Returns index of new record.  */
 
@@ -655,11 +624,14 @@ x_create_bitmap_from_data (f, bits, width, height)
   bitmap = XCreateBitmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                                  bits, width, height);
 
+
+
   if (! bitmap)
     return -1;
 
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
+  dpyinfo->bitmaps[id - 1].have_mask = 0;
   dpyinfo->bitmaps[id - 1].file = NULL;
   dpyinfo->bitmaps[id - 1].refcount = 1;
   dpyinfo->bitmaps[id - 1].depth = 1;
@@ -711,6 +683,7 @@ x_create_bitmap_from_file (f, file)
 
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
+  dpyinfo->bitmaps[id - 1].have_mask = 0;
   dpyinfo->bitmaps[id - 1].refcount = 1;
   dpyinfo->bitmaps[id - 1].file
     = (char *) xmalloc (SBYTES (file) + 1);
@@ -738,6 +711,8 @@ x_destroy_bitmap (f, id)
        {
          BLOCK_INPUT;
          XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].pixmap);
+         if (dpyinfo->bitmaps[id - 1].have_mask)
+           XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].mask);
          if (dpyinfo->bitmaps[id - 1].file)
            {
              xfree (dpyinfo->bitmaps[id - 1].file);
@@ -759,33 +734,120 @@ x_destroy_all_bitmaps (dpyinfo)
     if (dpyinfo->bitmaps[i].refcount > 0)
       {
        XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].pixmap);
+       if (dpyinfo->bitmaps[i].have_mask)
+         XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].mask);
        if (dpyinfo->bitmaps[i].file)
          xfree (dpyinfo->bitmaps[i].file);
       }
   dpyinfo->bitmaps_last = 0;
 }
 \f
-/* Connect the frame-parameter names for X frames
-   to the ways of passing the parameter values to the window system.
 
-   The name of a parameter, as a Lisp symbol,
-   has an `x-frame-parameter' property which is an integer in Lisp
-   that is an index in this table.  */
 
-struct x_frame_parm_table
+
+/* Useful functions defined in the section
+   `Image type independent image structures' below. */
+
+static unsigned long four_corners_best P_ ((XImage *ximg, unsigned long width,
+                                           unsigned long height));
+
+static int x_create_x_image_and_pixmap P_ ((struct frame *f, int width, int height,
+                                           int depth, XImage **ximg,
+                                           Pixmap *pixmap));
+
+static void x_destroy_x_image P_ ((XImage *ximg));
+
+
+/* Create a mask of a bitmap. Note is this not a perfect mask.
+   It's nicer with some borders in this context */
+
+int
+x_create_bitmap_mask (f, id)
+     struct frame *f;
+     int id;
 {
-  char *name;
-  void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object));
-};
+  Pixmap pixmap, mask;
+  XImage *ximg, *mask_img;
+  unsigned long width, height;
+  int result;
+  unsigned long bg;
+  unsigned long x, y, xp, xm, yp, ym;
+  GC gc;
+
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+
+  if (!(id > 0))
+    return -1;
+
+  pixmap = x_bitmap_pixmap (f, id);
+  width = x_bitmap_width (f, id);
+  height = x_bitmap_height (f, id);
+
+  BLOCK_INPUT;
+  ximg = XGetImage (FRAME_X_DISPLAY (f), pixmap, 0, 0, width, height,
+                   ~0, ZPixmap);
+
+  if (!ximg)
+    {
+      UNBLOCK_INPUT;
+      return -1;
+    }
+
+  result = x_create_x_image_and_pixmap (f, width, height, 1, &mask_img, &mask);
+
+  UNBLOCK_INPUT;
+  if (!result)
+    {
+      XDestroyImage (ximg);
+      return -1;
+    }
+
+  bg = four_corners_best (ximg, width, height);
+
+  for (y = 0; y < ximg->height; ++y)
+    {
+      for (x = 0; x < ximg->width; ++x)
+       {
+         xp = x != ximg->width - 1 ? x + 1 : 0;
+         xm = x != 0 ? x - 1 : ximg->width - 1;
+         yp = y != ximg->height - 1 ? y + 1 : 0;
+         ym = y != 0 ? y - 1 : ximg->height - 1;
+         if (XGetPixel (ximg, x, y) == bg
+             && XGetPixel (ximg, x, yp) == bg
+             && XGetPixel (ximg, x, ym) == bg
+             && XGetPixel (ximg, xp, y) == bg
+             && XGetPixel (ximg, xp, yp) == bg
+             && XGetPixel (ximg, xp, ym) == bg
+             && XGetPixel (ximg, xm, y) == bg
+             && XGetPixel (ximg, xm, yp) == bg
+             && XGetPixel (ximg, xm, ym) == bg)
+           XPutPixel (mask_img, x, y, 0);
+         else
+           XPutPixel (mask_img, x, y, 1);
+       }
+    }
+
+  xassert (interrupt_input_blocked);
+  gc = XCreateGC (FRAME_X_DISPLAY (f), mask, 0, NULL);
+  XPutImage (FRAME_X_DISPLAY (f), mask, gc, mask_img, 0, 0, 0, 0,
+            width, height);
+  XFreeGC (FRAME_X_DISPLAY (f), gc);
+
+  dpyinfo->bitmaps[id - 1].have_mask = 1;
+  dpyinfo->bitmaps[id - 1].mask = mask;
+
+  XDestroyImage (ximg);
+  x_destroy_x_image (mask_img);
+
+  return 0;
+}
 
 static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
 static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
-static void x_change_window_heights P_ ((Lisp_Object, int));
 static void x_disable_image P_ ((struct frame *, struct image *));
+
 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
-static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
 static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object));
-static void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
@@ -793,21 +855,9 @@ void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
-static void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
-                                     Lisp_Object));
 void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
-                                    Lisp_Object));
-void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
                                      Lisp_Object));
@@ -818,7 +868,6 @@ static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *,
                                                             Lisp_Object,
                                                             char *, char *,
                                                             int));
-static void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
 static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object,
                                  Lisp_Object));
 static void init_color_table P_ ((void));
@@ -829,369 +878,8 @@ static unsigned long lookup_pixel_color P_ ((struct frame *f, unsigned long p));
 
 
 
-static struct x_frame_parm_table x_frame_parms[] =
-{
-  {"auto-raise",               x_set_autoraise},
-  {"auto-lower",               x_set_autolower},
-  {"background-color",         x_set_background_color},
-  {"border-color",             x_set_border_color},
-  {"border-width",             x_set_border_width},
-  {"cursor-color",             x_set_cursor_color},
-  {"cursor-type",              x_set_cursor_type},
-  {"font",                     x_set_font},
-  {"foreground-color",         x_set_foreground_color},
-  {"icon-name",                        x_set_icon_name},
-  {"icon-type",                        x_set_icon_type},
-  {"internal-border-width",    x_set_internal_border_width},
-  {"menu-bar-lines",           x_set_menu_bar_lines},
-  {"mouse-color",              x_set_mouse_color},
-  {"name",                     x_explicitly_set_name},
-  {"scroll-bar-width",         x_set_scroll_bar_width},
-  {"title",                    x_set_title},
-  {"unsplittable",             x_set_unsplittable},
-  {"vertical-scroll-bars",     x_set_vertical_scroll_bars},
-  {"visibility",               x_set_visibility},
-  {"tool-bar-lines",           x_set_tool_bar_lines},
-  {"scroll-bar-foreground",    x_set_scroll_bar_foreground},
-  {"scroll-bar-background",    x_set_scroll_bar_background},
-  {"screen-gamma",             x_set_screen_gamma},
-  {"line-spacing",             x_set_line_spacing},
-  {"left-fringe",              x_set_fringe_width},
-  {"right-fringe",             x_set_fringe_width},
-  {"wait-for-wm",              x_set_wait_for_wm},
-  {"fullscreen",                x_set_fullscreen},
-
-};
-
-/* Attach the `x-frame-parameter' properties to
-   the Lisp symbol names of parameters relevant to X.  */
-
-void
-init_x_parm_symbols ()
-{
-  int i;
-
-  for (i = 0; i < sizeof (x_frame_parms) / sizeof (x_frame_parms[0]); i++)
-    Fput (intern (x_frame_parms[i].name), Qx_frame_parameter,
-         make_number (i));
-}
 \f
 
-/* Really try to move where we want to be in case of fullscreen.  Some WMs
-   moves the window where we tell them.  Some (mwm, twm) moves the outer
-   window manager window there instead.
-   Try to compensate for those WM here. */
-static void
-x_fullscreen_move (f, new_top, new_left)
-     struct frame *f;
-     int new_top;
-     int new_left;
-{
-  if (new_top != f->output_data.x->top_pos
-      || new_left != f->output_data.x->left_pos)
-    {
-      int move_x = new_left + f->output_data.x->x_pixels_outer_diff;
-      int move_y = new_top + f->output_data.x->y_pixels_outer_diff;
-
-      f->output_data.x->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
-      x_set_offset (f, move_x, move_y, 1);
-    }
-}
-
-/* Change the parameters of frame F as specified by ALIST.
-   If a parameter is not specially recognized, do nothing special;
-   otherwise call the `x_set_...' function for that parameter.
-   Except for certain geometry properties, always call store_frame_param
-   to store the new value in the parameter alist.  */
-
-void
-x_set_frame_parameters (f, alist)
-     FRAME_PTR f;
-     Lisp_Object alist;
-{
-  Lisp_Object tail;
-
-  /* If both of these parameters are present, it's more efficient to
-     set them both at once.  So we wait until we've looked at the
-     entire list before we set them.  */
-  int width, height;
-
-  /* Same here.  */
-  Lisp_Object left, top;
-
-  /* Same with these.  */
-  Lisp_Object icon_left, icon_top;
-
-  /* Record in these vectors all the parms specified.  */
-  Lisp_Object *parms;
-  Lisp_Object *values;
-  int i, p;
-  int left_no_change = 0, top_no_change = 0;
-  int icon_left_no_change = 0, icon_top_no_change = 0;
-  int fullscreen_is_being_set = 0;
-
-  struct gcpro gcpro1, gcpro2;
-
-  i = 0;
-  for (tail = alist; CONSP (tail); tail = Fcdr (tail))
-    i++;
-
-  parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
-  values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
-
-  /* Extract parm names and values into those vectors.  */
-
-  i = 0;
-  for (tail = alist; CONSP (tail); tail = Fcdr (tail))
-    {
-      Lisp_Object elt;
-
-      elt = Fcar (tail);
-      parms[i] = Fcar (elt);
-      values[i] = Fcdr (elt);
-      i++;
-    }
-  /* TAIL and ALIST are not used again below here.  */
-  alist = tail = Qnil;
-
-  GCPRO2 (*parms, *values);
-  gcpro1.nvars = i;
-  gcpro2.nvars = i;
-
-  /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
-     because their values appear in VALUES and strings are not valid.  */
-  top = left = Qunbound;
-  icon_left = icon_top = Qunbound;
-
-  /* Provide default values for HEIGHT and WIDTH.  */
-  if (FRAME_NEW_WIDTH (f))
-    width = FRAME_NEW_WIDTH (f);
-  else
-    width = FRAME_WIDTH (f);
-
-  if (FRAME_NEW_HEIGHT (f))
-    height = FRAME_NEW_HEIGHT (f);
-  else
-    height = FRAME_HEIGHT (f);
-
-  /* Process foreground_color and background_color before anything else.
-     They are independent of other properties, but other properties (e.g.,
-     cursor_color) are dependent upon them.  */
-  /* Process default font as well, since fringe widths depends on it.  */
-  /* Also, process fullscreen, width and height depend upon that */
-  for (p = 0; p < i; p++)
-    {
-      Lisp_Object prop, val;
-
-      prop = parms[p];
-      val = values[p];
-      if (EQ (prop, Qforeground_color)
-         || EQ (prop, Qbackground_color)
-         || EQ (prop, Qfont)
-          || EQ (prop, Qfullscreen))
-       {
-         register Lisp_Object param_index, old_value;
-
-         old_value = get_frame_param (f, prop);
-         fullscreen_is_being_set |= EQ (prop, Qfullscreen);
-
-         if (NILP (Fequal (val, old_value)))
-           {
-             store_frame_param (f, prop, val);
-
-             param_index = Fget (prop, Qx_frame_parameter);
-             if (NATNUMP (param_index)
-                 && (XFASTINT (param_index)
-                     < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
-               (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
-           }
-       }
-    }
-
-  /* Now process them in reverse of specified order.  */
-  for (i--; i >= 0; i--)
-    {
-      Lisp_Object prop, val;
-
-      prop = parms[i];
-      val = values[i];
-
-      if (EQ (prop, Qwidth) && NUMBERP (val))
-       width = XFASTINT (val);
-      else if (EQ (prop, Qheight) && NUMBERP (val))
-       height = XFASTINT (val);
-      else if (EQ (prop, Qtop))
-       top = val;
-      else if (EQ (prop, Qleft))
-       left = val;
-      else if (EQ (prop, Qicon_top))
-       icon_top = val;
-      else if (EQ (prop, Qicon_left))
-       icon_left = val;
-      else if (EQ (prop, Qforeground_color)
-              || EQ (prop, Qbackground_color)
-              || EQ (prop, Qfont)
-               || EQ (prop, Qfullscreen))
-       /* Processed above.  */
-       continue;
-      else
-       {
-         register Lisp_Object param_index, old_value;
-
-         old_value = get_frame_param (f, prop);
-
-         store_frame_param (f, prop, val);
-
-         param_index = Fget (prop, Qx_frame_parameter);
-         if (NATNUMP (param_index)
-             && (XFASTINT (param_index)
-                 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
-           (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
-       }
-    }
-
-  /* Don't die if just one of these was set.  */
-  if (EQ (left, Qunbound))
-    {
-      left_no_change = 1;
-      if (f->output_data.x->left_pos < 0)
-       left = Fcons (Qplus, Fcons (make_number (f->output_data.x->left_pos), Qnil));
-      else
-       XSETINT (left, f->output_data.x->left_pos);
-    }
-  if (EQ (top, Qunbound))
-    {
-      top_no_change = 1;
-      if (f->output_data.x->top_pos < 0)
-       top = Fcons (Qplus, Fcons (make_number (f->output_data.x->top_pos), Qnil));
-      else
-       XSETINT (top, f->output_data.x->top_pos);
-    }
-
-  /* If one of the icon positions was not set, preserve or default it.  */
-  if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
-    {
-      icon_left_no_change = 1;
-      icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
-      if (NILP (icon_left))
-       XSETINT (icon_left, 0);
-    }
-  if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
-    {
-      icon_top_no_change = 1;
-      icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
-      if (NILP (icon_top))
-       XSETINT (icon_top, 0);
-    }
-
-  if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)
-    {
-      /* If the frame is visible already and the fullscreen parameter is
-         being set, it is too late to set WM manager hints to specify
-         size and position.
-         Here we first get the width, height and position that applies to
-         fullscreen.  We then move the frame to the appropriate
-         position.  Resize of the frame is taken care of in the code after
-         this if-statement. */
-      int new_left, new_top;
-
-      x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
-      x_fullscreen_move (f, new_top, new_left);
-    }
-
-  /* Don't set these parameters unless they've been explicitly
-     specified.  The window might be mapped or resized while we're in
-     this function, and we don't want to override that unless the lisp
-     code has asked for it.
-
-     Don't set these parameters unless they actually differ from the
-     window's current parameters; the window may not actually exist
-     yet.  */
-  {
-    Lisp_Object frame;
-
-    check_frame_size (f, &height, &width);
-
-    XSETFRAME (frame, f);
-
-    if (width != FRAME_WIDTH (f)
-       || height != FRAME_HEIGHT (f)
-       || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
-      Fset_frame_size (frame, make_number (width), make_number (height));
-
-    if ((!NILP (left) || !NILP (top))
-       && ! (left_no_change && top_no_change)
-       && ! (NUMBERP (left) && XINT (left) == f->output_data.x->left_pos
-             && NUMBERP (top) && XINT (top) == f->output_data.x->top_pos))
-      {
-       int leftpos = 0;
-       int toppos = 0;
-
-       /* Record the signs.  */
-       f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);
-       if (EQ (left, Qminus))
-         f->output_data.x->size_hint_flags |= XNegative;
-       else if (INTEGERP (left))
-         {
-           leftpos = XINT (left);
-           if (leftpos < 0)
-             f->output_data.x->size_hint_flags |= XNegative;
-         }
-       else if (CONSP (left) && EQ (XCAR (left), Qminus)
-                && CONSP (XCDR (left))
-                && INTEGERP (XCAR (XCDR (left))))
-         {
-           leftpos = - XINT (XCAR (XCDR (left)));
-           f->output_data.x->size_hint_flags |= XNegative;
-         }
-       else if (CONSP (left) && EQ (XCAR (left), Qplus)
-                && CONSP (XCDR (left))
-                && INTEGERP (XCAR (XCDR (left))))
-         {
-           leftpos = XINT (XCAR (XCDR (left)));
-         }
-
-       if (EQ (top, Qminus))
-         f->output_data.x->size_hint_flags |= YNegative;
-       else if (INTEGERP (top))
-         {
-           toppos = XINT (top);
-           if (toppos < 0)
-             f->output_data.x->size_hint_flags |= YNegative;
-         }
-       else if (CONSP (top) && EQ (XCAR (top), Qminus)
-                && CONSP (XCDR (top))
-                && INTEGERP (XCAR (XCDR (top))))
-         {
-           toppos = - XINT (XCAR (XCDR (top)));
-           f->output_data.x->size_hint_flags |= YNegative;
-         }
-       else if (CONSP (top) && EQ (XCAR (top), Qplus)
-                && CONSP (XCDR (top))
-                && INTEGERP (XCAR (XCDR (top))))
-         {
-           toppos = XINT (XCAR (XCDR (top)));
-         }
-
-
-       /* Store the numeric value of the position.  */
-       f->output_data.x->top_pos = toppos;
-       f->output_data.x->left_pos = leftpos;
-
-       f->output_data.x->win_gravity = NorthWestGravity;
-
-       /* Actually set that position, and convert to absolute.  */
-       x_set_offset (f, leftpos, toppos, -1);
-      }
-
-    if ((!NILP (icon_left) || !NILP (icon_top))
-       && ! (icon_left_no_change && icon_top_no_change))
-      x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
-  }
-
-  UNGCPRO;
-}
-
 /* Store the screen positions of frame F into XPTR and YPTR.
    These are the positions of the containing window manager window,
    not Emacs's own window.  */
@@ -1292,7 +980,7 @@ x_real_positions (f, xptr, yptr)
 
                                  /* Child of win.  */
                                  &child);
-    }
+       }
 
       had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
     }
@@ -1303,84 +991,16 @@ x_real_positions (f, xptr, yptr)
 
   if (had_errors) return;
 
-  f->output_data.x->x_pixels_diff = -win_x;
-  f->output_data.x->y_pixels_diff = -win_y;
-  f->output_data.x->x_pixels_outer_diff = -outer_x;
-  f->output_data.x->y_pixels_outer_diff = -outer_y;
+  f->x_pixels_diff = -win_x;
+  f->y_pixels_diff = -win_y;
+
+  FRAME_X_OUTPUT (f)->x_pixels_outer_diff = -outer_x;
+  FRAME_X_OUTPUT (f)->y_pixels_outer_diff = -outer_y;
 
   *xptr = real_x;
   *yptr = real_y;
 }
 
-/* Insert a description of internally-recorded parameters of frame X
-   into the parameter alist *ALISTPTR that is to be given to the user.
-   Only parameters that are specific to the X window system
-   and whose values are not correctly recorded in the frame's
-   param_alist need to be considered here.  */
-
-void
-x_report_frame_params (f, alistptr)
-     struct frame *f;
-     Lisp_Object *alistptr;
-{
-  char buf[16];
-  Lisp_Object tem;
-
-  /* Represent negative positions (off the top or left screen edge)
-     in a way that Fmodify_frame_parameters will understand correctly.  */
-  XSETINT (tem, f->output_data.x->left_pos);
-  if (f->output_data.x->left_pos >= 0)
-    store_in_alist (alistptr, Qleft, tem);
-  else
-    store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
-
-  XSETINT (tem, f->output_data.x->top_pos);
-  if (f->output_data.x->top_pos >= 0)
-    store_in_alist (alistptr, Qtop, tem);
-  else
-    store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
-
-  store_in_alist (alistptr, Qborder_width,
-                  make_number (f->output_data.x->border_width));
-  store_in_alist (alistptr, Qinternal_border_width,
-                  make_number (f->output_data.x->internal_border_width));
-  store_in_alist (alistptr, Qleft_fringe,
-                  make_number (f->output_data.x->left_fringe_width));
-  store_in_alist (alistptr, Qright_fringe,
-                  make_number (f->output_data.x->right_fringe_width));
-  store_in_alist (alistptr, Qscroll_bar_width,
-                 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
-                  ? make_number (0)
-                  : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
-                  ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
-                  /* nil means "use default width"
-                     for non-toolkit scroll bar.
-                     ruler-mode.el depends on this.  */
-                  : Qnil));
-  sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
-  store_in_alist (alistptr, Qwindow_id,
-                  build_string (buf));
-#ifdef USE_X_TOOLKIT
-  /* Tooltip frame may not have this widget.  */
-  if (f->output_data.x->widget)
-#endif
-    sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
-  store_in_alist (alistptr, Qouter_window_id,
-                  build_string (buf));
-  store_in_alist (alistptr, Qicon_name, f->icon_name);
-  FRAME_SAMPLE_VISIBILITY (f);
-  store_in_alist (alistptr, Qvisibility,
-                 (FRAME_VISIBLE_P (f) ? Qt
-                  : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
-  store_in_alist (alistptr, Qdisplay,
-                 XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));
-
-  if (f->output_data.x->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
-    tem = Qnil;
-  else
-    XSETFASTINT (tem, f->output_data.x->parent_desc);
-  store_in_alist (alistptr, Qparent_id, tem);
-}
 \f
 
 
@@ -1465,26 +1085,6 @@ x_decode_color (f, color_name, mono_color)
 
 
 \f
-/* Change the `line-spacing' frame parameter of frame F.  OLD_VALUE is
-   the previous value of that parameter, NEW_VALUE is the new value.  */
-
-static void
-x_set_line_spacing (f, new_value, old_value)
-     struct frame *f;
-     Lisp_Object new_value, old_value;
-{
-  if (NILP (new_value))
-    f->extra_line_spacing = 0;
-  else if (NATNUMP (new_value))
-    f->extra_line_spacing = XFASTINT (new_value);
-  else
-    Fsignal (Qerror, Fcons (build_string ("Invalid line-spacing"),
-                           Fcons (new_value, Qnil)));
-  if (FRAME_VISIBLE_P (f))
-    redraw_frame (f);
-}
-
-
 /* Change the `wait-for-wm' frame parameter of frame F.  OLD_VALUE is
    the previous value of that parameter, NEW_VALUE is the new value.
    See also the comment of wait_for_wm in struct x_output.  */
@@ -1497,46 +1097,55 @@ x_set_wait_for_wm (f, new_value, old_value)
   f->output_data.x->wait_for_wm = !NILP (new_value);
 }
 
+#ifdef USE_GTK
+
+static Lisp_Object x_find_image_file P_ ((Lisp_Object file));
 
-/* Change the `fullscreen' frame parameter of frame F.  OLD_VALUE is
-   the previous value of that parameter, NEW_VALUE is the new value. */
+/* Set icon from FILE for frame F.  By using GTK functions the icon
+   may be any format that GdkPixbuf knows about, i.e. not just bitmaps.  */
 
-static void
-x_set_fullscreen (f, new_value, old_value)
-     struct frame *f;
-     Lisp_Object new_value, old_value;
+int
+xg_set_icon (f, file)
+    FRAME_PTR f;
+    Lisp_Object file;
 {
-  if (NILP (new_value))
-    f->output_data.x->want_fullscreen = FULLSCREEN_NONE;
-  else if (EQ (new_value, Qfullboth))
-    f->output_data.x->want_fullscreen = FULLSCREEN_BOTH;
-  else if (EQ (new_value, Qfullwidth))
-    f->output_data.x->want_fullscreen = FULLSCREEN_WIDTH;
-  else if (EQ (new_value, Qfullheight))
-    f->output_data.x->want_fullscreen = FULLSCREEN_HEIGHT;
-}
+  struct gcpro gcpro1;
+  int result = 0;
+  Lisp_Object found;
 
+  GCPRO1 (found);
 
-/* Change the `screen-gamma' frame parameter of frame F.  OLD_VALUE is
-   the previous value of that parameter, NEW_VALUE is the new
-   value.  */
+  found = x_find_image_file (file);
 
-static void
-x_set_screen_gamma (f, new_value, old_value)
-     struct frame *f;
-     Lisp_Object new_value, old_value;
-{
-  if (NILP (new_value))
-    f->gamma = 0;
-  else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
-    /* The value 0.4545 is the normal viewing gamma.  */
-    f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
-  else
-    Fsignal (Qerror, Fcons (build_string ("Invalid screen-gamma"),
-                           Fcons (new_value, Qnil)));
+  if (! NILP (found))
+    {
+      GdkPixbuf *pixbuf;
+      GError *err = NULL;
+      char *filename;
+
+      filename = SDATA (found);
+      BLOCK_INPUT;
+
+      pixbuf = gdk_pixbuf_new_from_file (filename, &err);
+
+      if (pixbuf)
+       {
+         gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                              pixbuf);
+         g_object_unref (pixbuf);
+
+         result = 1;
+       }
+      else
+       g_error_free (err);
+
+      UNBLOCK_INPUT;
+    }
 
-  clear_face_cache (0);
+  UNGCPRO;
+  return result;
 }
+#endif /* USE_GTK */
 
 
 /* Functions called only from `x_set_frame_param'
@@ -1690,7 +1299,6 @@ x_set_mouse_color (f, arg, oldval)
     hourglass_cursor = XCreateFontCursor (dpy, XC_watch);
   x_check_errors (dpy, "bad hourglass pointer cursor: %s");
 
-  x_check_errors (dpy, "bad nontext pointer cursor: %s");
   if (!NILP (Vx_mode_pointer_shape))
     {
       CHECK_NUMBER (Vx_mode_pointer_shape);
@@ -1847,43 +1455,19 @@ x_set_cursor_color (f, arg, oldval)
   update_face_from_frame_parameter (f, Qcursor_color, arg);
 }
 \f
-/* Set the border-color of frame F to value described by ARG.
-   ARG can be a string naming a color.
-   The border-color is used for the border that is drawn by the X server.
+/* Set the border-color of frame F to pixel value PIX.
    Note that this does not fully take effect if done before
-   F has an x-window; it must be redone when the window is created.
-
-   Note: this is done in two routines because of the way X10 works.
-
-   Note: under X11, this is normally the province of the window manager,
-   and so emacs' border colors may be overridden.  */
+   F has an x-window.  */
 
 void
-x_set_border_color (f, arg, oldval)
+x_set_border_pixel (f, pix)
      struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  int pix;
-
-  CHECK_STRING (arg);
-  pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
-  x_set_border_pixel (f, pix);
-  update_face_from_frame_parameter (f, Qborder_color, arg);
-}
-
-/* Set the border-color of frame F to pixel value PIX.
-   Note that this does not fully take effect if done before
-   F has an x-window.  */
-
-void
-x_set_border_pixel (f, pix)
-     struct frame *f;
-     int pix;
+     int pix;
 {
   unload_color (f, f->output_data.x->border_pixel);
   f->output_data.x->border_pixel = pix;
 
-  if (FRAME_X_WINDOW (f) != 0 && f->output_data.x->border_width > 0)
+  if (FRAME_X_WINDOW (f) != 0 && f->border_width > 0)
     {
       BLOCK_INPUT;
       XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
@@ -1895,6 +1479,29 @@ x_set_border_pixel (f, pix)
     }
 }
 
+/* Set the border-color of frame F to value described by ARG.
+   ARG can be a string naming a color.
+   The border-color is used for the border that is drawn by the X server.
+   Note that this does not fully take effect if done before
+   F has an x-window; it must be redone when the window is created.
+
+   Note: this is done in two routines because of the way X10 works.
+
+   Note: under X11, this is normally the province of the window manager,
+   and so emacs' border colors may be overridden.  */
+
+void
+x_set_border_color (f, arg, oldval)
+     struct frame *f;
+     Lisp_Object arg, oldval;
+{
+  int pix;
+
+  CHECK_STRING (arg);
+  pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+  x_set_border_pixel (f, pix);
+  update_face_from_frame_parameter (f, Qborder_color, arg);
+}
 
 
 void
@@ -1942,21 +1549,6 @@ x_set_icon_type (f, arg, oldval)
   UNBLOCK_INPUT;
 }
 
-/* Return non-nil if frame F wants a bitmap icon.  */
-
-Lisp_Object
-x_icon_type (f)
-     FRAME_PTR f;
-{
-  Lisp_Object tem;
-
-  tem = assq_no_quit (Qicon_type, f->param_alist);
-  if (CONSP (tem))
-    return XCDR (tem);
-  else
-    return Qnil;
-}
-
 void
 x_set_icon_name (f, arg, oldval)
      struct frame *f;
@@ -1995,170 +1587,15 @@ x_set_icon_name (f, arg, oldval)
   XFlush (FRAME_X_DISPLAY (f));
   UNBLOCK_INPUT;
 }
-\f
-void
-x_set_font (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  Lisp_Object result;
-  Lisp_Object fontset_name;
-  Lisp_Object frame;
-  int old_fontset = f->output_data.x->fontset;
-
-  CHECK_STRING (arg);
-
-  fontset_name = Fquery_fontset (arg, Qnil);
-
-  BLOCK_INPUT;
-  result = (STRINGP (fontset_name)
-           ? x_new_fontset (f, SDATA (fontset_name))
-           : x_new_font (f, SDATA (arg)));
-  UNBLOCK_INPUT;
-
-  if (EQ (result, Qnil))
-    error ("Font `%s' is not defined", SDATA (arg));
-  else if (EQ (result, Qt))
-    error ("The characters of the given font have varying widths");
-  else if (STRINGP (result))
-    {
-      if (STRINGP (fontset_name))
-       {
-         /* Fontset names are built from ASCII font names, so the
-            names may be equal despite there was a change.  */
-         if (old_fontset == f->output_data.x->fontset)
-           return;
-       }
-      else if (!NILP (Fequal (result, oldval)))
-       return;
-
-      store_frame_param (f, Qfont, result);
-      recompute_basic_faces (f);
-    }
-  else
-    abort ();
-
-  do_pending_window_change (0);
-
-  /* Don't call `face-set-after-frame-default' when faces haven't been
-     initialized yet.  This is the case when called from
-     Fx_create_frame.  In that case, the X widget or window doesn't
-     exist either, and we can end up in x_report_frame_params with a
-     null widget which gives a segfault.  */
-  if (FRAME_FACE_CACHE (f))
-    {
-      XSETFRAME (frame, f);
-      call1 (Qface_set_after_frame_default, frame);
-    }
-}
-
-static void
-x_set_fringe_width (f, new_value, old_value)
-     struct frame *f;
-     Lisp_Object new_value, old_value;
-{
-  compute_fringe_widths (f, 1);
-}
-
-void
-x_set_border_width (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  CHECK_NUMBER (arg);
-
-  if (XINT (arg) == f->output_data.x->border_width)
-    return;
-
-  if (FRAME_X_WINDOW (f) != 0)
-    error ("Cannot change the border width of a window");
-
-  f->output_data.x->border_width = XINT (arg);
-}
-
-void
-x_set_internal_border_width (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  int old = f->output_data.x->internal_border_width;
-
-  CHECK_NUMBER (arg);
-  f->output_data.x->internal_border_width = XINT (arg);
-  if (f->output_data.x->internal_border_width < 0)
-    f->output_data.x->internal_border_width = 0;
-
-#ifdef USE_X_TOOLKIT
-  if (f->output_data.x->edit_widget)
-    widget_store_internal_border (f->output_data.x->edit_widget);
-#endif
-
-  if (f->output_data.x->internal_border_width == old)
-    return;
-
-  if (FRAME_X_WINDOW (f) != 0)
-    {
-      x_set_window_size (f, 0, f->width, f->height);
-      SET_FRAME_GARBAGED (f);
-      do_pending_window_change (0);
-    }
-  else
-    SET_FRAME_GARBAGED (f);
-}
-
-void
-x_set_visibility (f, value, oldval)
-     struct frame *f;
-     Lisp_Object value, oldval;
-{
-  Lisp_Object frame;
-  XSETFRAME (frame, f);
-
-  if (NILP (value))
-    Fmake_frame_invisible (frame, Qt);
-  else if (EQ (value, Qicon))
-    Ficonify_frame (frame);
-  else
-    Fmake_frame_visible (frame);
-}
 
 \f
-/* Change window heights in windows rooted in WINDOW by N lines.  */
-
-static void
-x_change_window_heights (window, n)
-  Lisp_Object window;
-  int n;
-{
-  struct window *w = XWINDOW (window);
-
-  XSETFASTINT (w->top, XFASTINT (w->top) + n);
-  XSETFASTINT (w->height, XFASTINT (w->height) - n);
-
-  if (INTEGERP (w->orig_top))
-    XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
-  if (INTEGERP (w->orig_height))
-    XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
-
-  /* Handle just the top child in a vertical split.  */
-  if (!NILP (w->vchild))
-    x_change_window_heights (w->vchild, n);
-
-  /* Adjust all children in a horizontal split.  */
-  for (window = w->hchild; !NILP (window); window = w->next)
-    {
-      w = XWINDOW (window);
-      x_change_window_heights (window, n);
-    }
-}
-
 void
 x_set_menu_bar_lines (f, value, oldval)
      struct frame *f;
      Lisp_Object value, oldval;
 {
   int nlines;
-#ifndef USE_X_TOOLKIT
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
   int olines = FRAME_MENU_BAR_LINES (f);
 #endif
 
@@ -2196,7 +1633,7 @@ x_set_menu_bar_lines (f, value, oldval)
     }
 #else /* not USE_X_TOOLKIT && not USE_GTK */
   FRAME_MENU_BAR_LINES (f) = nlines;
-  x_change_window_heights (f->root_window, nlines - olines);
+  change_window_heights (f->root_window, nlines - olines);
 #endif /* not USE_X_TOOLKIT */
   adjust_glyphs (f);
 }
@@ -2253,7 +1690,7 @@ x_set_tool_bar_lines (f, value, oldval)
 
   /* Don't resize the tool-bar to more than we have room for.  */
   root_window = FRAME_ROOT_WINDOW (f);
-  root_height = XINT (XWINDOW (root_window)->height);
+  root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
   if (root_height - delta < 1)
     {
       delta = root_height - 1;
@@ -2261,7 +1698,7 @@ x_set_tool_bar_lines (f, value, oldval)
     }
 
   FRAME_TOOL_BAR_LINES (f) = nlines;
-  x_change_window_heights (root_window, delta);
+  change_window_heights (root_window, delta);
   adjust_glyphs (f);
 
   /* We also have to make sure that the internal border at the top of
@@ -2284,8 +1721,8 @@ x_set_tool_bar_lines (f, value, oldval)
   if (delta < 0)
     {
       int height = FRAME_INTERNAL_BORDER_WIDTH (f);
-      int width = PIXEL_WIDTH (f);
-      int y = nlines * CANON_Y_UNIT (f);
+      int width = FRAME_PIXEL_WIDTH (f);
+      int y = nlines * FRAME_LINE_HEIGHT (f);
 
       BLOCK_INPUT;
       x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
@@ -2524,11 +1961,11 @@ x_set_name (f, name, explicit)
           managers which don't support that encoding.  So, if NAME
           contains only ASCII and 8859-1 characters, encode it by
           iso-latin-1, and use "STRING" in text.encoding hoping that
-          such window manager at least analize this format correctly,
+          such window managers at least analyze this format correctly,
           i.e. treat 8-bit bytes as 8859-1 characters.
 
           We may also be able to use "UTF8_STRING" in text.encoding
-          in the feature which can encode all Unicode characters.
+          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;
@@ -2658,510 +2095,57 @@ x_set_title (f, name, old_name)
                             : 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 (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;
-    }
-}
-\f
-void
-x_set_autoraise (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  f->auto_raise = !EQ (Qnil, arg);
-}
-
-void
-x_set_autolower (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  f->auto_lower = !EQ (Qnil, arg);
-}
-
-void
-x_set_unsplittable (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  f->no_split = !NILP (arg);
-}
-
-void
-x_set_vertical_scroll_bars (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
-      || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
-      || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))
-      || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f)))
-    {
-      FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
-       = (NILP (arg)
-          ? vertical_scroll_bar_none
-          : EQ (Qright, arg)
-          ? vertical_scroll_bar_right
-          : vertical_scroll_bar_left);
-
-      /* We set this parameter before creating the X window for the
-        frame, so we can get the geometry right from the start.
-        However, if the window hasn't been created yet, we shouldn't
-        call x_set_window_size.  */
-      if (FRAME_X_WINDOW (f))
-       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
-      do_pending_window_change (0);
-    }
-}
-
-void
-x_set_scroll_bar_width (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  int wid = FONT_WIDTH (f->output_data.x->font);
-
-  if (NILP (arg))
-    {
-#ifdef USE_TOOLKIT_SCROLL_BARS
-      /* A minimum width of 14 doesn't look good for toolkit scroll bars.  */
-      int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;
-      FRAME_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;
-      FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width;
-#else
-      /* Make the actual width at least 14 pixels and a multiple of a
-        character width.  */
-      FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
-
-      /* Use all of that space (aside from required margins) for the
-        scroll bar.  */
-      FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
-#endif
-
-      if (FRAME_X_WINDOW (f))
-        x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
-      do_pending_window_change (0);
-    }
-  else if (INTEGERP (arg) && XINT (arg) > 0
-          && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
-    {
-      if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
-       XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
-
-      FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
-      FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
-      if (FRAME_X_WINDOW (f))
-       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
-    }
-
-  change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
-  XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
-  XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
-}
-
-
-\f
-/* Subroutines of creating an X frame.  */
-
-/* Make sure that Vx_resource_name is set to a reasonable value.
-   Fix it up, or set it to `emacs' if it is too hopeless.  */
-
-static void
-validate_x_resource_name ()
-{
-  int len = 0;
-  /* Number of valid characters in the resource name.  */
-  int good_count = 0;
-  /* Number of invalid characters in the resource name.  */
-  int bad_count = 0;
-  Lisp_Object new;
-  int i;
-
-  if (!STRINGP (Vx_resource_class))
-    Vx_resource_class = build_string (EMACS_CLASS);
-
-  if (STRINGP (Vx_resource_name))
-    {
-      unsigned char *p = SDATA (Vx_resource_name);
-      int i;
-
-      len = SBYTES (Vx_resource_name);
-
-      /* Only letters, digits, - and _ are valid in resource names.
-        Count the valid characters and count the invalid ones.  */
-      for (i = 0; i < len; i++)
-       {
-         int c = p[i];
-         if (! ((c >= 'a' && c <= 'z')
-                || (c >= 'A' && c <= 'Z')
-                || (c >= '0' && c <= '9')
-                || c == '-' || c == '_'))
-           bad_count++;
-         else
-           good_count++;
-       }
-    }
-  else
-    /* Not a string => completely invalid.  */
-    bad_count = 5, good_count = 0;
-
-  /* If name is valid already, return.  */
-  if (bad_count == 0)
-    return;
-
-  /* If name is entirely invalid, or nearly so, use `emacs'.  */
-  if (good_count == 0
-      || (good_count == 1 && bad_count > 0))
-    {
-      Vx_resource_name = build_string ("emacs");
-      return;
-    }
-
-  /* Name is partly valid.  Copy it and replace the invalid characters
-     with underscores.  */
-
-  Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);
-
-  for (i = 0; i < len; i++)
-    {
-      int c = SREF (new, i);
-      if (! ((c >= 'a' && c <= 'z')
-            || (c >= 'A' && c <= 'Z')
-            || (c >= '0' && c <= '9')
-            || c == '-' || c == '_'))
-       SSET (new, i, '_');
-    }
-}
-
-
-extern char *x_get_string_resource ();
-
-DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
-       doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
-This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
-class, where INSTANCE is the name under which Emacs was invoked, or
-the name specified by the `-name' or `-rn' command-line arguments.
-
-The optional arguments COMPONENT and SUBCLASS add to the key and the
-class, respectively.  You must specify both of them or neither.
-If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
-and the class is `Emacs.CLASS.SUBCLASS'.  */)
-     (attribute, class, component, subclass)
-     Lisp_Object attribute, class, component, subclass;
-{
-  register char *value;
-  char *name_key;
-  char *class_key;
-
-  check_x ();
-
-  CHECK_STRING (attribute);
-  CHECK_STRING (class);
-
-  if (!NILP (component))
-    CHECK_STRING (component);
-  if (!NILP (subclass))
-    CHECK_STRING (subclass);
-  if (NILP (component) != NILP (subclass))
-    error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
-
-  validate_x_resource_name ();
-
-  /* Allocate space for the components, the dots which separate them,
-     and the final '\0'.  Make them big enough for the worst case.  */
-  name_key = (char *) alloca (SBYTES (Vx_resource_name)
-                             + (STRINGP (component)
-                                ? SBYTES (component) : 0)
-                             + SBYTES (attribute)
-                             + 3);
-
-  class_key = (char *) alloca (SBYTES (Vx_resource_class)
-                              + SBYTES (class)
-                              + (STRINGP (subclass)
-                                 ? SBYTES (subclass) : 0)
-                              + 3);
-
-  /* Start with emacs.FRAMENAME for the name (the specific one)
-     and with `Emacs' for the class key (the general one).  */
-  strcpy (name_key, SDATA (Vx_resource_name));
-  strcpy (class_key, SDATA (Vx_resource_class));
-
-  strcat (class_key, ".");
-  strcat (class_key, SDATA (class));
-
-  if (!NILP (component))
-    {
-      strcat (class_key, ".");
-      strcat (class_key, SDATA (subclass));
-
-      strcat (name_key, ".");
-      strcat (name_key, SDATA (component));
-    }
-
-  strcat (name_key, ".");
-  strcat (name_key, SDATA (attribute));
-
-  value = x_get_string_resource (check_x_display_info (Qnil)->xrdb,
-                                name_key, class_key);
-
-  if (value != (char *) 0)
-    return build_string (value);
-  else
-    return Qnil;
-}
-
-/* Get an X resource, like Fx_get_resource, but for display DPYINFO.  */
-
-Lisp_Object
-display_x_get_resource (dpyinfo, attribute, class, component, subclass)
-     struct x_display_info *dpyinfo;
-     Lisp_Object attribute, class, component, subclass;
-{
-  register char *value;
-  char *name_key;
-  char *class_key;
-
-  CHECK_STRING (attribute);
-  CHECK_STRING (class);
-
-  if (!NILP (component))
-    CHECK_STRING (component);
-  if (!NILP (subclass))
-    CHECK_STRING (subclass);
-  if (NILP (component) != NILP (subclass))
-    error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
-
-  validate_x_resource_name ();
-
-  /* Allocate space for the components, the dots which separate them,
-     and the final '\0'.  Make them big enough for the worst case.  */
-  name_key = (char *) alloca (SBYTES (Vx_resource_name)
-                             + (STRINGP (component)
-                                ? SBYTES (component) : 0)
-                             + SBYTES (attribute)
-                             + 3);
-
-  class_key = (char *) alloca (SBYTES (Vx_resource_class)
-                              + SBYTES (class)
-                              + (STRINGP (subclass)
-                                 ? SBYTES (subclass) : 0)
-                              + 3);
-
-  /* Start with emacs.FRAMENAME for the name (the specific one)
-     and with `Emacs' for the class key (the general one).  */
-  strcpy (name_key, SDATA (Vx_resource_name));
-  strcpy (class_key, SDATA (Vx_resource_class));
-
-  strcat (class_key, ".");
-  strcat (class_key, SDATA (class));
-
-  if (!NILP (component))
-    {
-      strcat (class_key, ".");
-      strcat (class_key, SDATA (subclass));
-
-      strcat (name_key, ".");
-      strcat (name_key, SDATA (component));
-    }
-
-  strcat (name_key, ".");
-  strcat (name_key, SDATA (attribute));
-
-  value = x_get_string_resource (dpyinfo->xrdb, name_key, class_key);
-
-  if (value != (char *) 0)
-    return build_string (value);
-  else
-    return Qnil;
-}
-
-/* Used when C code wants a resource value.  */
-
-char *
-x_get_resource_string (attribute, class)
-     char *attribute, *class;
-{
-  char *name_key;
-  char *class_key;
-  struct frame *sf = SELECTED_FRAME ();
-
-  /* Allocate space for the components, the dots which separate them,
-     and the final '\0'.  */
-  name_key = (char *) alloca (SBYTES (Vinvocation_name)
-                             + strlen (attribute) + 2);
-  class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
-                              + strlen (class) + 2);
-
-  sprintf (name_key, "%s.%s",
-          SDATA (Vinvocation_name),
-          attribute);
-  sprintf (class_key, "%s.%s", EMACS_CLASS, class);
-
-  return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
-                               name_key, class_key);
-}
-
-/* Types we might convert a resource string into.  */
-enum resource_types
-{
-  RES_TYPE_NUMBER,
-  RES_TYPE_FLOAT,
-  RES_TYPE_BOOLEAN,
-  RES_TYPE_STRING,
-  RES_TYPE_SYMBOL
-};
-
-/* Return the value of parameter PARAM.
-
-   First search ALIST, then Vdefault_frame_alist, then the X defaults
-   database, using ATTRIBUTE as the attribute name and CLASS as its class.
-
-   Convert the resource to the type specified by desired_type.
-
-   If no default is specified, return Qunbound.  If you call
-   x_get_arg, make sure you deal with Qunbound in a reasonable way,
-   and don't let it get stored in any Lisp-visible variables!  */
-
-static Lisp_Object
-x_get_arg (dpyinfo, alist, param, attribute, class, type)
-     struct x_display_info *dpyinfo;
-     Lisp_Object alist, param;
-     char *attribute;
-     char *class;
-     enum resource_types type;
-{
-  register Lisp_Object tem;
-
-  tem = Fassq (param, alist);
-  if (EQ (tem, Qnil))
-    tem = Fassq (param, Vdefault_frame_alist);
-  if (EQ (tem, Qnil))
-    {
-
-      if (attribute)
-       {
-         tem = display_x_get_resource (dpyinfo,
-                                       build_string (attribute),
-                                       build_string (class),
-                                       Qnil, Qnil);
-
-         if (NILP (tem))
-           return Qunbound;
-
-         switch (type)
-           {
-           case RES_TYPE_NUMBER:
-             return make_number (atoi (SDATA (tem)));
-
-           case RES_TYPE_FLOAT:
-             return make_float (atof (SDATA (tem)));
-
-           case RES_TYPE_BOOLEAN:
-             tem = Fdowncase (tem);
-             if (!strcmp (SDATA (tem), "on")
-                 || !strcmp (SDATA (tem), "true"))
-               return Qt;
-             else
-               return Qnil;
+         }
 
-           case RES_TYPE_STRING:
-             return tem;
+#ifdef USE_GTK
+        gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                              SDATA (name));
+#else /* not USE_GTK */
+       XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
+#endif /* not USE_GTK */
 
-           case RES_TYPE_SYMBOL:
-             /* As a special case, we map the values `true' and `on'
-                to Qt, and `false' and `off' to Qnil.  */
-             {
-               Lisp_Object lower;
-               lower = Fdowncase (tem);
-               if (!strcmp (SDATA (lower), "on")
-                   || !strcmp (SDATA (lower), "true"))
-                 return Qt;
-               else if (!strcmp (SDATA (lower), "off")
-                     || !strcmp (SDATA (lower), "false"))
-                 return Qnil;
-               else
-                 return Fintern (tem, Qnil);
-             }
+       XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+                        &icon);
 
-           default:
-             abort ();
-           }
-       }
-      else
-       return Qunbound;
+       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;
     }
-  return Fcdr (tem);
 }
 
-/* Like x_get_arg, but also record the value in f->param_alist.  */
-
-static Lisp_Object
-x_get_and_record_arg (f, alist, param, attribute, class, type)
+void
+x_set_scroll_bar_default_width (f)
      struct frame *f;
-     Lisp_Object alist, param;
-     char *attribute;
-     char *class;
-     enum resource_types type;
 {
-  Lisp_Object value;
-
-  value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,
-                    attribute, class, type);
-  if (! NILP (value))
-    store_frame_param (f, param, value);
+  int wid = FRAME_COLUMN_WIDTH (f);
 
-  return value;
-}
-
-/* Record in frame F the specified or default value according to ALIST
-   of the parameter named PROP (a Lisp symbol).
-   If no value is specified for PROP, look for an X default for XPROP
-   on the frame named NAME.
-   If that is not found either, use the value DEFLT.  */
-
-static Lisp_Object
-x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
-     struct frame *f;
-     Lisp_Object alist;
-     Lisp_Object prop;
-     Lisp_Object deflt;
-     char *xprop;
-     char *xclass;
-     enum resource_types type;
-{
-  Lisp_Object tem;
+#ifdef USE_TOOLKIT_SCROLL_BARS
+  /* A minimum width of 14 doesn't look good for toolkit scroll bars.  */
+  int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;
+  FRAME_CONFIG_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;
+  FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = width;
+#else
+  /* Make the actual width at least 14 pixels and a multiple of a
+     character width.  */
+  FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
 
-  tem = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, prop, xprop, xclass, type);
-  if (EQ (tem, Qunbound))
-    tem = deflt;
-  x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
-  return tem;
+  /* Use all of that space (aside from required margins) for the
+     scroll bar.  */
+  FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 0;
+#endif
 }
 
-
+\f
 /* Record in frame F the specified or default value according to ALIST
    of the parameter named PROP (a Lisp symbol).  If no value is
    specified for PROP, look for an X default for XPROP on the frame
@@ -3216,209 +2200,6 @@ x_default_scroll_bar_color_parameter (f, alist, prop, xprop, xclass,
 }
 
 
-\f
-DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
-       doc: /* Parse an X-style geometry string STRING.
-Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
-The properties returned may include `top', `left', `height', and `width'.
-The value of `left' or `top' may be an integer,
-or a list (+ N) meaning N pixels relative to top/left corner,
-or a list (- N) meaning -N pixels relative to bottom/right corner.  */)
-     (string)
-     Lisp_Object string;
-{
-  int geometry, x, y;
-  unsigned int width, height;
-  Lisp_Object result;
-
-  CHECK_STRING (string);
-
-  geometry = XParseGeometry ((char *) SDATA (string),
-                            &x, &y, &width, &height);
-
-#if 0
-  if (!!(geometry & XValue) != !!(geometry & YValue))
-    error ("Must specify both x and y position, or neither");
-#endif
-
-  result = Qnil;
-  if (geometry & XValue)
-    {
-      Lisp_Object element;
-
-      if (x >= 0 && (geometry & XNegative))
-       element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
-      else if (x < 0 && ! (geometry & XNegative))
-       element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
-      else
-       element = Fcons (Qleft, make_number (x));
-      result = Fcons (element, result);
-    }
-
-  if (geometry & YValue)
-    {
-      Lisp_Object element;
-
-      if (y >= 0 && (geometry & YNegative))
-       element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
-      else if (y < 0 && ! (geometry & YNegative))
-       element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
-      else
-       element = Fcons (Qtop, make_number (y));
-      result = Fcons (element, result);
-    }
-
-  if (geometry & WidthValue)
-    result = Fcons (Fcons (Qwidth, make_number (width)), result);
-  if (geometry & HeightValue)
-    result = Fcons (Fcons (Qheight, make_number (height)), result);
-
-  return result;
-}
-
-/* Calculate the desired size and position of this window,
-   and return the flags saying which aspects were specified.
-
-   This function does not make the coordinates positive.  */
-
-#define DEFAULT_ROWS 40
-#define DEFAULT_COLS 80
-
-static int
-x_figure_window_size (f, parms)
-     struct frame *f;
-     Lisp_Object parms;
-{
-  register Lisp_Object tem0, tem1, tem2;
-  long window_prompting = 0;
-  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-
-  /* Default values if we fall through.
-     Actually, if that happens we should get
-     window manager prompting.  */
-  SET_FRAME_WIDTH (f, DEFAULT_COLS);
-  f->height = DEFAULT_ROWS;
-  /* Window managers expect that if program-specified
-     positions are not (0,0), they're intentional, not defaults.  */
-  f->output_data.x->top_pos = 0;
-  f->output_data.x->left_pos = 0;
-
-  tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
-  tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
-  tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER);
-  if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
-    {
-      if (!EQ (tem0, Qunbound))
-       {
-         CHECK_NUMBER (tem0);
-         f->height = XINT (tem0);
-       }
-      if (!EQ (tem1, Qunbound))
-       {
-         CHECK_NUMBER (tem1);
-         SET_FRAME_WIDTH (f, XINT (tem1));
-       }
-      if (!NILP (tem2) && !EQ (tem2, Qunbound))
-       window_prompting |= USSize;
-      else
-       window_prompting |= PSize;
-    }
-
-  f->output_data.x->vertical_scroll_bar_extra
-    = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
-       ? 0
-       : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));
-
-  compute_fringe_widths (f, 0);
-
-  f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
-  f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
-
-  tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
-  tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
-  tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER);
-  if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
-    {
-      if (EQ (tem0, Qminus))
-       {
-         f->output_data.x->top_pos = 0;
-         window_prompting |= YNegative;
-       }
-      else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
-              && CONSP (XCDR (tem0))
-              && INTEGERP (XCAR (XCDR (tem0))))
-       {
-         f->output_data.x->top_pos = - XINT (XCAR (XCDR (tem0)));
-         window_prompting |= YNegative;
-       }
-      else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
-              && CONSP (XCDR (tem0))
-              && INTEGERP (XCAR (XCDR (tem0))))
-       {
-         f->output_data.x->top_pos = XINT (XCAR (XCDR (tem0)));
-       }
-      else if (EQ (tem0, Qunbound))
-       f->output_data.x->top_pos = 0;
-      else
-       {
-         CHECK_NUMBER (tem0);
-         f->output_data.x->top_pos = XINT (tem0);
-         if (f->output_data.x->top_pos < 0)
-           window_prompting |= YNegative;
-       }
-
-      if (EQ (tem1, Qminus))
-       {
-         f->output_data.x->left_pos = 0;
-         window_prompting |= XNegative;
-       }
-      else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
-              && CONSP (XCDR (tem1))
-              && INTEGERP (XCAR (XCDR (tem1))))
-       {
-         f->output_data.x->left_pos = - XINT (XCAR (XCDR (tem1)));
-         window_prompting |= XNegative;
-       }
-      else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
-              && CONSP (XCDR (tem1))
-              && INTEGERP (XCAR (XCDR (tem1))))
-       {
-         f->output_data.x->left_pos = XINT (XCAR (XCDR (tem1)));
-       }
-      else if (EQ (tem1, Qunbound))
-       f->output_data.x->left_pos = 0;
-      else
-       {
-         CHECK_NUMBER (tem1);
-         f->output_data.x->left_pos = XINT (tem1);
-         if (f->output_data.x->left_pos < 0)
-           window_prompting |= XNegative;
-       }
-
-      if (!NILP (tem2) && ! EQ (tem2, Qunbound))
-       window_prompting |= USPosition;
-      else
-       window_prompting |= PPosition;
-    }
-
-  if (f->output_data.x->want_fullscreen != FULLSCREEN_NONE)
-    {
-      int left, top;
-      int width, height;
-
-      /* It takes both for some WM:s to place it where we want */
-      window_prompting = USPosition | PPosition;
-      x_fullscreen_adjust (f, &width, &height, &top, &left);
-      f->width = width;
-      f->height = height;
-      f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
-      f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
-      f->output_data.x->left_pos = left;
-      f->output_data.x->top_pos = top;
-    }
-
-  return window_prompting;
-}
 
 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
 
@@ -3510,7 +2291,7 @@ static XFontSet xic_create_xfontset P_ ((struct frame *, char *));
 static XIMStyle best_xim_style P_ ((XIMStyles *, XIMStyles *));
 
 
-/* Supported XIM styles, ordered by preferenc.  */
+/* Supported XIM styles, ordered by preference.  */
 
 static XIMStyle supported_xim_styles[] =
 {
@@ -3675,8 +2456,8 @@ create_frame_xic (f)
 
       xic = XCreateIC (xim,
                       XNInputStyle, xic_style,
-                      XNClientWindow, FRAME_X_WINDOW(f),
-                      XNFocusWindow, FRAME_X_WINDOW(f),
+                      XNClientWindow, FRAME_X_WINDOW (f),
+                      XNFocusWindow, FRAME_X_WINDOW (f),
                       XNStatusAttributes, status_attr,
                       XNPreeditAttributes, preedit_attr,
                       NULL);
@@ -3720,7 +2501,7 @@ xic_set_preeditarea (w, x, y)
   XVaNestedList attr;
   XPoint spot;
 
-  spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);
+  spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x) + WINDOW_LEFT_FRINGE_WIDTH (w);
   spot.y = WINDOW_TO_FRAME_PIXEL_Y (w, y) + FONT_BASE (FRAME_FONT (f));
   attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
   XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL);
@@ -3759,15 +2540,15 @@ xic_set_statusarea (f)
 
   area.width  = needed->width;
   area.height = needed->height;
-  area.x = PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
-  area.y = (PIXEL_HEIGHT (f) - area.height
+  area.x = FRAME_PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
+  area.y = (FRAME_PIXEL_HEIGHT (f) - area.height
            - FRAME_MENUBAR_HEIGHT (f)
            - FRAME_TOOLBAR_HEIGHT (f)
             - FRAME_INTERNAL_BORDER_WIDTH (f));
   XFree (needed);
 
   attr = XVaCreateNestedList (0, XNArea, &area, NULL);
-  XSetICValues(xic, XNStatusAttributes, attr, NULL);
+  XSetICValues (xic, XNStatusAttributes, attr, NULL);
   XFree (attr);
 }
 
@@ -3838,7 +2619,7 @@ x_window (f, window_prompting, minibuffer_only)
   XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
   XtSetArg (al[ac], XtNinput, 1); ac++;
   XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
-  XtSetArg (al[ac], XtNborderWidth, f->output_data.x->border_width); ac++;
+  XtSetArg (al[ac], XtNborderWidth, f->border_width); ac++;
   XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
   XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
   XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
@@ -3887,7 +2668,7 @@ x_window (f, window_prompting, minibuffer_only)
   {
     int len;
     char *tem, shell_position[32];
-    Arg al[2];
+    Arg al[10];
     int ac = 0;
     int extra_borders = 0;
     int menubar_size
@@ -3923,9 +2704,9 @@ x_window (f, window_prompting, minibuffer_only)
        is a user-specified or program-specified one.
        We pass that information later, in x_wm_set_size_hints.  */
     {
-      int left = f->output_data.x->left_pos;
+      int left = f->left_pos;
       int xneg = window_prompting & XNegative;
-      int top = f->output_data.x->top_pos;
+      int top = f->top_pos;
       int yneg = window_prompting & YNegative;
       if (xneg)
        left = -left;
@@ -3934,14 +2715,24 @@ x_window (f, window_prompting, minibuffer_only)
 
       if (window_prompting & USPosition)
        sprintf (shell_position, "=%dx%d%c%d%c%d",
-                PIXEL_WIDTH (f) + extra_borders,
-                PIXEL_HEIGHT (f) + menubar_size + extra_borders,
+                FRAME_PIXEL_WIDTH (f) + extra_borders,
+                FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders,
                 (xneg ? '-' : '+'), left,
                 (yneg ? '-' : '+'), top);
       else
-       sprintf (shell_position, "=%dx%d",
-                PIXEL_WIDTH (f) + extra_borders,
-                PIXEL_HEIGHT (f) + menubar_size + extra_borders);
+        {
+          sprintf (shell_position, "=%dx%d",
+                   FRAME_PIXEL_WIDTH (f) + extra_borders,
+                   FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders);
+
+          /* Setting x and y when the position is not specified in
+             the geometry string will set program position in the WM hints.
+             If Emacs had just one program position, we could set it in
+             fallback resources, but since each make-frame call can specify
+             different program positions, this is easier.  */
+          XtSetArg (al[ac], XtNx, left); ac++;
+          XtSetArg (al[ac], XtNy, top); ac++;
+        }
     }
 
     len = strlen (shell_position) + 1;
@@ -3968,9 +2759,8 @@ x_window (f, window_prompting, minibuffer_only)
 
 #ifdef HAVE_X_I18N
   FRAME_XIC (f) = NULL;
-#ifdef USE_XIM
-  create_frame_xic (f);
-#endif
+  if (use_xim)
+    create_frame_xic (f);
 #endif
 
   f->output_data.x->wm_hints.input = True;
@@ -4001,7 +2791,7 @@ x_window (f, window_prompting, minibuffer_only)
     {
       /* XIM server might require some X events. */
       unsigned long fevent = NoEventMask;
-      XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
+      XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
       attributes.event_mask |= fevent;
     }
 #endif /* HAVE_X_I18N */
@@ -4047,31 +2837,32 @@ x_window (f)
 
 #ifdef HAVE_X_I18N
   FRAME_XIC (f) = NULL;
-#ifdef USE_XIM
-  BLOCK_INPUT;
-  create_frame_xic (f);
-  if (FRAME_XIC (f))
-    {
-      /* XIM server might require some X events. */
-      unsigned long fevent = NoEventMask;
-      XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
+if (use_xim)
+  {
+    BLOCK_INPUT;
+    create_frame_xic (f);
+    if (FRAME_XIC (f))
+      {
+       /* XIM server might require some X events. */
+       unsigned long fevent = NoEventMask;
+       XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
 
-      if (fevent != NoEventMask)
-        {
-          XSetWindowAttributes attributes;
-          XWindowAttributes wattr;
-          unsigned long attribute_mask;
-
-          XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                                &wattr);
-          attributes.event_mask = wattr.your_event_mask | fevent;
-          attribute_mask = CWEventMask;
-          XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                                   attribute_mask, &attributes);
-        }
-    }
-  UNBLOCK_INPUT;
-#endif
+       if (fevent != NoEventMask)
+         {
+           XSetWindowAttributes attributes;
+           XWindowAttributes wattr;
+           unsigned long attribute_mask;
+
+           XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                                 &wattr);
+           attributes.event_mask = wattr.your_event_mask | fevent;
+           attribute_mask = CWEventMask;
+           XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                                    attribute_mask, &attributes);
+         }
+      }
+    UNBLOCK_INPUT;
+  }
 #endif
 }
 
@@ -4101,29 +2892,30 @@ x_window (f)
   FRAME_X_WINDOW (f)
     = XCreateWindow (FRAME_X_DISPLAY (f),
                     f->output_data.x->parent_desc,
-                    f->output_data.x->left_pos,
-                    f->output_data.x->top_pos,
-                    PIXEL_WIDTH (f), PIXEL_HEIGHT (f),
-                    f->output_data.x->border_width,
+                    f->left_pos,
+                    f->top_pos,
+                    FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f),
+                    f->border_width,
                     CopyFromParent, /* depth */
                     InputOutput, /* class */
                     FRAME_X_VISUAL (f),
                     attribute_mask, &attributes);
 
 #ifdef HAVE_X_I18N
-#ifdef USE_XIM
-  create_frame_xic (f);
-  if (FRAME_XIC (f))
+  if (use_xim)
     {
-      /* XIM server might require some X events. */
-      unsigned long fevent = NoEventMask;
-      XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
-      attributes.event_mask |= fevent;
-      attribute_mask = CWEventMask;
-      XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                              attribute_mask, &attributes);
+      create_frame_xic (f);
+      if (FRAME_XIC (f))
+       {
+         /* XIM server might require some X events. */
+         unsigned long fevent = NoEventMask;
+         XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
+         attributes.event_mask |= fevent;
+         attribute_mask = CWEventMask;
+         XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                                  attribute_mask, &attributes);
+       }
     }
-#endif
 #endif /* HAVE_X_I18N */
 
   validate_x_resource_name ();
@@ -4195,8 +2987,8 @@ x_icon (f, parms)
 
   /* Set the position of the icon.  Note that twm groups all
      icons in an icon window.  */
-  icon_x = x_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
-  icon_y = x_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
+  icon_x = x_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
+  icon_y = x_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_NUMBER (icon_x);
@@ -4248,7 +3040,7 @@ x_make_gc (f)
      Note that many default values are used.  */
 
   /* Normal video */
-  gc_values.font = f->output_data.x->font->fid;
+  gc_values.font = FRAME_FONT (f)->fid;
   gc_values.foreground = f->output_data.x->foreground_pixel;
   gc_values.background = f->output_data.x->background_pixel;
   gc_values.line_width = 0;    /* Means 1 using fast algorithm.  */
@@ -4454,7 +3246,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
   f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
   bzero (f->output_data.x, sizeof (struct x_output));
   f->output_data.x->icon_bitmap = -1;
-  f->output_data.x->fontset = -1;
+  FRAME_FONTSET (f) = -1;
   f->output_data.x->scroll_bar_foreground_pixel = -1;
   f->output_data.x->scroll_bar_background_pixel = -1;
 #ifdef USE_TOOLKIT_SCROLL_BARS
@@ -4582,7 +3374,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
 #ifdef USE_LUCID
   /* Prevent lwlib/xlwmenu.c from crashing because of a bug
      whereby it fails to get any font.  */
-  xlwmenu_default_font = f->output_data.x->font;
+  xlwmenu_default_font = FRAME_FONT (f);
 #endif
 
   x_default_parameter (f, parms, Qborder_width, make_number (2),
@@ -4659,53 +3451,8 @@ This function is an internal primitive--use `make-frame' instead.  */)
 
   f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
 
-  /* Add the tool-bar height to the initial frame height so that the
-     user gets a text display area of the size he specified with -g or
-     via .Xdefaults.  Later changes of the tool-bar height don't
-     change the frame size.  This is done so that users can create
-     tall Emacs frames without having to guess how tall the tool-bar
-     will get.  */
-  if (FRAME_TOOL_BAR_LINES (f))
-    {
-      int margin, relief, bar_height;
-
-      relief = (tool_bar_button_relief >= 0
-               ? tool_bar_button_relief
-               : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
-
-      if (INTEGERP (Vtool_bar_button_margin)
-         && XINT (Vtool_bar_button_margin) > 0)
-       margin = XFASTINT (Vtool_bar_button_margin);
-      else if (CONSP (Vtool_bar_button_margin)
-              && INTEGERP (XCDR (Vtool_bar_button_margin))
-              && XINT (XCDR (Vtool_bar_button_margin)) > 0)
-       margin = XFASTINT (XCDR (Vtool_bar_button_margin));
-      else
-       margin = 0;
-
-      bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
-      f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
-    }
-
   /* Compute the size of the X window.  */
-  window_prompting = x_figure_window_size (f, parms);
-
-  if (window_prompting & XNegative)
-    {
-      if (window_prompting & YNegative)
-       f->output_data.x->win_gravity = SouthEastGravity;
-      else
-       f->output_data.x->win_gravity = NorthEastGravity;
-    }
-  else
-    {
-      if (window_prompting & YNegative)
-       f->output_data.x->win_gravity = SouthWestGravity;
-      else
-       f->output_data.x->win_gravity = NorthWestGravity;
-    }
-
-  f->output_data.x->size_hint_flags = window_prompting;
+  window_prompting = x_figure_window_size (f, parms, 1);
 
   tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
@@ -4739,23 +3486,16 @@ This function is an internal primitive--use `make-frame' instead.  */)
                       "scrollBarWidth", "ScrollBarWidth",
                       RES_TYPE_NUMBER);
 
-  /* Dimensions, especially f->height, must be done via change_frame_size.
+  /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
-     f->height.  */
-  width = f->width;
-  height = f->height;
+     FRAME_LINES (f).  */
+  width = FRAME_COLS (f);
+  height = FRAME_LINES (f);
 
-  f->height = 0;
-  SET_FRAME_WIDTH (f, 0);
+  SET_FRAME_COLS (f, 0);
+  FRAME_LINES (f) = 0;
   change_frame_size (f, height, width, 1, 0, 0);
 
-  /* Set up faces after all frame parameters are known.  This call
-     also merges in face attributes specified for new frames.  If we
-     don't do this, the `menu' face for instance won't have the right
-     colors, and the menu bar won't appear in the specified colors for
-     new frames.  */
-  call1 (Qface_set_after_frame_default, frame);
-
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   /* Create the menu bar.  */
   if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
@@ -4802,6 +3542,19 @@ This function is an internal primitive--use `make-frame' instead.  */)
        ;
     }
 
+  /* Set the WM leader property.  GTK does this itself, so this is not
+     needed when using GTK.  */
+  if (dpyinfo->client_leader_window != 0)
+    {
+      BLOCK_INPUT;
+      XChangeProperty (FRAME_X_DISPLAY (f),
+                       FRAME_OUTER_WINDOW (f),
+                       dpyinfo->Xatom_wm_client_leader,
+                       XA_WINDOW, 32, PropModeReplace,
+                       (char *) &dpyinfo->client_leader_window, 1);
+      UNBLOCK_INPUT;
+    }
+
   UNGCPRO;
 
   /* Make sure windows on this frame appear in calls to next-window
@@ -5197,28 +3950,28 @@ int
 x_pixel_width (f)
      register struct frame *f;
 {
-  return PIXEL_WIDTH (f);
+  return FRAME_PIXEL_WIDTH (f);
 }
 
 int
 x_pixel_height (f)
      register struct frame *f;
 {
-  return PIXEL_HEIGHT (f);
+  return FRAME_PIXEL_HEIGHT (f);
 }
 
 int
 x_char_width (f)
      register struct frame *f;
 {
-  return FONT_WIDTH (f->output_data.x->font);
+  return FRAME_COLUMN_WIDTH (f);
 }
 
 int
 x_char_height (f)
      register struct frame *f;
 {
-  return f->output_data.x->line_height;
+  return FRAME_LINE_HEIGHT (f);
 }
 
 int
@@ -5467,9 +4220,6 @@ If DISPLAY is nil, that stands for the selected frame's display.  */)
   for (i = 0; i < dpyinfo->n_fonts; i++)
     if (dpyinfo->font_table[i].name)
       {
-       if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
-         xfree (dpyinfo->font_table[i].full_name);
-       xfree (dpyinfo->font_table[i].name);
        XFreeFont (dpyinfo->display, dpyinfo->font_table[i].font);
       }
 
@@ -5545,11 +4295,6 @@ x_sync (f)
 
 static struct image_type *image_types;
 
-/* The symbol `image' which is the car of the lists used to represent
-   images in Lisp.  */
-
-extern Lisp_Object Qimage;
-
 /* The symbol `xbm' which is used as the type symbol for XBM images.  */
 
 Lisp_Object Qxbm;
@@ -5629,7 +4374,7 @@ valid_image_p (object)
 {
   int valid_p = 0;
 
-  if (CONSP (object) && EQ (XCAR (object), Qimage))
+  if (IMAGEP (object))
     {
       Lisp_Object tem;
 
@@ -5731,7 +4476,7 @@ parse_image_spec (spec, keywords, nkeywords, type)
   int i;
   Lisp_Object plist;
 
-  if (!CONSP (spec) || !EQ (XCAR (spec), Qimage))
+  if (!IMAGEP (spec))
     return 0;
 
   plist = XCDR (spec);
@@ -5909,8 +4654,8 @@ or omitted means use the selected frame.  */)
       int height = img->height + 2 * img->vmargin;
 
       if (NILP (pixels))
-       size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
-                     make_float ((double) height / CANON_Y_UNIT (f)));
+       size = Fcons (make_float ((double) width / FRAME_COLUMN_WIDTH (f)),
+                     make_float ((double) height / FRAME_LINE_HEIGHT (f)));
       else
        size = Fcons (make_number (width), make_number (height));
     }
@@ -7681,6 +6426,14 @@ xpm_lookup_color (f, color_name, color)
                                       color->blue);
       p = xpm_cache_color (f, color_name, color, h);
     }
+  /* You get `opaque' at least from ImageMagick converting pbm to xpm
+     with transparency, and it's useful.  */
+  else if (strcmp ("opaque", color_name) == 0)
+    {
+      bzero (color, sizeof (XColor));  /* Is this necessary/correct?  */
+      color->pixel = FRAME_FOREGROUND_PIXEL (f);
+      p = xpm_cache_color (f, color_name, color, h);
+    }
 
   return p != NULL;
 }
@@ -8002,7 +6755,37 @@ lookup_rgb_color (f, r, g, b)
   unsigned hash = CT_HASH_RGB (r, g, b);
   int i = hash % CT_SIZE;
   struct ct_color *p;
+  struct x_display_info *dpyinfo;
+
+  /* Handle TrueColor visuals specially, which improves performance by
+     two orders of magnitude.  Freeing colors on TrueColor visuals is
+     a nop, and pixel colors specify RGB values directly.  See also
+     the Xlib spec, chapter 3.1.  */
+  dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  if (dpyinfo->red_bits > 0)
+    {
+      unsigned long pr, pg, pb;
 
+      /* Apply gamma-correction like normal color allocation does.  */
+      if (f->gamma)
+       {
+         XColor color;
+         color.red = r, color.green = g, color.blue = b;
+         gamma_correct (f, &color);
+         r = color.red, g = color.green, b = color.blue;
+       }
+
+      /* Scale down RGB values to the visual's bits per RGB, and shift
+        them to the right position in the pixel color.  Note that the
+        original RGB values are 16-bit values, as usual in X.  */
+      pr = (r >> (16 - dpyinfo->red_bits))   << dpyinfo->red_offset;
+      pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
+      pb = (b >> (16 - dpyinfo->blue_bits))  << dpyinfo->blue_offset;
+
+      /* Assemble the pixel color.  */
+      return pr | pg | pb;
+    }
+  
   for (p = ct_table[i]; p; p = p->next)
     if (p->r == r && p->g == g && p->b == b)
       break;
@@ -8853,7 +7636,11 @@ pbm_load (f, img)
 
 #if HAVE_PNG
 
-#include <png.h>
+#if defined HAVE_LIBPNG_PNG_H
+# include <libpng/png.h>
+#else
+# include <png.h>
+#endif
 
 /* Function prototypes.  */
 
@@ -9004,8 +7791,7 @@ png_load (f, img)
   png_byte channels;
   png_uint_32 row_bytes;
   int transparent_p;
-  double screen_gamma, image_gamma;
-  int intent;
+  double screen_gamma;
   struct png_memory_storage tbr;  /* Data to be read */
 
   /* Find out what file to load.  */
@@ -9144,19 +7930,22 @@ png_load (f, img)
   screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);
 
 #if 0 /* Avoid double gamma correction for PNG images. */
-  /* Tell the PNG lib to handle gamma correction for us.  */
+  { /* Tell the PNG lib to handle gamma correction for us.  */
+    int intent;
+    double image_gamma;
 #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
-  if (png_get_sRGB (png_ptr, info_ptr, &intent))
-    /* The libpng documentation says this is right in this case.  */
-    png_set_gamma (png_ptr, screen_gamma, 0.45455);
-  else
+    if (png_get_sRGB (png_ptr, info_ptr, &intent))
+      /* The libpng documentation says this is right in this case.  */
+      png_set_gamma (png_ptr, screen_gamma, 0.45455);
+    else
 #endif
-  if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
-    /* Image contains gamma information.  */
-    png_set_gamma (png_ptr, screen_gamma, image_gamma);
-  else
-    /* Use the standard default for the image gamma.  */
-    png_set_gamma (png_ptr, screen_gamma, 0.45455);
+      if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
+       /* Image contains gamma information.  */
+       png_set_gamma (png_ptr, screen_gamma, image_gamma);
+      else
+       /* Use the standard default for the image gamma.  */
+       png_set_gamma (png_ptr, screen_gamma, 0.45455);
+  }
 #endif /* if 0 */
 
   /* Handle alpha channel by combining the image with a background
@@ -10251,7 +9040,7 @@ gif_load (f, img)
       memsrc.len = SBYTES (specified_data);
       memsrc.index = 0;
 
-      gif = DGifOpen(&memsrc, gif_read_from_memory);
+      gif = DGifOpen (&memsrc, gif_read_from_memory);
       if (!gif)
        {
          image_error ("Cannot open memory source `%s'", img->spec, Qnil);
@@ -10684,24 +9473,85 @@ x_kill_gs_process (pixmap, f)
  ***********************************************************************/
 
 DEFUN ("x-change-window-property", Fx_change_window_property,
-       Sx_change_window_property, 2, 3, 0,
+       Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-PROP and VALUE must be strings.  FRAME nil or omitted means use the
-selected frame.  Value is VALUE.  */)
-     (prop, value, frame)
-     Lisp_Object frame, prop, value;
+PROP must be a string.
+VALUE may be a string or a list of conses, numbers and/or strings.
+If an element in the list is a string, it is converted to
+an Atom and the value of the Atom is used.  If an element is a cons,
+it is converted to a 32 bit number where the car is the 16 top bits and the
+cdr is the lower 16 bits.
+FRAME nil or omitted means use the selected frame.
+If TYPE is given and non-nil, it is the name of the type of VALUE.
+If TYPE is not given or nil, the type is STRING.
+FORMAT gives the size in bits of each element if VALUE is a list.
+It must be one of 8, 16 or 32.
+If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
+If OUTER_P is non-nil, the property is changed for the outer X window of
+FRAME.  Default is to change on the edit X window.
+
+Value is VALUE.  */)
+     (prop, value, frame, type, format, outer_p)
+     Lisp_Object prop, value, frame, type, format, outer_p;
 {
   struct frame *f = check_x_frame (frame);
   Atom prop_atom;
+  Atom target_type = XA_STRING;
+  int element_format = 8;
+  unsigned char *data;
+  int nelements;
+  Window w;
 
   CHECK_STRING (prop);
-  CHECK_STRING (value);
+
+  if (! NILP (format))
+    {
+      CHECK_NUMBER (format);
+      element_format = XFASTINT (format);
+
+      if (element_format != 8 && element_format != 16
+          && element_format != 32)
+        error ("FORMAT must be one of 8, 16 or 32");
+    }
+
+  if (CONSP (value))
+    {
+      nelements = x_check_property_data (value);
+      if (nelements == -1)
+        error ("Bad data in VALUE, must be number, string or cons");
+
+      if (element_format == 8)
+        data = (unsigned char *) xmalloc (nelements);
+      else if (element_format == 16)
+        data = (unsigned char *) xmalloc (nelements*2);
+      else
+        data = (unsigned char *) xmalloc (nelements*4);
+
+      x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
+    }
+  else
+    {
+      CHECK_STRING (value);
+      data = SDATA (value);
+      nelements = SCHARS (value);
+    }
 
   BLOCK_INPUT;
   prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
-  XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                  prop_atom, XA_STRING, 8, PropModeReplace,
-                  SDATA (value), SCHARS (value));
+  if (! NILP (type))
+    {
+      CHECK_STRING (type);
+      target_type = XInternAtom (FRAME_X_DISPLAY (f), SDATA (type), False);
+    }
+
+  if (! NILP (outer_p)) w = FRAME_OUTER_WINDOW (f);
+  else w = FRAME_X_WINDOW (f);
+  XChangeProperty (FRAME_X_DISPLAY (f), w,
+                  prop_atom, target_type, element_format, PropModeReplace,
+                  data, nelements);
+
+  if (CONSP (value)) xfree (data);
 
   /* Make sure the property is set when we return.  */
   XFlush (FRAME_X_DISPLAY (f));
@@ -10735,13 +9585,20 @@ FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
 
 
 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
-       1, 2, 0,
+       1, 6, 0,
        doc: /* Value is the value of window property PROP on FRAME.
-If FRAME is nil or omitted, use the selected frame.  Value is nil
-if FRAME hasn't a property with name PROP or if PROP has no string
-value.  */)
-     (prop, frame)
-     Lisp_Object prop, frame;
+If FRAME is nil or omitted, use the selected frame.
+If TYPE is nil or omitted, get the property as a string.  Otherwise TYPE
+is the name of the Atom that denotes the type expected.
+If SOURCE is non-nil, get the property on that window instead of from
+FRAME.  The number 0 denotes the root window.
+If DELETE_P is non-nil, delete the property after retreiving it.
+If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
+
+Value is nil if FRAME hasn't a property with name PROP or if PROP has
+no value of TYPE.  */)
+     (prop, frame, type, source, delete_p, vector_ret_p)
+     Lisp_Object prop, frame, type, source, delete_p, vector_ret_p;
 {
   struct frame *f = check_x_frame (frame);
   Atom prop_atom;
@@ -10749,14 +9606,43 @@ value.  */)
   Lisp_Object prop_value = Qnil;
   char *tmp_data = NULL;
   Atom actual_type;
+  Atom target_type = XA_STRING;
   int actual_format;
   unsigned long actual_size, bytes_remaining;
+  Window target_window = FRAME_X_WINDOW (f);
+  struct gcpro gcpro1;
 
+  GCPRO1 (prop_value);
   CHECK_STRING (prop);
+
+  if (! NILP (source))
+    {
+      if (NUMBERP (source))
+        {
+          if (FLOATP (source))
+            target_window = (Window) XFLOAT (source);
+          else
+            target_window = XFASTINT (source);
+
+          if (target_window == 0)
+            target_window = FRAME_X_DISPLAY_INFO (f)->root_window;
+        }
+      else if (CONSP (source))
+        target_window = cons_to_long (source);
+    }
+
   BLOCK_INPUT;
+  if (STRINGP (type))
+    {
+      if (strcmp ("AnyPropertyType", SDATA (type)) == 0)
+        target_type = AnyPropertyType;
+      else
+        target_type = XInternAtom (FRAME_X_DISPLAY (f), SDATA (type), False);
+    }
+
   prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
-  rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                          prop_atom, 0, 0, False, XA_STRING,
+  rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
+                          prop_atom, 0, 0, False, target_type,
                           &actual_type, &actual_format, &actual_size,
                           &bytes_remaining, (unsigned char **) &tmp_data);
   if (rc == Success)
@@ -10766,19 +9652,29 @@ value.  */)
       XFree (tmp_data);
       tmp_data = NULL;
 
-      rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+      rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
                               prop_atom, 0, bytes_remaining,
-                              False, XA_STRING,
+                              ! NILP (delete_p), target_type,
                               &actual_type, &actual_format,
                               &actual_size, &bytes_remaining,
                               (unsigned char **) &tmp_data);
       if (rc == Success && tmp_data)
-       prop_value = make_string (tmp_data, size);
+        {
+          if (NILP (vector_ret_p))
+            prop_value = make_string (tmp_data, size);
+          else
+            prop_value = x_property_data_to_lisp (f,
+                                                  (unsigned char *) tmp_data,
+                                                  actual_type,
+                                                  actual_format,
+                                                  actual_size);
+        }
 
-      XFree (tmp_data);
+      if (tmp_data) XFree (tmp_data);
     }
 
   UNBLOCK_INPUT;
+  UNGCPRO;
   return prop_value;
 }
 
@@ -11058,7 +9954,7 @@ x_create_tip_frame (dpyinfo, parms, text)
   XSETFRAME (frame, f);
 
   buffer = Fget_buffer_create (build_string (" *tip*"));
-  Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer);
+  Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
   old_buffer = current_buffer;
   set_buffer_internal_1 (XBUFFER (buffer));
   current_buffer->truncate_lines = Qnil;
@@ -11077,7 +9973,7 @@ x_create_tip_frame (dpyinfo, parms, text)
   f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
   bzero (f->output_data.x, sizeof (struct x_output));
   f->output_data.x->icon_bitmap = -1;
-  f->output_data.x->fontset = -1;
+  FRAME_FONTSET (f) = -1;
   f->output_data.x->scroll_bar_foreground_pixel = -1;
   f->output_data.x->scroll_bar_background_pixel = -1;
 #ifdef USE_TOOLKIT_SCROLL_BARS
@@ -11216,24 +10112,9 @@ x_create_tip_frame (dpyinfo, parms, text)
   init_frame_faces (f);
 
   f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
-  window_prompting = x_figure_window_size (f, parms);
 
-  if (window_prompting & XNegative)
-    {
-      if (window_prompting & YNegative)
-       f->output_data.x->win_gravity = SouthEastGravity;
-      else
-       f->output_data.x->win_gravity = NorthEastGravity;
-    }
-  else
-    {
-      if (window_prompting & YNegative)
-       f->output_data.x->win_gravity = SouthWestGravity;
-      else
-       f->output_data.x->win_gravity = NorthWestGravity;
-    }
+  window_prompting = x_figure_window_size (f, parms, 0);
 
-  f->output_data.x->size_hint_flags = window_prompting;
   {
     XSetWindowAttributes attrs;
     unsigned long mask;
@@ -11273,13 +10154,13 @@ x_create_tip_frame (dpyinfo, parms, text)
   x_default_parameter (f, parms, Qcursor_type, Qbox,
                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
 
-  /* Dimensions, especially f->height, must be done via change_frame_size.
+  /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
-     f->height.  */
-  width = f->width;
-  height = f->height;
-  f->height = 0;
-  SET_FRAME_WIDTH (f, 0);
+     FRAME_LINES (f).  */
+  width = FRAME_COLS (f);
+  height = FRAME_LINES (f);
+  SET_FRAME_COLS (f, 0);
+  FRAME_LINES (f) = 0;
   change_frame_size (f, height, width, 1, 0, 0);
 
   /* Add `tooltip' frame parameter's default value. */
@@ -11468,8 +10349,8 @@ Text larger than the specified size is clipped.  */)
            }
 
          BLOCK_INPUT;
-         compute_tip_xy (f, parms, dx, dy, PIXEL_WIDTH (f),
-                         PIXEL_HEIGHT (f), &root_x, &root_y);
+         compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
+                         FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
          XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                       root_x, root_y);
          UNBLOCK_INPUT;
@@ -11504,7 +10385,7 @@ Text larger than the specified size is clipped.  */)
 
   /* Set up the frame's root window.  */
   w = XWINDOW (FRAME_ROOT_WINDOW (f));
-  w->left = w->top = make_number (0);
+  w->left_col = w->top_line = make_number (0);
 
   if (CONSP (Vx_max_tooltip_size)
       && INTEGERP (XCAR (Vx_max_tooltip_size))
@@ -11512,16 +10393,16 @@ Text larger than the specified size is clipped.  */)
       && INTEGERP (XCDR (Vx_max_tooltip_size))
       && XINT (XCDR (Vx_max_tooltip_size)) > 0)
     {
-      w->width = XCAR (Vx_max_tooltip_size);
-      w->height = XCDR (Vx_max_tooltip_size);
+      w->total_cols = XCAR (Vx_max_tooltip_size);
+      w->total_lines = XCDR (Vx_max_tooltip_size);
     }
   else
     {
-      w->width = make_number (80);
-      w->height = make_number (40);
+      w->total_cols = make_number (80);
+      w->total_lines = make_number (40);
     }
 
-  f->window_width = XINT (w->width);
+  FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
   adjust_glyphs (f);
   w->pseudo_window_p = 1;
 
@@ -11845,7 +10726,6 @@ selection dialog's entry field, if MUSTMATCH is non-nil.")
   int count = specpdl_ptr - specpdl;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   char *cdef_file;
-  char *cprompt;
 
   GCPRO5 (prompt, dir, default_filename, mustmatch, file);
   CHECK_STRING (prompt);
@@ -11973,6 +10853,42 @@ usual X keysyms.  */)
                            Initialization
  ***********************************************************************/
 
+/* Keep this list in the same order as frame_parms in frame.c.
+   Use 0 for unsupported frame parameters.  */
+
+frame_parm_handler x_frame_parm_handlers[] =
+{
+  x_set_autoraise,
+  x_set_autolower,
+  x_set_background_color,
+  x_set_border_color,
+  x_set_border_width,
+  x_set_cursor_color,
+  x_set_cursor_type,
+  x_set_font,
+  x_set_foreground_color,
+  x_set_icon_name,
+  x_set_icon_type,
+  x_set_internal_border_width,
+  x_set_menu_bar_lines,
+  x_set_mouse_color,
+  x_explicitly_set_name,
+  x_set_scroll_bar_width,
+  x_set_title,
+  x_set_unsplittable,
+  x_set_vertical_scroll_bars,
+  x_set_visibility,
+  x_set_tool_bar_lines,
+  x_set_scroll_bar_foreground,
+  x_set_scroll_bar_background,
+  x_set_screen_gamma,
+  x_set_line_spacing,
+  x_set_fringe_width,
+  x_set_fringe_width,
+  x_set_wait_for_wm,
+  x_set_fullscreen,
+};
+
 void
 syms_of_xfns ()
 {
@@ -11982,86 +10898,18 @@ syms_of_xfns ()
   /* The section below is built by the lisp expression at the top of the file,
      just above where these variables are declared.  */
   /*&&& init symbols here &&&*/
-  Qauto_raise = intern ("auto-raise");
-  staticpro (&Qauto_raise);
-  Qauto_lower = intern ("auto-lower");
-  staticpro (&Qauto_lower);
-  Qborder_color = intern ("border-color");
-  staticpro (&Qborder_color);
-  Qborder_width = intern ("border-width");
-  staticpro (&Qborder_width);
-  Qcursor_color = intern ("cursor-color");
-  staticpro (&Qcursor_color);
-  Qcursor_type = intern ("cursor-type");
-  staticpro (&Qcursor_type);
-  Qgeometry = intern ("geometry");
-  staticpro (&Qgeometry);
-  Qicon_left = intern ("icon-left");
-  staticpro (&Qicon_left);
-  Qicon_top = intern ("icon-top");
-  staticpro (&Qicon_top);
-  Qicon_type = intern ("icon-type");
-  staticpro (&Qicon_type);
-  Qicon_name = intern ("icon-name");
-  staticpro (&Qicon_name);
-  Qinternal_border_width = intern ("internal-border-width");
-  staticpro (&Qinternal_border_width);
-  Qleft = intern ("left");
-  staticpro (&Qleft);
-  Qright = intern ("right");
-  staticpro (&Qright);
-  Qmouse_color = intern ("mouse-color");
-  staticpro (&Qmouse_color);
   Qnone = intern ("none");
   staticpro (&Qnone);
-  Qparent_id = intern ("parent-id");
-  staticpro (&Qparent_id);
-  Qscroll_bar_width = intern ("scroll-bar-width");
-  staticpro (&Qscroll_bar_width);
   Qsuppress_icon = intern ("suppress-icon");
   staticpro (&Qsuppress_icon);
   Qundefined_color = intern ("undefined-color");
   staticpro (&Qundefined_color);
-  Qvertical_scroll_bars = intern ("vertical-scroll-bars");
-  staticpro (&Qvertical_scroll_bars);
-  Qvisibility = intern ("visibility");
-  staticpro (&Qvisibility);
-  Qwindow_id = intern ("window-id");
-  staticpro (&Qwindow_id);
-  Qouter_window_id = intern ("outer-window-id");
-  staticpro (&Qouter_window_id);
-  Qx_frame_parameter = intern ("x-frame-parameter");
-  staticpro (&Qx_frame_parameter);
-  Qx_resource_name = intern ("x-resource-name");
-  staticpro (&Qx_resource_name);
-  Quser_position = intern ("user-position");
-  staticpro (&Quser_position);
-  Quser_size = intern ("user-size");
-  staticpro (&Quser_size);
-  Qscroll_bar_foreground = intern ("scroll-bar-foreground");
-  staticpro (&Qscroll_bar_foreground);
-  Qscroll_bar_background = intern ("scroll-bar-background");
-  staticpro (&Qscroll_bar_background);
-  Qscreen_gamma = intern ("screen-gamma");
-  staticpro (&Qscreen_gamma);
-  Qline_spacing = intern ("line-spacing");
-  staticpro (&Qline_spacing);
   Qcenter = intern ("center");
   staticpro (&Qcenter);
   Qcompound_text = intern ("compound-text");
   staticpro (&Qcompound_text);
   Qcancel_timer = intern ("cancel-timer");
   staticpro (&Qcancel_timer);
-  Qwait_for_wm = intern ("wait-for-wm");
-  staticpro (&Qwait_for_wm);
-  Qfullscreen = intern ("fullscreen");
-  staticpro (&Qfullscreen);
-  Qfullwidth = intern ("fullwidth");
-  staticpro (&Qfullwidth);
-  Qfullheight = intern ("fullheight");
-  staticpro (&Qfullheight);
-  Qfullboth = intern ("fullboth");
-  staticpro (&Qfullboth);
   /* This is the end of symbol initialization.  */
 
   /* Text property `display' should be nonsticky by default.  */
@@ -12084,16 +10932,11 @@ syms_of_xfns ()
   QCmask = intern (":mask");
   staticpro (&QCmask);
 
-  Qface_set_after_frame_default = intern ("face-set-after-frame-default");
-  staticpro (&Qface_set_after_frame_default);
-
   Fput (Qundefined_color, Qerror_conditions,
        Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
   Fput (Qundefined_color, Qerror_message,
        build_string ("Undefined color"));
 
-  init_x_parm_symbols ();
-
   DEFVAR_BOOL ("cross-disabled-images", &cross_disabled_images,
     doc: /* Non-nil means always draw a cross over disabled images.
 Disabled images are those having an `:conversion disabled' property.
@@ -12110,30 +10953,6 @@ Changing the value does not affect existing frames
 unless you set the mouse color.  */);
   Vx_pointer_shape = Qnil;
 
-  DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
-    doc: /* The name Emacs uses to look up X resources.
-`x-get-resource' uses this as the first component of the instance name
-when requesting resource values.
-Emacs initially sets `x-resource-name' to the name under which Emacs
-was invoked, or to the value specified with the `-name' or `-rn'
-switches, if present.
-
-It may be useful to bind this variable locally around a call
-to `x-get-resource'.  See also the variable `x-resource-class'.  */);
-  Vx_resource_name = Qnil;
-
-  DEFVAR_LISP ("x-resource-class", &Vx_resource_class,
-    doc: /* The class Emacs uses to look up X resources.
-`x-get-resource' uses this as the first component of the instance class
-when requesting resource values.
-
-Emacs initially sets `x-resource-class' to "Emacs".
-
-Setting this variable permanently is not a reasonable thing to do,
-but binding this variable locally around a call to `x-get-resource'
-is a reasonable practice.  See also the variable `x-resource-name'.  */);
-  Vx_resource_class = build_string (EMACS_CLASS);
-
 #if 0 /* This doesn't really do anything.  */
   DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
     doc: /* The shape of the pointer when not over text.
@@ -12224,7 +11043,18 @@ meaning don't clear the cache.  */);
 #endif /* USE_MOTIF */
 #endif /* USE_X_TOOLKIT */
 
-  defsubr (&Sx_get_resource);
+#ifdef USE_GTK
+  Fprovide (intern ("gtk"), Qnil);
+
+  DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
+               doc: /* Version info for GTK+.  */);
+  {
+    char gtk_version[40];
+    g_snprintf (gtk_version, sizeof (gtk_version), "%u.%u.%u",
+                GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+    Vgtk_version_string = build_string (gtk_version);
+  }
+#endif /* USE_GTK */
 
   /* X window properties.  */
   defsubr (&Sx_change_window_property);
@@ -12248,7 +11078,6 @@ meaning don't clear the cache.  */);
   defsubr (&Sx_display_visual_class);
   defsubr (&Sx_display_backing_store);
   defsubr (&Sx_display_save_under);
-  defsubr (&Sx_parse_geometry);
   defsubr (&Sx_create_frame);
   defsubr (&Sx_open_connection);
   defsubr (&Sx_close_connection);
@@ -12381,3 +11210,6 @@ init_xfns ()
 }
 
 #endif /* HAVE_X_WINDOWS */
+
+/* arch-tag: 55040d02-5485-4d58-8b22-95a7a05f3288
+   (do not change this comment) */