(emacs_doprnt_1): Fix problem with %0XXd for a negative integer.
[chise/xemacs-chise.git-] / src / glyphs-x.c
index 70b15e0..a1f0051 100644 (file)
@@ -4,6 +4,7 @@
    Copyright (C) 1995 Tinker Systems
    Copyright (C) 1995, 1996 Ben Wing
    Copyright (C) 1995 Sun Microsystems
+   Copyright (C) 1999 Andy Piper
 
 This file is part of XEmacs.
 
@@ -51,12 +52,16 @@ Boston, MA 02111-1307, USA.  */
 #include "console-x.h"
 #include "glyphs-x.h"
 #include "objects-x.h"
+#include "gui-x.h"
 #include "xmu.h"
 
 #include "buffer.h"
+#include "window.h"
 #include "frame.h"
 #include "insdel.h"
 #include "opaque.h"
+#include "gui.h"
+#include "faces.h"
 
 #include "imgproc.h"
 
@@ -68,6 +73,11 @@ Boston, MA 02111-1307, USA.  */
 #include "file-coding.h"
 #endif
 
+#ifdef LWLIB_USES_MOTIF
+#include <Xm/Xm.h>
+#endif
+#include <X11/IntrinsicP.h>
+
 #if INTBITS == 32
 # define FOUR_BYTE_TYPE unsigned int
 #elif LONGBITS == 32
@@ -80,9 +90,29 @@ Boston, MA 02111-1307, USA.  */
 
 #define LISP_DEVICE_TO_X_SCREEN(dev) XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev)))
 
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
+#ifdef HAVE_JPEG
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
+#endif
+#ifdef HAVE_TIFF
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
+#endif  
+#ifdef HAVE_PNG
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
+#endif  
+#ifdef HAVE_GIF
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
+#endif  
+#ifdef HAVE_XPM
+DEFINE_DEVICE_IIFORMAT (x, xpm);
+#endif
+DEFINE_DEVICE_IIFORMAT (x, xbm);
+DEFINE_DEVICE_IIFORMAT (x, subwindow);
 #ifdef HAVE_XFACE
-DEFINE_IMAGE_INSTANTIATOR_FORMAT (xface);
-Lisp_Object Qxface;
+DEFINE_DEVICE_IIFORMAT (x, xface);
 #endif
 
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (cursor_font);
@@ -92,6 +122,12 @@ DEFINE_IMAGE_INSTANTIATOR_FORMAT (font);
 
 DEFINE_IMAGE_INSTANTIATOR_FORMAT (autodetect);
 
