Mercurial > emacs
comparison src/xfns.c @ 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 | 3cf8aa53c4cf |
children | bcc9342cf633 |
comparison
equal
deleted
inserted
replaced
9562:46e38c41b66c | 9563:ca99ee51077f |
---|---|
37 #include "window.h" | 37 #include "window.h" |
38 #include "buffer.h" | 38 #include "buffer.h" |
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 |
44 extern void abort (); | 45 extern void abort (); |
45 | 46 |
46 #ifndef VMS | 47 #ifndef VMS |
142 Lisp_Object Vx_no_window_manager; | 143 Lisp_Object Vx_no_window_manager; |
143 | 144 |
144 /* `t' if a mouse button is depressed. */ | 145 /* `t' if a mouse button is depressed. */ |
145 | 146 |
146 Lisp_Object Vmouse_depressed; | 147 Lisp_Object Vmouse_depressed; |
148 | |
149 /* Search path for bitmap files. */ | |
150 Lisp_Object Vx_bitmap_file_path; | |
147 | 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. */ |
150 static struct x_screen the_x_screen; | 154 static struct x_screen the_x_screen; |
151 | 155 |
384 struct x_bitmap_record | 388 struct x_bitmap_record |
385 { | 389 { |
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. */ |
392 static struct x_bitmap_record *x_bitmaps; | 398 static struct x_bitmap_record *x_bitmaps; |
393 | 399 |
397 /* Last used bitmap index. */ | 403 /* Last used bitmap index. */ |
398 static int x_bitmaps_last; | 404 static int x_bitmaps_last; |
399 | 405 |
400 /* Count of free bitmaps before X_BITMAPS_LAST. */ | 406 /* Count of free bitmaps before X_BITMAPS_LAST. */ |
401 static int x_bitmaps_free; | 407 static int x_bitmaps_free; |
408 | |
409 /* Functions to access the contents of a bitmap, given an id. */ | |
410 | |
411 int | |
412 x_bitmap_height (f, id) | |
413 FRAME_PTR f; | |
414 int id; | |
415 { | |
416 return x_bitmaps[id - 1].height; | |
417 } | |
418 | |
419 int | |
420 x_bitmap_width (f, id) | |
421 FRAME_PTR f; | |
422 int id; | |
423 { | |
424 return x_bitmaps[id - 1].width; | |
425 } | |
426 | |
427 int | |
428 x_bitmap_pixmap (f, id) | |
429 FRAME_PTR f; | |
430 int id; | |
431 { | |
432 return x_bitmaps[id - 1].pixmap; | |
433 } | |
434 | |
402 | 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 |
405 static int | 438 static int |
406 x_allocate_bitmap_record () | 439 x_allocate_bitmap_record () |
436 } | 469 } |
437 | 470 |
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 |
440 void | 473 void |
441 x_reference_bitmap (id) | 474 x_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; |
445 } | 479 } |
446 | 480 |
463 | 497 |
464 id = x_allocate_bitmap_record (); | 498 id = x_allocate_bitmap_record (); |
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 } |
471 | 508 |
472 /* Create bitmap from file FILE for frame F. */ | 509 /* Create bitmap from file FILE for frame F. */ |
473 | 510 |
474 int | 511 int |
475 x_create_bitmap_from_file (f, file) | 512 x_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 } |
508 | 559 |
509 /* Remove reference to bitmap with id number ID. */ | 560 /* Remove reference to bitmap with id number ID. */ |
510 | 561 |
511 int | 562 int |
512 x_destroy_bitmap (id) | 563 x_destroy_bitmap (f, id) |
564 FRAME_PTR f; | |
513 int id; | 565 int id; |
514 { | 566 { |
515 if (id > 0) | 567 if (id > 0) |
516 { | 568 { |
517 --x_bitmaps[id - 1].refcount; | 569 --x_bitmaps[id - 1].refcount; |
1263 return; | 1315 return; |
1264 | 1316 |
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 { |
1275 UNBLOCK_INPUT; | 1325 UNBLOCK_INPUT; |
1276 error ("No icon window available"); | 1326 error ("No icon window available"); |
1286 | 1336 |
1287 XFlushQueue (); | 1337 XFlushQueue (); |
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 |
1293 int | 1343 Lisp_Object |
1294 x_icon_type (f) | 1344 x_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 |
1303 extern Lisp_Object x_new_font (); | 1356 extern Lisp_Object x_new_font (); |
1304 | 1357 |
1305 void | 1358 void |
4355 Fput (Qundefined_color, Qerror_message, | 4408 Fput (Qundefined_color, Qerror_message, |
4356 build_string ("Undefined color")); | 4409 build_string ("Undefined color")); |
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; |
4363 | 4420 |
4364 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, | 4421 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, |