diff options
| author | Richard M. Stallman | 1994-10-25 10:33:36 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-25 10:33:36 +0000 |
| commit | 08a90d6aea5d7554da2cf7e172a19a75f2f6d50c (patch) | |
| tree | 6aa851d059c27781dcd4658929b3528dff7c8a16 /src | |
| parent | e4fe371d2834c375611ebd76bf63c194ddea565e (diff) | |
| download | emacs-08a90d6aea5d7554da2cf7e172a19a75f2f6d50c.tar.gz emacs-08a90d6aea5d7554da2cf7e172a19a75f2f6d50c.zip | |
(Fx_create_frame): Don't increment refernce_count
until the frame is put on the frame list.
(Fx_close_connection): Call x_delete_display.
(x_display_info_for_name, Fx_open_connection):
Signal error if x_term_init fails.
(Fx_open_connection): New arg must_succeed.
(x_real_positions): Catch errors and retry if error happens.
No need to block input here.
(Fx_create_frame): Don't store the frame name
till after FRAME_X_DISPLAY_INFO is set up.
(Fx_close_connection): Renamed from Fx_close_current_connection
Many doc fixes and Lisp function arg renamings.
(x_bitmaps, x_bitmap_size, x_bitmap_last):
Variables deleted. Use fields in x_display_info instead.
(x_bitmaps_free): Variable deleted.
(x_destroy_bitmap, x_allocate_bitmap_record): Don't use or set it.
(x_allocate_bitmap_record): New arg f. Callers changed.
(x_lookup_pixmap): Function deleted.
(x_destroy_all_bitmaps): New function.
(Fx_close_current_connection): Call x_destroy_all_bitmaps.
Free the fonts in the font table. Free various other data
that dpyinfo points to. Avoid using Fdelq.
(x_set_name, Fx_create_frame): Use x_id_name field.
(Fx_close_current_connection):
Call delete_keyboard_wait_descriptor.
(Fx_close_current_connection): Call check_x_display_info.
Delete the display from x_display_list and x_display_name_list.
(Fx_display_list): New function.
(syms_of_xfns): defsubr it.
(Fx_list_fonts): Use `name_list_element' field.
(x_display_info_for_name): Scan x_display_name_list
along with x_display_list.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 559 |
1 files changed, 324 insertions, 235 deletions
diff --git a/src/xfns.c b/src/xfns.c index dd3cf50ef18..5ae6ae5c93e 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -101,9 +101,6 @@ extern void free_frame_menubar (); | |||
| 101 | /* The name we're using in resource queries. */ | 101 | /* The name we're using in resource queries. */ |
| 102 | Lisp_Object Vx_resource_name; | 102 | Lisp_Object Vx_resource_name; |
| 103 | 103 | ||
| 104 | /* Title name and application name for X stuff. */ | ||
| 105 | extern char *x_id_name; | ||
| 106 | |||
| 107 | /* The background and shape of the mouse pointer, and shape when not | 104 | /* The background and shape of the mouse pointer, and shape when not |
| 108 | over text or in the modeline. */ | 105 | over text or in the modeline. */ |
| 109 | Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; | 106 | Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; |
| @@ -381,30 +378,6 @@ x_top_window_to_frame (wdesc) | |||
| 381 | data more than once will not be caught. */ | 378 | data more than once will not be caught. */ |
| 382 | 379 | ||
| 383 | 380 | ||
| 384 | /* Structure recording X pixmap and reference count. | ||
| 385 | If REFCOUNT is 0 then this record is free to be reused. */ | ||
| 386 | |||
| 387 | struct x_bitmap_record | ||
| 388 | { | ||
| 389 | Pixmap pixmap; | ||
| 390 | char *file; | ||
| 391 | int refcount; | ||
| 392 | /* Record some info about this pixmap. */ | ||
| 393 | int height, width, depth; | ||
| 394 | }; | ||
| 395 | |||
| 396 | /* Pointer to bitmap records. */ | ||
| 397 | static struct x_bitmap_record *x_bitmaps; | ||
| 398 | |||
| 399 | /* Allocated size of x_bitmaps. */ | ||
| 400 | static int x_bitmaps_size; | ||
| 401 | |||
| 402 | /* Last used bitmap index. */ | ||
| 403 | static int x_bitmaps_last; | ||
| 404 | |||
| 405 | /* Count of free bitmaps before X_BITMAPS_LAST. */ | ||
| 406 | static int x_bitmaps_free; | ||
| 407 | |||
| 408 | /* Functions to access the contents of a bitmap, given an id. */ | 381 | /* Functions to access the contents of a bitmap, given an id. */ |
| 409 | 382 | ||
| 410 | int | 383 | int |
| @@ -412,7 +385,7 @@ x_bitmap_height (f, id) | |||
| 412 | FRAME_PTR f; | 385 | FRAME_PTR f; |
| 413 | int id; | 386 | int id; |
| 414 | { | 387 | { |
| 415 | return x_bitmaps[id - 1].height; | 388 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; |
| 416 | } | 389 | } |
| 417 | 390 | ||
| 418 | int | 391 | int |
| @@ -420,7 +393,7 @@ x_bitmap_width (f, id) | |||
| 420 | FRAME_PTR f; | 393 | FRAME_PTR f; |
| 421 | int id; | 394 | int id; |
| 422 | { | 395 | { |
| 423 | return x_bitmaps[id - 1].width; | 396 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; |
| 424 | } | 397 | } |
| 425 | 398 | ||
| 426 | int | 399 | int |
| @@ -428,43 +401,40 @@ x_bitmap_pixmap (f, id) | |||
| 428 | FRAME_PTR f; | 401 | FRAME_PTR f; |
| 429 | int id; | 402 | int id; |
| 430 | { | 403 | { |
| 431 | return x_bitmaps[id - 1].pixmap; | 404 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; |
| 432 | } | 405 | } |
| 433 | 406 | ||
| 434 | 407 | ||
| 435 | /* Allocate a new bitmap record. Returns index of new record. */ | 408 | /* Allocate a new bitmap record. Returns index of new record. */ |
| 436 | 409 | ||
| 437 | static int | 410 | static int |
| 438 | x_allocate_bitmap_record () | 411 | x_allocate_bitmap_record (f) |
| 412 | FRAME_PTR f; | ||
| 439 | { | 413 | { |
| 440 | if (x_bitmaps == NULL) | 414 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 415 | int i; | ||
| 416 | |||
| 417 | if (dpyinfo->bitmaps == NULL) | ||
| 441 | { | 418 | { |
| 442 | x_bitmaps_size = 10; | 419 | dpyinfo->bitmaps_size = 10; |
| 443 | x_bitmaps | 420 | dpyinfo->bitmaps |
| 444 | = (struct x_bitmap_record *) xmalloc (x_bitmaps_size * sizeof (struct x_bitmap_record)); | 421 | = (struct x_bitmap_record *) xmalloc (dpyinfo->bitmaps_size * sizeof (struct x_bitmap_record)); |
| 445 | x_bitmaps_last = 1; | 422 | dpyinfo->bitmaps_last = 1; |
| 446 | return 1; | 423 | return 1; |
| 447 | } | 424 | } |
| 448 | 425 | ||
| 449 | if (x_bitmaps_last < x_bitmaps_size) | 426 | if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size) |
| 450 | return ++x_bitmaps_last; | 427 | return ++dpyinfo->bitmaps_last; |
| 451 | 428 | ||
| 452 | if (x_bitmaps_free > 0) | 429 | for (i = 0; i < dpyinfo->bitmaps_size; ++i) |
| 453 | { | 430 | if (dpyinfo->bitmaps[i].refcount == 0) |
| 454 | int i; | 431 | return i + 1; |
| 455 | for (i = 0; i < x_bitmaps_size; ++i) | ||
| 456 | { | ||
| 457 | if (x_bitmaps[i].refcount == 0) | ||
| 458 | { | ||
| 459 | --x_bitmaps_free; | ||
| 460 | return i + 1; | ||
| 461 | } | ||
| 462 | } | ||
| 463 | } | ||
| 464 | 432 | ||
| 465 | x_bitmaps_size *= 2; | 433 | dpyinfo->bitmaps_size *= 2; |
| 466 | x_bitmaps = (struct x_bitmap_record *) xrealloc (x_bitmaps, x_bitmaps_size * sizeof (struct x_bitmap_record)); | 434 | dpyinfo->bitmaps |
| 467 | return ++x_bitmaps_last; | 435 | = (struct x_bitmap_record *) xrealloc (dpyinfo->bitmaps, |
| 436 | dpyinfo->bitmaps_size * sizeof (struct x_bitmap_record)); | ||
| 437 | return ++dpyinfo->bitmaps_last; | ||
| 468 | } | 438 | } |
| 469 | 439 | ||
| 470 | /* Add one reference to the reference count of the bitmap with id ID. */ | 440 | /* Add one reference to the reference count of the bitmap with id ID. */ |
| @@ -474,7 +444,7 @@ x_reference_bitmap (f, id) | |||
| 474 | FRAME_PTR f; | 444 | FRAME_PTR f; |
| 475 | int id; | 445 | int id; |
| 476 | { | 446 | { |
| 477 | ++x_bitmaps[id - 1].refcount; | 447 | ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; |
| 478 | } | 448 | } |
| 479 | 449 | ||
| 480 | /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ | 450 | /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ |
| @@ -485,6 +455,7 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 485 | char *bits; | 455 | char *bits; |
| 486 | unsigned int width, height; | 456 | unsigned int width, height; |
| 487 | { | 457 | { |
| 458 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 488 | Pixmap bitmap; | 459 | Pixmap bitmap; |
| 489 | int id; | 460 | int id; |
| 490 | 461 | ||
| @@ -494,13 +465,13 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 494 | if (! bitmap) | 465 | if (! bitmap) |
| 495 | return -1; | 466 | return -1; |
| 496 | 467 | ||
| 497 | id = x_allocate_bitmap_record (); | 468 | id = x_allocate_bitmap_record (f); |
| 498 | x_bitmaps[id - 1].pixmap = bitmap; | 469 | dpyinfo->bitmaps[id - 1].pixmap = bitmap; |
| 499 | x_bitmaps[id - 1].file = NULL; | 470 | dpyinfo->bitmaps[id - 1].file = NULL; |
| 500 | x_bitmaps[id - 1].refcount = 1; | 471 | dpyinfo->bitmaps[id - 1].refcount = 1; |
| 501 | x_bitmaps[id - 1].depth = 1; | 472 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 502 | x_bitmaps[id - 1].height = height; | 473 | dpyinfo->bitmaps[id - 1].height = height; |
| 503 | x_bitmaps[id - 1].width = width; | 474 | dpyinfo->bitmaps[id - 1].width = width; |
| 504 | 475 | ||
| 505 | return id; | 476 | return id; |
| 506 | } | 477 | } |
| @@ -512,6 +483,7 @@ x_create_bitmap_from_file (f, file) | |||
| 512 | struct frame *f; | 483 | struct frame *f; |
| 513 | Lisp_Object file; | 484 | Lisp_Object file; |
| 514 | { | 485 | { |
| 486 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 515 | unsigned int width, height; | 487 | unsigned int width, height; |
| 516 | Pixmap bitmap; | 488 | Pixmap bitmap; |
| 517 | int xhot, yhot, result, id; | 489 | int xhot, yhot, result, id; |
| @@ -520,13 +492,13 @@ x_create_bitmap_from_file (f, file) | |||
| 520 | char *filename; | 492 | char *filename; |
| 521 | 493 | ||
| 522 | /* Look for an existing bitmap with the same name. */ | 494 | /* Look for an existing bitmap with the same name. */ |
| 523 | for (id = 0; id < x_bitmaps_last; ++id) | 495 | for (id = 0; id < dpyinfo->bitmaps_last; ++id) |
| 524 | { | 496 | { |
| 525 | if (x_bitmaps[id].refcount | 497 | if (dpyinfo->bitmaps[id].refcount |
| 526 | && x_bitmaps[id].file | 498 | && dpyinfo->bitmaps[id].file |
| 527 | && !strcmp (x_bitmaps[id].file, (char *) XSTRING (file)->data)) | 499 | && !strcmp (dpyinfo->bitmaps[id].file, (char *) XSTRING (file)->data)) |
| 528 | { | 500 | { |
| 529 | ++x_bitmaps[id].refcount; | 501 | ++dpyinfo->bitmaps[id].refcount; |
| 530 | return id + 1; | 502 | return id + 1; |
| 531 | } | 503 | } |
| 532 | } | 504 | } |
| @@ -544,14 +516,14 @@ x_create_bitmap_from_file (f, file) | |||
| 544 | if (result != BitmapSuccess) | 516 | if (result != BitmapSuccess) |
| 545 | return -1; | 517 | return -1; |
| 546 | 518 | ||
| 547 | id = x_allocate_bitmap_record (); | 519 | id = x_allocate_bitmap_record (f); |
| 548 | x_bitmaps[id - 1].pixmap = bitmap; | 520 | dpyinfo->bitmaps[id - 1].pixmap = bitmap; |
| 549 | x_bitmaps[id - 1].refcount = 1; | 521 | dpyinfo->bitmaps[id - 1].refcount = 1; |
| 550 | x_bitmaps[id - 1].file = (char *) xmalloc (XSTRING (file)->size + 1); | 522 | dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (XSTRING (file)->size + 1); |
| 551 | x_bitmaps[id - 1].depth = 1; | 523 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 552 | x_bitmaps[id - 1].height = height; | 524 | dpyinfo->bitmaps[id - 1].height = height; |
| 553 | x_bitmaps[id - 1].width = width; | 525 | dpyinfo->bitmaps[id - 1].width = width; |
| 554 | strcpy (x_bitmaps[id - 1].file, XSTRING (file)->data); | 526 | strcpy (dpyinfo->bitmaps[id - 1].file, XSTRING (file)->data); |
| 555 | 527 | ||
| 556 | return id; | 528 | return id; |
| 557 | } | 529 | } |
| @@ -563,28 +535,38 @@ x_destroy_bitmap (f, id) | |||
| 563 | FRAME_PTR f; | 535 | FRAME_PTR f; |
| 564 | int id; | 536 | int id; |
| 565 | { | 537 | { |
| 538 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 539 | |||
| 566 | if (id > 0) | 540 | if (id > 0) |
| 567 | { | 541 | { |
| 568 | --x_bitmaps[id - 1].refcount; | 542 | --dpyinfo->bitmaps[id - 1].refcount; |
| 569 | if (! x_bitmaps[id - 1].refcount) | 543 | if (dpyinfo->bitmaps[id - 1].refcount == 0) |
| 570 | { | 544 | { |
| 571 | XFreePixmap (FRAME_X_DISPLAY (f), x_bitmaps[id - 1].pixmap); | 545 | XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].pixmap); |
| 572 | if (x_bitmaps[id - 1].file) | 546 | if (dpyinfo->bitmaps[id - 1].file) |
| 573 | { | 547 | { |
| 574 | free (x_bitmaps[id - 1].file); | 548 | free (dpyinfo->bitmaps[id - 1].file); |
| 575 | x_bitmaps[id - 1].file = NULL; | 549 | dpyinfo->bitmaps[id - 1].file = NULL; |
| 576 | } | 550 | } |
| 577 | } | 551 | } |
| 578 | } | 552 | } |
| 579 | } | 553 | } |
| 580 | 554 | ||
| 581 | /* Return the actual X pixmap number for a given bitmap id. */ | 555 | /* Free all the bitmaps for the display specified by DPYINFO. */ |
| 582 | 556 | ||
| 583 | Pixmap | 557 | static void |
| 584 | x_lookup_pixmap (id) | 558 | x_destroy_all_bitmaps (dpyinfo) |
| 585 | int id; | 559 | struct x_display_info *dpyinfo; |
| 586 | { | 560 | { |
| 587 | return x_bitmaps[id - 1].pixmap; | 561 | int i; |
| 562 | for (i = 0; i < dpyinfo->bitmaps_last; i++) | ||
| 563 | if (dpyinfo->bitmaps[i].refcount > 0) | ||
| 564 | { | ||
| 565 | XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].pixmap); | ||
| 566 | if (dpyinfo->bitmaps[i].file) | ||
| 567 | free (dpyinfo->bitmaps[i].file); | ||
| 568 | } | ||
| 569 | dpyinfo->bitmaps_last = 0; | ||
| 588 | } | 570 | } |
| 589 | 571 | ||
| 590 | /* Connect the frame-parameter names for X frames | 572 | /* Connect the frame-parameter names for X frames |
| @@ -861,7 +843,7 @@ x_set_frame_parameters (f, alist) | |||
| 861 | } | 843 | } |
| 862 | } | 844 | } |
| 863 | 845 | ||
| 864 | /* Store the positions of frame F into XPTR and YPTR. | 846 | /* Store the screen positions of frame F into XPTR and YPTR. |
| 865 | These are the positions of the containing window manager window, | 847 | These are the positions of the containing window manager window, |
| 866 | not Emacs's own window. */ | 848 | not Emacs's own window. */ |
| 867 | 849 | ||
| @@ -870,7 +852,7 @@ x_real_positions (f, xptr, yptr) | |||
| 870 | FRAME_PTR f; | 852 | FRAME_PTR f; |
| 871 | int *xptr, *yptr; | 853 | int *xptr, *yptr; |
| 872 | { | 854 | { |
| 873 | int win_x = 0, win_y = 0; | 855 | int win_x, win_y; |
| 874 | Window child; | 856 | Window child; |
| 875 | 857 | ||
| 876 | /* This is pretty gross, but seems to be the easiest way out of | 858 | /* This is pretty gross, but seems to be the easiest way out of |
| @@ -885,36 +867,51 @@ x_real_positions (f, xptr, yptr) | |||
| 885 | Window *tmp_children; | 867 | Window *tmp_children; |
| 886 | int tmp_nchildren; | 868 | int tmp_nchildren; |
| 887 | 869 | ||
| 888 | XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window, | 870 | x_catch_errors (f); |
| 889 | &f->display.x->parent_desc, | 871 | while (1) |
| 890 | &tmp_children, &tmp_nchildren); | ||
| 891 | xfree (tmp_children); | ||
| 892 | |||
| 893 | /* Find the position of the outside upper-left corner of | ||
| 894 | the inner window, with respect to the outer window. */ | ||
| 895 | if (f->display.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | ||
| 896 | { | 872 | { |
| 897 | BLOCK_INPUT; | 873 | XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window, |
| 898 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | 874 | &f->display.x->parent_desc, |
| 899 | 875 | &tmp_children, &tmp_nchildren); | |
| 900 | /* From-window, to-window. */ | 876 | xfree (tmp_children); |
| 877 | |||
| 878 | win_x = win_y = 0; | ||
| 879 | |||
| 880 | /* Find the position of the outside upper-left corner of | ||
| 881 | the inner window, with respect to the outer window. */ | ||
| 882 | if (f->display.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | ||
| 883 | { | ||
| 884 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | ||
| 885 | |||
| 886 | /* From-window, to-window. */ | ||
| 901 | #ifdef USE_X_TOOLKIT | 887 | #ifdef USE_X_TOOLKIT |
| 902 | XtWindow (f->display.x->widget), | 888 | XtWindow (f->display.x->widget), |
| 903 | #else | 889 | #else |
| 904 | f->display.x->window_desc, | 890 | f->display.x->window_desc, |
| 905 | #endif | 891 | #endif |
| 906 | f->display.x->parent_desc, | 892 | f->display.x->parent_desc, |
| 907 | 893 | ||
| 908 | /* From-position, to-position. */ | 894 | /* From-position, to-position. */ |
| 909 | 0, 0, &win_x, &win_y, | 895 | 0, 0, &win_x, &win_y, |
| 910 | 896 | ||
| 911 | /* Child of win. */ | 897 | /* Child of win. */ |
| 912 | &child); | 898 | &child); |
| 913 | UNBLOCK_INPUT; | 899 | |
| 900 | win_x += f->display.x->border_width; | ||
| 901 | win_y += f->display.x->border_width; | ||
| 902 | } | ||
| 914 | 903 | ||
| 915 | win_x += f->display.x->border_width; | 904 | /* It is possible for the window returned by the XQueryNotify |
| 916 | win_y += f->display.x->border_width; | 905 | to become invalid by the time we call XTranslateCoordinates. |
| 906 | That can happen when you restart some window managers. | ||
| 907 | If so, we get an error in XTranslateCoordinates. | ||
| 908 | Detect that and try the whole thing over. */ | ||
| 909 | if (! x_had_errors_p (f)) | ||
| 910 | break; | ||
| 917 | } | 911 | } |
| 912 | |||
| 913 | x_uncatch_errors (f); | ||
| 914 | |||
| 918 | *xptr = f->display.x->left_pos - win_x; | 915 | *xptr = f->display.x->left_pos - win_x; |
| 919 | *yptr = f->display.x->top_pos - win_y; | 916 | *yptr = f->display.x->top_pos - win_y; |
| 920 | } | 917 | } |
| @@ -1547,9 +1544,10 @@ x_set_name (f, name, explicit) | |||
| 1547 | { | 1544 | { |
| 1548 | /* Check for no change needed in this very common case | 1545 | /* Check for no change needed in this very common case |
| 1549 | before we do any consing. */ | 1546 | before we do any consing. */ |
| 1550 | if (!strcmp (x_id_name, XSTRING (f->name)->data)) | 1547 | if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name, |
| 1548 | XSTRING (f->name)->data)) | ||
| 1551 | return; | 1549 | return; |
| 1552 | name = build_string (x_id_name); | 1550 | name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name); |
| 1553 | } | 1551 | } |
| 1554 | else | 1552 | else |
| 1555 | CHECK_STRING (name, 0); | 1553 | CHECK_STRING (name, 0); |
| @@ -2565,12 +2563,14 @@ x_make_gc (f) | |||
| 2565 | DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, | 2563 | DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, |
| 2566 | 1, 1, 0, | 2564 | 1, 1, 0, |
| 2567 | "Make a new X window, which is called a \"frame\" in Emacs terms.\n\ | 2565 | "Make a new X window, which is called a \"frame\" in Emacs terms.\n\ |
| 2568 | Return an Emacs frame object representing the X window.\n\ | 2566 | Returns an Emacs frame object.\n\ |
| 2569 | ALIST is an alist of frame parameters.\n\ | 2567 | ALIST is an alist of frame parameters.\n\ |
| 2570 | If the parameters specify that the frame should not have a minibuffer,\n\ | 2568 | If the parameters specify that the frame should not have a minibuffer,\n\ |
| 2571 | and do not specify a specific minibuffer window to use,\n\ | 2569 | and do not specify a specific minibuffer window to use,\n\ |
| 2572 | then `default-minibuffer-frame' must be a frame whose minibuffer can\n\ | 2570 | then `default-minibuffer-frame' must be a frame whose minibuffer can\n\ |
| 2573 | be shared by the new frame.") | 2571 | be shared by the new frame.\n\ |
| 2572 | \n\ | ||
| 2573 | This function is an internal primitive--use `make-frame' instead.") | ||
| 2574 | (parms) | 2574 | (parms) |
| 2575 | Lisp_Object parms; | 2575 | Lisp_Object parms; |
| 2576 | { | 2576 | { |
| @@ -2596,7 +2596,7 @@ be shared by the new frame.") | |||
| 2596 | if (!STRINGP (name) | 2596 | if (!STRINGP (name) |
| 2597 | && ! EQ (name, Qunbound) | 2597 | && ! EQ (name, Qunbound) |
| 2598 | && ! NILP (name)) | 2598 | && ! NILP (name)) |
| 2599 | error ("x-create-frame: name parameter must be a string"); | 2599 | error ("Invalid frame name--not a string or nil"); |
| 2600 | 2600 | ||
| 2601 | tem = x_get_arg (parms, Qminibuffer, 0, 0, symbol); | 2601 | tem = x_get_arg (parms, Qminibuffer, 0, 0, symbol); |
| 2602 | if (EQ (tem, Qnone) || NILP (tem)) | 2602 | if (EQ (tem, Qnone) || NILP (tem)) |
| @@ -2614,11 +2614,24 @@ be shared by the new frame.") | |||
| 2614 | /* Note that X Windows does support scroll bars. */ | 2614 | /* Note that X Windows does support scroll bars. */ |
| 2615 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; | 2615 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; |
| 2616 | 2616 | ||
| 2617 | XSETFRAME (frame, f); | ||
| 2618 | GCPRO1 (frame); | ||
| 2619 | |||
| 2620 | f->output_method = output_x_window; | ||
| 2621 | f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display)); | ||
| 2622 | bzero (f->display.x, sizeof (struct x_display)); | ||
| 2623 | f->display.x->icon_bitmap = -1; | ||
| 2624 | |||
| 2625 | FRAME_X_DISPLAY_INFO (f) = dpyinfo; | ||
| 2626 | |||
| 2627 | /* Note that the frame has no physical cursor right now. */ | ||
| 2628 | f->phys_cursor_x = -1; | ||
| 2629 | |||
| 2617 | /* Set the name; the functions to which we pass f expect the name to | 2630 | /* Set the name; the functions to which we pass f expect the name to |
| 2618 | be set. */ | 2631 | be set. */ |
| 2619 | if (EQ (name, Qunbound) || NILP (name)) | 2632 | if (EQ (name, Qunbound) || NILP (name)) |
| 2620 | { | 2633 | { |
| 2621 | f->name = build_string (x_id_name); | 2634 | f->name = build_string (dpyinfo->x_id_name); |
| 2622 | f->explicit_name = 0; | 2635 | f->explicit_name = 0; |
| 2623 | } | 2636 | } |
| 2624 | else | 2637 | else |
| @@ -2629,20 +2642,6 @@ be shared by the new frame.") | |||
| 2629 | specbind (Qx_resource_name, name); | 2642 | specbind (Qx_resource_name, name); |
| 2630 | } | 2643 | } |
| 2631 | 2644 | ||
| 2632 | XSETFRAME (frame, f); | ||
| 2633 | GCPRO1 (frame); | ||
| 2634 | |||
| 2635 | f->output_method = output_x_window; | ||
| 2636 | f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display)); | ||
| 2637 | bzero (f->display.x, sizeof (struct x_display)); | ||
| 2638 | f->display.x->icon_bitmap = -1; | ||
| 2639 | |||
| 2640 | FRAME_X_DISPLAY_INFO (f) = dpyinfo; | ||
| 2641 | FRAME_X_DISPLAY_INFO (f)->reference_count++; | ||
| 2642 | |||
| 2643 | /* Note that the frame has no physical cursor right now. */ | ||
| 2644 | f->phys_cursor_x = -1; | ||
| 2645 | |||
| 2646 | /* Extract the window parameters from the supplied values | 2645 | /* Extract the window parameters from the supplied values |
| 2647 | that are needed to determine window geometry. */ | 2646 | that are needed to determine window geometry. */ |
| 2648 | { | 2647 | { |
| @@ -2777,6 +2776,10 @@ be shared by the new frame.") | |||
| 2777 | or making it visible won't work. */ | 2776 | or making it visible won't work. */ |
| 2778 | Vframe_list = Fcons (frame, Vframe_list); | 2777 | Vframe_list = Fcons (frame, Vframe_list); |
| 2779 | 2778 | ||
| 2779 | /* Now that the frame is official, it counts as a reference to | ||
| 2780 | its display. */ | ||
| 2781 | FRAME_X_DISPLAY_INFO (f)->reference_count++; | ||
| 2782 | |||
| 2780 | /* Make the window appear on the frame and enable display, | 2783 | /* Make the window appear on the frame and enable display, |
| 2781 | unless the caller says not to. */ | 2784 | unless the caller says not to. */ |
| 2782 | { | 2785 | { |
| @@ -2850,7 +2853,7 @@ PATTERN is a string, perhaps with wildcard characters;\n\ | |||
| 2850 | the * character matches any substring, and\n\ | 2853 | the * character matches any substring, and\n\ |
| 2851 | the ? character matches any single character.\n\ | 2854 | the ? character matches any single character.\n\ |
| 2852 | PATTERN is case-insensitive.\n\ | 2855 | PATTERN is case-insensitive.\n\ |
| 2853 | FACE is a face name - a symbol.\n\ | 2856 | FACE is a face name--a symbol.\n\ |
| 2854 | \n\ | 2857 | \n\ |
| 2855 | The return value is a list of strings, suitable as arguments to\n\ | 2858 | The return value is a list of strings, suitable as arguments to\n\ |
| 2856 | set-face-font.\n\ | 2859 | set-face-font.\n\ |
| @@ -2900,7 +2903,8 @@ even if they match PATTERN and FACE.") | |||
| 2900 | } | 2903 | } |
| 2901 | 2904 | ||
| 2902 | /* See if we cached the result for this particular query. */ | 2905 | /* See if we cached the result for this particular query. */ |
| 2903 | list = Fassoc (pattern, FRAME_X_DISPLAY_INFO (f)->font_list_cache); | 2906 | list = Fassoc (pattern, |
| 2907 | XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr); | ||
| 2904 | 2908 | ||
| 2905 | /* We have info in the cache for this PATTERN. */ | 2909 | /* We have info in the cache for this PATTERN. */ |
| 2906 | if (!NILP (list)) | 2910 | if (!NILP (list)) |
| @@ -2964,9 +2968,9 @@ even if they match PATTERN and FACE.") | |||
| 2964 | full_list = Qnil; | 2968 | full_list = Qnil; |
| 2965 | for (i = 0; i < num_fonts; i++) | 2969 | for (i = 0; i < num_fonts; i++) |
| 2966 | full_list = Fcons (build_string (names[i]), full_list); | 2970 | full_list = Fcons (build_string (names[i]), full_list); |
| 2967 | FRAME_X_DISPLAY_INFO (f)->font_list_cache | 2971 | XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr |
| 2968 | = Fcons (Fcons (pattern, full_list), | 2972 | = Fcons (Fcons (pattern, full_list), |
| 2969 | FRAME_X_DISPLAY_INFO (f)->font_list_cache); | 2973 | XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr); |
| 2970 | 2974 | ||
| 2971 | /* Make a list of the fonts that have the right width. */ | 2975 | /* Make a list of the fonts that have the right width. */ |
| 2972 | list = Qnil; | 2976 | list = Qnil; |
| @@ -3001,7 +3005,8 @@ even if they match PATTERN and FACE.") | |||
| 3001 | 3005 | ||
| 3002 | 3006 | ||
| 3003 | DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0, | 3007 | DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0, |
| 3004 | "Return non-nil color COLOR is supported on frame FRAME.") | 3008 | "Return non-nil color COLOR is supported on frame FRAME.\n\ |
| 3009 | If FRAME is omitted or nil, use the selected frame.") | ||
| 3005 | (color, frame) | 3010 | (color, frame) |
| 3006 | Lisp_Object color, frame; | 3011 | Lisp_Object color, frame; |
| 3007 | { | 3012 | { |
| @@ -3019,7 +3024,8 @@ DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0, | |||
| 3019 | DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0, | 3024 | DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0, |
| 3020 | "Return a description of the color named COLOR on frame FRAME.\n\ | 3025 | "Return a description of the color named COLOR on frame FRAME.\n\ |
| 3021 | The value is a list of integer RGB values--(RED GREEN BLUE).\n\ | 3026 | The value is a list of integer RGB values--(RED GREEN BLUE).\n\ |
| 3022 | These values appear to range from 0 to 65280; white is (65280 65280 65280).") | 3027 | These values appear to range from 0 to 65280; white is (65280 65280 65280).\n\ |
| 3028 | If FRAME is omitted or nil, use the selected frame.") | ||
| 3023 | (color, frame) | 3029 | (color, frame) |
| 3024 | Lisp_Object color, frame; | 3030 | Lisp_Object color, frame; |
| 3025 | { | 3031 | { |
| @@ -3042,11 +3048,14 @@ These values appear to range from 0 to 65280; white is (65280 65280 65280).") | |||
| 3042 | } | 3048 | } |
| 3043 | 3049 | ||
| 3044 | DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0, | 3050 | DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0, |
| 3045 | "Return t if the X screen FRAME is on supports color.") | 3051 | "Return t if the X display supports color.\n\ |
| 3046 | (frame) | 3052 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3047 | Lisp_Object frame; | 3053 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3054 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3055 | (display) | ||
| 3056 | Lisp_Object display; | ||
| 3048 | { | 3057 | { |
| 3049 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3058 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3050 | 3059 | ||
| 3051 | if (dpyinfo->n_planes <= 2) | 3060 | if (dpyinfo->n_planes <= 2) |
| 3052 | return Qnil; | 3061 | return Qnil; |
| @@ -3066,11 +3075,14 @@ DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0, | |||
| 3066 | 3075 | ||
| 3067 | DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, | 3076 | DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, |
| 3068 | 0, 1, 0, | 3077 | 0, 1, 0, |
| 3069 | "Return t if the X screen FRAME is on supports grayscale.") | 3078 | "Return t if the X display supports shades of gray.\n\ |
| 3070 | (frame) | 3079 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3071 | Lisp_Object frame; | 3080 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3081 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3082 | (display) | ||
| 3083 | Lisp_Object display; | ||
| 3072 | { | 3084 | { |
| 3073 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3085 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3074 | 3086 | ||
| 3075 | if (dpyinfo->n_planes <= 2) | 3087 | if (dpyinfo->n_planes <= 2) |
| 3076 | return Qnil; | 3088 | return Qnil; |
| @@ -3082,44 +3094,56 @@ DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, | |||
| 3082 | 3094 | ||
| 3083 | DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, | 3095 | DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, |
| 3084 | 0, 1, 0, | 3096 | 0, 1, 0, |
| 3085 | "Returns the width in pixels of the display FRAME is on.") | 3097 | "Returns the width in pixels of the X display DISPLAY.\n\ |
| 3086 | (frame) | 3098 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3087 | Lisp_Object frame; | 3099 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3100 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3101 | (display) | ||
| 3102 | Lisp_Object display; | ||
| 3088 | { | 3103 | { |
| 3089 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3104 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3090 | 3105 | ||
| 3091 | return make_number (dpyinfo->width); | 3106 | return make_number (dpyinfo->width); |
| 3092 | } | 3107 | } |
| 3093 | 3108 | ||
| 3094 | DEFUN ("x-display-pixel-height", Fx_display_pixel_height, | 3109 | DEFUN ("x-display-pixel-height", Fx_display_pixel_height, |
| 3095 | Sx_display_pixel_height, 0, 1, 0, | 3110 | Sx_display_pixel_height, 0, 1, 0, |
| 3096 | "Returns the height in pixels of the display FRAME is on.") | 3111 | "Returns the height in pixels of the X display DISPLAY.\n\ |
| 3097 | (frame) | 3112 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3098 | Lisp_Object frame; | 3113 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3114 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3115 | (display) | ||
| 3116 | Lisp_Object display; | ||
| 3099 | { | 3117 | { |
| 3100 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3118 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3101 | 3119 | ||
| 3102 | return make_number (dpyinfo->height); | 3120 | return make_number (dpyinfo->height); |
| 3103 | } | 3121 | } |
| 3104 | 3122 | ||
| 3105 | DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, | 3123 | DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, |
| 3106 | 0, 1, 0, | 3124 | 0, 1, 0, |
| 3107 | "Returns the number of bitplanes of the display FRAME is on.") | 3125 | "Returns the number of bitplanes of the X display DISPLAY.\n\ |
| 3108 | (frame) | 3126 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3109 | Lisp_Object frame; | 3127 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3128 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3129 | (display) | ||
| 3130 | Lisp_Object display; | ||
| 3110 | { | 3131 | { |
| 3111 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3132 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3112 | 3133 | ||
| 3113 | return make_number (dpyinfo->n_planes); | 3134 | return make_number (dpyinfo->n_planes); |
| 3114 | } | 3135 | } |
| 3115 | 3136 | ||
| 3116 | DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, | 3137 | DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, |
| 3117 | 0, 1, 0, | 3138 | 0, 1, 0, |
| 3118 | "Returns the number of color cells of the display FRAME is on.") | 3139 | "Returns the number of color cells of the X display DISPLAY.\n\ |
| 3119 | (frame) | 3140 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3120 | Lisp_Object frame; | 3141 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3142 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3143 | (display) | ||
| 3144 | Lisp_Object display; | ||
| 3121 | { | 3145 | { |
| 3122 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3146 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3123 | 3147 | ||
| 3124 | return make_number (DisplayCells (dpyinfo->display, | 3148 | return make_number (DisplayCells (dpyinfo->display, |
| 3125 | XScreenNumberOfScreen (dpyinfo->screen))); | 3149 | XScreenNumberOfScreen (dpyinfo->screen))); |
| @@ -3128,21 +3152,27 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, | |||
| 3128 | DEFUN ("x-server-max-request-size", Fx_server_max_request_size, | 3152 | DEFUN ("x-server-max-request-size", Fx_server_max_request_size, |
| 3129 | Sx_server_max_request_size, | 3153 | Sx_server_max_request_size, |
| 3130 | 0, 1, 0, | 3154 | 0, 1, 0, |
| 3131 | "Returns the maximum request size of the X server FRAME is using.") | 3155 | "Returns the maximum request size of the X server of display DISPLAY.\n\ |
| 3132 | (frame) | 3156 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3133 | Lisp_Object frame; | 3157 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3158 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3159 | (display) | ||
| 3160 | Lisp_Object display; | ||
| 3134 | { | 3161 | { |
| 3135 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3162 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3136 | 3163 | ||
| 3137 | return make_number (MAXREQUEST (dpyinfo->display)); | 3164 | return make_number (MAXREQUEST (dpyinfo->display)); |
| 3138 | } | 3165 | } |
| 3139 | 3166 | ||
| 3140 | DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, | 3167 | DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, |
| 3141 | "Returns the vendor ID string of the X server FRAME is on.") | 3168 | "Returns the vendor ID string of the X server of display DISPLAY.\n\ |
| 3142 | (frame) | 3169 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3143 | Lisp_Object frame; | 3170 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3171 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3172 | (display) | ||
| 3173 | Lisp_Object display; | ||
| 3144 | { | 3174 | { |
| 3145 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3175 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3146 | char *vendor = ServerVendor (dpyinfo->display); | 3176 | char *vendor = ServerVendor (dpyinfo->display); |
| 3147 | 3177 | ||
| 3148 | if (! vendor) vendor = ""; | 3178 | if (! vendor) vendor = ""; |
| @@ -3150,14 +3180,17 @@ DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, | |||
| 3150 | } | 3180 | } |
| 3151 | 3181 | ||
| 3152 | DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, | 3182 | DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, |
| 3153 | "Returns the version numbers of the X server in use.\n\ | 3183 | "Returns the version numbers of the X server of display DISPLAY.\n\ |
| 3154 | The value is a list of three integers: the major and minor\n\ | 3184 | The value is a list of three integers: the major and minor\n\ |
| 3155 | version numbers of the X Protocol in use, and the vendor-specific release\n\ | 3185 | version numbers of the X Protocol in use, and the vendor-specific release\n\ |
| 3156 | number. See also the variable `x-server-vendor'.") | 3186 | number. See also the function `x-server-vendor'.\n\n\ |
| 3157 | (frame) | 3187 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3158 | Lisp_Object frame; | 3188 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3189 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3190 | (display) | ||
| 3191 | Lisp_Object display; | ||
| 3159 | { | 3192 | { |
| 3160 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3193 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3161 | Display *dpy = dpyinfo->display; | 3194 | Display *dpy = dpyinfo->display; |
| 3162 | 3195 | ||
| 3163 | return Fcons (make_number (ProtocolVersion (dpy)), | 3196 | return Fcons (make_number (ProtocolVersion (dpy)), |
| @@ -3166,43 +3199,55 @@ number. See also the variable `x-server-vendor'.") | |||
| 3166 | } | 3199 | } |
| 3167 | 3200 | ||
| 3168 | DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, | 3201 | DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, |
| 3169 | "Returns the number of screens on the X server FRAME is on.") | 3202 | "Returns the number of screens on the X server of display DISPLAY.\n\ |
| 3170 | (frame) | 3203 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3171 | Lisp_Object frame; | 3204 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3205 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3206 | (display) | ||
| 3207 | Lisp_Object display; | ||
| 3172 | { | 3208 | { |
| 3173 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3209 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3174 | 3210 | ||
| 3175 | return make_number (ScreenCount (dpyinfo->display)); | 3211 | return make_number (ScreenCount (dpyinfo->display)); |
| 3176 | } | 3212 | } |
| 3177 | 3213 | ||
| 3178 | DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0, | 3214 | DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0, |
| 3179 | "Returns the height in millimeters of the X screen FRAME is on.") | 3215 | "Returns the height in millimeters of the X display DISPLAY.\n\ |
| 3180 | (frame) | 3216 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3181 | Lisp_Object frame; | 3217 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3218 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3219 | (display) | ||
| 3220 | Lisp_Object display; | ||
| 3182 | { | 3221 | { |
| 3183 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3222 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3184 | 3223 | ||
| 3185 | return make_number (HeightMMOfScreen (dpyinfo->screen)); | 3224 | return make_number (HeightMMOfScreen (dpyinfo->screen)); |
| 3186 | } | 3225 | } |
| 3187 | 3226 | ||
| 3188 | DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, | 3227 | DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, |
| 3189 | "Returns the width in millimeters of the X screen FRAME is on.") | 3228 | "Returns the width in millimeters of the X display DISPLAY.\n\ |
| 3190 | (frame) | 3229 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3191 | Lisp_Object frame; | 3230 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3231 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3232 | (display) | ||
| 3233 | Lisp_Object display; | ||
| 3192 | { | 3234 | { |
| 3193 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3235 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3194 | 3236 | ||
| 3195 | return make_number (WidthMMOfScreen (dpyinfo->screen)); | 3237 | return make_number (WidthMMOfScreen (dpyinfo->screen)); |
| 3196 | } | 3238 | } |
| 3197 | 3239 | ||
| 3198 | DEFUN ("x-display-backing-store", Fx_display_backing_store, | 3240 | DEFUN ("x-display-backing-store", Fx_display_backing_store, |
| 3199 | Sx_display_backing_store, 0, 1, 0, | 3241 | Sx_display_backing_store, 0, 1, 0, |
| 3200 | "Returns an indication of whether the X screen FRAME is on does backing store.\n\ | 3242 | "Returns an indication of whether X display DISPLAY does backing store.\n\ |
| 3201 | The value may be `always', `when-mapped', or `not-useful'.") | 3243 | The value may be `always', `when-mapped', or `not-useful'.\n\ |
| 3202 | (frame) | 3244 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3203 | Lisp_Object frame; | 3245 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3246 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3247 | (display) | ||
| 3248 | Lisp_Object display; | ||
| 3204 | { | 3249 | { |
| 3205 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3250 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3206 | 3251 | ||
| 3207 | switch (DoesBackingStore (dpyinfo->screen)) | 3252 | switch (DoesBackingStore (dpyinfo->screen)) |
| 3208 | { | 3253 | { |
| @@ -3222,13 +3267,16 @@ The value may be `always', `when-mapped', or `not-useful'.") | |||
| 3222 | 3267 | ||
| 3223 | DEFUN ("x-display-visual-class", Fx_display_visual_class, | 3268 | DEFUN ("x-display-visual-class", Fx_display_visual_class, |
| 3224 | Sx_display_visual_class, 0, 1, 0, | 3269 | Sx_display_visual_class, 0, 1, 0, |
| 3225 | "Returns the visual class of the display FRAME is on.\n\ | 3270 | "Returns the visual class of the X display DISPLAY.\n\ |
| 3226 | The value is one of the symbols `static-gray', `gray-scale',\n\ | 3271 | The value is one of the symbols `static-gray', `gray-scale',\n\ |
| 3227 | `static-color', `pseudo-color', `true-color', or `direct-color'.") | 3272 | `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\ |
| 3228 | (frame) | 3273 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3229 | Lisp_Object frame; | 3274 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3275 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3276 | (display) | ||
| 3277 | Lisp_Object display; | ||
| 3230 | { | 3278 | { |
| 3231 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3279 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3232 | 3280 | ||
| 3233 | switch (dpyinfo->visual->class) | 3281 | switch (dpyinfo->visual->class) |
| 3234 | { | 3282 | { |
| @@ -3245,11 +3293,14 @@ The value is one of the symbols `static-gray', `gray-scale',\n\ | |||
| 3245 | 3293 | ||
| 3246 | DEFUN ("x-display-save-under", Fx_display_save_under, | 3294 | DEFUN ("x-display-save-under", Fx_display_save_under, |
| 3247 | Sx_display_save_under, 0, 1, 0, | 3295 | Sx_display_save_under, 0, 1, 0, |
| 3248 | "Returns t if the X screen FRAME is on supports the save-under feature.") | 3296 | "Returns t if the X display DISPLAY supports the save-under feature.\n\ |
| 3249 | (frame) | 3297 | The optional argument DISPLAY specifies which display to ask about.\n\ |
| 3250 | Lisp_Object frame; | 3298 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 3299 | If omitted or nil, that stands for the selected frame's display.") | ||
| 3300 | (display) | ||
| 3301 | Lisp_Object display; | ||
| 3251 | { | 3302 | { |
| 3252 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 3303 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 3253 | 3304 | ||
| 3254 | if (DoesSaveUnders (dpyinfo->screen) == True) | 3305 | if (DoesSaveUnders (dpyinfo->screen) == True) |
| 3255 | return Qt; | 3306 | return Qt; |
| @@ -4265,15 +4316,18 @@ struct x_display_info * | |||
| 4265 | x_display_info_for_name (name) | 4316 | x_display_info_for_name (name) |
| 4266 | Lisp_Object name; | 4317 | Lisp_Object name; |
| 4267 | { | 4318 | { |
| 4319 | Lisp_Object names; | ||
| 4268 | struct x_display_info *dpyinfo; | 4320 | struct x_display_info *dpyinfo; |
| 4269 | 4321 | ||
| 4270 | CHECK_STRING (name, 0); | 4322 | CHECK_STRING (name, 0); |
| 4271 | 4323 | ||
| 4272 | for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) | 4324 | for (dpyinfo = x_display_list, names = x_display_name_list; |
| 4325 | dpyinfo; | ||
| 4326 | dpyinfo = dpyinfo->next, names = XCONS (names)->cdr) | ||
| 4273 | { | 4327 | { |
| 4274 | Lisp_Object tem; | 4328 | Lisp_Object tem; |
| 4275 | tem = Fstring_equal (dpyinfo->name, name); | 4329 | tem = Fstring_equal (XCONS (XCONS (names)->car)->car, name); |
| 4276 | if (!NILP (name)) | 4330 | if (!NILP (tem)) |
| 4277 | return dpyinfo; | 4331 | return dpyinfo; |
| 4278 | } | 4332 | } |
| 4279 | 4333 | ||
| @@ -4282,6 +4336,9 @@ x_display_info_for_name (name) | |||
| 4282 | dpyinfo = x_term_init (name, (unsigned char *)0, | 4336 | dpyinfo = x_term_init (name, (unsigned char *)0, |
| 4283 | XSTRING (Vx_resource_name)->data); | 4337 | XSTRING (Vx_resource_name)->data); |
| 4284 | 4338 | ||
| 4339 | if (dpyinfo == 0) | ||
| 4340 | error ("X server %s not responding", XSTRING (name)->data); | ||
| 4341 | |||
| 4285 | x_in_use = 1; | 4342 | x_in_use = 1; |
| 4286 | XSETFASTINT (Vwindow_system_version, 11); | 4343 | XSETFASTINT (Vwindow_system_version, 11); |
| 4287 | 4344 | ||
| @@ -4289,11 +4346,13 @@ x_display_info_for_name (name) | |||
| 4289 | } | 4346 | } |
| 4290 | 4347 | ||
| 4291 | DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, | 4348 | DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, |
| 4292 | 1, 2, 0, "Open a connection to an X server.\n\ | 4349 | 1, 3, 0, "Open a connection to an X server.\n\ |
| 4293 | DISPLAY is the name of the display to connect to.\n\ | 4350 | DISPLAY is the name of the display to connect to.\n\ |
| 4294 | Optional second arg XRM_STRING is a string of resources in xrdb format.") | 4351 | Optional second arg XRM-STRING is a string of resources in xrdb format.\n\ |
| 4295 | (display, xrm_string) | 4352 | If the optional third arg MUST-SUCCEED is non-nil,\n\ |
| 4296 | Lisp_Object display, xrm_string; | 4353 | terminate Emacs if we can't open the connection.") |
| 4354 | (display, xrm_string, must_succeed) | ||
| 4355 | Lisp_Object display, xrm_string, must_succeed; | ||
| 4297 | { | 4356 | { |
| 4298 | unsigned int n_planes; | 4357 | unsigned int n_planes; |
| 4299 | unsigned char *xrm_option; | 4358 | unsigned char *xrm_option; |
| @@ -4315,54 +4374,83 @@ Optional second arg XRM_STRING is a string of resources in xrdb format.") | |||
| 4315 | dpyinfo = x_term_init (display, xrm_option, | 4374 | dpyinfo = x_term_init (display, xrm_option, |
| 4316 | XSTRING (Vx_resource_name)->data); | 4375 | XSTRING (Vx_resource_name)->data); |
| 4317 | 4376 | ||
| 4377 | if (dpyinfo == 0) | ||
| 4378 | { | ||
| 4379 | if (!NILP (must_succeed)) | ||
| 4380 | fatal ("X server %s not responding.\n\ | ||
| 4381 | Check the DISPLAY environment variable or use \"-d\"\n", | ||
| 4382 | XSTRING (display)->data); | ||
| 4383 | else | ||
| 4384 | error ("X server %s not responding", XSTRING (display)->data); | ||
| 4385 | } | ||
| 4386 | |||
| 4318 | x_in_use = 1; | 4387 | x_in_use = 1; |
| 4319 | 4388 | ||
| 4320 | XSETFASTINT (Vwindow_system_version, 11); | 4389 | XSETFASTINT (Vwindow_system_version, 11); |
| 4321 | return Qnil; | 4390 | return Qnil; |
| 4322 | } | 4391 | } |
| 4323 | 4392 | ||
| 4324 | DEFUN ("x-close-current-connection", Fx_close_current_connection, | 4393 | DEFUN ("x-close-connection", Fx_close_connection, |
| 4325 | Sx_close_current_connection, | 4394 | Sx_close_connection, 1, 1, 0, |
| 4326 | 1, 1, 0, "Close the connection to frame FRAME's X server.") | 4395 | "Close the connection to DISPLAY's X server.\n\ |
| 4327 | (frame) | 4396 | For DISPLAY, specify either a frame or a display name (a string).\n\ |
| 4328 | Lisp_Object frame; | 4397 | If DISPLAY is nil, that stands for the selected frame's display.") |
| 4398 | (display) | ||
| 4399 | Lisp_Object display; | ||
| 4329 | { | 4400 | { |
| 4330 | Display *dpy; | 4401 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 4331 | /* Note: If we're going to call check_x here, then the fatal error | 4402 | struct x_display_info *tail; |
| 4332 | can't happen. For the moment, this check is just for safety, | 4403 | int i; |
| 4333 | so a user won't try out the function and get a crash. If it's | ||
| 4334 | really intended only to be called when killing emacs, then there's | ||
| 4335 | no reason for it to have a lisp interface at all. */ | ||
| 4336 | check_x (); | ||
| 4337 | CHECK_LIVE_FRAME (frame, 0); | ||
| 4338 | dpy = FRAME_X_DISPLAY (XFRAME (frame)); | ||
| 4339 | 4404 | ||
| 4340 | /* This is ONLY used when killing emacs; For switching displays | 4405 | if (dpyinfo->reference_count > 0) |
| 4341 | we'll have to take care of setting CloseDownMode elsewhere. */ | 4406 | error ("Display still has frames on it"); |
| 4342 | 4407 | ||
| 4343 | if (dpy) | 4408 | BLOCK_INPUT; |
| 4409 | /* Free the fonts in the font table. */ | ||
| 4410 | for (i = 0; i < dpyinfo->n_fonts; i++) | ||
| 4344 | { | 4411 | { |
| 4345 | BLOCK_INPUT; | 4412 | if (dpyinfo->font_table[i].name) |
| 4346 | XSetCloseDownMode (dpy, DestroyAll); | 4413 | free (dpyinfo->font_table[i].name); |
| 4347 | XCloseDisplay (dpy); | 4414 | /* Don't free the full_name string; |
| 4348 | x_in_use = 0; | 4415 | it is always shared with something else. */ |
| 4416 | XFreeFont (dpyinfo->display, dpyinfo->font_table[i].font); | ||
| 4349 | } | 4417 | } |
| 4350 | else | 4418 | x_destroy_all_bitmaps (dpyinfo); |
| 4351 | error ("No current X display connection to close"); | 4419 | XSetCloseDownMode (dpyinfo->display, DestroyAll); |
| 4420 | XCloseDisplay (dpyinfo->display); | ||
| 4421 | |||
| 4422 | x_delete_display (dpyinfo); | ||
| 4423 | UNBLOCK_INPUT; | ||
| 4352 | 4424 | ||
| 4353 | return Qnil; | 4425 | return Qnil; |
| 4354 | } | 4426 | } |
| 4355 | 4427 | ||
| 4356 | DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, | 4428 | DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, |
| 4357 | 1, 2, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\ | 4429 | "Return the list of display names that Emacs has connections to.") |
| 4430 | () | ||
| 4431 | { | ||
| 4432 | Lisp_Object tail, result; | ||
| 4433 | |||
| 4434 | result = Qnil; | ||
| 4435 | for (tail = x_display_name_list; ! NILP (tail); tail = XCONS (tail)->cdr) | ||
| 4436 | result = Fcons (XCONS (XCONS (tail)->car)->car, result); | ||
| 4437 | |||
| 4438 | return result; | ||
| 4439 | } | ||
| 4440 | |||
| 4441 | DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0, | ||
| 4442 | "If ON is non-nil, report X errors as soon as the erring request is made.\n\ | ||
| 4358 | If ON is nil, allow buffering of requests.\n\ | 4443 | If ON is nil, allow buffering of requests.\n\ |
| 4359 | Turning on synchronization prohibits the Xlib routines from buffering\n\ | 4444 | Turning on synchronization prohibits the Xlib routines from buffering\n\ |
| 4360 | requests and seriously degrades performance, but makes debugging much\n\ | 4445 | requests and seriously degrades performance, but makes debugging much\n\ |
| 4361 | easier.") | 4446 | easier. |
| 4362 | (on, frame) | 4447 | The optional second argument DISPLAY specifies which display to act on.\n\ |
| 4363 | Lisp_Object frame, on; | 4448 | DISPLAY should be either a frame or a display name (a string).\n\ |
| 4449 | If DISPLAY is omitted or nil, that stands for the selected frame's display.") | ||
| 4450 | (on, display) | ||
| 4451 | Lisp_Object display, on; | ||
| 4364 | { | 4452 | { |
| 4365 | struct x_display_info *dpyinfo = check_x_display_info (frame); | 4453 | struct x_display_info *dpyinfo = check_x_display_info (display); |
| 4366 | 4454 | ||
| 4367 | XSynchronize (dpyinfo->display, !EQ (on, Qnil)); | 4455 | XSynchronize (dpyinfo->display, !EQ (on, Qnil)); |
| 4368 | 4456 | ||
| @@ -4554,7 +4642,8 @@ or when you set the mouse color."); | |||
| 4554 | defsubr (&Sx_horizontal_line); | 4642 | defsubr (&Sx_horizontal_line); |
| 4555 | #endif | 4643 | #endif |
| 4556 | defsubr (&Sx_open_connection); | 4644 | defsubr (&Sx_open_connection); |
| 4557 | defsubr (&Sx_close_current_connection); | 4645 | defsubr (&Sx_close_connection); |
| 4646 | defsubr (&Sx_display_list); | ||
| 4558 | defsubr (&Sx_synchronize); | 4647 | defsubr (&Sx_synchronize); |
| 4559 | } | 4648 | } |
| 4560 | 4649 | ||