+DEFINE_DEVICE_IIFORMAT (x, widget);
+DEFINE_DEVICE_IIFORMAT (x, button);
+DEFINE_DEVICE_IIFORMAT (x, progress_gauge);
+DEFINE_DEVICE_IIFORMAT (x, edit_field);
+DEFINE_DEVICE_IIFORMAT (x, combo_box);
+
 static void cursor_font_instantiate (Lisp_Object image_instance,
                                     Lisp_Object instantiator,
                                     Lisp_Object pointer_fg,
@@ -119,10 +155,10 @@ convert_EImage_to_XImage (Lisp_Object device, int width, int height,
   Colormap cmap;
   Visual *vis;
   XImage *outimg;
-  int depth, bitmap_pad, byte_cnt, i, j;
+  int depth, bitmap_pad, bits_per_pixel, byte_cnt, i, j;
   int rd,gr,bl,q;
   unsigned char *data, *ip, *dp;
-  quant_table *qtable;
+  quant_table *qtable = 0;
   union {
     FOUR_BYTE_TYPE val;
     char cp[4];
@@ -144,13 +180,15 @@ convert_EImage_to_XImage (Lisp_Object device, int width, int height,
   bitmap_pad = ((depth > 16) ? 32 :
                (depth >  8) ? 16 :
                8);
-  byte_cnt = bitmap_pad >> 3;
-  
+
   outimg = XCreateImage (dpy, vis,
                         depth, ZPixmap, 0, 0, width, height,
                         bitmap_pad, 0);
   if (!outimg) return NULL;
 
+  bits_per_pixel = outimg->bits_per_pixel;
+  byte_cnt = bits_per_pixel >> 3;
+
   data = (unsigned char *) xmalloc (outimg->bytes_per_line * height);
   if (!data)
     {
@@ -158,7 +196,7 @@ convert_EImage_to_XImage (Lisp_Object device, int width, int height,
       return NULL;
     }
   outimg->data = (char *) data;
-  
+
   if (vis->class == PseudoColor)
     {
       unsigned long pixarray[256];
@@ -174,7 +212,7 @@ convert_EImage_to_XImage (Lisp_Object device, int width, int height,
        {
          XColor color;
          int res;
-       
+
          color.red = qtable->rm[i] ? qtable->rm[i] << 8 : 0;
          color.green = qtable->gm[i] ? qtable->gm[i] << 8 : 0;
          color.blue = qtable->bm[i] ? qtable->bm[i] << 8 : 0;
@@ -287,7 +325,7 @@ convert_EImage_to_XImage (Lisp_Object device, int width, int height,
 #endif
            }
        }
-    }  
+    }
   return outimg;
 }
 
@@ -314,10 +352,6 @@ x_print_image_instance (struct Lisp_Image_Instance *p,
        }
       write_c_string (")", printcharfun);
       break;
-#if HAVE_SUBWINDOWS
-    case IMAGE_SUBWINDOW:
-      /* #### implement me */
-#endif
     default:
       break;
     }
@@ -333,27 +367,45 @@ x_finalize_image_instance (struct Lisp_Image_Instance *p)
     {
       Display *dpy = DEVICE_X_DISPLAY (XDEVICE (p->device));
 
-      if (IMAGE_INSTANCE_X_PIXMAP (p))
-       XFreePixmap (dpy, IMAGE_INSTANCE_X_PIXMAP (p));
-      if (IMAGE_INSTANCE_X_MASK (p) &&
-         IMAGE_INSTANCE_X_MASK (p) != IMAGE_INSTANCE_X_PIXMAP (p))
-       XFreePixmap (dpy, IMAGE_INSTANCE_X_MASK (p));
-      IMAGE_INSTANCE_X_PIXMAP (p) = 0;
-      IMAGE_INSTANCE_X_MASK (p) = 0;
-
-      if (IMAGE_INSTANCE_X_CURSOR (p))
+      if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
        {
-         XFreeCursor (dpy, IMAGE_INSTANCE_X_CURSOR (p));
-         IMAGE_INSTANCE_X_CURSOR (p) = 0;
+         if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
+           {
+             XtUnmanageChild (IMAGE_INSTANCE_X_WIDGET_ID (p));
+             XtDestroyWidget (IMAGE_INSTANCE_X_WIDGET_ID (p));
+             IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
+           }
        }
-
-      if (IMAGE_INSTANCE_X_NPIXELS (p) != 0)
+      else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
+       {
+         if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
+           XDestroyWindow (dpy, IMAGE_INSTANCE_X_SUBWINDOW_ID (p));
+         IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
+       }
+      else
        {
-         XFreeColors (dpy,
-                      IMAGE_INSTANCE_X_COLORMAP (p),
-                      IMAGE_INSTANCE_X_PIXELS (p),
-                      IMAGE_INSTANCE_X_NPIXELS (p), 0);
-         IMAGE_INSTANCE_X_NPIXELS (p) = 0;
+         if (IMAGE_INSTANCE_X_PIXMAP (p))
+           XFreePixmap (dpy, IMAGE_INSTANCE_X_PIXMAP (p));
+         if (IMAGE_INSTANCE_X_MASK (p) &&
+             IMAGE_INSTANCE_X_MASK (p) != IMAGE_INSTANCE_X_PIXMAP (p))
+           XFreePixmap (dpy, IMAGE_INSTANCE_X_MASK (p));
+         IMAGE_INSTANCE_X_PIXMAP (p) = 0;
+         IMAGE_INSTANCE_X_MASK (p) = 0;
+         
+         if (IMAGE_INSTANCE_X_CURSOR (p))
+           {
+             XFreeCursor (dpy, IMAGE_INSTANCE_X_CURSOR (p));
+             IMAGE_INSTANCE_X_CURSOR (p) = 0;
+           }
+         
+         if (IMAGE_INSTANCE_X_NPIXELS (p) != 0)
+           {
+             XFreeColors (dpy,
+                          IMAGE_INSTANCE_X_COLORMAP (p),
+                          IMAGE_INSTANCE_X_PIXELS (p),
+                          IMAGE_INSTANCE_X_NPIXELS (p), 0);
+             IMAGE_INSTANCE_X_NPIXELS (p) = 0;
+           }
        }
     }
   if (IMAGE_INSTANCE_X_PIXELS (p))
@@ -378,10 +430,6 @@ x_image_instance_equal (struct Lisp_Image_Instance *p1,
       if (IMAGE_INSTANCE_X_COLORMAP (p1) != IMAGE_INSTANCE_X_COLORMAP (p2) ||
          IMAGE_INSTANCE_X_NPIXELS (p1) != IMAGE_INSTANCE_X_NPIXELS (p2))
        return 0;
-#if HAVE_SUBWINDOWS
-    case IMAGE_SUBWINDOW:
-      /* #### implement me */
-#endif
       break;
     default:
       break;
@@ -399,11 +447,6 @@ x_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
     case IMAGE_COLOR_PIXMAP:
     case IMAGE_POINTER:
       return IMAGE_INSTANCE_X_NPIXELS (p);
-#if HAVE_SUBWINDOWS
-    case IMAGE_SUBWINDOW:
-      /* #### implement me */
-      return 0;
-#endif
     default:
       return 0;
     }
@@ -469,7 +512,7 @@ x_locate_pixmap_file (Lisp_Object name)
     }
 
   if (NILP (Vdefault_x_device))
-    /* This may occur during intialization. */
+    /* This may occur during initialization. */
     return Qnil;
   else
     /* We only check the bitmapFilePath resource on the original X device. */
@@ -508,13 +551,13 @@ x_locate_pixmap_file (Lisp_Object name)
 
   {
     Lisp_Object found;
-    if (locate_file (Vx_bitmap_file_path, name, "", &found, R_OK) < 0)
+    if (locate_file (Vx_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
       {
        Lisp_Object temp = list1 (Vdata_directory);
        struct gcpro gcpro1;
 
        GCPRO1 (temp);
-       locate_file (temp, name, "", &found, R_OK);
+       locate_file (temp, name, Qnil, &found, R_OK);
        UNGCPRO;
       }
 
@@ -609,7 +652,7 @@ write_lisp_string_to_temp_file (Lisp_Object string, char *filename_out)
       /* reset the dynarr */
       Lstream_rewind(ostr);
     }
-  
+
   if (fclose (tmpfil) != 0)
     fubar = 1;
   Lstream_close (istr);
@@ -791,7 +834,7 @@ init_image_instance_from_x_image (struct Lisp_Image_Instance *ii,
 static void
 x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
                                   int width, int height,
-                                  unsigned char *eimage, 
+                                  unsigned char *eimage,
                                   int dest_mask,
                                   Lisp_Object instantiator,
                                   Lisp_Object domain)
@@ -801,7 +844,7 @@ x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
   unsigned long *pixtbl = NULL;
   int npixels = 0;
   XImage* ximage;
-  
+
   ximage = convert_EImage_to_XImage (device, width, height, eimage,
                                     &pixtbl, &npixels);
   if (!ximage)
@@ -809,7 +852,7 @@ x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
       if (pixtbl) xfree (pixtbl);
       signal_image_error("EImage to XImage conversion failed", instantiator);
     }
-  
+
   /* Now create the pixmap and set up the image instance */
   init_image_instance_from_x_image (ii, ximage, dest_mask,
                                    cmap, pixtbl, npixels,
@@ -826,11 +869,11 @@ x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
     }
 }
 
-int read_bitmap_data_from_file (CONST char *filename, unsigned int *width, 
+int read_bitmap_data_from_file (CONST char *filename, unsigned int *width,
                                unsigned int *height, unsigned char **datap,
                                int *x_hot, int *y_hot)
 {
-  return XmuReadBitmapDataFromFile (filename, width, height, 
+  return XmuReadBitmapDataFromFile (filename, width, height,
                                    datap, x_hot, y_hot);
 }
 
@@ -1483,73 +1526,6 @@ x_xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
 /**********************************************************************
  *                             X-Face                                 *
  **********************************************************************/
-
-static void
-xface_validate (Lisp_Object instantiator)
-{
-  file_or_data_must_be_present (instantiator);
-}
-
-static Lisp_Object
-xface_normalize (Lisp_Object inst, Lisp_Object console_type)
-{
-  /* This funcation can call lisp */
-  Lisp_Object file = Qnil, mask_file = Qnil;
-  struct gcpro gcpro1, gcpro2, gcpro3;
-  Lisp_Object alist = Qnil;
-
-  GCPRO3 (file, mask_file, alist);
-
-  /* Now, convert any file data into inline data for both the regular
-     data and the mask data.  At the end of this, `data' will contain
-     the inline data (if any) or Qnil, and `file' will contain
-     the name this data was derived from (if known) or Qnil.
-     Likewise for `mask_file' and `mask_data'.
-
-     Note that if we cannot generate any regular inline data, we
-     skip out. */
-
-  file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
-                                            console_type);
-  mask_file = potential_pixmap_file_instantiator (inst, Q_mask_file,
-                                                 Q_mask_data, console_type);
-
-  if (CONSP (file)) /* failure locating filename */
-    signal_double_file_error ("Opening bitmap file",
-                             "no such file or directory",
-                             Fcar (file));
-
-  if (NILP (file) && NILP (mask_file)) /* no conversion necessary */
-    RETURN_UNGCPRO (inst);
-
-  alist = tagged_vector_to_alist (inst);
-
-  {
-    Lisp_Object data = make_string_from_file (file);
-    alist = remassq_no_quit (Q_file, alist);
-    /* there can't be a :data at this point. */
-    alist = Fcons (Fcons (Q_file, file),
-                  Fcons (Fcons (Q_data, data), alist));
-  }
-
-  alist = xbm_mask_file_munging (alist, file, mask_file, console_type);
-
-  {
-    Lisp_Object result = alist_to_tagged_vector (Qxface, alist);
-    free_alist (alist);
-    RETURN_UNGCPRO (result);
-  }
-}
-
-static int
-xface_possible_dest_types (void)
-{
-  return
-    IMAGE_MONO_PIXMAP_MASK  |
-    IMAGE_COLOR_PIXMAP_MASK |
-    IMAGE_POINTER_MASK;
-}
-
 #if defined(EXTERN)
 /* This is about to get redefined! */
 #undef EXTERN
@@ -1571,9 +1547,9 @@ extern jmp_buf comp_env;
 #undef SYSV32
 
 static void
-xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
-                  Lisp_Object pointer_fg, Lisp_Object pointer_bg,
-                  int dest_mask, Lisp_Object domain)
+x_xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                    Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                    int dest_mask, Lisp_Object domain)
 {
   Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
   int i, stattis;
@@ -2020,168 +1996,111 @@ x_colorize_image_instance (Lisp_Object image_instance,
 }
 
 \f
-#if HAVE_SUBWINDOWS
 /************************************************************************/
-/*                               subwindows                             */
+/*                      subwindow and widget support                      */
 /************************************************************************/
 
-Lisp_Object Qsubwindowp;
-
-static Lisp_Object
-mark_subwindow (Lisp_Object obj, void (*markobj) (Lisp_Object))
-{
-  struct Lisp_Subwindow *sw = XSUBWINDOW (obj);
-  return sw->frame;
-}
-
+/* unmap the image if it is a widget. This is used by redisplay via
+   redisplay_unmap_subwindows */
 static void
-print_subwindow (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
+x_unmap_subwindow (struct Lisp_Image_Instance *p)
 {
-  char buf[100];
-  struct Lisp_Subwindow *sw = XSUBWINDOW (obj);
-  struct frame *frm = XFRAME (sw->frame);
-
-  if (print_readably)
-    error ("printing unreadable object #<subwindow 0x%x>",
-          sw->header.uid);
-
-  write_c_string ("#<subwindow", printcharfun);
-  sprintf (buf, " %dx%d", sw->width, sw->height);
-  write_c_string (buf, printcharfun);
-
-  /* This is stolen from frame.c.  Subwindows are strange in that they
-     are specific to a particular frame so we want to print in their
-     description what that frame is. */
-
-  write_c_string (" on #<", printcharfun);
-  if (!FRAME_LIVE_P (frm))
-    write_c_string ("dead", printcharfun);
-  else if (FRAME_TTY_P (frm))
-    write_c_string ("tty", printcharfun);
-  else if (FRAME_X_P (frm))
-    write_c_string ("x", printcharfun);
-  else
-    write_c_string ("UNKNOWN", printcharfun);
-  write_c_string ("-frame ", printcharfun);
-  print_internal (frm->name, printcharfun, 1);
-  sprintf (buf, " 0x%x>", frm->header.uid);
-  write_c_string (buf, printcharfun);
-
-  sprintf (buf, ") 0x%x>", sw->header.uid);
-  write_c_string (buf, printcharfun);
+  if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
+    {
+      XUnmapWindow 
+       (DisplayOfScreen (IMAGE_INSTANCE_X_SUBWINDOW_SCREEN (p)), 
+        IMAGE_INSTANCE_X_SUBWINDOW_ID (p));
+    }
+  else                         /* must be a widget */
+    {
+      XtUnmapWidget (IMAGE_INSTANCE_X_WIDGET_ID (p));
+    }
 }
 
+/* map the subwindow. This is used by redisplay via
+   redisplay_output_subwindow */
 static void
-finalize_subwindow (void *header, int for_disksave)
+x_map_subwindow (struct Lisp_Image_Instance *p, int x, int y)
 {
-  struct Lisp_Subwindow *sw = (struct Lisp_Subwindow *) header;
-  if (for_disksave) finalose (sw);
-  if (sw->subwindow)
+  if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
     {
-      XDestroyWindow (DisplayOfScreen (sw->xscreen), sw->subwindow);
-      sw->subwindow = 0;
+      Window subwindow = IMAGE_INSTANCE_X_SUBWINDOW_ID (p);
+      Screen* screen = IMAGE_INSTANCE_X_SUBWINDOW_SCREEN (p);
+      XMapWindow (DisplayOfScreen (screen), subwindow);
+      XMoveWindow (DisplayOfScreen (screen), subwindow, x, y);
+    }
+  else                         /* must be a widget */
+    {
+      XtMoveWidget (IMAGE_INSTANCE_X_WIDGET_ID (p), 
+                   x + IMAGE_INSTANCE_X_WIDGET_XOFFSET (p),
+                   y + IMAGE_INSTANCE_X_WIDGET_YOFFSET (p));
+      XtMapWidget (IMAGE_INSTANCE_X_WIDGET_ID (p));
     }
 }
 
-/* subwindows are equal iff they have the same window XID */
-static int
-subwindow_equal (Lisp_Object o1, Lisp_Object o2, int depth)
-{
-  return (XSUBWINDOW (o1)->subwindow == XSUBWINDOW (o2)->subwindow);
-}
-
-static unsigned long
-subwindow_hash (Lisp_Object obj, int depth)
+/* when you click on a widget you may activate another widget this
+   needs to be checked and all appropriate widgets updated */
+static void
+x_update_subwindow (struct Lisp_Image_Instance *p)
 {
-  return XSUBWINDOW (obj)->subwindow;
+  if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
+    {
+      widget_value* wv = xmalloc_widget_value ();
+      button_item_to_widget_value (IMAGE_INSTANCE_WIDGET_SINGLE_ITEM (p),
+                                  wv, 1, 1);
+      lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), 
+                            wv, 1);
+    }
 }
 
-DEFINE_LRECORD_IMPLEMENTATION ("subwindow", subwindow,
-                              mark_subwindow, print_subwindow,
-                              finalize_subwindow, subwindow_equal,
-                              subwindow_hash, struct Lisp_Subwindow);
-\f
-/* #### PROBLEM: The display routines assume that the glyph is only
- being displayed in one buffer.  If it is in two different buffers
- which are both being displayed simultaneously you will lose big time.
- This can be dealt with in the new redisplay. */
-
-/* #### These are completely un-re-implemented in 19.14.  Get it done
-   for 19.15. */
-
-DEFUN ("make-subwindow", Fmake_subwindow, 0, 3, 0, /*
-Creates a new `subwindow' object of size WIDTH x HEIGHT.
-The default is a window of size 1x1, which is also the minimum allowed
-window size.  Subwindows are per-frame.  A buffer being shown in two
-different frames will only display a subwindow glyph in the frame in
-which it was actually created.  If two windows on the same frame are
-displaying the buffer then the most recently used window will actually
-display the window.  If the frame is not specified, the selected frame
-is used.
-
-Subwindows are not currently implemented.
-*/
-       (width, height, frame))
+/* instantiate and x type subwindow */
+static void
+x_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                       Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                       int dest_mask, Lisp_Object domain)
 {
+  /* This function can GC */
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
+  Lisp_Object frame = FW_FRAME (domain);
+  struct frame* f = XFRAME (frame);
   Display *dpy;
   Screen *xs;
-  Window pw;
-  struct frame *f;
-  unsigned int iw, ih;
+  Window pw, win;
   XSetWindowAttributes xswa;
   Mask valueMask = 0;
+  unsigned int w = IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii), 
+    h = IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii);
 
