comparison src/xfns.c @ 8782:51241477cfc5

Delete X11 conditionals. (defined_color, x_decode_color, x_set_foreground_color) (x_set_background_color, x_set_mouse_color, x_set_cursor_color) (x_set_border_color, x_set_border_pixel, Fx_create_frame) (Fx_open_connection, Fx_close_current_connection, syms_of_xfns): Delete X10 code. (Fx_get_default, Fx_get_resource, Fx_rubber_band) (Fx_store_cut_buffer, Fx_get_cut_buffer): Delete X10 definitions.
author Richard M. Stallman <rms@gnu.org>
date Fri, 16 Sep 1994 09:23:48 +0000
parents ac49ab734a12
children c4b7fda8f611
comparison
equal deleted inserted replaced
8781:98741404d3e0 8782:51241477cfc5
84 #endif /* USE_X_TOOLKIT */ 84 #endif /* USE_X_TOOLKIT */
85 85
86 #define min(a,b) ((a) < (b) ? (a) : (b)) 86 #define min(a,b) ((a) < (b) ? (a) : (b))
87 #define max(a,b) ((a) > (b) ? (a) : (b)) 87 #define max(a,b) ((a) > (b) ? (a) : (b))
88 88
89 #ifdef HAVE_X11
90 /* X Resource data base */ 89 /* X Resource data base */
91 static XrmDatabase xrdb; 90 static XrmDatabase xrdb;
92 91
93 /* The class of this X application. */ 92 /* The class of this X application. */
94 #define EMACS_CLASS "Emacs" 93 #define EMACS_CLASS "Emacs"
153 extern Atom Xatom_wm_configure_denied; /* When our config request is denied */ 152 extern Atom Xatom_wm_configure_denied; /* When our config request is denied */
154 extern Atom Xatom_wm_window_moved; /* When the WM moves us. */ 153 extern Atom Xatom_wm_window_moved; /* When the WM moves us. */
155 154
156 /* EditRes protocol */ 155 /* EditRes protocol */
157 extern Atom Xatom_editres_name; 156 extern Atom Xatom_editres_name;
158
159 #else /* X10 */
160
161 /* Default size of an Emacs window. */
162 static char *default_window = "=80x24+0+0";
163
164 #define MAXICID 80
165 char iconidentity[MAXICID];
166 #define ICONTAG "emacs@"
167 char minibuffer_iconidentity[MAXICID];
168 #define MINIBUFFER_ICONTAG "minibuffer@"
169
170 #endif /* X10 */
171 157
172 /* The last 23 bits of the timestamp of the last mouse button event. */ 158 /* The last 23 bits of the timestamp of the last mouse button event. */
173 Time mouse_timestamp; 159 Time mouse_timestamp;
174 160
175 /* Evaluate this expression to rebuild the section of syms_of_xfns 161 /* Evaluate this expression to rebuild the section of syms_of_xfns
678 { 664 {
679 register int foo; 665 register int foo;
680 Colormap screen_colormap; 666 Colormap screen_colormap;
681 667
682 BLOCK_INPUT; 668 BLOCK_INPUT;
683 #ifdef HAVE_X11
684 screen_colormap 669 screen_colormap
685 = DefaultColormap (x_current_display, XDefaultScreen (x_current_display)); 670 = DefaultColormap (x_current_display, XDefaultScreen (x_current_display));
686 671
687 foo = XParseColor (x_current_display, screen_colormap, color, color_def); 672 foo = XParseColor (x_current_display, screen_colormap, color, color_def);
688 if (foo && alloc) 673 if (foo && alloc)
689 foo = XAllocColor (x_current_display, screen_colormap, color_def); 674 foo = XAllocColor (x_current_display, screen_colormap, color_def);
690 #else
691 foo = XParseColor (color, color_def);
692 if (foo && alloc)
693 foo = XGetHardwareColor (color_def);
694 #endif /* not HAVE_X11 */
695 UNBLOCK_INPUT; 675 UNBLOCK_INPUT;
696 676
697 if (foo) 677 if (foo)
698 return 1; 678 return 1;
699 else 679 else
717 if (strcmp (XSTRING (arg)->data, "black") == 0) 697 if (strcmp (XSTRING (arg)->data, "black") == 0)
718 return BLACK_PIX_DEFAULT; 698 return BLACK_PIX_DEFAULT;
719 else if (strcmp (XSTRING (arg)->data, "white") == 0) 699 else if (strcmp (XSTRING (arg)->data, "white") == 0)
720 return WHITE_PIX_DEFAULT; 700 return WHITE_PIX_DEFAULT;
721 701
722 #ifdef HAVE_X11
723 if (x_screen_planes == 1) 702 if (x_screen_planes == 1)
724 return def; 703 return def;
725 #else
726 if (DISPLAY_CELLS == 1)
727 return def;
728 #endif
729 704
730 if (defined_color (XSTRING (arg)->data, &cdef, 1)) 705 if (defined_color (XSTRING (arg)->data, &cdef, 1))
731 return cdef.pixel; 706 return cdef.pixel;
732 else 707 else
733 Fsignal (Qundefined_color, Fcons (arg, Qnil)); 708 Fsignal (Qundefined_color, Fcons (arg, Qnil));
747 Lisp_Object arg, oldval; 722 Lisp_Object arg, oldval;
748 { 723 {
749 f->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); 724 f->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT);
750 if (FRAME_X_WINDOW (f) != 0) 725 if (FRAME_X_WINDOW (f) != 0)
751 { 726 {
752 #ifdef HAVE_X11
753 BLOCK_INPUT; 727 BLOCK_INPUT;
754 XSetForeground (x_current_display, f->display.x->normal_gc, 728 XSetForeground (x_current_display, f->display.x->normal_gc,
755 f->display.x->foreground_pixel); 729 f->display.x->foreground_pixel);
756 XSetBackground (x_current_display, f->display.x->reverse_gc, 730 XSetBackground (x_current_display, f->display.x->reverse_gc,
757 f->display.x->foreground_pixel); 731 f->display.x->foreground_pixel);
758 UNBLOCK_INPUT; 732 UNBLOCK_INPUT;
759 #endif /* HAVE_X11 */
760 recompute_basic_faces (f); 733 recompute_basic_faces (f);
761 if (FRAME_VISIBLE_P (f)) 734 if (FRAME_VISIBLE_P (f))
762 redraw_frame (f); 735 redraw_frame (f);
763 } 736 }
764 } 737 }
774 f->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT); 747 f->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT);
775 748
776 if (FRAME_X_WINDOW (f) != 0) 749 if (FRAME_X_WINDOW (f) != 0)
777 { 750 {
778 BLOCK_INPUT; 751 BLOCK_INPUT;
779 #ifdef HAVE_X11
780 /* The main frame area. */ 752 /* The main frame area. */
781 XSetBackground (x_current_display, f->display.x->normal_gc, 753 XSetBackground (x_current_display, f->display.x->normal_gc,
782 f->display.x->background_pixel); 754 f->display.x->background_pixel);
783 XSetForeground (x_current_display, f->display.x->reverse_gc, 755 XSetForeground (x_current_display, f->display.x->reverse_gc,
784 f->display.x->background_pixel); 756 f->display.x->background_pixel);
792 bar = XSCROLL_BAR (bar)->next) 764 bar = XSCROLL_BAR (bar)->next)
793 XSetWindowBackground (x_current_display, 765 XSetWindowBackground (x_current_display,
794 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), 766 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
795 f->display.x->background_pixel); 767 f->display.x->background_pixel);
796 } 768 }
797 #else
798 temp = XMakeTile (f->display.x->background_pixel);
799 XChangeBackground (FRAME_X_WINDOW (f), temp);
800 XFreePixmap (temp);
801 #endif /* not HAVE_X11 */
802 UNBLOCK_INPUT; 769 UNBLOCK_INPUT;
803 770
804 recompute_basic_faces (f); 771 recompute_basic_faces (f);
805 772
806 if (FRAME_VISIBLE_P (f)) 773 if (FRAME_VISIBLE_P (f))
823 if (mask_color == f->display.x->mouse_pixel 790 if (mask_color == f->display.x->mouse_pixel
824 && mask_color == f->display.x->background_pixel) 791 && mask_color == f->display.x->background_pixel)
825 f->display.x->mouse_pixel = f->display.x->foreground_pixel; 792 f->display.x->mouse_pixel = f->display.x->foreground_pixel;
826 793
827 BLOCK_INPUT; 794 BLOCK_INPUT;
828 #ifdef HAVE_X11
829 795
830 /* It's not okay to crash if the user selects a screwy cursor. */ 796 /* It's not okay to crash if the user selects a screwy cursor. */
831 x_catch_errors (); 797 x_catch_errors ();
832 798
833 if (!EQ (Qnil, Vx_pointer_shape)) 799 if (!EQ (Qnil, Vx_pointer_shape))
893 XRecolorCursor (x_current_display, mode_cursor, 859 XRecolorCursor (x_current_display, mode_cursor,
894 &fore_color, &back_color); 860 &fore_color, &back_color);
895 XRecolorCursor (x_current_display, cross_cursor, 861 XRecolorCursor (x_current_display, cross_cursor,
896 &fore_color, &back_color); 862 &fore_color, &back_color);
897 } 863 }
898 #else /* X10 */
899 cursor = XCreateCursor (16, 16, MouseCursor, MouseMask,
900 0, 0,
901 f->display.x->mouse_pixel,
902 f->display.x->background_pixel,
903 GXcopy);
904 #endif /* X10 */
905 864
906 if (FRAME_X_WINDOW (f) != 0) 865 if (FRAME_X_WINDOW (f) != 0)
907 { 866 {
908 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), cursor); 867 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), cursor);
909 } 868 }
910 869
911 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0) 870 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0)
912 XFreeCursor (XDISPLAY f->display.x->text_cursor); 871 XFreeCursor (XDISPLAY f->display.x->text_cursor);
913 f->display.x->text_cursor = cursor; 872 f->display.x->text_cursor = cursor;
914 #ifdef HAVE_X11 873
915 if (nontext_cursor != f->display.x->nontext_cursor 874 if (nontext_cursor != f->display.x->nontext_cursor
916 && f->display.x->nontext_cursor != 0) 875 && f->display.x->nontext_cursor != 0)
917 XFreeCursor (XDISPLAY f->display.x->nontext_cursor); 876 XFreeCursor (XDISPLAY f->display.x->nontext_cursor);
918 f->display.x->nontext_cursor = nontext_cursor; 877 f->display.x->nontext_cursor = nontext_cursor;
919 878
923 f->display.x->modeline_cursor = mode_cursor; 882 f->display.x->modeline_cursor = mode_cursor;
924 if (cross_cursor != f->display.x->cross_cursor 883 if (cross_cursor != f->display.x->cross_cursor
925 && f->display.x->cross_cursor != 0) 884 && f->display.x->cross_cursor != 0)
926 XFreeCursor (XDISPLAY f->display.x->cross_cursor); 885 XFreeCursor (XDISPLAY f->display.x->cross_cursor);
927 f->display.x->cross_cursor = cross_cursor; 886 f->display.x->cross_cursor = cross_cursor;
928 #endif /* HAVE_X11 */
929 887
930 XFlushQueue (); 888 XFlushQueue ();
931 UNBLOCK_INPUT; 889 UNBLOCK_INPUT;
932 } 890 }
933 891
953 } 911 }
954 f->display.x->cursor_foreground_pixel = fore_pixel; 912 f->display.x->cursor_foreground_pixel = fore_pixel;
955 913
956 if (FRAME_X_WINDOW (f) != 0) 914 if (FRAME_X_WINDOW (f) != 0)
957 { 915 {
958 #ifdef HAVE_X11
959 BLOCK_INPUT; 916 BLOCK_INPUT;
960 XSetBackground (x_current_display, f->display.x->cursor_gc, 917 XSetBackground (x_current_display, f->display.x->cursor_gc,
961 f->display.x->cursor_pixel); 918 f->display.x->cursor_pixel);
962 XSetForeground (x_current_display, f->display.x->cursor_gc, 919 XSetForeground (x_current_display, f->display.x->cursor_gc,
963 fore_pixel); 920 fore_pixel);
964 UNBLOCK_INPUT; 921 UNBLOCK_INPUT;
965 #endif /* HAVE_X11 */
966 922
967 if (FRAME_VISIBLE_P (f)) 923 if (FRAME_VISIBLE_P (f))
968 { 924 {
969 x_display_cursor (f, 0); 925 x_display_cursor (f, 0);
970 x_display_cursor (f, 1); 926 x_display_cursor (f, 1);
992 int pix; 948 int pix;
993 949
994 CHECK_STRING (arg, 0); 950 CHECK_STRING (arg, 0);
995 str = XSTRING (arg)->data; 951 str = XSTRING (arg)->data;
996 952
997 #ifndef HAVE_X11
998 if (!strcmp (str, "grey") || !strcmp (str, "Grey")
999 || !strcmp (str, "gray") || !strcmp (str, "Gray"))
1000 pix = -1;
1001 else
1002 #endif /* X10 */
1003
1004 pix = x_decode_color (arg, BLACK_PIX_DEFAULT); 953 pix = x_decode_color (arg, BLACK_PIX_DEFAULT);
1005 954
1006 x_set_border_pixel (f, pix); 955 x_set_border_pixel (f, pix);
1007 } 956 }
1008 957
1020 { 969 {
1021 Pixmap temp; 970 Pixmap temp;
1022 int mask; 971 int mask;
1023 972
1024 BLOCK_INPUT; 973 BLOCK_INPUT;
1025 #ifdef HAVE_X11
1026 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (f), 974 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (f),
1027 pix); 975 pix);
1028 #else
1029 if (pix < 0)
1030 temp = XMakePixmap ((Bitmap) XStoreBitmap (gray_width, gray_height,
1031 gray_bits),
1032 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT);
1033 else
1034 temp = XMakeTile (pix);
1035 XChangeBorder (FRAME_X_WINDOW (f), temp);
1036 XFreePixmap (XDISPLAY temp);
1037 #endif /* not HAVE_X11 */
1038 UNBLOCK_INPUT; 976 UNBLOCK_INPUT;
1039 977
1040 if (FRAME_VISIBLE_P (f)) 978 if (FRAME_VISIBLE_P (f))
1041 redraw_frame (f); 979 redraw_frame (f);
1042 } 980 }
1384 } 1322 }
1385 } 1323 }
1386 1324
1387 /* Subroutines of creating an X frame. */ 1325 /* Subroutines of creating an X frame. */
1388 1326
1389 #ifdef HAVE_X11
1390
1391 /* Make sure that Vx_resource_name is set to a reasonable value. */ 1327 /* Make sure that Vx_resource_name is set to a reasonable value. */
1392 static void 1328 static void
1393 validate_x_resource_name () 1329 validate_x_resource_name ()
1394 { 1330 {
1395 if (STRINGP (Vx_resource_name)) 1331 if (STRINGP (Vx_resource_name))
1522 attribute); 1458 attribute);
1523 sprintf (class_key, "%s.%s", EMACS_CLASS, class); 1459 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
1524 1460
1525 return x_get_string_resource (xrdb, name_key, class_key); 1461 return x_get_string_resource (xrdb, name_key, class_key);
1526 } 1462 }
1527
1528 #else /* X10 */
1529
1530 DEFUN ("x-get-default", Fx_get_default, Sx_get_default, 1, 1, 0,
1531 "Get X default ATTRIBUTE from the system, or nil if no default.\n\
1532 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\
1533 The defaults are specified in the file `~/.Xdefaults'.")
1534 (arg)
1535 Lisp_Object arg;
1536 {
1537 register unsigned char *value;
1538
1539 CHECK_STRING (arg, 1);
1540
1541 value = (unsigned char *) XGetDefault (XDISPLAY
1542 XSTRING (Vinvocation_name)->data,
1543 XSTRING (arg)->data);
1544 if (value == 0)
1545 /* Try reversing last two args, in case this is the buggy version of X. */
1546 value = (unsigned char *) XGetDefault (XDISPLAY
1547 XSTRING (arg)->data,
1548 XSTRING (Vinvocation_name)->data);
1549 if (value != 0)
1550 return build_string (value);
1551 else
1552 return (Qnil);
1553 }
1554
1555 #define Fx_get_resource(attribute, class, component, subclass) \
1556 Fx_get_default (attribute)
1557
1558 #endif /* X10 */
1559 1463
1560 /* Types we might convert a resource string into. */ 1464 /* Types we might convert a resource string into. */
1561 enum resource_types 1465 enum resource_types
1562 { 1466 {
1563 number, boolean, string, symbol 1467 number, boolean, string, symbol
1717 result = Fcons (Fcons (Qheight, make_number (height)), result); 1621 result = Fcons (Fcons (Qheight, make_number (height)), result);
1718 1622
1719 return result; 1623 return result;
1720 } 1624 }
1721 1625
1722 #ifdef HAVE_X11
1723 /* Calculate the desired size and position of this window, 1626 /* Calculate the desired size and position of this window,
1724 and return the flags saying which aspects were specified. 1627 and return the flags saying which aspects were specified.
1725 1628
1726 This function does not make the coordinates positive. */ 1629 This function does not make the coordinates positive. */
1727 1630
2245 f->display.x->background_pixel, 2148 f->display.x->background_pixel,
2246 DefaultDepth (x_current_display, XDefaultScreen (x_current_display)))); 2149 DefaultDepth (x_current_display, XDefaultScreen (x_current_display))));
2247 2150
2248 UNBLOCK_INPUT; 2151 UNBLOCK_INPUT;
2249 } 2152 }
2250 #endif /* HAVE_X11 */
2251 2153
2252 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 2154 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
2253 1, 1, 0, 2155 1, 1, 0,
2254 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\ 2156 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\
2255 Return an Emacs frame object representing the X window.\n\ 2157 Return an Emacs frame object representing the X window.\n\
2259 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\ 2161 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
2260 be shared by the new frame.") 2162 be shared by the new frame.")
2261 (parms) 2163 (parms)
2262 Lisp_Object parms; 2164 Lisp_Object parms;
2263 { 2165 {
2264 #ifdef HAVE_X11
2265 struct frame *f; 2166 struct frame *f;
2266 Lisp_Object frame, tem; 2167 Lisp_Object frame, tem;
2267 Lisp_Object name; 2168 Lisp_Object name;
2268 int minibuffer_only = 0; 2169 int minibuffer_only = 0;
2269 long window_prompting = 0; 2170 long window_prompting = 0;
2469 /* Must have been Qnil. */ 2370 /* Must have been Qnil. */
2470 ; 2371 ;
2471 } 2372 }
2472 2373
2473 return unbind_to (count, frame); 2374 return unbind_to (count, frame);
2474 #else /* X10 */
2475 struct frame *f;
2476 Lisp_Object frame, tem;
2477 Lisp_Object name;
2478 int pixelwidth, pixelheight;
2479 Cursor cursor;
2480 int height, width;
2481 Window parent;
2482 Pixmap temp;
2483 int minibuffer_only = 0;
2484 Lisp_Object vscroll, hscroll;
2485
2486 if (x_current_display == 0)
2487 error ("X windows are not in use or not initialized");
2488
2489 name = Fassq (Qname, parms);
2490
2491 tem = x_get_arg (parms, Qminibuffer, 0, 0, symbol);
2492 if (EQ (tem, Qnone))
2493 f = make_frame_without_minibuffer (Qnil);
2494 else if (EQ (tem, Qonly))
2495 {
2496 f = make_minibuffer_frame ();
2497 minibuffer_only = 1;
2498 }
2499 else if (EQ (tem, Qnil) || EQ (tem, Qunbound))
2500 f = make_frame (1);
2501 else
2502 f = make_frame_without_minibuffer (tem);
2503
2504 parent = ROOT_WINDOW;
2505
2506 XSET (frame, Lisp_Frame, f);
2507 f->output_method = output_x_window;
2508 f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display));
2509 bzero (f->display.x, sizeof (struct x_display));
2510
2511 /* Some temporary default values for height and width. */
2512 width = 80;
2513 height = 40;
2514 f->display.x->left_pos = -1;
2515 f->display.x->top_pos = -1;
2516
2517 /* Give the frame a default name (which may be overridden with PARMS). */
2518
2519 strncpy (iconidentity, ICONTAG, MAXICID);
2520 if (gethostname (&iconidentity[sizeof (ICONTAG) - 1],
2521 (MAXICID - 1) - sizeof (ICONTAG)))
2522 iconidentity[sizeof (ICONTAG) - 2] = '\0';
2523 f->name = build_string (iconidentity);
2524
2525 /* Extract some window parameters from the supplied values.
2526 These are the parameters that affect window geometry. */
2527
2528 tem = x_get_arg (parms, Qfont, "BodyFont", 0, string);
2529 if (EQ (tem, Qunbound))
2530 tem = build_string ("9x15");
2531 x_set_font (f, tem, Qnil);
2532 x_default_parameter (f, parms, Qborder_color,
2533 build_string ("black"), "Border", 0, string);
2534 x_default_parameter (f, parms, Qbackground_color,
2535 build_string ("white"), "Background", 0, string);
2536 x_default_parameter (f, parms, Qforeground_color,
2537 build_string ("black"), "Foreground", 0, string);
2538 x_default_parameter (f, parms, Qmouse_color,
2539 build_string ("black"), "Mouse", 0, string);
2540 x_default_parameter (f, parms, Qcursor_color,
2541 build_string ("black"), "Cursor", 0, string);
2542 x_default_parameter (f, parms, Qborder_width,
2543 make_number (2), "BorderWidth", 0, number);
2544 x_default_parameter (f, parms, Qinternal_border_width,
2545 make_number (4), "InternalBorderWidth", 0, number);
2546 x_default_parameter (f, parms, Qauto_raise,
2547 Qnil, "AutoRaise", 0, boolean);
2548
2549 hscroll = EQ (x_get_arg (parms, Qhorizontal_scroll_bar, 0, 0, boolean), Qt);
2550 vscroll = EQ (x_get_arg (parms, Qvertical_scroll_bar, 0, 0, boolean), Qt);
2551
2552 if (f->display.x->internal_border_width < 0)
2553 f->display.x->internal_border_width = 0;
2554
2555 tem = x_get_arg (parms, Qwindow_id, 0, 0, number);
2556 if (!EQ (tem, Qunbound))
2557 {
2558 WINDOWINFO_TYPE wininfo;
2559 int nchildren;
2560 Window *children, root;
2561
2562 CHECK_NUMBER (tem, 0);
2563 FRAME_X_WINDOW (f) = (Window) XINT (tem);
2564
2565 BLOCK_INPUT;
2566 XGetWindowInfo (FRAME_X_WINDOW (f), &wininfo);
2567 XQueryTree (FRAME_X_WINDOW (f), &parent, &nchildren, &children);
2568 xfree (children);
2569 UNBLOCK_INPUT;
2570
2571 height = PIXEL_TO_CHAR_HEIGHT (f, wininfo.height);
2572 width = PIXEL_TO_CHAR_WIDTH (f, wininfo.width);
2573 f->display.x->left_pos = wininfo.x;
2574 f->display.x->top_pos = wininfo.y;
2575 FRAME_SET_VISIBILITY (f, wininfo.mapped != 0);
2576 f->display.x->border_width = wininfo.bdrwidth;
2577 f->display.x->parent_desc = parent;
2578 }
2579 else
2580 {
2581 tem = x_get_arg (parms, Qparent_id, 0, 0, number);
2582 if (!EQ (tem, Qunbound))
2583 {
2584 CHECK_NUMBER (tem, 0);
2585 parent = (Window) XINT (tem);
2586 }
2587 f->display.x->parent_desc = parent;
2588 tem = x_get_arg (parms, Qheight, 0, 0, number);
2589 if (EQ (tem, Qunbound))
2590 {
2591 tem = x_get_arg (parms, Qwidth, 0, 0, number);
2592 if (EQ (tem, Qunbound))
2593 {
2594 tem = x_get_arg (parms, Qtop, 0, 0, number);
2595 if (EQ (tem, Qunbound))
2596 tem = x_get_arg (parms, Qleft, 0, 0, number);
2597 }
2598 }
2599 /* Now TEM is Qunbound if no edge or size was specified.
2600 In that case, we must do rubber-banding. */
2601 if (EQ (tem, Qunbound))
2602 {
2603 tem = x_get_arg (parms, Qgeometry, 0, 0, number);
2604 x_rubber_band (f,
2605 &f->display.x->left_pos, &f->display.x->top_pos,
2606 &width, &height,
2607 (XTYPE (tem) == Lisp_String
2608 ? (char *) XSTRING (tem)->data : ""),
2609 XSTRING (f->name)->data,
2610 !NILP (hscroll), !NILP (vscroll));
2611 }
2612 else
2613 {
2614 /* Here if at least one edge or size was specified.
2615 Demand that they all were specified, and use them. */
2616 tem = x_get_arg (parms, Qheight, 0, 0, number);
2617 if (EQ (tem, Qunbound))
2618 error ("Height not specified");
2619 CHECK_NUMBER (tem, 0);
2620 height = XINT (tem);
2621
2622 tem = x_get_arg (parms, Qwidth, 0, 0, number);
2623 if (EQ (tem, Qunbound))
2624 error ("Width not specified");
2625 CHECK_NUMBER (tem, 0);
2626 width = XINT (tem);
2627
2628 tem = x_get_arg (parms, Qtop, 0, 0, number);
2629 if (EQ (tem, Qunbound))
2630 error ("Top position not specified");
2631 CHECK_NUMBER (tem, 0);
2632 f->display.x->left_pos = XINT (tem);
2633
2634 tem = x_get_arg (parms, Qleft, 0, 0, number);
2635 if (EQ (tem, Qunbound))
2636 error ("Left position not specified");
2637 CHECK_NUMBER (tem, 0);
2638 f->display.x->top_pos = XINT (tem);
2639 }
2640
2641 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, width);
2642 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, height);
2643
2644 BLOCK_INPUT;
2645 FRAME_X_WINDOW (f)
2646 = XCreateWindow (parent,
2647 f->display.x->left_pos, /* Absolute horizontal offset */
2648 f->display.x->top_pos, /* Absolute Vertical offset */
2649 pixelwidth, pixelheight,
2650 f->display.x->border_width,
2651 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT);
2652 UNBLOCK_INPUT;
2653 if (FRAME_X_WINDOW (f) == 0)
2654 error ("Unable to create window.");
2655 }
2656
2657 /* Install the now determined height and width
2658 in the windows and in phys_lines and desired_lines. */
2659 change_frame_size (f, height, width, 1, 0);
2660 XSelectInput (FRAME_X_WINDOW (f), KeyPressed | ExposeWindow
2661 | ButtonPressed | ButtonReleased | ExposeRegion | ExposeCopy
2662 | EnterWindow | LeaveWindow | UnmapWindow );
2663 x_set_resize_hint (f);
2664
2665 /* Tell the server the window's default name. */
2666 XStoreName (XDISPLAY FRAME_X_WINDOW (f), XSTRING (f->name)->data);
2667
2668 /* Now override the defaults with all the rest of the specified
2669 parms. */
2670 tem = x_get_arg (parms, Qunsplittable, 0, 0, boolean);
2671 f->no_split = minibuffer_only || EQ (tem, Qt);
2672
2673 /* Do not create an icon window if the caller says not to */
2674 if (!EQ (x_get_arg (parms, Qsuppress_icon, 0, 0, boolean), Qt)
2675 || f->display.x->parent_desc != ROOT_WINDOW)
2676 {
2677 x_text_icon (f, iconidentity);
2678 x_default_parameter (f, parms, Qicon_type, Qnil,
2679 "BitmapIcon", 0, symbol);
2680 }
2681
2682 /* Tell the X server the previously set values of the
2683 background, border and mouse colors; also create the mouse cursor. */
2684 BLOCK_INPUT;
2685 temp = XMakeTile (f->display.x->background_pixel);
2686 XChangeBackground (FRAME_X_WINDOW (f), temp);
2687 XFreePixmap (temp);
2688 UNBLOCK_INPUT;
2689 x_set_border_pixel (f, f->display.x->border_pixel);
2690
2691 x_set_mouse_color (f, Qnil, Qnil);
2692
2693 /* Now override the defaults with all the rest of the specified parms. */
2694
2695 Fmodify_frame_parameters (frame, parms);
2696
2697 /* Make the window appear on the frame and enable display. */
2698 {
2699 Lisp_Object visibility;
2700
2701 visibility = x_get_arg (parms, Qvisibility, 0, 0, symbol);
2702 if (EQ (visibility, Qunbound))
2703 visibility = Qt;
2704
2705 if (! EQ (visibility, Qicon)
2706 && ! NILP (visibility))
2707 x_make_window_visible (f);
2708 }
2709
2710 SET_FRAME_GARBAGED (f);
2711
2712 Vframe_list = Fcons (frame, Vframe_list);
2713 return frame;
2714 #endif /* X10 */
2715 } 2375 }
2716 2376
2717 Lisp_Object 2377 Lisp_Object
2718 x_get_focus_frame () 2378 x_get_focus_frame ()
2719 { 2379 {
2754 UNBLOCK_INPUT; 2414 UNBLOCK_INPUT;
2755 } 2415 }
2756 2416
2757 return Qnil; 2417 return Qnil;
2758 } 2418 }
2759
2760 #ifndef HAVE_X11
2761 /* Computes an X-window size and position either from geometry GEO
2762 or with the mouse.
2763
2764 F is a frame. It specifies an X window which is used to
2765 determine which display to compute for. Its font, borders
2766 and colors control how the rectangle will be displayed.
2767
2768 X and Y are where to store the positions chosen.
2769 WIDTH and HEIGHT are where to store the sizes chosen.
2770
2771 GEO is the geometry that may specify some of the info.
2772 STR is a prompt to display.
2773 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */
2774
2775 int
2776 x_rubber_band (f, x, y, width, height, geo, str, hscroll, vscroll)
2777 struct frame *f;
2778 int *x, *y, *width, *height;
2779 char *geo;
2780 char *str;
2781 int hscroll, vscroll;
2782 {
2783 OpaqueFrame frame;
2784 Window tempwindow;
2785 WindowInfo wininfo;
2786 int border_color;
2787 int background_color;
2788 Lisp_Object tem;
2789 int mask;
2790
2791 BLOCK_INPUT;
2792
2793 background_color = f->display.x->background_pixel;
2794 border_color = f->display.x->border_pixel;
2795
2796 frame.bdrwidth = f->display.x->border_width;
2797 frame.border = XMakeTile (border_color);
2798 frame.background = XMakeTile (background_color);
2799 tempwindow = XCreateTerm (str, "emacs", geo, default_window, &frame, 10, 5,
2800 (2 * f->display.x->internal_border_width
2801 + (vscroll ? VSCROLL_WIDTH : 0)),
2802 (2 * f->display.x->internal_border_width
2803 + (hscroll ? HSCROLL_HEIGHT : 0)),
2804 width, height, f->display.x->font,
2805 FONT_WIDTH (f->display.x->font),
2806 f->display.x->line_height);
2807 XFreePixmap (frame.border);
2808 XFreePixmap (frame.background);
2809
2810 if (tempwindow != 0)
2811 {
2812 XQueryWindow (tempwindow, &wininfo);
2813 XDestroyWindow (tempwindow);
2814 *x = wininfo.x;
2815 *y = wininfo.y;
2816 }
2817
2818 /* Coordinates we got are relative to the root window.
2819 Convert them to coordinates relative to desired parent window
2820 by scanning from there up to the root. */
2821 tempwindow = f->display.x->parent_desc;
2822 while (tempwindow != ROOT_WINDOW)
2823 {
2824 int nchildren;
2825 Window *children;
2826 XQueryWindow (tempwindow, &wininfo);
2827 *x -= wininfo.x;
2828 *y -= wininfo.y;
2829 XQueryTree (tempwindow, &tempwindow, &nchildren, &children);
2830 xfree (children);
2831 }
2832
2833 UNBLOCK_INPUT;
2834 return tempwindow != 0;
2835 }
2836 #endif /* not HAVE_X11 */
2837 2419
2838 DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 3, 0, 2420 DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 3, 0,
2839 "Return a list of the names of available fonts matching PATTERN.\n\ 2421 "Return a list of the names of available fonts matching PATTERN.\n\
2840 If optional arguments FACE and FRAME are specified, return only fonts\n\ 2422 If optional arguments FACE and FRAME are specified, return only fonts\n\
2841 the same size as FACE on FRAME.\n\ 2423 the same size as FACE on FRAME.\n\
4020 XCopyPlane (x_current_display, image, FRAME_X_WINDOW (f), 3602 XCopyPlane (x_current_display, image, FRAME_X_WINDOW (f),
4021 f->display.x->normal_gc, 0, 0, width, height, x, y); 3603 f->display.x->normal_gc, 0, 0, width, height, x, y);
4022 } 3604 }
4023 #endif 3605 #endif
4024 3606
4025 #ifndef HAVE_X11
4026 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer, Sx_store_cut_buffer,
4027 1, 1, "sStore text in cut buffer: ",
4028 "Store contents of STRING into the cut buffer of the X window system.")
4029 (string)
4030 register Lisp_Object string;
4031 {
4032 int mask;
4033
4034 CHECK_STRING (string, 1);
4035 if (! FRAME_X_P (selected_frame))
4036 error ("Selected frame does not understand X protocol.");
4037
4038 BLOCK_INPUT;
4039 XStoreBytes ((char *) XSTRING (string)->data, XSTRING (string)->size);
4040 UNBLOCK_INPUT;
4041
4042 return Qnil;
4043 }
4044
4045 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer, Sx_get_cut_buffer, 0, 0, 0,
4046 "Return contents of cut buffer of the X window system, as a string.")
4047 ()
4048 {
4049 int len;
4050 register Lisp_Object string;
4051 int mask;
4052 register char *d;
4053
4054 BLOCK_INPUT;
4055 d = XFetchBytes (&len);
4056 string = make_string (d, len);
4057 XFree (d);
4058 UNBLOCK_INPUT;
4059 return string;
4060 }
4061 #endif /* X10 */
4062
4063 #if 0 /* I'm told these functions are superfluous 3607 #if 0 /* I'm told these functions are superfluous
4064 given the ability to bind function keys. */ 3608 given the ability to bind function keys. */
4065 3609
4066 #ifdef HAVE_X11 3610 #ifdef HAVE_X11
4067 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0, 3611 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0,
4159 return Qnil; 3703 return Qnil;
4160 } 3704 }
4161 #endif /* HAVE_X11 */ 3705 #endif /* HAVE_X11 */
4162 #endif /* 0 */ 3706 #endif /* 0 */
4163 3707
4164 #ifdef HAVE_X11
4165
4166 #ifndef HAVE_XSCREENNUMBEROFSCREEN 3708 #ifndef HAVE_XSCREENNUMBEROFSCREEN
4167 int 3709 int
4168 XScreenNumberOfScreen (scr) 3710 XScreenNumberOfScreen (scr)
4169 register Screen *scr; 3711 register Screen *scr;
4170 { 3712 {
4223 } 3765 }
4224 3766
4225 XFree ((char *) vinfo); 3767 XFree ((char *) vinfo);
4226 return v; 3768 return v;
4227 } 3769 }
4228 #endif /* HAVE_X11 */
4229 3770
4230 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, 3771 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
4231 1, 2, 0, "Open a connection to an X server.\n\ 3772 1, 2, 0, "Open a connection to an X server.\n\
4232 DISPLAY is the name of the display to connect to.\n\ 3773 DISPLAY is the name of the display to connect to.\n\
4233 Optional second arg XRM_STRING is a string of resources in xrdb format.") 3774 Optional second arg XRM_STRING is a string of resources in xrdb format.")
4253 /* This is what opens the connection and sets x_current_display. 3794 /* This is what opens the connection and sets x_current_display.
4254 This also initializes many symbols, such as those used for input. */ 3795 This also initializes many symbols, such as those used for input. */
4255 x_term_init (XSTRING (display)->data, xrm_option, 3796 x_term_init (XSTRING (display)->data, xrm_option,
4256 XSTRING (Vx_resource_name)->data); 3797 XSTRING (Vx_resource_name)->data);
4257 3798
4258 #ifdef HAVE_X11
4259 XFASTINT (Vwindow_system_version) = 11; 3799 XFASTINT (Vwindow_system_version) = 11;
4260 3800
4261 BLOCK_INPUT; 3801 BLOCK_INPUT;
4262 xrdb = x_load_resources (x_current_display, xrm_option, 3802 xrdb = x_load_resources (x_current_display, xrm_option,
4263 (char *) XSTRING (Vx_resource_name)->data, 3803 (char *) XSTRING (Vx_resource_name)->data,
4293 "WM_CONFIGURE_DENIED", False); 3833 "WM_CONFIGURE_DENIED", False);
4294 Xatom_wm_window_moved = XInternAtom (x_current_display, "WM_MOVED", 3834 Xatom_wm_window_moved = XInternAtom (x_current_display, "WM_MOVED",
4295 False); 3835 False);
4296 Xatom_editres_name = XInternAtom (x_current_display, "Editres", False); 3836 Xatom_editres_name = XInternAtom (x_current_display, "Editres", False);
4297 UNBLOCK_INPUT; 3837 UNBLOCK_INPUT;
4298 #else /* not HAVE_X11 */
4299 XFASTINT (Vwindow_system_version) = 10;
4300 #endif /* not HAVE_X11 */
4301 return Qnil; 3838 return Qnil;
4302 } 3839 }
4303 3840
4304 DEFUN ("x-close-current-connection", Fx_close_current_connection, 3841 DEFUN ("x-close-current-connection", Fx_close_current_connection,
4305 Sx_close_current_connection, 3842 Sx_close_current_connection,
4310 can't happen. For the moment, this check is just for safety, 3847 can't happen. For the moment, this check is just for safety,
4311 so a user won't try out the function and get a crash. If it's 3848 so a user won't try out the function and get a crash. If it's
4312 really intended only to be called when killing emacs, then there's 3849 really intended only to be called when killing emacs, then there's
4313 no reason for it to have a lisp interface at all. */ 3850 no reason for it to have a lisp interface at all. */
4314 check_x(); 3851 check_x();
4315 #ifdef HAVE_X11 3852
4316 /* This is ONLY used when killing emacs; For switching displays 3853 /* This is ONLY used when killing emacs; For switching displays
4317 we'll have to take care of setting CloseDownMode elsewhere. */ 3854 we'll have to take care of setting CloseDownMode elsewhere. */
4318 3855
4319 if (x_current_display) 3856 if (x_current_display)
4320 { 3857 {
4323 XCloseDisplay (x_current_display); 3860 XCloseDisplay (x_current_display);
4324 x_current_display = 0; 3861 x_current_display = 0;
4325 } 3862 }
4326 else 3863 else
4327 fatal ("No current X display connection to close\n"); 3864 fatal ("No current X display connection to close\n");
4328 #endif 3865
4329 return Qnil; 3866 return Qnil;
4330 } 3867 }
4331 3868
4332 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 3869 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize,
4333 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\ 3870 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
4488 4025
4489 #ifdef USE_X_TOOLKIT 4026 #ifdef USE_X_TOOLKIT
4490 Fprovide (intern ("x-toolkit")); 4027 Fprovide (intern ("x-toolkit"));
4491 #endif 4028 #endif
4492 4029
4493 #ifdef HAVE_X11
4494 defsubr (&Sx_get_resource); 4030 defsubr (&Sx_get_resource);
4495 #if 0 4031 #if 0
4496 defsubr (&Sx_draw_rectangle); 4032 defsubr (&Sx_draw_rectangle);
4497 defsubr (&Sx_erase_rectangle); 4033 defsubr (&Sx_erase_rectangle);
4498 defsubr (&Sx_contour_region); 4034 defsubr (&Sx_contour_region);
4521 defsubr (&Sx_rebind_keys); 4057 defsubr (&Sx_rebind_keys);
4522 defsubr (&Sx_track_pointer); 4058 defsubr (&Sx_track_pointer);
4523 defsubr (&Sx_grab_pointer); 4059 defsubr (&Sx_grab_pointer);
4524 defsubr (&Sx_ungrab_pointer); 4060 defsubr (&Sx_ungrab_pointer);
4525 #endif 4061 #endif
4526 #else
4527 defsubr (&Sx_get_default);
4528 defsubr (&Sx_store_cut_buffer);
4529 defsubr (&Sx_get_cut_buffer);
4530 #endif
4531 defsubr (&Sx_parse_geometry); 4062 defsubr (&Sx_parse_geometry);
4532 defsubr (&Sx_create_frame); 4063 defsubr (&Sx_create_frame);
4533 defsubr (&Sfocus_frame); 4064 defsubr (&Sfocus_frame);
4534 defsubr (&Sunfocus_frame); 4065 defsubr (&Sunfocus_frame);
4535 #if 0 4066 #if 0