emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/x_emacs e7c3d39 4/7: Rename non-X x_* identifiers


From: Alexander Gramiak
Subject: [Emacs-diffs] scratch/x_emacs e7c3d39 4/7: Rename non-X x_* identifiers 2
Date: Sat, 13 Apr 2019 23:30:09 -0400 (EDT)

branch: scratch/x_emacs
commit e7c3d39925dea5e69f9880b6f5609755f34b9d52
Author: Alexander Gramiak <address@hidden>
Commit: Alexander Gramiak <address@hidden>

    Rename non-X x_* identifiers 2
    
    * src/alloc.c:
    * src/frame.c:
    * src/xdisp.c: Use FRAME_OUTPUT_DATA instead of FRAME_X_OUTPUT.
    
    * src/termhooks.c (frame_visible_invisible_hook, set_window_size_hook)
    (set_frame_offset_hook, set_bitmap_icon_hook, activate_menubar_hook)
    (get_string_resource_hook): New terminal hooks.
---
 src/alloc.c      |   2 +-
 src/dispextern.h |  35 +++++-----
 src/dispnew.c    |   2 +-
 src/fontset.c    |   2 +-
 src/frame.c      | 202 ++++++++++++++++++++++++++++---------------------------
 src/frame.h      |  29 ++++----
 src/image.c      |  42 ++++++------
 src/keyboard.c   |   6 +-
 src/menu.h       |   3 +
 src/nsfns.m      |  92 ++++++++++++++-----------
 src/nsgui.h      |   3 -
 src/nsmenu.m     |   2 +-
 src/nsterm.h     |  11 +--
 src/nsterm.m     |  24 ++++---
 src/termhooks.h  |  38 ++++++++++-
 src/w32fns.c     | 122 ++++++++++++++++++---------------
 src/w32gui.h     |   2 -
 src/w32menu.c    |   2 +-
 src/w32reg.c     |  15 +++--
 src/w32term.c    |  27 +++++---
 src/w32term.h    |  18 +++--
 src/window.c     |  14 ++--
 src/xdisp.c      |  78 ++++++++++-----------
 src/xfaces.c     |  40 +++++------
 src/xfns.c       | 125 +++++++++++++++++++++-------------
 src/xrdb.c       |  17 ++---
 src/xterm.c      |  63 +++++++++--------
 src/xterm.h      |  12 ++--
 28 files changed, 579 insertions(+), 449 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index dd78386..008c8fd 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6517,7 +6517,7 @@ mark_frame (struct Lisp_Vector *ptr)
   mark_vectorlike (&ptr->header);
   mark_face_cache (f->face_cache);
 #ifdef HAVE_WINDOW_SYSTEM
-  if (FRAME_WINDOW_P (f) && FRAME_X_OUTPUT (f))
+  if (FRAME_WINDOW_P (f) && FRAME_OUTPUT_DATA (f))
     {
       struct font *font = FRAME_FONT (f);
 
diff --git a/src/dispextern.h b/src/dispextern.h
index 0fc8ca9..6c1cdf3 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1680,7 +1680,7 @@ struct face
 
   /* True means that colors of this face may not be freed because they
      have been copied bitwise from a base face (see
-     realize_x_face).  */
+     realize_gui_face).  */
   bool_bf colors_copied_bitwise_p : 1;
 
   /* If non-zero, use overstrike (to simulate bold-face).  */
@@ -3352,18 +3352,19 @@ extern bool buffer_flipping_blocked_p (void);
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-extern ptrdiff_t x_bitmap_pixmap (struct frame *, ptrdiff_t);
-extern void gui_reference_bitmap (struct frame *, ptrdiff_t);
-extern ptrdiff_t gui_create_bitmap_from_data (struct frame *, char *,
-                                           unsigned int, unsigned int);
-extern ptrdiff_t gui_create_bitmap_from_file (struct frame *, Lisp_Object);
+extern ptrdiff_t image_bitmap_pixmap (struct frame *, ptrdiff_t);
+extern void image_reference_bitmap (struct frame *, ptrdiff_t);
+extern ptrdiff_t image_create_bitmap_from_data (struct frame *, char *,
+                                                unsigned int, unsigned int);
+extern ptrdiff_t image_create_bitmap_from_file (struct frame *, Lisp_Object);
 #if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK
 extern ptrdiff_t x_create_bitmap_from_xpm_data (struct frame *, const char **);
 #endif
-#ifndef x_destroy_bitmap
-extern void x_destroy_bitmap (struct frame *, ptrdiff_t);
+#ifndef image_destroy_bitmap
+extern void image_destroy_bitmap (struct frame *, ptrdiff_t);
 #endif
-extern void gui_destroy_all_bitmaps (Display_Info *);
+extern void image_destroy_all_bitmaps (Display_Info *);
+#ifdef HAVE_X_WINDOWS
 extern void x_create_bitmap_mask (struct frame *, ptrdiff_t);
 #endif
 extern Lisp_Object image_find_image_file (Lisp_Object);
@@ -3587,19 +3588,17 @@ enum resource_types
 };
 
 extern Display_Info *check_x_display_info (Lisp_Object);
-extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object,
-                              Lisp_Object, const char *, const char *class,
-                              enum resource_types);
-extern Lisp_Object x_frame_get_and_record_arg (struct frame *, Lisp_Object,
-                                               Lisp_Object,
-                                              const char *, const char *,
-                                               enum resource_types);
+extern Lisp_Object gui_display_get_arg (Display_Info *, Lisp_Object,
+                                        Lisp_Object, const char *, const char 
*,
+                                        enum resource_types);
+extern Lisp_Object gui_frame_get_and_record_arg (struct frame *, Lisp_Object,
+                                                 Lisp_Object,
+                                                 const char *, const char *,
+                                                 enum resource_types);
 extern Lisp_Object gui_default_parameter (struct frame *, Lisp_Object,
                                           Lisp_Object, Lisp_Object,
                                           const char *, const char *,
                                           enum resource_types);
-extern char *x_get_string_resource (XrmDatabase, const char *,
-                                   const char *);
 
 #ifndef HAVE_NS /* These both used on W32 and X only.  */
 extern bool gui_mouse_grabbed (Display_Info *);
diff --git a/src/dispnew.c b/src/dispnew.c
index ccb08ec..8022093 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5551,7 +5551,7 @@ change_frame_size_1 (struct frame *f, int new_width, int 
new_height,
                        * FRAME_LINE_HEIGHT (f));
        }
 
-      /* Adjust frame size but make sure x_set_window_size does not
+      /* Adjust frame size but make sure set_window_size_hook does not
         get called.  */
       adjust_frame_size (f, new_width, new_height, 5, pretend,
                         Qchange_frame_size);
diff --git a/src/fontset.c b/src/fontset.c
index 0a6edc7..2c45c95 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1061,7 +1061,7 @@ font_for_char (struct face *face, int c, ptrdiff_t pos, 
Lisp_Object object)
 /* Make a realized fontset for ASCII face FACE on frame F from the
    base fontset BASE_FONTSET_ID.  If BASE_FONTSET_ID is -1, use the
    default fontset as the base.  Value is the id of the new fontset.
-   Called from realize_x_face.  */
+   Called from realize_gui_face.  */
 
 int
 make_fontset_for_ascii_face (struct frame *f, int base_fontset_id, struct face 
*face)
diff --git a/src/frame.c b/src/frame.c
index 982d9f3..e133972 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -482,7 +482,7 @@ keep_ratio (struct frame *f, struct frame *p, int 
old_width, int old_height,
              f->top_pos = pos_y;
            }
 
-         x_set_offset (f, pos_x, pos_y, -1);
+         FRAME_TERMINAL (f)->set_frame_offset_hook (f, pos_x, pos_y, -1);
        }
 
       if (!CONSP (keep_ratio) || !NILP (Fcar (keep_ratio)))