-  error ("subwindows are not functional in 20.2; they may be again someday");
+  if (!DEVICE_X_P (XDEVICE (device)))
+    signal_simple_error ("Not an X device", device);
+
+  dpy = DEVICE_X_DISPLAY (XDEVICE (device));
+  xs = DefaultScreenOfDisplay (dpy);
 
-  f = decode_x_frame (frame);
+  IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
 
-  xs = LISP_DEVICE_TO_X_SCREEN (FRAME_DEVICE (f));
-  dpy = DisplayOfScreen (xs);
   pw = XtWindow (FRAME_X_TEXT_WIDGET (f));
 
-  if (NILP (width))
-    iw = 1;
-  else
-    {
-      CHECK_INT (width);
-      iw = XINT (width);
-      if (iw < 1) iw = 1;
-    }
-  if (NILP (height))
-    ih = 1;
-  else
-    {
-      CHECK_INT (height);
-      ih = XINT (height);
-      if (ih < 1) ih = 1;
-    }
+  ii->data = xnew_and_zero (struct x_subwindow_data);
 
-  {
-    struct Lisp_Subwindow *sw =
-      alloc_lcrecord_type (struct Lisp_Subwindow, lrecord_subwindow);
-    Lisp_Object val;
-    sw->frame = frame;
-    sw->xscreen = xs;
-    sw->parent_window = pw;
-    sw->height = ih;
-    sw->width = iw;
-
-    xswa.backing_store = Always;
-    valueMask |= CWBackingStore;
-
-    xswa.colormap = DefaultColormapOfScreen (xs);
-    valueMask |= CWColormap;
-
-    sw->subwindow = XCreateWindow (dpy, pw, 0, 0, iw, ih, 0, CopyFromParent,
-                                  InputOutput, CopyFromParent, valueMask,
-                                  &xswa);
-
-    XSETSUBWINDOW (val, sw);
-    return val;
-  }
+  IMAGE_INSTANCE_X_SUBWINDOW_PARENT (ii) = pw;
+  IMAGE_INSTANCE_X_SUBWINDOW_SCREEN (ii) = xs;
+
+  xswa.backing_store = Always;
+  valueMask |= CWBackingStore;
+  xswa.colormap = DefaultColormapOfScreen (xs);
+  valueMask |= CWColormap;
+  
+  win = XCreateWindow (dpy, pw, 0, 0, w, h, 0, CopyFromParent,
+                      InputOutput, CopyFromParent, valueMask,
+                      &xswa);
+  
+  IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)win;
 }
 
