aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c85
1 files changed, 71 insertions, 14 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 11a9c47c06c..68102501db5 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -39,6 +39,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
39#include "dispextern.h" 39#include "dispextern.h"
40#include "keyboard.h" 40#include "keyboard.h"
41#include "blockinput.h" 41#include "blockinput.h"
42#include "paths.h"
42 43
43#ifdef HAVE_X_WINDOWS 44#ifdef HAVE_X_WINDOWS
44extern void abort (); 45extern void abort ();
@@ -145,6 +146,9 @@ Lisp_Object Vx_no_window_manager;
145 146
146Lisp_Object Vmouse_depressed; 147Lisp_Object Vmouse_depressed;
147 148
149/* Search path for bitmap files. */
150Lisp_Object Vx_bitmap_file_path;
151
148/* For now, we have just one x_display structure since we only support 152/* For now, we have just one x_display structure since we only support
149 one X display. */ 153 one X display. */
150static struct x_screen the_x_screen; 154static struct x_screen the_x_screen;
@@ -386,6 +390,8 @@ struct x_bitmap_record
386 Pixmap pixmap; 390 Pixmap pixmap;
387 char *file; 391 char *file;
388 int refcount; 392 int refcount;
393 /* Record some info about this pixmap. */
394 int height, width, depth;
389}; 395};
390 396
391/* Pointer to bitmap records. */ 397/* Pointer to bitmap records. */
@@ -400,6 +406,33 @@ static int x_bitmaps_last;
400/* Count of free bitmaps before X_BITMAPS_LAST. */ 406/* Count of free bitmaps before X_BITMAPS_LAST. */
401static int x_bitmaps_free; 407static int x_bitmaps_free;
402 408
409/* Functions to access the contents of a bitmap, given an id. */
410
411int
412x_bitmap_height (f, id)
413 FRAME_PTR f;
414 int id;
415{
416 return x_bitmaps[id - 1].height;
417}
418
419int
420x_bitmap_width (f, id)
421 FRAME_PTR f;
422 int id;
423{
424 return x_bitmaps[id - 1].width;
425}
426
427int
428x_bitmap_pixmap (f, id)
429 FRAME_PTR f;
430 int id;
431{
432 return x_bitmaps[id - 1].pixmap;
433}
434
435
403/* Allocate a new bitmap record. Returns index of new record. */ 436/* Allocate a new bitmap record. Returns index of new record. */
404 437
405static int 438static int
@@ -438,7 +471,8 @@ x_allocate_bitmap_record ()
438/* Add one reference to the reference count of the bitmap with id ID. */ 471/* Add one reference to the reference count of the bitmap with id ID. */
439 472
440void 473void
441x_reference_bitmap (id) 474x_reference_bitmap (f, id)
475 FRAME_PTR f;
442 int id; 476 int id;
443{ 477{
444 ++x_bitmaps[id - 1].refcount; 478 ++x_bitmaps[id - 1].refcount;
@@ -465,6 +499,9 @@ x_create_bitmap_from_data (f, bits, width, height)
465 x_bitmaps[id - 1].pixmap = bitmap; 499 x_bitmaps[id - 1].pixmap = bitmap;
466 x_bitmaps[id - 1].file = NULL; 500 x_bitmaps[id - 1].file = NULL;
467 x_bitmaps[id - 1].refcount = 1; 501 x_bitmaps[id - 1].refcount = 1;
502 x_bitmaps[id - 1].depth = 1;
503 x_bitmaps[id - 1].height = height;
504 x_bitmaps[id - 1].width = width;
468 505
469 return id; 506 return id;
470} 507}
@@ -474,34 +511,48 @@ x_create_bitmap_from_data (f, bits, width, height)
474int 511int
475x_create_bitmap_from_file (f, file) 512x_create_bitmap_from_file (f, file)
476 struct frame *f; 513 struct frame *f;
477 char *file; 514 Lisp_Object file;
478{ 515{
479 unsigned int width, height; 516 unsigned int width, height;
480 Pixmap bitmap; 517 Pixmap bitmap;
481 int xhot, yhot, result, id; 518 int xhot, yhot, result, id;
519 Lisp_Object found;
520 int fd;
521 char *filename;
482 522
483 /* Look for an existing bitmap with the same name. */ 523 /* Look for an existing bitmap with the same name. */
484 for (id = 0; id < x_bitmaps_last; ++id) 524 for (id = 0; id < x_bitmaps_last; ++id)
485 { 525 {
486 if (x_bitmaps[id].refcount 526 if (x_bitmaps[id].refcount
487 && x_bitmaps[id].file 527 && x_bitmaps[id].file
488 && !strcmp (x_bitmaps[id].file, file)) 528 && !strcmp (x_bitmaps[id].file, (char *) XSTRING (file)->data))
489 { 529 {
490 ++x_bitmaps[id].refcount; 530 ++x_bitmaps[id].refcount;
491 return id + 1; 531 return id + 1;
492 } 532 }
493 } 533 }
494 534
535 /* Search bitmap-file-path for the file, if appropriate. */
536 fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
537 if (fd < 0)
538 return -1;
539 close (fd);
540
541 filename = (char *) XSTRING (found)->data;
542
495 result = XReadBitmapFile (x_current_display, FRAME_X_WINDOW (f), 543 result = XReadBitmapFile (x_current_display, FRAME_X_WINDOW (f),
496 file, &width, &height, &bitmap, &xhot, &yhot); 544 filename, &width, &height, &bitmap, &xhot, &yhot);
497 if (result != BitmapSuccess) 545 if (result != BitmapSuccess)
498 return -1; 546 return -1;
499 547
500 id = x_allocate_bitmap_record (); 548 id = x_allocate_bitmap_record ();
501 x_bitmaps[id - 1].pixmap = bitmap; 549 x_bitmaps[id - 1].pixmap = bitmap;
502 x_bitmaps[id - 1].refcount = 1; 550 x_bitmaps[id - 1].refcount = 1;
503 x_bitmaps[id - 1].file = (char *) xmalloc ((strlen (file) + 1)); 551 x_bitmaps[id - 1].file = (char *) xmalloc (XSTRING (file)->size + 1);
504 strcpy (x_bitmaps[id - 1].file, file); 552 x_bitmaps[id - 1].depth = 1;
553 x_bitmaps[id - 1].height = height;
554 x_bitmaps[id - 1].width = width;
555 strcpy (x_bitmaps[id - 1].file, XSTRING (file)->data);
505 556
506 return id; 557 return id;
507} 558}
@@ -509,7 +560,8 @@ x_create_bitmap_from_file (f, file)
509/* Remove reference to bitmap with id number ID. */ 560/* Remove reference to bitmap with id number ID. */
510 561
511int 562int
512x_destroy_bitmap (id) 563x_destroy_bitmap (f, id)
564 FRAME_PTR f;
513 int id; 565 int id;
514{ 566{
515 if (id > 0) 567 if (id > 0)
@@ -1265,10 +1317,8 @@ x_set_icon_type (f, arg, oldval)
1265 BLOCK_INPUT; 1317 BLOCK_INPUT;
1266 if (NILP (arg)) 1318 if (NILP (arg))
1267 result = x_text_icon (f, 0); 1319 result = x_text_icon (f, 0);
1268 else if (STRINGP (arg)) 1320 else
1269 result = x_bitmap_icon (f, XSTRING (arg)->data); 1321 result = x_bitmap_icon (f, arg);
1270 else
1271 result = x_bitmap_icon (f, 0);
1272 1322
1273 if (result) 1323 if (result)
1274 { 1324 {
@@ -1288,16 +1338,19 @@ x_set_icon_type (f, arg, oldval)
1288 UNBLOCK_INPUT; 1338 UNBLOCK_INPUT;
1289} 1339}
1290 1340
1291/* Return 1 if frame F wants a bitmap icon. */ 1341/* Return non-nil if frame F wants a bitmap icon. */
1292 1342
1293int 1343Lisp_Object
1294x_icon_type (f) 1344x_icon_type (f)
1295 FRAME_PTR f; 1345 FRAME_PTR f;
1296{ 1346{
1297 Lisp_Object tem; 1347 Lisp_Object tem;
1298 1348
1299 tem = assq_no_quit (Qicon_type, f->param_alist); 1349 tem = assq_no_quit (Qicon_type, f->param_alist);
1300 return (CONSP (tem) && ! NILP (XCONS (tem)->cdr)); 1350 if (CONSP (tem))
1351 return XCONS (tem)->cdr;
1352 else
1353 return Qnil;
1301} 1354}
1302 1355
1303extern Lisp_Object x_new_font (); 1356extern Lisp_Object x_new_font ();
@@ -4357,6 +4410,10 @@ syms_of_xfns ()
4357 4410
4358 init_x_parm_symbols (); 4411 init_x_parm_symbols ();
4359 4412
4413 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
4414 "List of directories to search for bitmap files for X.");
4415 Vx_bitmap_file_path = Fcons (build_string (PATH_BITMAPS), Qnil);
4416
4360 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset, 4417 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset,
4361 "The buffer offset of the character under the pointer."); 4418 "The buffer offset of the character under the pointer.");
4362 mouse_buffer_offset = 0; 4419 mouse_buffer_offset = 0;