@@ -518,36 +518,37 @@ keep_ratio (struct frame *f, struct frame *p, int 
old_width, int old_height,
  * text size of F in pixels.  A value of -1 means no change is requested
  * for that direction (but the frame may still have to be resized to
  * accommodate windows with their minimum sizes).  This can either issue
- * a request to resize the frame externally (via x_set_window_size), to
+ * a request to resize the frame externally (via set_window_size_hook), to
  * resize the frame internally (via resize_frame_windows) or do nothing
  * at all.
  *
  * The argument INHIBIT can assume the following values:
  *
- * 0 means to unconditionally call x_set_window_size even if sizes
+ * 0 means to unconditionally call set_window_size_hook even if sizes
  *   apparently do not change.  Fx_create_frame uses this to pass the
  *   initial size to the window manager.
  *
- * 1 means to call x_set_window_size if the native frame size really
+ * 1 means to call set_window_size_hook if the native frame size really
  *   changes.  Fset_frame_size, Fset_frame_height, ... use this.
  *
- * 2 means to call x_set_window_size provided frame_inhibit_resize
+ * 2 means to call set_window_size_hook provided frame_inhibit_resize
  *   allows it.  The menu and tool bar code use this ("3" won't work
  *   here in general because menu and tool bar are often not counted in
  *   the frame's text height).
  *
- * 3 means call x_set_window_size if window minimum sizes must be
- *   preserved or frame_inhibit_resize allows it.  gui_set_left_fringe,
- *   gui_set_scroll_bar_width, gui_new_font ... use (or should use) this.
+ * 3 means call set_window_size_hook if window minimum sizes must be
+ *   preserved or frame_inhibit_resize allows it.
+ *   gui_set_left_fringe, gui_set_scroll_bar_width, gui_new_font
+ *   ... use (or should use) this.
  *
- * 4 means call x_set_window_size only if window minimum sizes must be
- *   preserved.  x_set_right_divider_width, x_set_border_width and the
- *   code responsible for wrapping the tool bar use this.
+ * 4 means call set_window_size_hook only if window minimum sizes must
+ *   be preserved.  x_set_right_divider_width, x_set_border_width and
+ *   the code responsible for wrapping the tool bar use this.
  *
- * 5 means to never call x_set_window_size.  change_frame_size uses
+ * 5 means to never call set_window_size_hook.  change_frame_size uses
  *   this.
  *
- * Note that even when x_set_window_size is not called, individual
+ * Note that even when set_window_size_hook is not called, individual
  * windows may have to be resized (via `window--sanitize-window-sizes')
  * in order to support minimum size constraints.
  *
@@ -570,7 +571,7 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
   /* The following two values are calculated from the old frame pixel
      sizes and any "new" settings for tool bar, menu bar and internal
      borders.  We do it this way to detect whether we have to call
-     x_set_window_size as consequence of the new settings.  */
+     set_window_size_hook as consequence of the new settings.  */
   int windows_width = FRAME_WINDOWS_WIDTH (f);
   int windows_height = FRAME_WINDOWS_HEIGHT (f);
   int min_windows_width, min_windows_height;
@@ -645,7 +646,7 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f)
-      && f->can_x_set_window_size
+      && f->can_set_window_size
       && ((!inhibit_horizontal
           && (new_pixel_width != old_pixel_width
               || inhibit == 0 || inhibit == 2))
@@ -668,7 +669,11 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
         list2 (inhibit_horizontal ? Qt : Qnil,
                inhibit_vertical ? Qt : Qnil));
 
-      x_set_window_size (f, 0, new_text_width, new_text_height, 1);
+      FRAME_TERMINAL (f)->set_window_size_hook (f,
+                                                0,
+                                                new_text_width,
+                                                new_text_height,
+                                                1);
       f->resized_p = true;
 
       return;
@@ -827,7 +832,7 @@ make_frame (bool mini_p)
   f->wants_modeline = true;
   f->redisplay = true;
   f->garbaged = true;
-  f->can_x_set_window_size = false;
+  f->can_set_window_size = false;
   f->after_make_frame = false;
   f->inhibit_horizontal_resize = false;
   f->inhibit_vertical_resize = false;
@@ -1089,7 +1094,7 @@ make_initial_frame (void)
 
   last_nonminibuf_frame = f;
 
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
   f->after_make_frame = true;
 
   return f;
@@ -1290,7 +1295,7 @@ affects all frames on the same terminal device.  */)
   for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem))
     XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem))));
 
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
   f->after_make_frame = true;
 
   return frame;
@@ -3593,11 +3598,13 @@ bottom edge of FRAME's display.  */)
   CHECK_TYPE_RANGED_INTEGER (int, x);
   CHECK_TYPE_RANGED_INTEGER (int, y);
 
-  /* I think this should be done with a hook.  */
   if (FRAME_WINDOW_P (f))
     {
 #ifdef HAVE_WINDOW_SYSTEM
-      x_set_offset (f, XFIXNUM (x), XFIXNUM (y), 1);
+      FRAME_TERMINAL (f)->set_frame_offset_hook (f,
+                                                 XFIXNUM (x),
+                                                 XFIXNUM (y),
+                                                 1);
 #endif
     }
 
@@ -4087,7 +4094,7 @@ gui_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
        all.  With the old setting it can get a Heisenbug when
        EmacsFrameResize intermittently provokes a delayed
        change_frame_size in the middle of adjust_frame_size.  */
-    /**        || (f->can_x_set_window_size && (f->new_height || 
f->new_width))) **/
+    /**        || (f->can_set_window_size && (f->new_height || f->new_width))) 
**/
     adjust_frame_size (f, width, height, 1, 0, Qgui_set_frame_parameters);
 
   if ((!NILP (left) || !NILP (top))
@@ -4153,7 +4160,7 @@ gui_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
       f->win_gravity = NorthWestGravity;
 
       /* Actually set that position, and convert to absolute.  */
-      x_set_offset (f, leftpos, toppos, -1);
+      FRAME_TERMINAL (f)->set_frame_offset_hook (f, leftpos, toppos, -1);
     }
 
   if (fullscreen_change)
@@ -4161,7 +4168,7 @@ gui_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
       Lisp_Object old_value = get_frame_param (f, Qfullscreen);
 
       frame_size_history_add
-       (f, Qx_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
+       (f, Qgui_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
 
       store_frame_param (f, Qfullscreen, fullscreen);
       if (!EQ (fullscreen, old_value))
@@ -4231,11 +4238,11 @@ gui_report_frame_params (struct frame *f, Lisp_Object 
*alistptr)
                   /* nil means "use default height"
                      for non-toolkit scroll bar.  */
                   : Qnil));
-  /* FRAME_X_WINDOW is not guaranteed to return an integer.  E.g., on
-     MS-Windows it returns a value whose type is HANDLE, which is
-     actually a pointer.  Explicit casting avoids compiler
+  /* FRAME_NATIVE_WINDOW is not guaranteed to return an integer.
+     E.g., on MS-Windows it returns a value whose type is HANDLE,
+     which is actually a pointer.  Explicit casting avoids compiler
      warnings.  */
-  w = (uintptr_t) FRAME_X_WINDOW (f);
+  w = (uintptr_t) FRAME_NATIVE_WINDOW (f);
   store_in_alist (alistptr, Qwindow_id,
                  make_formatted_string (buf, "%"pMu, w));
 #ifdef HAVE_X_WINDOWS
@@ -4254,10 +4261,10 @@ gui_report_frame_params (struct frame *f, Lisp_Object 
*alistptr)
   store_in_alist (alistptr, Qdisplay,
                  XCAR (FRAME_DISPLAY_INFO (f)->name_list_element));
 
-  if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window)
+  if (FRAME_OUTPUT_DATA (f)->parent_desc == FRAME_DISPLAY_INFO 
(f)->root_window)
     tem = Qnil;
   else
-    tem = make_fixed_natnum ((uintptr_t) FRAME_X_OUTPUT (f)->parent_desc);
+    tem = make_fixed_natnum ((uintptr_t) FRAME_OUTPUT_DATA (f)->parent_desc);
   store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
   store_in_alist (alistptr, Qparent_id, tem);
   store_in_alist (alistptr, Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f));
@@ -4530,7 +4537,7 @@ gui_set_left_fringe (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_val
       f->fringe_cols /* Round up.  */
        = (new_width + FRAME_RIGHT_FRINGE_WIDTH (f) + unit - 1) / unit;
 
-      if (FRAME_X_WINDOW (f) != 0)
+      if (FRAME_NATIVE_WINDOW (f) != 0)
        adjust_frame_size (f, -1, -1, 3, 0, Qleft_fringe);
 
       SET_FRAME_GARBAGED (f);
@@ -4554,7 +4561,7 @@ gui_set_right_fringe (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_va
       f->fringe_cols /* Round up.  */
        = (new_width + FRAME_LEFT_FRINGE_WIDTH (f) + unit - 1) / unit;
 
-      if (FRAME_X_WINDOW (f) != 0)
+      if (FRAME_NATIVE_WINDOW (f) != 0)
        adjust_frame_size (f, -1, -1, 3, 0, Qright_fringe);
 
       SET_FRAME_GARBAGED (f);
@@ -4570,7 +4577,7 @@ gui_set_border_width (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
   if (XFIXNUM (arg) == f->border_width)
     return;
 
-  if (FRAME_X_WINDOW (f) != 0)
+  if (FRAME_NATIVE_WINDOW (f) != 0)
     error ("Cannot change the border width of a frame");
 
   f->border_width = XFIXNUM (arg);
@@ -4659,11 +4666,11 @@ gui_set_vertical_scroll_bars (struct frame *f, 
Lisp_Object arg, Lisp_Object oldv
           ? vertical_scroll_bar_right
           : vertical_scroll_bar_none);
 
-      /* We set this parameter before creating the X window for the
-        frame, so we can get the geometry right from the start.
+      /* We set this parameter before creating the native 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))
+        call set_window_size_hook.  */
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qvertical_scroll_bars);
 
       SET_FRAME_GARBAGED (f);
@@ -4679,11 +4686,11 @@ gui_set_horizontal_scroll_bars (struct frame *f, 
Lisp_Object arg, Lisp_Object ol
     {
       f->horizontal_scroll_bars = NILP (arg) ? false : true;
 
-      /* We set this parameter before creating the X window for the
-        frame, so we can get the geometry right from the start.
+      /* We set this parameter before creating the native 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))
+        call set_window_size_hook.  */
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qhorizontal_scroll_bars);
 
       SET_FRAME_GARBAGED (f);
@@ -4701,7 +4708,7 @@ gui_set_scroll_bar_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
     {
       FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
       FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
-      if (FRAME_X_WINDOW (f))
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
 
       SET_FRAME_GARBAGED (f);
@@ -4710,7 +4717,7 @@ gui_set_scroll_bar_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
     {
       FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f);
 
-      if (FRAME_X_WINDOW (f))
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
 
       SET_FRAME_GARBAGED (f);
@@ -4731,7 +4738,7 @@ gui_set_scroll_bar_height (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
     {
       FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
       FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
-      if (FRAME_X_WINDOW (f))
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
 
       SET_FRAME_GARBAGED (f);
@@ -4740,7 +4747,7 @@ gui_set_scroll_bar_height (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
     {
       FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f);
 
-      if (FRAME_X_WINDOW (f))
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
 
       SET_FRAME_GARBAGED (f);
@@ -4916,11 +4923,13 @@ validate_x_resource_name (void)
     }
 }
 
-/* Get specified attribute from resource database RDB.
+/* Get a GUI resource, like Fx_get_resource, but for display DPYINFO.
    See Fx_get_resource below for other parameters.  */
 
-static Lisp_Object
-xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, 
Lisp_Object component, Lisp_Object subclass)
+Lisp_Object
+gui_display_get_resource (Display_Info *dpyinfo, Lisp_Object attribute,
+                          Lisp_Object class, Lisp_Object component,
+                          Lisp_Object subclass)
 {
   CHECK_STRING (attribute);
   CHECK_STRING (class);
@@ -4973,7 +4982,10 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object 
attribute, Lisp_Object class, Li
   *nz++ = '.';
   lispstpcpy (nz, attribute);
 
-  char *value = x_get_string_resource (rdb, name_key, class_key);
+  const char *value =
+    dpyinfo->terminal->get_string_resource_hook (&dpyinfo->rdb,
+                                                 name_key,
+                                                 class_key);
   SAFE_FREE();
 
   if (value && *value)
@@ -4998,28 +5010,17 @@ and the class is `Emacs.CLASS.SUBCLASS'.  */)
 {
   check_window_system (NULL);
 
-  return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
-                           attribute, class, component, subclass);
-}
-
-/* Get an X resource, like Fx_get_resource, but for display DPYINFO.  */
-
-Lisp_Object
-display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute,
-                       Lisp_Object class, Lisp_Object component,
-                       Lisp_Object subclass)
-{
-  return xrdb_get_resource (dpyinfo->xrdb,
-                           attribute, class, component, subclass);
+  return gui_display_get_resource (check_x_display_info (Qnil),
+                                   attribute, class, component, subclass);
 }
 
 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK
 /* Used when C code wants a resource value.  */
 /* Called from oldXMenu/Create.c.  */
-char *
+const char *
 x_get_resource_string (const char *attribute, const char *class)
 {
-  char *result;
+  const char *result;
   struct frame *sf = SELECTED_FRAME ();
   ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name);
   USE_SAFE_ALLOCA;
@@ -5036,8 +5037,8 @@ x_get_resource_string (const char *attribute, const char 
*class)
   esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
   sprintf (class_key, "%s.%s", EMACS_CLASS, class);
 
-  result = x_get_string_resource (FRAME_DISPLAY_INFO (sf)->xrdb,
-                                 name_key, class_key);
+  result = gui_display_get_resource (&FRAME_DISPLAY_INFO (sf)->rdb,
+                                     name_key, class_key);
   SAFE_FREE ();
   return result;
 }
@@ -5045,18 +5046,21 @@ x_get_resource_string (const char *attribute, const 
char *class)
 
 /* 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.
+   First search ALIST, then Vdefault_frame_alist, then the GUI
+   resource 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!  */
+   gui_display_get_arg, make sure you deal with Qunbound in a
+   reasonable way, and don't let it get stored in any Lisp-visible
+   variables!  */
 
 Lisp_Object
-x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
-          const char *attribute, const char *class, enum resource_types type)
+gui_display_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object 
param,
+                     const char *attribute, const char *class,
+                     enum resource_types type)
 {
   Lisp_Object tem;
 
@@ -5086,7 +5090,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, 
Lisp_Object param,
        {
          AUTO_STRING (at, attribute);
          AUTO_STRING (cl, class);
-         tem = display_x_get_resource (dpyinfo, at, cl, Qnil, Qnil);
+         tem = gui_display_get_resource (dpyinfo, at, cl, Qnil, Qnil);
 
          if (NILP (tem))
            return Qunbound;
@@ -5153,26 +5157,26 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, 
Lisp_Object param,
 }
 
 static Lisp_Object
-x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
-                const char *attribute, const char *class,
-                enum resource_types type)
+gui_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
+                   const char *attribute, const char *class,
+                   enum resource_types type)
 {
-  return x_get_arg (FRAME_DISPLAY_INFO (f),
-                   alist, param, attribute, class, type);
+  return gui_display_get_arg (FRAME_DISPLAY_INFO (f),
+                              alist, param, attribute, class, type);
 }
 
-/* Like x_frame_get_arg, but also record the value in f->param_alist.  */
+/* Like gui_frame_get_arg, but also record the value in f->param_alist.  */
 
 Lisp_Object
-x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
-                           Lisp_Object param,
-                           const char *attribute, const char *class,
-                           enum resource_types type)
+gui_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
+                              Lisp_Object param,
+                              const char *attribute, const char *class,
+                              enum resource_types type)
 {
   Lisp_Object value;
 
-  value = x_get_arg (FRAME_DISPLAY_INFO (f), alist, param,
-                    attribute, class, type);
+  value = gui_display_get_arg (FRAME_DISPLAY_INFO (f), alist, param,
+                               attribute, class, type);
   if (! NILP (value) && ! EQ (value, Qunbound))
     store_frame_param (f, param, value);
 
@@ -5193,7 +5197,7 @@ gui_default_parameter (struct frame *f, Lisp_Object 
alist, Lisp_Object prop,
 {
   Lisp_Object tem;
 
-  tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
+  tem = gui_frame_get_arg (f, alist, prop, xprop, xclass, type);
   if (EQ (tem, Qunbound))
     tem = deflt;
   AUTO_FRAME_ARG (arg, prop, tem);
@@ -5427,8 +5431,8 @@ gui_figure_window_size (struct frame *f, Lisp_Object 
parms, bool toolbar_p,
      override what we specify below.  */
   f->new_width = f->new_height = 0;
 
-  height = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
-  width = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
+  height = gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, 
RES_TYPE_NUMBER);
+  width = gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
   if (!EQ (width, Qunbound) || !EQ (height, Qunbound))
     {
       if (!EQ (width, Qunbound))
@@ -5505,16 +5509,18 @@ gui_figure_window_size (struct frame *f, Lisp_Object 
parms, bool toolbar_p,
            }
        }
 
-      user_size = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, 
RES_TYPE_NUMBER);
+      user_size = gui_display_get_arg (dpyinfo, parms, Quser_size, 0, 0,
+                                       RES_TYPE_NUMBER);
       if (!NILP (user_size) && !EQ (user_size, Qunbound))
        window_prompting |= USSize;
       else
        window_prompting |= PSize;
     }
 
-  top = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
-  left = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
-  user_position = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, 
RES_TYPE_NUMBER);
+  top = gui_display_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
+  left = gui_display_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
+  user_position = gui_display_get_arg (dpyinfo, parms, Quser_position, 0, 0,
+                                       RES_TYPE_NUMBER);
   if (! EQ (top, Qunbound) || ! EQ (left, Qunbound))
     {
       if (EQ (top, Qminus))
@@ -5827,15 +5833,15 @@ syms_of_frame (void)
   DEFSYM (QEmacsFrameResize, "EmacsFrameResize");
   DEFSYM (Qset_frame_size, "set-frame-size");
   DEFSYM (Qframe_inhibit_resize, "frame-inhibit-resize");
-  DEFSYM (Qx_set_fullscreen, "x-set-fullscreen");
+  DEFSYM (Qgui_set_fullscreen, "gui-set-fullscreen");
   DEFSYM (Qx_check_fullscreen, "x-check-fullscreen");
   DEFSYM (Qxg_frame_resized, "xg-frame-resized");
   DEFSYM (Qxg_frame_set_char_size_1, "xg-frame-set-char-size-1");
   DEFSYM (Qxg_frame_set_char_size_2, "xg-frame-set-char-size-2");
   DEFSYM (Qxg_frame_set_char_size_3, "xg-frame-set-char-size-3");
-  DEFSYM (Qx_set_window_size_1, "x-set-window-size-1");
-  DEFSYM (Qx_set_window_size_2, "x-set-window-size-2");
-  DEFSYM (Qx_set_window_size_3, "x-set-window-size-3");
+  DEFSYM (Qgui_set_window_size_1, "gui-set-window-size-1");
+  DEFSYM (Qgui_set_window_size_2, "gui-set-window-size-2");
+  DEFSYM (Qgui_set_window_size_3, "gui-set-window-size-3");
   DEFSYM (Qxg_change_toolbar_position, "xg-change-toolbar-position");
   DEFSYM (Qx_net_wm_state, "x-net-wm-state");
   DEFSYM (Qx_handle_net_wm_state, "x-handle-net-wm-state");
@@ -5846,8 +5852,8 @@ syms_of_frame (void)
   DEFSYM (Qchange_frame_size, "change-frame-size");
   DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size");
   DEFSYM (Qset_window_configuration, "set-window-configuration");
-  DEFSYM (Qx_create_frame_1, "x-create-frame-1");
-  DEFSYM (Qx_create_frame_2, "x-create-frame-2");
+  DEFSYM (Qgui_create_frame_1, "gui-create-frame-1");
+  DEFSYM (Qgui_create_frame_2, "gui-create-frame-2");
   DEFSYM (Qterminal_frame, "terminal-frame");
 
 #ifdef HAVE_NS
diff --git a/src/frame.h b/src/frame.h
index 67463e8..a780ea6 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -397,9 +397,9 @@ struct frame
      in pixels.  */
   bool_bf new_pixelwise : 1;
 
-  /* True means x_set_window_size requests can be processed for this
-     frame.  */
-  bool_bf can_x_set_window_size : 1;
+  /* True means set_window_size_hook requests can be processed for
+     this frame.  */
+  bool_bf can_set_window_size : 1;
 
   /* Set to true after this frame was made by `make-frame'.  */
   bool_bf after_make_frame : 1;
@@ -543,6 +543,10 @@ struct frame
   }
   output_data;
 
+  /* Interface for accessing frame data generic constructs that are
+     device-dependent.  */
+  struct frame_output_interface *foif;
+
   /* List of font-drivers available on the frame.  */
   struct font_driver_list *font_driver_list;
 
@@ -786,8 +790,8 @@ default_pixels_per_inch_y (void)
 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
 #endif
 
-/* FRAME_WINDOW_P tests whether the frame is a window, and is
-   defined to be the predicate for the window system being used.  */
+/* FRAME_WINDOW_P tests whether the frame is a graphical window system
+   frame.  */
 
 #ifdef HAVE_X_WINDOWS
 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