-/* #### Should this function exist? */
+#if 0
+/* #### Should this function exist? If there's any doubt I'm not implementing it --andyp */
 DEFUN ("change-subwindow-property", Fchange_subwindow_property, 3, 3, 0, /*
 For the given SUBWINDOW, set PROPERTY to DATA, which is a string.
 Subwindows are not currently implemented.
@@ -2208,91 +2127,297 @@ Subwindows are not currently implemented.
 
   return property;
 }
+#endif
 
-DEFUN ("subwindowp", Fsubwindowp, 1, 1, 0, /*
-Return non-nil if OBJECT is a subwindow.
-Subwindows are not currently implemented.
-*/
-       (object))
+static void 
+x_resize_subwindow (struct Lisp_Image_Instance* ii, int w, int h)
 {
-  return SUBWINDOWP (object) ? Qt : Qnil;
+  if (IMAGE_INSTANCE_TYPE (ii) == IMAGE_SUBWINDOW)
+    {
+      XResizeWindow (DisplayOfScreen (IMAGE_INSTANCE_X_SUBWINDOW_SCREEN (ii)),
+                    IMAGE_INSTANCE_X_SUBWINDOW_ID (ii),
+                    w, h);
+    }
+  else                         /* must be a widget */
+    {
+      Arg al[2];
+      XtSetArg (al [0], XtNwidth, (Dimension)w);
+      XtSetArg (al [1], XtNheight, (Dimension)h);
+      XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 2);
+    }
 }
 
