changeset 9563:ca99ee51077f

Include paths.h. Support background stipple, and search path for bitmap files: (x_set_icon_type): Pass x_bitmap_icon 2nd arg as Lisp_Object. (x_icon_type): Return a Lisp_Object. (x_destroy_bitmap, x_reference_bitmap): Take frame as arg. Callers changed. (struct x_bitmap_record): New fields height, width, depth. (x_create_bitmap_from_data): Fill in those fields. (x_bitmap_height, x_bitmap_width, x_bitmap_pixmap): New functions. (x_create_bitmap_from_file): Arg FILE is now a Lisp_Object. Search Vbitmap_file_path for it. Fill in new fields. (syms_of_xfns): Set up Vbitmap_file_path.
author Richard M. Stallman <rms@gnu.org>
date Mon, 17 Oct 1994 06:56:52 +0000
parents 46e38c41b66c
children 1bfb920ab23e
files src/xfns.c
diffstat 1 files changed, 72 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Mon Oct 17 06:03:09 1994 +0000
+++ b/src/xfns.c	Mon Oct 17 06:56:52 1994 +0000
@@ -39,6 +39,7 @@
 #include "dispextern.h"
 #include "keyboard.h"
 #include "blockinput.h"
+#include "paths.h"
 
 #ifdef HAVE_X_WINDOWS
 extern void abort ();
@@ -145,6 +146,9 @@
 
 Lisp_Object Vmouse_depressed;
 
+/* Search path for bitmap files.  */
+Lisp_Object Vx_bitmap_file_path;
+
 /* For now, we have just one x_display structure since we only support
    one X display.  */
 static struct x_screen the_x_screen;
@@ -386,6 +390,8 @@
   Pixmap pixmap;
   char *file;
   int refcount;
+  /* Record some info about this pixmap.  */
+  int height, width, depth;
 };
 
 /* Pointer to bitmap records.  */
@@ -400,6 +406,33 @@
 /* Count of free bitmaps before X_BITMAPS_LAST.  */
 static int x_bitmaps_free;
 
+/* Functions to access the contents of a bitmap, given an id.  */
+
+int
+x_bitmap_height (f, id)
+     FRAME_PTR f;
+     int id;
+{
+  return x_bitmaps[id - 1].height;
+}
+
+int
+x_bitmap_width (f, id)
+     FRAME_PTR f;
+     int id;
+{
+  return x_bitmaps[id - 1].width;
+}
+
+int
+x_bitmap_pixmap (f, id)
+     FRAME_PTR f;
+     int id;
+{
+  return x_bitmaps[id - 1].pixmap;
+}
+
+
 /* Allocate a new bitmap record.  Returns index of new record.  */
 
 static int
@@ -438,7 +471,8 @@
 /* Add one reference to the reference count of the bitmap with id ID.  */
 
 void
-x_reference_bitmap (id)
+x_reference_bitmap (f, id)
+     FRAME_PTR f;
      int id;
 {
   ++x_bitmaps[id - 1].refcount;
@@ -465,6 +499,9 @@
   x_bitmaps[id - 1].pixmap = bitmap;
   x_bitmaps[id - 1].file = NULL;
   x_bitmaps[id - 1].refcount = 1;
+  x_bitmaps[id - 1].depth = 1;
+  x_bitmaps[id - 1].height = height;
+  x_bitmaps[id - 1].width = width;
 
   return id;
 }
@@ -474,34 +511,48 @@
 int
 x_create_bitmap_from_file (f, file)
      struct frame *f;
-     char *file;
+     Lisp_Object file;
 {
   unsigned int width, height;
   Pixmap bitmap;
   int xhot, yhot, result, id;
+  Lisp_Object found;
+  int fd;
+  char *filename;
 
   /* Look for an existing bitmap with the same name.  */
   for (id = 0; id < x_bitmaps_last; ++id)
     {
       if (x_bitmaps[id].refcount
 	  && x_bitmaps[id].file
-	  && !strcmp (x_bitmaps[id].file, file))
+	  && !strcmp (x_bitmaps[id].file, (char *) XSTRING (file)->data))
 	{
 	  ++x_bitmaps[id].refcount;
 	  return id + 1;
 	}
     }
 
+  /* Search bitmap-file-path for the file, if appropriate.  */
+  fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
+  if (fd < 0)
+    return -1;
+  close (fd);
+
+  filename = (char *) XSTRING (found)->data;
+
   result = XReadBitmapFile (x_current_display, FRAME_X_WINDOW (f),
-			    file, &width, &height, &bitmap, &xhot, &yhot);
+			    filename, &width, &height, &bitmap, &xhot, &yhot);
   if (result != BitmapSuccess)
     return -1;
 
   id = x_allocate_bitmap_record ();
   x_bitmaps[id - 1].pixmap = bitmap;
   x_bitmaps[id - 1].refcount = 1;
-  x_bitmaps[id - 1].file = (char *) xmalloc ((strlen (file) + 1));
-  strcpy (x_bitmaps[id - 1].file, file);
+  x_bitmaps[id - 1].file = (char *) xmalloc (XSTRING (file)->size + 1);
+  x_bitmaps[id - 1].depth = 1;
+  x_bitmaps[id - 1].height = height;
+  x_bitmaps[id - 1].width = width;
+  strcpy (x_bitmaps[id - 1].file, XSTRING (file)->data);
 
   return id;
 }
@@ -509,7 +560,8 @@
 /* Remove reference to bitmap with id number ID.  */
 
 int
-x_destroy_bitmap (id)
+x_destroy_bitmap (f, id)
+     FRAME_PTR f;
      int id;
 {
   if (id > 0)
@@ -1265,10 +1317,8 @@
   BLOCK_INPUT;
   if (NILP (arg))
     result = x_text_icon (f, 0);
-  else if (STRINGP (arg))
-    result = x_bitmap_icon (f, XSTRING (arg)->data);
-  else 
-    result = x_bitmap_icon (f, 0);
+  else
+    result = x_bitmap_icon (f, arg);
 
   if (result)
     {
@@ -1288,16 +1338,19 @@
   UNBLOCK_INPUT;
 }
 
-/* Return 1 if frame F wants a bitmap icon.  */
-
-int
+/* Return non-nil if frame F wants a bitmap icon.  */
+
+Lisp_Object
 x_icon_type (f)
      FRAME_PTR f;
 {
   Lisp_Object tem;
 
   tem = assq_no_quit (Qicon_type, f->param_alist);
-  return (CONSP (tem) && ! NILP (XCONS (tem)->cdr));
+  if (CONSP (tem))
+    return XCONS (tem)->cdr;
+  else
+    return Qnil;
 }
 
 extern Lisp_Object x_new_font ();
@@ -4357,6 +4410,10 @@
 
   init_x_parm_symbols ();
 
+  DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
+    "List of directories to search for bitmap files for X.");
+  Vx_bitmap_file_path = Fcons (build_string (PATH_BITMAPS), Qnil);
+
   DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset,
     "The buffer offset of the character under the pointer.");
   mouse_buffer_offset = 0;