@@ -1573,15 +1577,14 @@ extern void gui_set_no_special_glyphs (struct frame *, 
Lisp_Object, Lisp_Object)
 
 extern void validate_x_resource_name (void);
 
-extern Lisp_Object display_x_get_resource (Display_Info *,
-                                          Lisp_Object attribute,
-                                          Lisp_Object class,
-                                          Lisp_Object component,
-                                          Lisp_Object subclass);
+extern Lisp_Object gui_display_get_resource (Display_Info *,
+                                             Lisp_Object attribute,
+                                             Lisp_Object class,
+                                             Lisp_Object component,
+                                             Lisp_Object subclass);
 
 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int 
pix_y);
-extern void x_activate_menubar (struct frame *);
 extern void free_frame_menubar (struct frame *);
 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
 extern enum internal_border_part frame_internal_border_part (struct frame *f, 
int x, int y);
@@ -1596,8 +1599,6 @@ extern void x_sync (struct frame *);
 
 #ifndef HAVE_NS
 
-extern bool x_bitmap_icon (struct frame *, Lisp_Object);
-
 /* Set F's bitmap icon, if specified among F's parameters.  */
 
 INLINE void
@@ -1606,7 +1607,7 @@ gui_set_bitmap_icon (struct frame *f)
   Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
 
   if (CONSP (obj) && !NILP (XCDR (obj)))
-    x_bitmap_icon (f, XCDR (obj));
+    FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, XCDR (obj));
 }
 
 #endif /* !HAVE_NS */
diff --git a/src/image.c b/src/image.c
index 072d4b5..47e8643 100644
--- a/src/image.c
+++ b/src/image.c
@@ -129,8 +129,8 @@ static unsigned long *colors_in_color_table (int *n);
    Bitmap indices are guaranteed to be > 0, so a negative number can
    be used to indicate no bitmap.
 
-   If you use gui_create_bitmap_from_data, then you must keep track of
-   the bitmaps yourself.  That is, creating a bitmap from the same
+   If you use image_create_bitmap_from_data, then you must keep track
+   of the bitmaps yourself.  That is, creating a bitmap from the same
    data more than once will not be caught.  */
 
 #ifdef HAVE_NS
@@ -169,7 +169,7 @@ x_bitmap_width (struct frame *f, ptrdiff_t id)
 
 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
 ptrdiff_t
-x_bitmap_pixmap (struct frame *f, ptrdiff_t id)
+image_bitmap_pixmap (struct frame *f, ptrdiff_t id)
 {
   /* HAVE_NTGUI needs the explicit cast here.  */
   return (ptrdiff_t) FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
@@ -187,7 +187,7 @@ x_bitmap_mask (struct frame *f, ptrdiff_t id)
 /* Allocate a new bitmap record.  Returns index of new record.  */
 
 static ptrdiff_t
-gui_allocate_bitmap_record (struct frame *f)
+image_allocate_bitmap_record (struct frame *f)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
   ptrdiff_t i;
@@ -208,7 +208,7 @@ gui_allocate_bitmap_record (struct frame *f)
 /* Add one reference to the reference count of the bitmap with id ID.  */
 
 void
-gui_reference_bitmap (struct frame *f, ptrdiff_t id)
+image_reference_bitmap (struct frame *f, ptrdiff_t id)
 {
   ++FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].refcount;
 }
@@ -216,8 +216,8 @@ gui_reference_bitmap (struct frame *f, ptrdiff_t id)
 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS.  */
 
 ptrdiff_t
-gui_create_bitmap_from_data (struct frame *f, char *bits,
-                             unsigned int width, unsigned int height)
+image_create_bitmap_from_data (struct frame *f, char *bits,
+                               unsigned int width, unsigned int height)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
   ptrdiff_t id;
@@ -247,7 +247,7 @@ gui_create_bitmap_from_data (struct frame *f, char *bits,
       return -1;
 #endif
 
-  id = gui_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
 
 #ifdef HAVE_NS
   dpyinfo->bitmaps[id - 1].img = bitmap;
@@ -277,7 +277,7 @@ gui_create_bitmap_from_data (struct frame *f, char *bits,
 /* Create bitmap from file FILE for frame F.  */
 
 ptrdiff_t
-gui_create_bitmap_from_file (struct frame *f, Lisp_Object file)
+image_create_bitmap_from_file (struct frame *f, Lisp_Object file)
 {
 #ifdef HAVE_NTGUI
   return -1;  /* W32_TODO : bitmap support */
@@ -293,7 +293,7 @@ gui_create_bitmap_from_file (struct frame *f, Lisp_Object 
file)
       return -1;
 
 
-  id = gui_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].img = bitmap;
   dpyinfo->bitmaps[id - 1].refcount = 1;
   dpyinfo->bitmaps[id - 1].file = xlispstrdup (file);
@@ -336,7 +336,7 @@ gui_create_bitmap_from_file (struct frame *f, Lisp_Object 
file)
   if (result != BitmapSuccess)
     return -1;
 
-  id = gui_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].have_mask = false;
   dpyinfo->bitmaps[id - 1].refcount = 1;
@@ -378,7 +378,7 @@ free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record 
*bm)
 /* Remove reference to bitmap with id number ID.  */
 
 void
-x_destroy_bitmap (struct frame *f, ptrdiff_t id)
+image_destroy_bitmap (struct frame *f, ptrdiff_t id)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
 
@@ -398,7 +398,7 @@ x_destroy_bitmap (struct frame *f, ptrdiff_t id)
 /* Free all the bitmaps for the display specified by DPYINFO.  */
 
 void
-gui_destroy_all_bitmaps (Display_Info *dpyinfo)
+image_destroy_all_bitmaps (Display_Info *dpyinfo)
 {
   ptrdiff_t i;
   Bitmap_Record *bm = dpyinfo->bitmaps;
@@ -465,7 +465,7 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
   if (!(id > 0))
     return;
 
-  pixmap = x_bitmap_pixmap (f, id);
+  pixmap = image_bitmap_pixmap (f, id);
   width = x_bitmap_width (f, id);
   height = x_bitmap_height (f, id);
 
@@ -3775,7 +3775,7 @@ x_create_bitmap_from_xpm_data (struct frame *f, const 
char **bits)
       return -1;
     }
 
-  id = gui_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].have_mask = true;
   dpyinfo->bitmaps[id - 1].mask = mask;
@@ -4911,7 +4911,7 @@ static int laplace_matrix[9] = {
    allocated with xmalloc; it must be freed by the caller.  */
 
 static XColor *
-x_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
+image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
 {
   int x, y;
   XColor *colors, *p;
@@ -5019,7 +5019,7 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
    COLORS will be freed; an existing IMG->pixmap will be freed, too.  */
 
 static void
-x_from_xcolors (struct frame *f, struct image *img, XColor *colors)
+image_from_xcolors (struct frame *f, struct image *img, XColor *colors)
 {
   int x, y;
   XImagePtr oimg = NULL;
@@ -5061,7 +5061,7 @@ static void
 image_detect_edges (struct frame *f, struct image *img,
                     int *matrix, int color_adjust)
 {
-  XColor *colors = x_to_xcolors (f, img, 1);
+  XColor *colors = image_to_xcolors (f, img, 1);
   XColor *new, *p;
   int x, y, i, sum;
   ptrdiff_t nbytes;
@@ -5119,7 +5119,7 @@ image_detect_edges (struct frame *f, struct image *img,
     }
 
   xfree (colors);
-  x_from_xcolors (f, img, new);
+  image_from_xcolors (f, img, new);
 
 #undef COLOR
 }
@@ -5202,7 +5202,7 @@ image_disable_image (struct frame *f, struct image *img)
       /* Color (or grayscale).  Convert to gray, and equalize.  Just
         drawing such images with a stipple can look very odd, so
         we're using this method instead.  */
-      XColor *colors = x_to_xcolors (f, img, 1);
+      XColor *colors = image_to_xcolors (f, img, 1);
       XColor *p, *end;
       const int h = 15000;
       const int l = 30000;
@@ -5216,7 +5216,7 @@ image_disable_image (struct frame *f, struct image *img)
          p->red = p->green = p->blue = i2;
        }
 
-      x_from_xcolors (f, img, colors);
+      image_from_xcolors (f, img, colors);
     }
 
   /* Draw a cross over the disabled image, if we must or if we
diff --git a/src/keyboard.c b/src/keyboard.c
index b6521e5..1714860 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3892,10 +3892,12 @@ kbd_buffer_get_event (KBOARD **kbp,
 #ifdef HAVE_EXT_MENU_BAR
       case MENU_BAR_ACTIVATE_EVENT:
        {
+          struct frame *f;
          kbd_fetch_ptr = next_kbd_event (event);
          input_pending = readable_events (0);
-         if (FRAME_LIVE_P (XFRAME (event->ie.frame_or_window)))
-           x_activate_menubar (XFRAME (event->ie.frame_or_window));
+          f = (XFRAME (event->ie.frame_or_window));
+         if (FRAME_LIVE_P (f) && FRAME_TERMINAL (f)->activate_menubar_hook)
+           FRAME_TERMINAL (f)->activate_menubar_hook (f);
        }
         break;
 #endif
diff --git a/src/menu.h b/src/menu.h
index 0321c27..4412948 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -47,14 +47,17 @@ extern widget_value *digest_single_submenu (int, int, bool);
 #if defined (HAVE_X_WINDOWS) || defined (MSDOS)
 extern Lisp_Object x_menu_show (struct frame *, int, int, int,
                                Lisp_Object, const char **);
+extern void x_activate_menubar (struct frame *);
 #endif
 #ifdef HAVE_NTGUI
 extern Lisp_Object w32_menu_show (struct frame *, int, int, int,
                                  Lisp_Object, const char **);
+extern void w32_activate_menubar (struct frame *);
 #endif
 #ifdef HAVE_NS
 extern Lisp_Object ns_menu_show (struct frame *, int, int, int,
                                 Lisp_Object, const char **);
+extern void ns_activate_menubar (struct frame *);
 #endif
 extern Lisp_Object tty_menu_show (struct frame *, int, int, int,
                                  Lisp_Object, const char **);
diff --git a/src/nsfns.m b/src/nsfns.m
index bc47c40..09dcd86 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -692,7 +692,7 @@ ns_set_internal_border_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldv
   if (FRAME_INTERNAL_BORDER_WIDTH (f) == old_width)
     return;
 
-  if (FRAME_X_WINDOW (f) != 0)
+  if (FRAME_NATIVE_WINDOW (f) != 0)
     adjust_frame_size (f, -1, -1, 3, 0, Qinternal_border_width);
 
   SET_FRAME_GARBAGED (f);
@@ -879,8 +879,10 @@ ns_icon (struct frame *f, Lisp_Object parms)
   f->output_data.ns->icon_left = -1;
 
   /* Set the position of the icon.  */
-  icon_x = x_get_arg (dpyinfo, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
-  icon_y = x_get_arg (dpyinfo, parms, Qicon_top, 0, 0,  RES_TYPE_NUMBER);
+  icon_x = gui_display_get_arg (dpyinfo, parms, Qicon_left, 0, 0,
+                                RES_TYPE_NUMBER);
+  icon_y = gui_display_get_arg (dpyinfo, parms, Qicon_top, 0, 0,
+                                RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_FIXNUM (icon_x);
@@ -1022,8 +1024,8 @@ get_geometry_from_preferences (struct ns_display_info 
*dpyinfo,
       if (NILP (Fassq (r[i].tem, parms)))
         {
           Lisp_Object value
-            = x_get_arg (dpyinfo, parms, r[i].tem, r[i].val, r[i].cls,
-                         RES_TYPE_NUMBER);
+            = gui_display_get_arg (dpyinfo, parms, r[i].tem, r[i].val, 
r[i].cls,
+                                   RES_TYPE_NUMBER);
           if (! EQ (value, Qunbound))
             parms = Fcons (Fcons (r[i].tem, value), parms);
         }
@@ -1056,14 +1058,15 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   static int desc_ctr = 1;
   int x_width = 0, x_height = 0;
 
-  /* x_get_arg modifies parms.  */
+  /* gui_display_get_arg modifies parms.  */
   parms = Fcopy_alist (parms);
 
   /* Use this general default value to start with
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING);
+  display = gui_display_get_arg (dpyinfo, parms, Qterminal, 0, 0,
+                                 RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_ns_display_info (display);
@@ -1072,7 +1075,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
-  name = x_get_arg (dpyinfo, parms, Qname, 0, 0, RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, 0, 0,
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -1081,7 +1085,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (STRINGP (name))
     Vx_resource_name = name;
 
-  parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER);
+  parent = gui_display_get_arg (dpyinfo, parms, Qparent_id, 0, 0,
+                                RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   if (! NILP (parent))
@@ -1091,8 +1096,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   /* No need to protect DISPLAY because that's not used after passing
      it to make_frame_without_minibuffer.  */
   frame = Qnil;
-  tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
-                  RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo, parms, Qminibuffer,
+                             "minibuffer", "Minibuffer",
+                             RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
       f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -1114,9 +1120,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
   FRAME_FONTSET (f) = -1;
 
-  fset_icon_name (f, x_get_arg (dpyinfo, parms, Qicon_name,
-                               "iconName", "Title",
-                               RES_TYPE_STRING));
+  fset_icon_name (f, gui_display_get_arg (dpyinfo, parms, Qicon_name,
+                                          "iconName", "Title",
+                                          RES_TYPE_STRING));
   if (! STRINGP (f->icon_name))
     fset_icon_name (f, Qnil);
 
@@ -1224,34 +1230,38 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   init_frame_faces (f);
 
   /* Read comment about this code in corresponding place in xfns.c.  */
-  tem = x_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_width, tem);
-  tem = x_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_height, tem);
   adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
                     FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1,
-                    Qx_create_frame_1);
+                    Qgui_create_frame_1);
 
-  tem = x_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL,
+                             RES_TYPE_BOOLEAN);
   FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil);
 
 #ifdef NS_IMPL_COCOA
-  tem = x_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, 
RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL,
+                             RES_TYPE_SYMBOL);
   FRAME_NS_APPEARANCE (f) = EQ (tem, Qdark)
     ? ns_appearance_vibrant_dark : ns_appearance_aqua;
   store_frame_param (f, Qns_appearance, tem);
 
-  tem = x_get_arg (dpyinfo, parms, Qns_transparent_titlebar,
-                   NULL, NULL, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qns_transparent_titlebar,
+                             NULL, NULL, RES_TYPE_BOOLEAN);
   FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qns_transparent_titlebar, tem);
 #endif
 