-DEFUN ("subwindow-width", Fsubwindow_width, 1, 1, 0, /*
-Width of SUBWINDOW.
-Subwindows are not currently implemented.
-*/
-       (subwindow))
+/************************************************************************/
+/*                            widgets                            */
+/************************************************************************/
+
+static void
+x_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                     Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                     int dest_mask, Lisp_Object domain,
+                     CONST char* type, widget_value* wv)
 {
-  CHECK_SUBWINDOW (subwindow);
-  return make_int (XSUBWINDOW (subwindow)->width);
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), pixel;
+  struct device* d = XDEVICE (device);
+  Lisp_Object frame = FW_FRAME (domain);
+  struct frame* f = XFRAME (frame);
+  XColor fcolor, bcolor;
+  Extbyte* nm=0;
+  Widget wid;
+  Arg al [32];
+  int ac = 0;
+  int id = new_lwlib_id ();
+#ifdef LWLIB_USES_MOTIF
+  XmFontList fontList;
+#endif
+
+  if (!DEVICE_X_P (d))
+    signal_simple_error ("Not an mswindows device", device);
+
+  /* have to set the type this late in case there is no device
+     instantiation for a widget. But we can go ahead and do it without
+     checking because there is always a generic instantiator. */
+  IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
+
+  if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
+    GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm);
+
+  ii->data = xnew_and_zero (struct x_subwindow_data);
+
+  /* copy any args we were given */
+  if (wv->nargs)
+    lw_add_value_args_to_args (wv, al, &ac);
+
+  /* add our own arguments */
+  pixel = FACE_FOREGROUND 
+    (IMAGE_INSTANCE_WIDGET_FACE (ii),
+     IMAGE_INSTANCE_SUBWINDOW_FRAME (ii));
+  fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel));
+  pixel = FACE_BACKGROUND
+    (IMAGE_INSTANCE_WIDGET_FACE (ii),
+     IMAGE_INSTANCE_SUBWINDOW_FRAME (ii));
+  bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel));
+
+  XtSetArg (al [ac], XtNbackground, bcolor.pixel);             ac++;
+  XtSetArg (al [ac], XtNforeground, fcolor.pixel);             ac++;
+#ifdef LWLIB_USES_MOTIF
+  fontList = XmFontListCreate 
+    ((void*)FONT_INSTANCE_X_FONT 
+     (XFONT_INSTANCE (widget_face_font_info 
+                     (domain, IMAGE_INSTANCE_WIDGET_FACE (ii),
+                      0, 0))), XmSTRING_DEFAULT_CHARSET);
+  XtSetArg (al [ac], XmNfontList, fontList );                          ac++;
+#else
+  XtSetArg (al [ac], XtNfont, (void*)FONT_INSTANCE_X_FONT 
+           (XFONT_INSTANCE (widget_face_font_info 
+                            (domain, 
+                             IMAGE_INSTANCE_WIDGET_FACE (ii),
+                             0, 0))));                 ac++;
+#endif
+
+  wv->nargs = ac;
+  wv->args = al;
+  
+  wid = lw_create_widget (type, wv->name, id, wv, FRAME_X_CONTAINER_WIDGET (f),
+                         False, 0, popup_selection_callback, 0);
+
+  IMAGE_INSTANCE_X_WIDGET_LWID (ii) = id;
+#ifdef LWLIB_USES_MOTIF
+  XmFontListFree (fontList);
+#endif
+  /* because the EmacsManager is the widgets parent we have to
+     offset the redisplay of the widget by the amount the text
+     widget is inside the manager. */
+  ac = 0;
+  XtSetArg (al [ac], XtNwidth, 
+           (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii)); ac++;
+  XtSetArg (al [ac], XtNheight, 
+           (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii)); ac++;
+  XtSetValues (wid, al, ac);
+  /* finally get offsets in the frame */
+  ac = 0;
+  XtSetArg (al [ac], XtNx, &IMAGE_INSTANCE_X_WIDGET_XOFFSET (ii)); ac++;
+  XtSetArg (al [ac], XtNy, &IMAGE_INSTANCE_X_WIDGET_YOFFSET (ii)); ac++;
+  XtGetValues (FRAME_X_TEXT_WIDGET (f), al, ac);
+
+  IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)wid; 
+
+  free_widget_value (wv);
 }
 
