Contents in 1999-06-04-13 of release-21-2.
[chise/xemacs-chise.git.1] / src / glyphs-x.c
index c6015e4..bbe3cf1 100644 (file)
@@ -87,8 +87,7 @@ DEFINE_DEVICE_IIFORMAT (x, xpm);
 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);
@@ -125,7 +124,7 @@ 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 = 0;
@@ -150,13 +149,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)
     {
@@ -512,13 +513,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;
       }
 
@@ -1487,73 +1488,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 function 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
@@ -1575,9 +1509,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;
@@ -2200,19 +2134,8 @@ image_instantiator_format_create_glyphs_x (void)
   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,
@@ -2229,10 +2152,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.