-  parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL,
-                           RES_TYPE_SYMBOL);
+  parent_frame = gui_display_get_arg (dpyinfo, parms, Qparent_frame, NULL, 
NULL,
+                                      RES_TYPE_SYMBOL);
   /* Accept parent-frame iff parent-id was not specified.  */
   if (!NILP (parent)
       || EQ (parent_frame, Qunbound)
@@ -1290,7 +1300,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   window_prompting = gui_figure_window_size (f, parms, true,
                                              &x_width, &x_height);
 
-  tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0,
+                             RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem));
 
   /* NOTE: on other terms, this is done in set_mouse_color, however this
@@ -1351,8 +1362,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   gui_default_parameter (f, parms, Qfullscreen, Qnil,
                          "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
 
-  /* Allow x_set_window_size, now.  */
-  f->can_x_set_window_size = true;
+  /* Allow set_window_size_hook, now.  */
+  f->can_set_window_size = true;
 
   if (x_width > 0)
     SET_FRAME_WIDTH (f, x_width);
@@ -1360,14 +1371,14 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
     SET_FRAME_HEIGHT (f, x_height);
 
   adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1,
-                    Qx_create_frame_2);
+                    Qgui_create_frame_2);
 
   if (! f->output_data.ns->explicit_parent)
     {
       Lisp_Object visibility;
 
-      visibility = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
-                              RES_TYPE_SYMBOL);
+      visibility = gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+                                        RES_TYPE_SYMBOL);
       if (EQ (visibility, Qunbound))
        visibility = Qt;
 
@@ -1389,8 +1400,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
           || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
     kset_default_minibuffer_frame (kb, frame);
 
-  /* All remaining specified parameters, which have not been "used"
-     by x_get_arg and friends, now go in the misc. alist of the frame.  */
+  /* All remaining specified parameters, which have not been "used" by
+     gui_display_get_arg and friends, now go in the misc. alist of the
+     frame.  */
   for (tem = parms; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
@@ -2234,8 +2246,8 @@ ns_set_scroll_bar_default_height (struct frame *f)
 }
 
 /* Terms implement this instead of x-get-resource directly.  */
-char *
-x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
+const char *
+ns_get_string_resource (void *_rdb, const char *name, const char *class)
 {
   /* remove appname prefix; TODO: allow for !="Emacs" */
   const char *res, *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0);
@@ -2247,10 +2259,10 @@ x_get_string_resource (XrmDatabase rdb, const char 
*name, const char *class)
     return NULL;
 
   res = ns_get_defaults_value (toCheck);
-  return (char *) (!res ? NULL
-                  : !c_strncasecmp (res, "YES", 3) ? "true"
-                  : !c_strncasecmp (res, "NO", 2) ? "false"
-                  : res);
+  return (const char *) (!res ? NULL
+                         : !c_strncasecmp (res, "YES", 3) ? "true"
+                         : !c_strncasecmp (res, "NO", 2) ? "false"
+                         : res);
 }
 
 /* ==========================================================================
@@ -2720,11 +2732,13 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
   else
     Fx_hide_tip ();
 
-  t = x_get_arg (NULL, parms, Qbackground_color, NULL, NULL, RES_TYPE_STRING);
+  t = gui_display_get_arg (NULL, parms, Qbackground_color, NULL, NULL,
+                           RES_TYPE_STRING);
   if (ns_lisp_to_color (t, &color) == 0)
     [ns_tooltip setBackgroundColor: color];
 
-  t = x_get_arg (NULL, parms, Qforeground_color, NULL, NULL, RES_TYPE_STRING);
+  t = gui_display_get_arg (NULL, parms, Qforeground_color, NULL, NULL,
+                           RES_TYPE_STRING);
   if (ns_lisp_to_color (t, &color) == 0)
     [ns_tooltip setForegroundColor: color];
 
diff --git a/src/nsgui.h b/src/nsgui.h
index c857d77..c147f4d 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -117,9 +117,6 @@ typedef void * Color;
 typedef int Window;
 typedef int Display;
 
-/* Xism */
-typedef Lisp_Object XrmDatabase;
-
 
 /* Some sort of attempt to normalize rectangle handling.  Seems a bit
    much for what is accomplished.  */
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 34ec980..fd13233 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -470,7 +470,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool 
deep_p)
 }
 
 void