-DEFUN ("subwindow-height", Fsubwindow_height, 1, 1, 0, /*
-Height of SUBWINDOW.
-Subwindows are not currently implemented.
-*/
-       (subwindow))
+static Lisp_Object
+x_widget_set_property (Lisp_Object image_instance, Lisp_Object prop,
+                      Lisp_Object val)
 {
-  CHECK_SUBWINDOW (subwindow);
-  return make_int (XSUBWINDOW (subwindow)->height);
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+
+  if (EQ (prop, Q_text))
+    {
+      Extbyte* str=0;
+      widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
+      CHECK_STRING (val);
+      GET_C_STRING_OS_DATA_ALLOCA (val, str);
+      wv->value = str;
+      lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (ii), wv, False);
+      return Qt;
+    }
+  return Qunbound;
 }
 
-DEFUN ("subwindow-xid", Fsubwindow_xid, 1, 1, 0, /*
-Return the xid of SUBWINDOW as a number.
-Subwindows are not currently implemented.
-*/
-       (subwindow))
+/* get properties of a control */
+static Lisp_Object
+x_widget_property (Lisp_Object image_instance, Lisp_Object prop)
 {
-  CHECK_SUBWINDOW (subwindow);
-  return make_int (XSUBWINDOW (subwindow)->subwindow);
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  /* get the text from a control */
+  if (EQ (prop, Q_text))
+    {
+      widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
+      return build_ext_string (wv->value, FORMAT_OS);
+    }
+  return Qunbound;
 }
 
-DEFUN ("resize-subwindow", Fresize_subwindow, 1, 3, 0, /*
-Resize SUBWINDOW to WIDTH x HEIGHT.
-If a value is nil that parameter is not changed.
-Subwindows are not currently implemented.
-*/
-       (subwindow, width, height))
+/* Instantiate a button widget. Unfortunately instantiated widgets are
+   particular to a frame since they need to have a parent. It's not
+   like images where you just select the image into the context you
+   want to display it in and BitBlt it. So images instances can have a
+   many-to-one relationship with things you see, whereas widgets can
+   only be one-to-one (i.e. per frame) */
+static void
+x_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                     Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                     int dest_mask, Lisp_Object domain)
 {
-  int neww, newh;
-  struct Lisp_Subwindow *sw;
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+  Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
+  widget_value* wv = xmalloc_widget_value ();
 
-  CHECK_SUBWINDOW (subwindow);
-  sw = XSUBWINDOW (subwindow);
+  button_item_to_widget_value (gui, wv, 1, 1);
 
-  if (NILP (width))
-    neww = sw->width;
-  else
-    neww = XINT (width);
+  if (!NILP (glyph))
+    {
+      if (!IMAGE_INSTANCEP (glyph))
+       glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1);
+    }
 
-  if (NILP (height))
-    newh = sw->height;
-  else
-    newh = XINT (height);
+  x_widget_instantiate (image_instance, instantiator, pointer_fg,
+                       pointer_bg, dest_mask, domain, "button", wv);
 
-  XResizeWindow (DisplayOfScreen (sw->xscreen), sw->subwindow, neww, newh);
+  /* add the image if one was given */
+  if (!NILP (glyph) && IMAGE_INSTANCEP (glyph))
+    {
+      Arg al [2];
+      int ac =0;
+#ifdef LWLIB_USES_MOTIF
+      XtSetArg (al [ac], XmNlabelType, XmPIXMAP);      ac++;
+      XtSetArg (al [ac], XmNlabelPixmap, XIMAGE_INSTANCE_X_PIXMAP (glyph));ac++;
+#else
+      XtSetArg (al [ac], XtNpixmap, XIMAGE_INSTANCE_X_PIXMAP (glyph)); ac++;
+#endif
+      XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, ac);
+    }
+}
 
-  sw->height = newh;
-  sw->width = neww;
+/* get properties of a button */
+static Lisp_Object
+x_button_property (Lisp_Object image_instance, Lisp_Object prop)
+{
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  /* check the state of a button */
+  if (EQ (prop, Q_selected))
+    {
+      widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
 
-  return subwindow;
+      if (wv->selected)
+       return Qt;
+      else
+       return Qnil;
+    }
+  return Qunbound;
 }
 
-DEFUN ("force-subwindow-map", Fforce_subwindow_map, 1, 1, 0, /*
-Generate a Map event for SUBWINDOW.
-Subwindows are not currently implemented.
-*/
-       (subwindow))
+/* instantiate a progress gauge */
+static void
+x_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                       Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                       int dest_mask, Lisp_Object domain)
 {
-  CHECK_SUBWINDOW (subwindow);
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+  widget_value* wv = xmalloc_widget_value ();
+
+  button_item_to_widget_value (gui, wv, 1, 1);
+
+  x_widget_instantiate (image_instance, instantiator, pointer_fg,
+                       pointer_bg, dest_mask, domain, "progress", wv);
+}
 
-  XMapWindow (DisplayOfScreen (XSUBWINDOW (subwindow)->xscreen),
-             XSUBWINDOW (subwindow)->subwindow);
+/* set the properties of a progres guage */
+static Lisp_Object
+x_progress_gauge_set_property (Lisp_Object image_instance, Lisp_Object prop,
+                        Lisp_Object val)
+{
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
 
-  return subwindow;
+  if (EQ (prop, Q_percent))
+    {
+      Arg al [1];
+      CHECK_INT (val);
+      XtSetArg (al[0], XtNvalue, XINT (val));
+      XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 1);
+      return Qt;
+    }
+  return Qunbound;
 }
+
+/* instantiate an edit control */
+static void
+x_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                   Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                   int dest_mask, Lisp_Object domain)
+{
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+  widget_value* wv = xmalloc_widget_value ();
+  
+  button_item_to_widget_value (gui, wv, 1, 1);
+  
+  x_widget_instantiate (image_instance, instantiator, pointer_fg,
+                       pointer_bg, dest_mask, domain, "text-field", wv);
+}
+
+/* instantiate a combo control */
+static void
+x_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+                    Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+                    int dest_mask, Lisp_Object domain)
+{
+  struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+  Lisp_Object rest;
+  Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+  widget_value* wv = xmalloc_widget_value ();
+
+  button_item_to_widget_value (gui, wv, 1, 1);
+  
+  x_widget_instantiate (image_instance, instantiator, pointer_fg,
+                       pointer_bg, dest_mask, domain, "combo-box", wv);
+  /* add items to the combo box */
+  LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil))
+    {
+#if 0
+      Extbyte* str;
+      XmString xmstr;
+      GET_C_STRING_OS_DATA_ALLOCA (XCAR (rest), str);
+      xmstr = XmStringCreate (str, XmSTRING_DEFAULT_CHARSET);
+      XmListAddItem (IMAGE_INSTANCE_X_WIDGET_ID (ii), xmstr, 0);
+      XmStringFree (xmstr);
 #endif
+    }
+}
+
 \f
 /************************************************************************/
 /*                            initialization                            */
@@ -2301,17 +2426,8 @@ Subwindows are not currently implemented.
 void
 syms_of_glyphs_x (void)
 {
-#if HAVE_SUBWINDOWS
-  defsymbol (&Qsubwindowp, "subwindowp");
-
-  DEFSUBR (Fmake_subwindow);
+#if 0
   DEFSUBR (Fchange_subwindow_property);
-  DEFSUBR (Fsubwindowp);
-  DEFSUBR (Fsubwindow_width);
-  DEFSUBR (Fsubwindow_height);
-  DEFSUBR (Fsubwindow_xid);
-  DEFSUBR (Fresize_subwindow);
-  DEFSUBR (Fforce_subwindow_map);
 #endif
 }
 
@@ -2327,17 +2443,64 @@ console_type_create_glyphs_x (void)
   CONSOLE_HAS_METHOD (x, colorize_image_instance);
   CONSOLE_HAS_METHOD (x, init_image_instance_from_eimage);
   CONSOLE_HAS_METHOD (x, locate_pixmap_file);