-x_activate_menubar (struct frame *f)
+ns_activate_menubar (struct frame *f)
 {
 #ifdef NS_IMPL_COCOA
   ns_update_menubar (f, true, nil);
diff --git a/src/nsterm.h b/src/nsterm.h
index 4d72ae2..55b06dd 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -869,7 +869,7 @@ struct ns_display_info
   Window root_window;
 
   /* Xism */
-  XrmDatabase xrdb;
+  Lisp_Object rdb;
 
   /* The cursor to use for vertical scroll bars.  */
   Cursor vertical_scroll_bar_cursor;
@@ -993,9 +993,9 @@ struct x_output
 
 /* This gives the ns_display_info structure for the display F is on.  */
 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
-#define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
+#define FRAME_OUTPUT_DATA(f) ((f)->output_data.ns)
 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
-#define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
+#define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f)
 
 /* This is the `Display *' which frame F is on.  */
 #define FRAME_NS_DISPLAY(f) (0)
@@ -1159,6 +1159,9 @@ extern void ns_implicitly_set_name (struct frame *f, 
Lisp_Object arg,
                                     Lisp_Object oldval);
 extern void ns_set_scroll_bar_default_width (struct frame *f);
 extern void ns_set_scroll_bar_default_height (struct frame *f);
+extern const char *ns_get_string_resource (void *_rdb,
+                                           const char *name,
+                                           const char *class);
 
 /* C access to ObjC functionality */
 extern void  ns_release_object (void *obj);
@@ -1217,7 +1220,7 @@ extern int ns_display_pixel_width (struct ns_display_info 
*);
 
 /* This in nsterm.m */
 extern float ns_antialias_threshold;
-extern void ns_make_frame_visible (struct frame *f)
+extern void ns_make_frame_visible (struct frame *f);
 extern void ns_iconify_frame (struct frame *f);
 extern void ns_set_undecorated (struct frame *f, Lisp_Object new_value,
                                 Lisp_Object old_value);
diff --git a/src/nsterm.m b/src/nsterm.m
index 980b88f..fa43b6a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -698,7 +698,7 @@ ns_release_autorelease_pool (void *pool)
    NSDisableScreenUpdates.
 
    We use these functions to prevent the user seeing a blank frame
-   after it has been resized.  x_set_window_size disables updates and
+   after it has been resized.  ns_set_window_size disables updates and
    when redisplay completes unwind_redisplay enables them again
    (bug#30699).  */
 
@@ -1820,12 +1820,12 @@ ns_set_offset (struct frame *f, int xoff, int yoff, int 
change_grav)
 }
 
 
-void
-x_set_window_size (struct frame *f,
-                   bool change_gravity,
-                   int width,
-                   int height,
-                   bool pixelwise)
+static void
+ns_set_window_size (struct frame *f,
+                    bool change_gravity,
+                    int width,
+                    int height,
+                    bool pixelwise)
 /* --------------------------------------------------------------------------
      Adjust window pixel size based on given character grid size
      Impl is a bit more complex than other terms, need to do some
@@ -1838,7 +1838,7 @@ x_set_window_size (struct frame *f,
   int pixelwidth, pixelheight;
   int orig_height = wr.size.height;
 
-  NSTRACE ("x_set_window_size");
+  NSTRACE ("ns_set_window_size");
 
   if (view == nil)
     return;
@@ -1884,7 +1884,7 @@ x_set_window_size (struct frame *f,
    wr.origin.y += orig_height - wr.size.height;
 
  frame_size_history_add
-   (f, Qx_set_window_size_1, width, height,
+   (f, Qgui_set_window_size_1, width, height,
     list5 (Fcons (make_fixnum (pixelwidth), make_fixnum (pixelheight)),
           Fcons (make_fixnum (wr.size.width), make_fixnum (wr.size.height)),
           make_fixnum (f->border_width),
@@ -5240,10 +5240,13 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
   terminal->frame_visible_invisible_hook = ns_make_frame_visible_invisible;
   terminal->fullscreen_hook = ns_fullscreen_hook;
   terminal->iconify_frame_hook = ns_iconify_frame;
+  terminal->set_window_size_hook = ns_set_window_size;
+  terminal->set_frame_offset_hook = ns_set_offset;
   terminal->set_frame_alpha_hook = ns_set_frame_alpha;
   terminal->set_new_font_hook = ns_new_font;
   terminal->implicit_set_name_hook = ns_implicitly_set_name;
   terminal->menu_show_hook = ns_menu_show;
+  terminal->activate_menubar_hook = ns_activate_menubar;
   terminal->popup_dialog_hook = ns_popup_dialog;
   terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar;
   terminal->set_horizontal_scroll_bar_hook = ns_set_horizontal_scroll_bar;
@@ -5252,6 +5255,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
   terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar;
   terminal->judge_scroll_bars_hook = ns_judge_scroll_bars;
+  terminal->get_string_resource_hook = ns_get_string_resource;
   terminal->delete_frame_hook = ns_destroy_window;
   terminal->delete_terminal_hook = ns_delete_terminal;
   /* Other hooks are NULL by default.  */
@@ -7576,7 +7580,7 @@ not_in_argv (NSString *arg)
 
 
 /* Called AFTER method below, but before our windowWillResize call there leads
-   to windowDidResize -> x_set_window_size.  Update emacs' notion of frame
+   to windowDidResize -> ns_set_window_size.  Update emacs' notion of frame
    location so set_window_size moves the frame.  */
 - (BOOL)windowShouldZoom: (NSWindow *)sender toFrame: (NSRect)newFrame
 {
diff --git a/src/termhooks.h b/src/termhooks.h
index 58f8d6e..29c5737 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -535,6 +535,10 @@ struct terminal
      windows.  */
   void (*frame_raise_lower_hook) (struct frame *f, bool raise_flag);
 
+  /* This hook is called to make the frame F visible if VISIBLE is
+     true, or invisible otherwise. */
+  void (*frame_visible_invisible_hook) (struct frame *f, bool visible);
+
   /* If the value of the frame parameter changed, this hook is called.
      For example, if going from fullscreen to not fullscreen this hook
      may do something OS dependent, like extended window manager hints on X11. 
 */
@@ -543,6 +547,22 @@ struct terminal
   /* This hook is called to iconify the frame.  */
   void (*iconify_frame_hook) (struct frame *f);
 
+  /* This hook is called to change the size of frame F's native
+   (underlying) window.  If CHANGE_GRAVITY, change to top-left-corner
+   window gravity for this size change and subsequent size changes.
+   Otherwise we leave the window gravity unchanged.  */
+  void (*set_window_size_hook) (struct frame *f, bool change_gravity,
+                                int width, int height, bool pixelwise);
+
+  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
+   to really change the position, and 0 when calling from
+   *_make_frame_visible (in that case, XOFF and YOFF are the current
+   position values).  It is -1 when calling from gui_set_frame_parameters,
+   which means, do adjust for borders but don't change the gravity.  */
+
+  void (*set_frame_offset_hook) (struct frame *f, register int xoff,
+                                 register int yoff, int change_gravity);
+
   /* This hook is called to set the frame's transparency.  */
   void (*set_frame_alpha_hook) (struct frame *f);
 
@@ -550,6 +570,10 @@ struct terminal
   Lisp_Object (*set_new_font_hook) (struct frame *f, Lisp_Object font_object,
                                     int fontset);
 
+  /* This hook is called to set the GUI window icon of F using FILE.  */
+  bool (*set_bitmap_icon_hook) (struct frame *f, Lisp_Object file);
+
+
   void (*implicit_set_name_hook) (struct frame *f, Lisp_Object arg,
                                   Lisp_Object oldval);
 
@@ -557,6 +581,11 @@ struct terminal
   Lisp_Object (*menu_show_hook) (struct frame *f, int x, int y, int menuflags,
                                 Lisp_Object title, const char **error_name);
 
+#ifdef HAVE_EXT_MENU_BAR
+  /* This hook is called to activate the menu bar.  */
+  void (*activate_menubar_hook) (struct frame *f);
+#endif
+
   /* This hook is called to display popup dialog.  */
   Lisp_Object (*popup_dialog_hook) (struct frame *f, Lisp_Object header,
                                    Lisp_Object contents);
@@ -608,10 +637,10 @@ struct terminal
                                          int position);
 
   /* Set the default scroll bar width on FRAME.  */
-  void (*x_set_scroll_bar_default_width) (struct frame *frame);
+  void (*set_scroll_bar_default_width_hook) (struct frame *frame);
 
   /* Set the default scroll bar height on FRAME.  */
-  void (*x_set_scroll_bar_default_height) (struct frame *frame);
+  void (*set_scroll_bar_default_height_hook) (struct frame *frame);
 
   /* The following three hooks are used when we're doing a thorough
      redisplay of the frame.  We don't explicitly know which scroll bars
@@ -674,6 +703,11 @@ struct terminal
      while it runs.  */
   void (*buffer_flipping_unblocked_hook) (struct frame *);
 
+  /* Retrieve the string resource specified by NAME with CLASS from
+     database RDB. */
+  const char * (*get_string_resource_hook) (void *rdb,
+                                            const char *name,
+                                            const char *class);
 
   /* Called to delete the device-specific portions of a frame that is
      on this terminal device. */
diff --git a/src/w32fns.c b/src/w32fns.c
index f01ced6..350f8d3 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1580,7 +1580,7 @@ w32_set_icon_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
   block_input ();
 
-  result = x_bitmap_icon (f, arg);
+  result = FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, arg);
   if (result)
     {
       unblock_input ();
@@ -1702,7 +1702,7 @@ w32_set_internal_border_width (struct frame *f, 
Lisp_Object arg, Lisp_Object old
     {
       f->internal_border_width = border;
 
-      if (FRAME_X_WINDOW (f) != 0)
+      if (FRAME_NATIVE_WINDOW (f) != 0)
        {
          adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width);
 
@@ -5413,10 +5413,12 @@ my_create_window (struct frame * f)
   Lisp_Object left, top;
   struct w32_display_info *dpyinfo = &one_w32_display_info;
 
-  /* When called with RES_TYPE_NUMBER, x_get_arg will return zero for
-     anything that is not a number and is not Qunbound.  */
-  left = x_get_arg (dpyinfo, Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
-  top = x_get_arg (dpyinfo, Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
+  /* When called with RES_TYPE_NUMBER, gui_display_get_arg will return
+     zero for anything that is not a number and is not Qunbound.  */
+  left = gui_display_get_arg (dpyinfo, Qnil, Qleft, "left", "Left",
+                              RES_TYPE_NUMBER);
+  top = gui_display_get_arg (dpyinfo, Qnil, Qtop, "top", "Top",
+                             RES_TYPE_NUMBER);
   if (EQ (left, Qunbound))
     coords[0] = CW_USEDEFAULT;
   else
@@ -5532,8 +5534,10 @@ w32_icon (struct frame *f, Lisp_Object parms)
 
   /* Set the position of the icon.  Note that Windows 95 groups all
      icons in the tray.  */
-  icon_x = x_get_arg (dpyinfo, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
-  icon_y = x_get_arg (dpyinfo, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
+  icon_x = gui_display_get_arg (dpyinfo, parms, Qicon_left, 0, 0,
+                                RES_TYPE_NUMBER);
+  icon_y = gui_display_get_arg (dpyinfo, parms, Qicon_top, 0, 0,
+                                RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_FIXNUM (icon_x);
@@ -5633,13 +5637,15 @@ static void
 w32_default_font_parameter (struct frame *f, Lisp_Object parms)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
-  Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL,
-                                      RES_TYPE_STRING);
+  Lisp_Object font_param = gui_display_get_arg (dpyinfo,
+                                                parms, Qfont, NULL, NULL,
+                                                RES_TYPE_STRING);
   Lisp_Object font;
   if (EQ (font_param, Qunbound))
     font_param = Qnil;
   font = !NILP (font_param) ? font_param
-    : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
+    : gui_display_get_arg (dpyinfo, parms, Qfont, "font", "Font",
+                           RES_TYPE_STRING);
 
   if (!STRINGP (font))
     {
@@ -5699,9 +5705,11 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parameters, Qterminal, 0, 0, RES_TYPE_NUMBER);
+  display = gui_display_get_arg (dpyinfo, parameters, Qterminal, 0, 0,
+                                 RES_TYPE_NUMBER);
   if (EQ (display, Qunbound))
-    display = x_get_arg (dpyinfo, parameters, Qdisplay, 0, 0, RES_TYPE_STRING);
+    display = gui_display_get_arg (dpyinfo, parameters, Qdisplay, 0, 0,
+                                   RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_x_display_info (display);
@@ -5710,7 +5718,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
-  name = x_get_arg (dpyinfo, parameters, Qname, "name", "Name", 
RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parameters, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -5720,8 +5729,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
     Vx_resource_name = name;
 
   /* See if parent window is specified.  */
-  parent = x_get_arg (dpyinfo, parameters, Qparent_id, NULL, NULL,
-                     RES_TYPE_NUMBER);
+  parent = gui_display_get_arg (dpyinfo, parameters, Qparent_id, NULL, NULL,
+                                RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   else if (!NILP (parent))
@@ -5731,8 +5740,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   /* No need to protect DISPLAY because that's not used after passing
      it to make_frame_without_minibuffer.  */
   frame = Qnil;
-  tem = x_get_arg (dpyinfo, parameters, Qminibuffer, "minibuffer", 
"Minibuffer",
-                  RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qminibuffer,
+                             "minibuffer", "Minibuffer",
+                             RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
     f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -5747,8 +5757,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
   XSETFRAME (frame, f);
 
-  parent_frame = x_get_arg (dpyinfo, parameters, Qparent_frame, NULL, NULL,
-                           RES_TYPE_SYMBOL);
+  parent_frame = gui_display_get_arg (dpyinfo, parameters, Qparent_frame,
+                                      NULL, NULL,
+                                      RES_TYPE_SYMBOL);
   /* Apply `parent-frame' parameter only when no `parent-id' was
      specified.  */
   if (!NILP (parent_frame)
@@ -5761,13 +5772,13 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   fset_parent_frame (f, parent_frame);
   store_frame_param (f, Qparent_frame, parent_frame);
 
-  tem = x_get_arg (dpyinfo, parameters, Qundecorated, NULL, NULL,
-                  RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qundecorated, NULL, NULL,
+                             RES_TYPE_BOOLEAN);
   FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil);
 
-  tem = x_get_arg (dpyinfo, parameters, Qskip_taskbar, NULL, NULL,
-                  RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qskip_taskbar, NULL, NULL,
+                             RES_TYPE_BOOLEAN);
   FRAME_SKIP_TASKBAR (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qskip_taskbar,
                     (NILP (tem) || EQ (tem, Qunbound)) ? Qnil : Qt);
@@ -5782,9 +5793,12 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   f->output_data.w32 = xzalloc (sizeof (struct w32_output));
   FRAME_FONTSET (f) = -1;
 
-  fset_icon_name
-    (f, x_get_arg (dpyinfo, parameters, Qicon_name, "iconName", "Title",
-                  RES_TYPE_STRING));
+  fset_icon_name (f, gui_display_get_arg (dpyinfo,
+                                          parameters,
+                                          Qicon_name,
+                                          "iconName",
+                                          "Title",
+                                          RES_TYPE_STRING));
   if (! STRINGP (f->icon_name))
     fset_icon_name (f, Qnil);
 
@@ -5851,8 +5865,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parameters, Qinternal_border_width,
-                        "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parameters, Qinternal_border_width,
+                                   "internalBorder", "InternalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parameters = Fcons (Fcons (Qinternal_border_width, value),
                            parameters);
@@ -5916,17 +5931,17 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
 
      Also process `min-width' and `min-height' parameters right here
      because `frame-windows-min-size' needs them.  */
-  tem = x_get_arg (dpyinfo, parameters, Qmin_width, NULL, NULL,
-                  RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qmin_width, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_width, tem);
-  tem = x_get_arg (dpyinfo, parameters, Qmin_height, NULL, NULL,
-                  RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qmin_height, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_height, tem);
   adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
                     FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, true,
-                    Qx_create_frame_1);
+                    Qgui_create_frame_1);
 
   /* The X resources controlling the menu-bar and tool-bar are
      processed specially at startup, and reflected in the mode
@@ -5974,7 +5989,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   window_prompting = gui_figure_window_size (f, parameters, true,
                                              &x_width, &x_height);
 
-  tem = x_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0,
+                             RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
 
   w32_window (f, window_prompting, minibuffer_only);
@@ -6003,8 +6019,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   gui_default_parameter (f, parameters, Qscroll_bar_height, Qnil,
                          "scrollBarHeight", "ScrollBarHeight", 
RES_TYPE_NUMBER);
 
-  /* Allow x_set_window_size, now.  */
-  f->can_x_set_window_size = true;
+  /* Allow set_window_size_hook, now.  */
+  f->can_set_window_size = true;
 
   if (x_width > 0)
     SET_FRAME_WIDTH (f, x_width);
@@ -6019,7 +6035,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   unblock_input ();
 
   adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
-                    Qx_create_frame_2);
+                    Qgui_create_frame_2);
 
   /* Process fullscreen parameter here in the hope that normalizing a
      fullheight/fullwidth frame will produce the size set by the last
@@ -6035,7 +6051,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (!f->output_data.w32->explicit_parent)
     {
       Lisp_Object visibility
-       = x_get_arg (dpyinfo, parameters, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+       = gui_display_get_arg (dpyinfo, parameters, Qvisibility, 0, 0,
+                               RES_TYPE_SYMBOL);
 
       if (EQ (visibility, Qicon))
        w32_iconify_frame (f);
@@ -6063,8 +6080,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
          || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
     kset_default_minibuffer_frame (kb, frame);
 
-  /* All remaining specified parameters, which have not been "used"
-     by x_get_arg and friends, now go in the misc. alist of the frame.  */
+  /* All remaining specified parameters, which have not been "used" by
+     gui_display_get_arg and friends, now go in the misc. alist of the
+     frame.  */
   for (tem = parameters; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
@@ -6500,13 +6518,6 @@ SOUND is nil to use the normal beep.  */)
   return sound;
 }
 
-#if 0  /* unused */
-int
-x_screen_planes (register struct frame *f)
-{
-  return FRAME_DISPLAY_INFO (f)->n_planes;
-}
-#endif
 
 /* Return the display structure for the display named NAME.
    Open a new connection if necessary.  */
@@ -6830,12 +6841,14 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
 
   kb = dpyinfo->terminal->kboard;
 
-  /* The calls to x_get_arg remove elements from PARMS, so copy it to
-     avoid destructive changes behind our caller's back.  */
+  /* The calls to gui_display_get_arg remove elements from PARMS, so
+     copy it to avoid destructive changes behind our caller's
+     back.  */
   parms = Fcopy_alist (parms);
 
   /* Get the name of the frame to use for resource lookup.  */
-  name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && !EQ (name, Qunbound)
       && !NILP (name))
@@ -6904,8 +6917,9 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
-                        "internalBorder", "internalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
+                                   "internalBorder", "internalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
@@ -7011,7 +7025,7 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
      below.  And the frame needs to be on Vframe_list or making it
      visible won't work.  */
   Vframe_list = Fcons (frame, Vframe_list);
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
 
   /* Setting attributes of faces of the tooltip frame from resources
      and similar will set face_change, which leads to the
diff --git a/src/w32gui.h b/src/w32gui.h
index dbc6799..5dcbbd9 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -42,8 +42,6 @@ typedef struct _XGCValues
 typedef HBITMAP Pixmap;
 typedef HBITMAP Bitmap;
 
-typedef char * XrmDatabase;
-
 typedef XGCValues * GC;
 typedef COLORREF Color;
 typedef HWND Window;
diff --git a/src/w32menu.c b/src/w32menu.c
index 42912db..669161c 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -153,7 +153,7 @@ w32_popup_dialog (struct frame *f, Lisp_Object header, 
Lisp_Object contents)
    This way we can safely execute Lisp code.  */
 
 void
-x_activate_menubar (struct frame *f)
+w32_activate_menubar (struct frame *f)
 {
   set_frame_menubar (f, false, true);
 
diff --git a/src/w32reg.c b/src/w32reg.c
index aff131d..e8201d3 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -21,7 +21,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include "lisp.h"
-#include "w32term.h"   /* for XrmDatabase, xrdb */
 #include "blockinput.h"
 
 #include <stdio.h>
@@ -73,8 +72,8 @@ w32_get_rdb_resource (const char *rdb, const char *resource)
   return NULL;
 }
 
-static char *
-w32_get_string_resource (const char *name, const char *class, DWORD dwexptype)
+static const char *
+w32_get_string_resource_1 (const char *name, const char *class, DWORD 
dwexptype)
 {
   LPBYTE lpvalue = NULL;
   HKEY hrootkey = NULL;
@@ -134,15 +133,17 @@ w32_get_string_resource (const char *name, const char 
*class, DWORD dwexptype)
       /* Check if there are Windows specific defaults defined.  */
       return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES, name);
     }
-  return (char *)lpvalue;
+  return (const char *)lpvalue;
 }
 
 /* Retrieve the string resource specified by NAME with CLASS from
    database RDB. */
 
-char *
-x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
+const char *
+w32_get_string_resource (void *v_rdb, const char *name, const char *class)
 {
+  const char *rdb = *((const char *)v_rdb);
+
   if (rdb)
     {
       char *resource;
@@ -157,5 +158,5 @@ x_get_string_resource (XrmDatabase rdb, const char *name, 
const char *class)
     /* --quick was passed, so this is a no-op.  */
     return NULL;
 
-  return w32_get_string_resource (name, class, REG_SZ);
+  return w32_get_string_resource_1 (name, class, REG_SZ);
 }
diff --git a/src/w32term.c b/src/w32term.c
index a011aca..9e51ddf 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3444,7 +3444,7 @@ w32_note_mouse_movement (struct frame *frame, MSG *msg)
   int mouse_y = HIWORD (msg->lParam);
   RECT *r;
 
-  if (!FRAME_X_OUTPUT (frame))
+  if (!FRAME_OUTPUT_DATA (frame))
     return 0;
 
   dpyinfo = FRAME_DISPLAY_INFO (frame);
@@ -5995,8 +5995,8 @@ w32_draw_window_cursor (struct window *w, struct 
glyph_row *glyph_row,
 
 /* Icons.  */
 
-bool
-x_bitmap_icon (struct frame *f, Lisp_Object icon)
+static bool
+w32_bitmap_icon (struct frame *f, Lisp_Object icon)
 {
   HANDLE main_icon;
   HANDLE small_icon = NULL;
@@ -6116,7 +6116,7 @@ w32_new_font (struct frame *f, Lisp_Object font_object, 
int fontset)
     }
 
   /* Now make the frame display the given font.  */
-  if (FRAME_X_WINDOW (f) != 0)
+  if (FRAME_NATIVE_WINDOW (f) != 0)
     {
       /* Don't change the size of a tip frame; there's no point in
         doing it because it's done in Fx_show_tip, and it leads to
@@ -6407,13 +6407,13 @@ w32fullscreen_hook (struct frame *f)
     f->want_fullscreen |= FULLSCREEN_WAIT;
 }
 
-/* Call this to change the size of frame F's x-window.
+/* Call this to change the size of frame F's native window.
    If CHANGE_GRAVITY, change to top-left-corner window gravity
    for this size change and subsequent size changes.
    Otherwise we leave the window gravity unchanged.  */
 
-void
-x_set_window_size (struct frame *f, bool change_gravity,
+static void
+w32_set_window_size (struct frame *f, bool change_gravity,
                   int width, int height, bool pixelwise)
 {
   int pixelwidth, pixelheight;
@@ -6499,7 +6499,7 @@ x_set_window_size (struct frame *f, bool change_gravity,
   if (pixelwidth > 0 || pixelheight > 0)
     {
       frame_size_history_add
-       (f, Qx_set_window_size_1, width, height,
+       (f, Qgui_set_window_size_1, width, height,
         list2 (Fcons (make_fixnum (pixelwidth),
                       make_fixnum (pixelheight)),
                Fcons (make_fixnum (rect.right - rect.left),
@@ -6964,7 +6964,7 @@ w32_show_hourglass (struct frame *f)
 {
   if (!menubar_in_use && !current_popup_menu)
     {
-      struct w32_output *w32 = FRAME_X_OUTPUT (f);
+      struct w32_output *w32 = FRAME_OUTPUT_DATA (f);
 
       w32->hourglass_p = 1;
       SetCursor (w32->hourglass_cursor);
@@ -6976,7 +6976,7 @@ w32_show_hourglass (struct frame *f)
 static void
 w32_hide_hourglass (struct frame *f)
 {
-  struct w32_output *w32 = FRAME_X_OUTPUT (f);
+  struct w32_output *w32 = FRAME_OUTPUT_DATA (f);
 
   w32->hourglass_p = 0;
   if (f->pointer_invisible)
@@ -7167,10 +7167,14 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
   terminal->frame_visible_invisible_hook = w32_make_frame_visible_invisible;
   terminal->fullscreen_hook = w32fullscreen_hook;
   terminal->iconify_frame_hook = w32_iconify_frame;
+  terminal->set_window_size_hook = w32_set_window_size;
+  terminal->set_frame_offset_hook = w32_set_offset;
   terminal->set_frame_alpha_hook = w32_set_frame_alpha;
   terminal->set_new_font_hook = w32_new_font;
+  terminal->set_bitmap_icon_hook = w32_bitmap_icon;
   terminal->implicit_set_name_hook = w32_implicitly_set_name;
   terminal->menu_show_hook = w32_menu_show;
+  terminal->activate_menubar_hook = w32_activate_menubar;
   terminal->popup_dialog_hook = w32_popup_dialog;
   terminal->change_tool_bar_height_hook = w32_change_tool_bar_height;
   terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
@@ -7180,6 +7184,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
   terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
   terminal->judge_scroll_bars_hook = w32_judge_scroll_bars;
+  terminal->get_string_resource_hook = w32_get_string_resource;
   terminal->delete_frame_hook = w32_destroy_window;
   terminal->delete_terminal_hook = w32_delete_terminal;
   /* Other hooks are NULL by default.  */
@@ -7237,7 +7242,7 @@ w32_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   /* Set the name of the terminal. */
   terminal->name = xlispstrdup (display_name);
 
-  dpyinfo->xrdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
+  dpyinfo->rdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
 
   /* Put this display on the chain.  */
   dpyinfo->next = x_display_list;
diff --git a/src/w32term.h b/src/w32term.h
index 6374704..d742aea 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -120,7 +120,7 @@ struct w32_display_info
   Cursor horizontal_scroll_bar_cursor;
 
   /* Resource data base */
-  XrmDatabase xrdb;
+  const char *rdb;
 
   /* color palette information.  */
   int has_palette;
@@ -231,7 +231,7 @@ extern struct frame *w32_window_to_frame (struct 
w32_display_info *, HWND);
 
 extern void w32_real_positions (struct frame *f, int *xptr, int *yptr);
 
-extern void w32_change_tool_bar_height (struct frame *, int)
+extern void w32_change_tool_bar_height (struct frame *, int);
 extern void w32_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
 extern void w32_set_scroll_bar_default_width (struct frame *);
 extern void w32_set_scroll_bar_default_height (struct frame *);
@@ -249,8 +249,8 @@ extern int w32_display_pixel_width (struct w32_display_info 
*);
 extern void initialize_frame_menubar (struct frame *);
 extern void w32_dialog_in_progress (Lisp_Object in_progress);
 
-extern void w32_make_frame_visible (struct frame *f)
-extern void w32_make_frame_invisible (struct frame *f)
+extern void w32_make_frame_visible (struct frame *f);
+extern void w32_make_frame_invisible (struct frame *f);
 extern void w32_iconify_frame (struct frame *f);
 extern void w32_free_frame_resources (struct frame *);
 extern void w32_wm_set_size_hint (struct frame *, long, bool);
@@ -263,6 +263,10 @@ extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
 extern void w32con_hide_cursor (void);
 extern void w32con_show_cursor (void);
 
+/* w32reg.c */
+extern const char *w32_get_string_resource (void *v_rdb,
+                                            const char *name,
+                                            const char *class);
 
 #define PIX_TYPE COLORREF
 
@@ -403,12 +407,12 @@ struct w32_output
 
 extern struct w32_output w32term_display;
 
-/* Return the X output data for frame F.  */
-#define FRAME_X_OUTPUT(f) ((f)->output_data.w32)
+/* Return the output data for frame F.  */
+#define FRAME_OUTPUT_DATA(f) ((f)->output_data.w32)
 
 /* Return the window associated with the frame F.  */
 #define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc)
-#define FRAME_X_WINDOW(f) FRAME_W32_WINDOW (f)
+#define FRAME_NATIVE_WINDOW(f) FRAME_W32_WINDOW (f)
 
 #define FRAME_FONT(f) ((f)->output_data.w32->font)
 #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset)
diff --git a/src/window.c b/src/window.c
index d805d2f..30ffad0 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3434,7 +3434,7 @@ run_window_configuration_change_hook (struct frame *f)
   XSETFRAME (frame, f);
 
   if (NILP (Vrun_hooks)
-      || !f->can_x_set_window_size
+      || !f->can_set_window_size
       || !f->after_make_frame)
     return;
 
@@ -3763,7 +3763,7 @@ run_window_change_functions (void)
       ptrdiff_t number_of_windows;
 
       if (!FRAME_LIVE_P (f)
-         || !f->can_x_set_window_size
+         || !f->can_set_window_size
          || !f->after_make_frame
          || FRAME_TOOLTIP_P (f)
          || !(frame_window_change
@@ -6867,8 +6867,8 @@ the return value is nil.  Otherwise the value is t.  */)
            call1 (Qrecord_window_buffer, window);
        }
 
-      /* Disallow x_set_window_size, temporarily.  */
-      f->can_x_set_window_size = false;
+      /* Disallow set_window_size_hook, temporarily.  */
+      f->can_set_window_size = false;
       /* The mouse highlighting code could get screwed up
         if it runs during this.  */
       block_input ();
@@ -7072,9 +7072,9 @@ the return value is nil.  Otherwise the value is t.  */)
        if (NILP (leaf_windows[i]->contents))
          free_window_matrices (leaf_windows[i]);
 
-      /* Allow x_set_window_size again and apply frame size changes if
-        needed.  */
-      f->can_x_set_window_size = true;
+      /* Allow set_window_size_hook again and apply frame size changes
+        if needed.  */
+      f->can_set_window_size = true;
       adjust_frame_size (f, -1, -1, 1, false, Qset_window_configuration);
 
       adjust_frame_glyphs (f);
diff --git a/src/xdisp.c b/src/xdisp.c
index 11667d2..371fdf4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -336,8 +336,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
-#ifndef FRAME_X_OUTPUT
-#define FRAME_X_OUTPUT(f) ((f)->output_data.x)
+#ifndef FRAME_OUTPUT_DATA
+#define FRAME_OUTPUT_DATA(f) (NULL)
 #endif
 
 #define DISP_INFINITY 10000000
@@ -11275,7 +11275,7 @@ resize_mini_window (struct window *w, bool exact_p)
   /* Nil means don't try to resize.  */
   if ((NILP (Vresize_mini_windows)
        && (NILP (resize_mini_frames) || !FRAME_MINIBUF_ONLY_P (f)))
-      || (FRAME_X_P (f) && FRAME_X_OUTPUT (f) == NULL))
+      || (FRAME_X_P (f) && FRAME_OUTPUT_DATA (f) == NULL))
     return false;
 
   /* By default, start display at the beginning.  */
@@ -30018,13 +30018,13 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum 
draw_glyphs_face draw)
 #ifndef HAVE_EXT_TOOL_BAR
       if (draw == DRAW_NORMAL_TEXT
          && !EQ (hlinfo->mouse_face_window, f->tool_bar_window))
-       FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
+       FRAME_RIF (f)->define_frame_cursor (f, FRAME_OUTPUT_DATA 
(f)->text_cursor);
       else
 #endif
       if (draw == DRAW_MOUSE_FACE)
-       FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
+       FRAME_RIF (f)->define_frame_cursor (f, FRAME_OUTPUT_DATA 
(f)->hand_cursor);
       else
-       FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT 
(f)->nontext_cursor);
+       FRAME_RIF (f)->define_frame_cursor (f, FRAME_OUTPUT_DATA 
(f)->nontext_cursor);
     }
 #endif /* HAVE_WINDOW_SYSTEM */
 }
@@ -30966,25 +30966,25 @@ define_frame_cursor1 (struct frame *f, Cursor cursor, 
Lisp_Object pointer)
   if (!NILP (pointer))
     {
       if (EQ (pointer, Qarrow))
-       cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
       else if (EQ (pointer, Qhand))
-       cursor = FRAME_X_OUTPUT (f)->hand_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->hand_cursor;
       else if (EQ (pointer, Qtext))
-       cursor = FRAME_X_OUTPUT (f)->text_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->text_cursor;
       else if (EQ (pointer, intern ("hdrag")))
-       cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
       else if (EQ (pointer, intern ("nhdrag")))
-       cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
 # ifdef HAVE_X_WINDOWS
       else if (EQ (pointer, intern ("vdrag")))
        cursor = FRAME_DISPLAY_INFO (f)->vertical_scroll_bar_cursor;
 # endif
       else if (EQ (pointer, intern ("hourglass")))
-       cursor = FRAME_X_OUTPUT (f)->hourglass_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->hourglass_cursor;
       else if (EQ (pointer, Qmodeline))
-       cursor = FRAME_X_OUTPUT (f)->modeline_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->modeline_cursor;
       else
-       cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
     }
 
   if (cursor != No_Cursor)
@@ -31136,7 +31136,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, 
int x, int y,
 
          if (STRINGP (string))
            {
-             cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+             cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
 
              if (NILP (pointer))
                pointer = Fget_text_property (pos, Qpointer, string);
@@ -31151,13 +31151,13 @@ note_mode_line_or_margin_highlight (Lisp_Object 
window, int x, int y,
                  if (!KEYMAPP (map))
                    map = Fget_text_property (pos, Qkeymap, string);
                  if (!KEYMAPP (map) && draggable && area == ON_MODE_LINE)
-                   cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+                   cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
                }
            }
          else if (draggable && area == ON_MODE_LINE)
-           cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+           cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
          else
-           cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+           cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
        }
 #endif
     }
@@ -31366,41 +31366,41 @@ note_mouse_highlight (struct frame *f, int x, int y)
       switch (part)
        {
        case INTERNAL_BORDER_NONE:
-         if (cursor != FRAME_X_OUTPUT (f)->nontext_cursor)
+         if (cursor != FRAME_OUTPUT_DATA (f)->nontext_cursor)
            /* Reset cursor.  */
-           cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+           cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
          break;
        case INTERNAL_BORDER_LEFT_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->left_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->left_edge_cursor;
          break;
        case INTERNAL_BORDER_TOP_LEFT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->top_left_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->top_left_corner_cursor;
          break;
        case INTERNAL_BORDER_TOP_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->top_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->top_edge_cursor;
          break;
        case INTERNAL_BORDER_TOP_RIGHT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->top_right_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->top_right_corner_cursor;
          break;
        case INTERNAL_BORDER_RIGHT_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->right_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->right_edge_cursor;
          break;
        case INTERNAL_BORDER_BOTTOM_RIGHT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->bottom_right_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->bottom_right_corner_cursor;
          break;
        case INTERNAL_BORDER_BOTTOM_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->bottom_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->bottom_edge_cursor;
          break;
        case INTERNAL_BORDER_BOTTOM_LEFT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->bottom_left_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->bottom_left_corner_cursor;
          break;
        default:
          /* This should not happen.  */
-         if (cursor != FRAME_X_OUTPUT (f)->nontext_cursor)
-           cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+         if (cursor != FRAME_OUTPUT_DATA (f)->nontext_cursor)
+           cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
        }
 
-      if (cursor != FRAME_X_OUTPUT (f)->nontext_cursor)
+      if (cursor != FRAME_OUTPUT_DATA (f)->nontext_cursor)
        {
          /* Do we really want a help echo here?  */
          help_echo_string = build_string ("drag-mouse-1: resize frame");
@@ -31436,7 +31436,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
 #ifdef HAVE_WINDOW_SYSTEM
       if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
        {
-         cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
          /* Show non-text cursor (Bug#16647).  */
          goto set_cursor;
        }
@@ -31448,13 +31448,13 @@ note_mouse_highlight (struct frame *f, int x, int y)
 #ifdef HAVE_WINDOW_SYSTEM
   if (part == ON_VERTICAL_BORDER)
     {
-      cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
+      cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
       help_echo_string = build_string ("drag-mouse-1: resize");
       goto set_cursor;
     }
   else if (part == ON_RIGHT_DIVIDER)
     {
-      cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
+      cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
       help_echo_string = build_string ("drag-mouse-1: resize");
       goto set_cursor;
     }
@@ -31463,18 +31463,18 @@ note_mouse_highlight (struct frame *f, int x, int y)
        || minibuf_level
        || NILP (Vresize_mini_windows))
       {
-       cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
        help_echo_string = build_string ("drag-mouse-1: resize");
        goto set_cursor;
       }
     else
-      cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
   else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
           || part == ON_VERTICAL_SCROLL_BAR
           || part == ON_HORIZONTAL_SCROLL_BAR)
-    cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+    cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
   else
-    cursor = FRAME_X_OUTPUT (f)->text_cursor;
+    cursor = FRAME_OUTPUT_DATA (f)->text_cursor;
 #endif
 
   /* Are we in a window whose display is up to date?
@@ -31565,7 +31565,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
            {
 #ifdef HAVE_WINDOW_SYSTEM
              if (area != TEXT_AREA)
-               cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+               cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
              else
                pointer = Vvoid_text_area_pointer;
 #endif
diff --git a/src/xfaces.c b/src/xfaces.c
index 24574ae..3f627d3 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -343,7 +343,7 @@ struct named_merge_point;
 
 static struct face *realize_face (struct face_cache *, Lisp_Object *,
                                  int);
-static struct face *realize_x_face (struct face_cache *, Lisp_Object *);
+static struct face *realize_gui_face (struct face_cache *, Lisp_Object *);
 static struct face *realize_tty_face (struct face_cache *, Lisp_Object *);
 static bool realize_basic_faces (struct frame *);
 static bool realize_default_face (struct frame *);
@@ -777,13 +777,13 @@ load_pixmap (struct frame *f, Lisp_Object name)
       h = XFIXNUM (Fcar (Fcdr (name)));
       bits = Fcar (Fcdr (Fcdr (name)));
 
-      bitmap_id = gui_create_bitmap_from_data (f, SSDATA (bits),
-                                               w, h);
+      bitmap_id = image_create_bitmap_from_data (f, SSDATA (bits),
+                                                 w, h);
     }
   else
     {
       /* It must be a string -- a file name.  */
-      bitmap_id = gui_create_bitmap_from_file (f, name);
+      bitmap_id = image_create_bitmap_from_file (f, name);
     }
   unblock_input ();
 
@@ -1188,7 +1188,7 @@ load_face_colors (struct frame *f, struct face *face,
   if (!face_color_supported_p (f, SSDATA (bg), false)
       && !NILP (Fbitmap_spec_p (Vface_default_stipple)))
     {
-      x_destroy_bitmap (f, face->stipple);
+      image_destroy_bitmap (f, face->stipple);
       face->stipple = load_pixmap (f, Vface_default_stipple);
     }
 
@@ -3484,8 +3484,8 @@ ordinary `x-get-resource' doesn't take a frame argument.  
*/)
   CHECK_STRING (class);
   f = decode_live_frame (frame);
   block_input ();
-  value = display_x_get_resource (FRAME_DISPLAY_INFO (f),
-                                 resource, class, Qnil, Qnil);
+  value = gui_display_get_resource (FRAME_DISPLAY_INFO (f),
+                                    resource, class, Qnil, Qnil);
   unblock_input ();
   return value;
 }
@@ -4153,7 +4153,7 @@ free_realized_face (struct frame *f, struct face *face)
 #ifdef HAVE_X_WINDOWS
          free_face_colors (f, face);
 #endif /* HAVE_X_WINDOWS */
-         x_destroy_bitmap (f, face->stipple);
+         image_destroy_bitmap (f, face->stipple);
        }
 #endif /* HAVE_WINDOW_SYSTEM */
 
@@ -4188,7 +4188,7 @@ prepare_face_for_display (struct frame *f, struct face 
*face)
       if (face->stipple)
        {
          xgcv.fill_style = FillOpaqueStippled;
-         xgcv.stipple = x_bitmap_pixmap (f, face->stipple);
+         xgcv.stipple = image_bitmap_pixmap (f, face->stipple);
          mask |= GCFillStyle | GCStipple;
        }
 #endif
@@ -4799,9 +4799,9 @@ DEFUN ("face-attributes-as-vector", 
Fface_attributes_as_vector,
     (2) `close in spirit' to what the attributes specify, if not exact.  */
 
 static bool
-x_supports_face_attributes_p (struct frame *f,
-                             Lisp_Object attrs[LFACE_VECTOR_SIZE],
-                             struct face *def_face)
+gui_supports_face_attributes_p (struct frame *f,
+                                Lisp_Object attrs[LFACE_VECTOR_SIZE],
+                                struct face *def_face)
 {
   Lisp_Object *def_attrs = def_face->lface;
 
@@ -5138,7 +5138,7 @@ face for italic.  */)
     supports = tty_supports_face_attributes_p (f, attrs, def_face);
 #ifdef HAVE_WINDOW_SYSTEM
   else
-    supports = x_supports_face_attributes_p (f, attrs, def_face);
+    supports = gui_supports_face_attributes_p (f, attrs, def_face);
 #endif
 
   return supports ? Qt : Qnil;
@@ -5524,7 +5524,7 @@ realize_face (struct face_cache *cache, Lisp_Object 
attrs[LFACE_VECTOR_SIZE],
     }
 
   if (FRAME_WINDOW_P (cache->f))
-    face = realize_x_face (cache, attrs);
+    face = realize_gui_face (cache, attrs);
   else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f))
     face = realize_tty_face (cache, attrs);
   else if (FRAME_INITIAL_P (cache->f))
@@ -5575,14 +5575,14 @@ realize_non_ascii_face (struct frame *f, Lisp_Object 
font_object,
 
 
 /* Realize the fully-specified face with attributes ATTRS in face
-   cache CACHE for ASCII characters.  Do it for X frame CACHE->f.  If
-   the new face doesn't share font with the default face, a fontname
-   is allocated from the heap and set in `font_name' of the new face,
-   but it is not yet loaded here.  Value is a pointer to the newly
-   created realized face.  */
+   cache CACHE for ASCII characters.  Do it for GUI frame CACHE->f.
+   If the new face doesn't share font with the default face, a
+   fontname is allocated from the heap and set in `font_name' of the
+   new face, but it is not yet loaded here.  Value is a pointer to the
+   newly created realized face.  */
 
 static struct face *
-realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
+realize_gui_face (struct face_cache *cache, Lisp_Object 
attrs[LFACE_VECTOR_SIZE])
 {
   struct face *face = NULL;
 #ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/xfns.c b/src/xfns.c
index b15f35b..b21d168 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1466,7 +1466,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
                                   ? f->icon_name
                                   : f->name)));
   else
-    result = x_bitmap_icon (f, arg);
+    result = FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, arg);
 
   if (result)
     {
@@ -2056,7 +2056,7 @@ x_set_title (struct frame *f, Lisp_Object name, 
Lisp_Object old_name)
   x_set_name_internal (f, name);
 }
 
-static void
+void
 x_set_scroll_bar_default_width (struct frame *f)
 {
   int unit = FRAME_COLUMN_WIDTH (f);
@@ -2077,7 +2077,7 @@ x_set_scroll_bar_default_width (struct frame *f)
 #endif
 }
 
-static void
+void
 x_set_scroll_bar_default_height (struct frame *f)
 {
   int height = FRAME_LINE_HEIGHT (f);
@@ -2115,7 +2115,8 @@ x_default_scroll_bar_color_parameter (struct frame *f,
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   Lisp_Object tem;
 
-  tem = x_get_arg (dpyinfo, alist, prop, xprop, xclass, RES_TYPE_STRING);
+  tem = gui_display_get_arg (dpyinfo, alist, prop, xprop, xclass,
+                             RES_TYPE_STRING);
   if (EQ (tem, Qunbound))
     {
 #ifdef USE_TOOLKIT_SCROLL_BARS
@@ -2125,7 +2126,7 @@ x_default_scroll_bar_color_parameter (struct frame *f,
       AUTO_STRING (foreground, "foreground");
       AUTO_STRING (background, "foreground");
       AUTO_STRING (verticalScrollBar, "verticalScrollBar");
-      tem = (display_x_get_resource
+      tem = (gui_display_get_resource
             (dpyinfo, foreground_p ? foreground : background,
              empty_unibyte_string,
              verticalScrollBar,
@@ -3257,8 +3258,8 @@ x_icon_verify (struct frame *f, Lisp_Object parms)
 
   /* Set the position of the icon.  Note that twm groups all
      icons in an icon window.  */
-  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);
+  icon_x = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, 
RES_TYPE_NUMBER);
+  icon_y = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, 
RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_FIXNUM (icon_x);
@@ -3278,9 +3279,9 @@ x_icon (struct frame *f, Lisp_Object parms)
   /* Set the position of the icon.  Note that twm groups all
      icons in an icon window.  */
   Lisp_Object icon_x
-    = x_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
+    = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, 
RES_TYPE_NUMBER);
   Lisp_Object icon_y
-    = x_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
+    = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, 
RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_TYPE_RANGED_INTEGER (int, icon_x);
@@ -3294,12 +3295,13 @@ x_icon (struct frame *f, Lisp_Object parms)
   if (! EQ (icon_x, Qunbound))
     x_wm_set_icon_position (f, XFIXNUM (icon_x), XFIXNUM (icon_y));
 
-#if false /* x_get_arg removes the visibility parameter as a side effect,
-            but x_create_frame still needs it.  */
+#if false /* gui_display_get_arg removes the visibility parameter as a
+            side effect, but x_create_frame still needs it.  */
   /* Start up iconic or window? */
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   x_wm_set_window_state
-    (f, (EQ (x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL),
+    (f, (EQ (gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+                                  RES_TYPE_SYMBOL),
             Qicon)
         ? IconicState
         : NormalState));
@@ -3463,8 +3465,8 @@ static void
 x_default_font_parameter (struct frame *f, Lisp_Object parms)
 {
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
-  Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL,
-                                      RES_TYPE_STRING);
+  Lisp_Object font_param = gui_display_get_arg (dpyinfo, parms, Qfont, NULL, 
NULL,
+                                                RES_TYPE_STRING);
   Lisp_Object font = Qnil;
   if (EQ (font_param, Qunbound))
     font_param = Qnil;
@@ -3481,7 +3483,8 @@ x_default_font_parameter (struct frame *f, Lisp_Object 
parms)
 
   if (NILP (font))
       font = !NILP (font_param) ? font_param
-      : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
+      : gui_display_get_arg (dpyinfo, parms, Qfont, "font", "Font",
+                             RES_TYPE_STRING);
 
   if (! FONTP (font) && ! STRINGP (font))
     {
@@ -3592,9 +3595,11 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_NUMBER);
+  display = gui_display_get_arg (dpyinfo, parms, Qterminal, 0, 0,
+                                 RES_TYPE_NUMBER);
   if (EQ (display, Qunbound))
-    display = x_get_arg (dpyinfo, parms, Qdisplay, 0, 0, RES_TYPE_STRING);
+    display = gui_display_get_arg (dpyinfo, parms, Qdisplay, 0, 0,
+                                   RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_x_display_info (display);
@@ -3603,7 +3608,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
-  name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -3613,15 +3619,17 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
     Vx_resource_name = name;
 
   /* See if parent window is specified.  */
-  parent = x_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
+  parent = gui_display_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL,
+                                RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   if (! NILP (parent))
     CHECK_FIXNUM (parent);
 
   frame = Qnil;
-  tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
-                  RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo,
+                             parms, Qminibuffer, "minibuffer", "Minibuffer",
+                             RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
     f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -3634,8 +3642,12 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   else
     f = make_frame (true);
 
-  parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL,
-                           RES_TYPE_SYMBOL);
+  parent_frame = gui_display_get_arg (dpyinfo,
+                                      parms,
+                                      Qparent_frame,
+                                      NULL,
+                                      NULL,
+                                      RES_TYPE_SYMBOL);
   /* Accept parent-frame iff parent-id was not specified.  */
   if (!NILP (parent)
       || EQ (parent_frame, Qunbound)
@@ -3648,16 +3660,24 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
   fset_parent_frame (f, parent_frame);
   store_frame_param (f, Qparent_frame, parent_frame);
 
-  if (!NILP (tem = (x_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL,
-                              RES_TYPE_BOOLEAN)))
+  if (!NILP (tem = (gui_display_get_arg (dpyinfo,
+                                         parms,
+                                         Qundecorated,
+                                         NULL,
+                                         NULL,
+                                         RES_TYPE_BOOLEAN)))
       && !(EQ (tem, Qunbound)))
     undecorated = true;
 
   FRAME_UNDECORATED (f) = undecorated;
   store_frame_param (f, Qundecorated, undecorated ? Qt : Qnil);
 
-  if (!NILP (tem = (x_get_arg (dpyinfo, parms, Qoverride_redirect, NULL, NULL,
-                              RES_TYPE_BOOLEAN)))
+  if (!NILP (tem = (gui_display_get_arg (dpyinfo,
+                                         parms,
+                                         Qoverride_redirect,
+                                         NULL,
+                                         NULL,
+                                         RES_TYPE_BOOLEAN)))
       && !(EQ (tem, Qunbound)))
     override_redirect = true;
 
@@ -3681,9 +3701,12 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   f->output_data.x->white_relief.pixel = -1;
   f->output_data.x->black_relief.pixel = -1;
 
-  fset_icon_name (f,
-                 x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
-                            RES_TYPE_STRING));
+  fset_icon_name (f, gui_display_get_arg (dpyinfo,
+                                          parms,
+                                          Qicon_name,
+                                          "iconName",
+                                          "Title",
+                                          RES_TYPE_STRING));
   if (! STRINGP (f->icon_name))
     fset_icon_name (f, Qnil);
 
@@ -3792,8 +3815,9 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
-                        "internalBorder", "internalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
+                                   "internalBorder", "internalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
@@ -3865,15 +3889,17 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
 
      Also process `min-width' and `min-height' parameters right here
      because `frame-windows-min-size' needs them.  */
-  tem = x_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_width, tem);
-  tem = x_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_height, tem);
   adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
                     FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, true,
-                    Qx_create_frame_1);
+                    Qgui_create_frame_1);
 
   /* Set the menu-bar-lines and tool-bar-lines parameters.  We don't
      look up the X resources controlling the menu-bar and tool-bar
@@ -3906,7 +3932,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   window_prompting = gui_figure_window_size (f, parms, true,
                                              &x_width, &x_height);
 
-  tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0,
+                             RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
 
   x_icon_verify (f, parms);
@@ -3980,7 +4007,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
 #endif /* USE_X_TOOLKIT || USE_GTK */
 
   /* Consider frame official, now.  */
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
 
   if (x_width > 0)
     SET_FRAME_WIDTH (f, x_width);
@@ -3995,7 +4022,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   unblock_input ();
 
   adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
-                    0, true, Qx_create_frame_2);
+                    0, true, Qgui_create_frame_2);
 
   /* Process fullscreen parameter here in the hope that normalizing a
      fullheight/fullwidth frame will produce the size set by the last
@@ -4009,7 +4036,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   if (!f->output_data.x->explicit_parent)
     {
       Lisp_Object visibility
-       = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+       = gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+                               RES_TYPE_SYMBOL);
 
       if (EQ (visibility, Qicon))
        x_iconify_frame (f);
@@ -4057,8 +4085,9 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
           || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
     kset_default_minibuffer_frame (kb, frame);
 
-  /* All remaining specified parameters, which have not been "used"
-     by x_get_arg and friends, now go in the misc. alist of the frame.  */
+  /* All remaining specified parameters, which have not been "used" by
+     gui_display_get_arg and friends, now go in the misc. alist of the
+     frame.  */
   for (tem = parms; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
@@ -5482,8 +5511,8 @@ select_visual (struct x_display_info *dpyinfo)
   /* See if a visual is specified.  */
   AUTO_STRING (visualClass, "visualClass");
   AUTO_STRING (VisualClass, "VisualClass");
-  Lisp_Object value = display_x_get_resource (dpyinfo, visualClass,
-                                             VisualClass, Qnil, Qnil);
+  Lisp_Object value = gui_display_get_resource (dpyinfo, visualClass,
+                                                VisualClass, Qnil, Qnil);
 
   if (STRINGP (value))
     {
@@ -6091,7 +6120,8 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
   parms = Fcopy_alist (parms);
 
   /* Get the name of the frame to use for resource lookup.  */
-  name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && !EQ (name, Qunbound)
       && !NILP (name))
@@ -6209,8 +6239,9 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
-                        "internalBorder", "internalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
+                                   "internalBorder", "internalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
@@ -6366,7 +6397,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
      below.  And the frame needs to be on Vframe_list or making it
      visible won't work.  */
   Vframe_list = Fcons (frame, Vframe_list);
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
 
   /* Setting attributes of faces of the tooltip frame from resources
      and similar will set face_change, which leads to the clearing of
diff --git a/src/xrdb.c b/src/xrdb.c
index 35de446..06db98c 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -60,12 +60,12 @@ x_get_customization_string (XrmDatabase db, const char 
*name,
 {
   char *full_name = alloca (strlen (name) + sizeof "customization" + 3);
   char *full_class = alloca (strlen (class) + sizeof "Customization" + 3);
-  char *result;
+  const char *result;
 
   sprintf (full_name,  "%s.%s", name,  "customization");
   sprintf (full_class, "%s.%s", class, "Customization");
 
-  result = x_get_string_resource (db, full_name, full_class);
+  result = x_get_string_resource (&db, full_name, full_class);
   return result ? xstrdup (result) : NULL;
 }
 
@@ -547,19 +547,20 @@ x_get_resource (XrmDatabase rdb, const char *name, const 
char *class,
 /* Retrieve the string resource specified by NAME with CLASS from
    database RDB. */
 
-char *
-x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
+const char *
+x_get_string_resource (void *v_rdb, const char *name, const char *class)
 {
+  XrmDatabase *rdb = v_rdb;
   XrmValue value;
 
   if (inhibit_x_resources)
     /* --quick was passed, so this is a no-op.  */
     return NULL;
 
-  if (x_get_resource (rdb, name, class, x_rm_string, &value))
-    return (char *) value.addr;
+  if (x_get_resource (*rdb, name, class, x_rm_string, &value))
+    return (const char *) value.addr;
 
-  return 0;
+  return NULL;
 }
 
 /* Stand-alone test facilities.  */
@@ -648,7 +649,7 @@ main (int argc, char **argv)
          printf ("Class: ");
          gets (query_class);
 
-         value = x_get_string_resource (xdb, query_name, query_class);
+         value = x_get_string_resource (&xdb, query_name, query_class);
 
          if (value != NULL)
            printf ("\t%s(%s):  %s\n\n", query_name, query_class, value);
diff --git a/src/xterm.c b/src/xterm.c
index ccb4007..82be9b2 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9541,7 +9541,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row 
*glyph_row, int x,
 
 /* Make the x-window of frame F use the gnu icon bitmap.  */
 
-bool
+static bool
 x_bitmap_icon (struct frame *f, Lisp_Object file)
 {
   ptrdiff_t bitmap_id;
@@ -9551,7 +9551,7 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
 
   /* Free up our existing icon bitmap and mask if any.  */
   if (f->output_data.x->icon_bitmap > 0)
-    x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
+    image_destroy_bitmap (f, f->output_data.x->icon_bitmap);
   f->output_data.x->icon_bitmap = 0;
 
   if (STRINGP (file))
@@ -9562,7 +9562,7 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
       if (xg_set_icon (f, file))
        return false;
 #endif /* USE_GTK */
-      bitmap_id = gui_create_bitmap_from_file (f, file);
+      bitmap_id = image_create_bitmap_from_file (f, file);
       x_create_bitmap_mask (f, bitmap_id);
     }
   else
@@ -9592,8 +9592,10 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
          /* If all else fails, use the (black and white) xbm image. */
          if (rc == -1)
            {
-              rc = gui_create_bitmap_from_data (f, (char *) gnu_xbm_bits,
-                                                gnu_xbm_width, gnu_xbm_height);
+              rc = image_create_bitmap_from_data (f,
+                                                  (char *) gnu_xbm_bits,
+                                                  gnu_xbm_width,
+                                                  gnu_xbm_height);
              if (rc == -1)
                return true;
 
@@ -9606,7 +9608,7 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
         this increments the ref-count one extra time.
         As a result, the GNU bitmap and mask are never freed.
         That way, we don't have to worry about allocating it again.  */
-      gui_reference_bitmap (f, FRAME_DISPLAY_INFO (f)->icon_bitmap_id);
+      image_reference_bitmap (f, FRAME_DISPLAY_INFO (f)->icon_bitmap_id);
 
       bitmap_id = FRAME_DISPLAY_INFO (f)->icon_bitmap_id;
     }
@@ -9637,7 +9639,7 @@ x_text_icon (struct frame *f, const char *icon_name)
   }
 
   if (f->output_data.x->icon_bitmap > 0)
-    x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
+    image_destroy_bitmap (f, f->output_data.x->icon_bitmap);
   f->output_data.x->icon_bitmap = 0;
   x_wm_set_icon_pixmap (f, 0);
 
@@ -10140,7 +10142,7 @@ xim_open_dpy (struct x_display_info *dpyinfo, char 
*resource_name)
     {
       if (dpyinfo->xim)
        XCloseIM (dpyinfo->xim);
-      xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
+      xim = XOpenIM (dpyinfo->display, dpyinfo->rdb, resource_name,
                     emacs_class);
       dpyinfo->xim = xim;
 
@@ -10239,7 +10241,7 @@ xim_initialize (struct x_display_info *dpyinfo, char 
*resource_name)
       xim_inst->dpyinfo = dpyinfo;
       xim_inst->resource_name = xstrdup (resource_name);
       ret = XRegisterIMInstantiateCallback
-       (dpyinfo->display, dpyinfo->xrdb, xim_inst->resource_name,
+       (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name,
         emacs_class, xim_instantiate_callback,
         /* This is XPointer in XFree86 but (XPointer *)
            on Tru64, at least, hence the configure test.  */
@@ -10267,7 +10269,7 @@ xim_close_dpy (struct x_display_info *dpyinfo)
       if (dpyinfo->display)
        {
          Bool ret = XUnregisterIMInstantiateCallback
-           (dpyinfo->display, dpyinfo->xrdb, xim_inst->resource_name,
+           (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name,
             emacs_class, xim_instantiate_callback,
             (XRegisterIMInstantiateCallback_arg6) xim_inst);
          eassert (ret == True);
@@ -10383,7 +10385,7 @@ x_calc_absolute_position (struct frame *f)
    position values).  It is -1 when calling from gui_set_frame_parameters,
    which means, do adjust for borders but don't change the gravity.  */
 
-void
+static void
 x_set_offset (struct frame *f, register int xoff, register int yoff, int 
change_gravity)
 {
   int modified_top, modified_left;
@@ -10796,7 +10798,7 @@ do_ewmh_fullscreen (struct frame *f)
   int cur;
   bool dummy;
 
-  get_current_wm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
+  x_get_current_wm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
 
   /* Some window managers don't say they support _NET_WM_STATE, but they do say
      they support _NET_WM_STATE_FULLSCREEN.  Try that also.  */
@@ -11201,7 +11203,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
   if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
     {
       frame_size_history_add
-       (f, Qx_set_window_size_1, width, height,
+       (f, Qgui_set_window_size_1, width, height,
         list2i (old_height, pixelheight + FRAME_MENUBAR_HEIGHT (f)));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
@@ -11210,7 +11212,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
   else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
     {
       frame_size_history_add
-       (f, Qx_set_window_size_2, width, height,
+       (f, Qgui_set_window_size_2, width, height,
         list2i (old_width, pixelwidth));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
@@ -11220,7 +11222,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
   else
     {
       frame_size_history_add
-       (f, Qx_set_window_size_3, width, height,
+       (f, Qgui_set_window_size_3, width, height,
         list3i (pixelwidth + FRAME_TOOLBAR_WIDTH (f),
                 (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
                  + FRAME_MENUBAR_HEIGHT (f)),
@@ -11358,7 +11360,7 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
 
 /* Raise frame F.  */
 
-void
+static void
 x_raise_frame (struct frame *f)
 {
   block_input ();
@@ -12183,7 +12185,7 @@ x_wm_set_icon_pixmap (struct frame *f, ptrdiff_t 
pixmap_id)
 
   if (pixmap_id > 0)
     {
-      icon_pixmap = x_bitmap_pixmap (f, pixmap_id);
+      icon_pixmap = image_bitmap_pixmap (f, pixmap_id);
       f->output_data.x->wm_hints.icon_pixmap = icon_pixmap;
       icon_mask = x_bitmap_mask (f, pixmap_id);
       f->output_data.x->wm_hints.icon_mask = icon_mask;
@@ -12757,7 +12759,7 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 #endif
   /* Put the rdb where we can find it in a way that works on
      all versions.  */
-  dpyinfo->xrdb = xrdb;
+  dpyinfo->rdb = xrdb;
 
   dpyinfo->screen = ScreenOfDisplay (dpyinfo->display,
                                     DefaultScreen (dpyinfo->display));
@@ -12788,8 +12790,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
          AUTO_STRING (privateColormap, "privateColormap");
          AUTO_STRING (PrivateColormap, "PrivateColormap");
          Lisp_Object value
-           = display_x_get_resource (dpyinfo, privateColormap,
-                                     PrivateColormap, Qnil, Qnil);
+           = gui_display_get_resource (dpyinfo, privateColormap,
+                                        PrivateColormap, Qnil, Qnil);
          if (STRINGP (value)
              && (!strcmp (SSDATA (value), "true")
                  || !strcmp (SSDATA (value), "on")))
@@ -13006,8 +13008,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   {
     AUTO_STRING (synchronous, "synchronous");
     AUTO_STRING (Synchronous, "Synchronous");
-    Lisp_Object value = display_x_get_resource (dpyinfo, synchronous,
-                                               Synchronous, Qnil, Qnil);
+    Lisp_Object value = gui_display_get_resource (dpyinfo, synchronous,
+                                                  Synchronous, Qnil, Qnil);
     if (STRINGP (value)
        && (!strcmp (SSDATA (value), "true")
            || !strcmp (SSDATA (value), "on")))
@@ -13017,8 +13019,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   {
     AUTO_STRING (useXIM, "useXIM");
     AUTO_STRING (UseXIM, "UseXIM");
-    Lisp_Object value = display_x_get_resource (dpyinfo, useXIM, UseXIM,
-                                               Qnil, Qnil);
+    Lisp_Object value = gui_display_get_resource (dpyinfo, useXIM, UseXIM,
+                                                  Qnil, Qnil);
 #ifdef USE_XIM
     if (STRINGP (value)
        && (!strcmp (SSDATA (value), "false")
@@ -13210,13 +13212,13 @@ x_delete_terminal (struct terminal *terminal)
   /* Normally, the display is available...  */
   if (dpyinfo->display)
     {
-      gui_destroy_all_bitmaps (dpyinfo);
+      image_destroy_all_bitmaps (dpyinfo);
       XSetCloseDownMode (dpyinfo->display, DestroyAll);
 
       /* Whether or not XCloseDisplay destroys the associated resource
         database depends on the version of libX11.  To avoid both
         crash and memory leak, we dissociate the database from the
-        display and then destroy dpyinfo->xrdb ourselves.
+        display and then destroy dpyinfo->rdb ourselves.
 
         Unfortunately, the above strategy does not work in some
         situations due to a bug in newer versions of libX11: because
@@ -13236,7 +13238,7 @@ x_delete_terminal (struct terminal *terminal)
       /* We used to call XrmDestroyDatabase from x_delete_display, but
         some older versions of libX11 crash if we call it after
         closing all the displays.  */
-      XrmDestroyDatabase (dpyinfo->xrdb);
+      XrmDestroyDatabase (dpyinfo->rdb);
 #endif
 
 #ifdef USE_GTK
@@ -13302,10 +13304,16 @@ x_create_terminal (struct x_display_info *dpyinfo)
   terminal->frame_visible_invisible_hook = x_make_frame_visible_invisible;
   terminal->fullscreen_hook = XTfullscreen_hook;
   terminal->iconify_frame_hook = x_iconify_frame;
+  terminal->set_window_size_hook = x_set_window_size;
+  terminal->set_frame_offset_hook = x_set_offset;
   terminal->set_frame_alpha_hook = x_set_frame_alpha;
   terminal->set_new_font_hook = x_new_font;
+  terminal->set_bitmap_icon_hook = x_bitmap_icon;
   terminal->implicit_set_name_hook = x_implicitly_set_name;
   terminal->menu_show_hook = x_menu_show;
+#ifdef HAVE_EXT_MENU_BAR
+  terminal->activate_menubar_hook = x_activate_menubar;
+#endif
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   terminal->popup_dialog_hook = xw_popup_dialog;
 #endif
@@ -13319,6 +13327,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
   terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
   terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
+  terminal->get_string_resource_hook = x_get_string_resource;
   terminal->delete_frame_hook = x_destroy_window;
   terminal->delete_terminal_hook = x_delete_terminal;
   /* Other hooks are NULL by default.  */
diff --git a/src/xterm.h b/src/xterm.h
index a5313cf..637ff2f 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -249,7 +249,7 @@ struct x_display_info
 #endif
 
   /* X Resource data base */
-  XrmDatabase xrdb;
+  XrmDatabase rdb;
 
   /* Minimum width over all characters in all fonts in font_table.  */
   int smallest_char_width;
@@ -764,9 +764,11 @@ enum
 
 /* Return the X output data for frame F.  */
 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
+#define FRAME_OUTPUT_DATA(f) FRAME_X_OUTPUT (f)
 
 /* Return the X window used for displaying data in frame F.  */
 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
+#define FRAME_NATIVE_WINDOW(f) FRAME_X_WINDOW (f)
 
 /* Return the drawable used for rendering to frame F.  */
 #define FRAME_X_RAW_DRAWABLE(f) ((f)->output_data.x->draw_desc)
@@ -1087,6 +1089,7 @@ extern void x_real_pos_and_offsets (struct frame *f,
 
 XrmDatabase x_load_resources (Display *, const char *, const char *,
                              const char *);
+extern const char *x_get_string_resource (void *, const char *, const char *);
 
 /* Defined in xterm.c */
 
@@ -1103,8 +1106,9 @@ extern bool x_had_errors_p (Display *);
 extern void x_uncatch_errors (void);
 extern void x_uncatch_errors_after_check (void);
 extern void x_clear_errors (Display *);
-extern void x_make_frame_visible (struct frame *f)
-extern void x_make_frame_invisible (struct frame *f)
+extern void x_set_window_size (struct frame *f, bool, int, int, bool);
+extern void x_make_frame_visible (struct frame *f);
+extern void x_make_frame_invisible (struct frame *f);
 extern void x_iconify_frame (struct frame *f);
 extern void x_free_frame_resources (struct frame *);
 extern void x_wm_set_size_hint (struct frame *, long, bool);
@@ -1200,7 +1204,7 @@ extern void initial_set_up_x_back_buffer (struct frame 
*f);
 
 /* Defined in xfns.c.  */
 extern void x_real_positions (struct frame *, int *, int *);
-extern void x_change_tool_bar_height (struct frame *, int)
+extern void x_change_tool_bar_height (struct frame *, int);
 extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_scroll_bar_default_width (struct frame *);
 extern void x_set_scroll_bar_default_height (struct frame *);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]