-#ifdef HAVE_XPM
-  CONSOLE_HAS_METHOD (x, xpm_instantiate);
-#endif
-  CONSOLE_HAS_METHOD (x, xbm_instantiate);
+  CONSOLE_HAS_METHOD (x, unmap_subwindow);
+  CONSOLE_HAS_METHOD (x, map_subwindow);
+  CONSOLE_HAS_METHOD (x, resize_subwindow);
+  CONSOLE_HAS_METHOD (x, update_subwindow);
 }
 
 void
 image_instantiator_format_create_glyphs_x (void)
 {
-
+  IIFORMAT_VALID_CONSOLE (x, nothing);
+  IIFORMAT_VALID_CONSOLE (x, string);
+  IIFORMAT_VALID_CONSOLE (x, formatted_string);
+  IIFORMAT_VALID_CONSOLE (x, inherit);
+#ifdef HAVE_XPM
+  INITIALIZE_DEVICE_IIFORMAT (x, xpm);
+  IIFORMAT_HAS_DEVMETHOD (x, xpm, instantiate);
+#endif
+#ifdef HAVE_JPEG
+  IIFORMAT_VALID_CONSOLE (x, jpeg);
+#endif
+#ifdef HAVE_TIFF
+  IIFORMAT_VALID_CONSOLE (x, tiff);
+#endif  
+#ifdef HAVE_PNG
+  IIFORMAT_VALID_CONSOLE (x, png);
+#endif  
+#ifdef HAVE_GIF
+  IIFORMAT_VALID_CONSOLE (x, gif);
+#endif  
+  INITIALIZE_DEVICE_IIFORMAT (x, xbm);
+  IIFORMAT_HAS_DEVMETHOD (x, xbm, instantiate);
+
+  INITIALIZE_DEVICE_IIFORMAT (x, subwindow);
+  IIFORMAT_HAS_DEVMETHOD (x, subwindow, instantiate);
+#ifdef LWLIB_USES_MOTIF
+  /* button widget */
+  INITIALIZE_DEVICE_IIFORMAT (x, button);
+  IIFORMAT_HAS_DEVMETHOD (x, button, property);
+  IIFORMAT_HAS_DEVMETHOD (x, button, instantiate);
+
+  INITIALIZE_DEVICE_IIFORMAT (x, widget);
+  IIFORMAT_HAS_DEVMETHOD (x, widget, property);
+  IIFORMAT_HAS_DEVMETHOD (x, widget, set_property);
+  /* progress gauge */
+  INITIALIZE_DEVICE_IIFORMAT (x, progress_gauge);
+  IIFORMAT_HAS_DEVMETHOD (x, progress_gauge, set_property);
+  IIFORMAT_HAS_DEVMETHOD (x, progress_gauge, instantiate);
+  /* text field */
+  INITIALIZE_DEVICE_IIFORMAT (x, edit_field);
+  IIFORMAT_HAS_DEVMETHOD (x, edit_field, instantiate);
+#if 0 /* XmVERSION > 1*/
+  /* combo box */
+  INITIALIZE_DEVICE_IIFORMAT (x, combo_box);
+  IIFORMAT_HAS_DEVMETHOD (x, combo_box, instantiate);
+#endif
+#endif
   INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (cursor_font, "cursor-font");
+  IIFORMAT_VALID_CONSOLE (x, cursor_font);
 
   IIFORMAT_HAS_METHOD (cursor_font, validate);
   IIFORMAT_HAS_METHOD (cursor_font, possible_dest_types);
@@ -2352,25 +2515,15 @@ image_instantiator_format_create_glyphs_x (void)
   IIFORMAT_HAS_METHOD (font, validate);
   IIFORMAT_HAS_METHOD (font, possible_dest_types);
   IIFORMAT_HAS_METHOD (font, instantiate);
+  IIFORMAT_VALID_CONSOLE (x, font);
 
   IIFORMAT_VALID_KEYWORD (font, Q_data, check_valid_string);
   IIFORMAT_VALID_KEYWORD (font, Q_foreground, check_valid_string);
   IIFORMAT_VALID_KEYWORD (font, Q_background, check_valid_string);
 
 #ifdef HAVE_XFACE
-  INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (xface, "xface");
-
-  IIFORMAT_HAS_METHOD (xface, validate);
-  IIFORMAT_HAS_METHOD (xface, normalize);
-  IIFORMAT_HAS_METHOD (xface, possible_dest_types);
-  IIFORMAT_HAS_METHOD (xface, instantiate);
-
-  IIFORMAT_VALID_KEYWORD (xface, Q_data, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (xface, Q_file, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (xface, Q_hotspot_x, check_valid_int);
-  IIFORMAT_VALID_KEYWORD (xface, Q_hotspot_y, check_valid_int);
-  IIFORMAT_VALID_KEYWORD (xface, Q_foreground, check_valid_string);
-  IIFORMAT_VALID_KEYWORD (xface, Q_background, check_valid_string);
+  INITIALIZE_DEVICE_IIFORMAT (x, xface);
+  IIFORMAT_HAS_DEVMETHOD (x, xface, instantiate);
 #endif
 
   INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (autodetect,
@@ -2380,6 +2533,7 @@ image_instantiator_format_create_glyphs_x (void)
   IIFORMAT_HAS_METHOD (autodetect, normalize);
   IIFORMAT_HAS_METHOD (autodetect, possible_dest_types);
   IIFORMAT_HAS_METHOD (autodetect, instantiate);
+  IIFORMAT_VALID_CONSOLE (x, autodetect);
 
   IIFORMAT_VALID_KEYWORD (autodetect, Q_data, check_valid_string);
 }
@@ -2387,10 +2541,6 @@ image_instantiator_format_create_glyphs_x (void)
 void
 vars_of_glyphs_x (void)
 {
-#ifdef HAVE_XFACE
-  Fprovide (Qxface);
-#endif
-
   DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path /*
 A list of the directories in which X bitmap files may be found.
 If nil, this is initialized from the "*bitmapFilePath" resource.