aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-22 04:27:25 +0000
committerRichard M. Stallman1994-10-22 04:27:25 +0000
commitb9dc44432a69fe6b69883752596b69d4131a8303 (patch)
treed2d7065292719b7dbf5e66d2381411e27051d0cb /src
parent437f611246ec01dcc65cefff02735abd6f662ccb (diff)
downloademacs-b9dc44432a69fe6b69883752596b69d4131a8303.tar.gz
emacs-b9dc44432a69fe6b69883752596b69d4131a8303.zip
(x_sync): Take frame ptr as arg.
(check_x_display_info): New function. (Fx_create_frame): Use it. (x_screen_planes): New function. (EMACS_CLASS): Macro moved to xterm.h. (Qdisplay): New variable. (syms_of_xfns): Set it up. (Fx_create_frame): Handle display parameter which says where to get the FRAME_X_DISPLAY_INFO. (x_display_info_for_name): New function. (select_visual): New arg dpy. (Fx_open_connection): Get dpyinfo from x_term_init. Don't set up atoms, xrdb here. Pass name as Lisp_Object. (the_x_screen): Variable moved to xterm.c. (syms_of_xfns): Don't staticpro it here. (xrdb): Variable deleted. (Fx_get_resource): Use selected_frame's xrdb. (x_get_resource_string): Likewise. (Fx_open_connection): Store the atoms in x_display_info. (hack_wm_protocols): New arg f. Get atoms from x_display_info. (x_window): Get atoms from x_display_info. (Vmouse_depressed, mouse_buffer_offset): Variables deleted. (syms_of_xfns): Delete Lisp variables too. (Fx_synchronize): Take frame as arg. (Fx_close_current_connection): Take frame as arg. Error is not fatal. (mouse_timestamp): Variable deleted. (screen_visual, x_screen_planes): Variables deleted. (x_screen, x_screen_height, x_screen_width): Variables deleted. (Fx_open_connection): Don't set them here. Put that info in the x_display_info structure. (x_window): Get the visual from x_display_info structure. (x_decode_color): Use n_planes from x_display_info structure. Use FRAME_X_DISPLAY instead of x_current_display and XDISPLAY. (x_in_use): New variable, (check_x, using_x_p): Test x_in_use. (Fx_open_connection): Set x_in_use. (check_x_frame): New function. (defined_color): New arg f specifies frame. Callers changed. (x_decode_color): New arg f. All callers changed. (Fx_color_values, Fx_color_defined_p): New arg FRAME. Use check_x_frame. (Fx_list_fonts): Use check_x_frame.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c819
1 files changed, 426 insertions, 393 deletions
diff --git a/src/xfns.c b/src/xfns.c
index faeceaa915d..dd3cf50ef18 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -24,10 +24,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24#include <signal.h> 24#include <signal.h>
25#include <config.h> 25#include <config.h>
26 26
27#if 0
28#include <stdio.h>
29#endif
30
31/* This makes the fields of a Display accessible, in Xlib header files. */ 27/* This makes the fields of a Display accessible, in Xlib header files. */
32#define XLIB_ILLEGAL_ACCESS 28#define XLIB_ILLEGAL_ACCESS
33 29
@@ -75,11 +71,11 @@ extern void abort ();
75/* Do the EDITRES protocol if running X11R5 */ 71/* Do the EDITRES protocol if running X11R5 */
76#if (XtSpecificationRelease >= 5) 72#if (XtSpecificationRelease >= 5)
77#define HACK_EDITRES 73#define HACK_EDITRES
78extern void _XEditResCheckMessages(); 74extern void _XEditResCheckMessages ();
79#endif /* R5 + Athena */ 75#endif /* R5 + Athena */
80 76
81/* Unique id counter for widgets created by the Lucid Widget 77/* Unique id counter for widgets created by the Lucid Widget
82 Library. */ 78 Library. */
83extern LWLIB_ID widget_id_tick; 79extern LWLIB_ID widget_id_tick;
84 80
85/* The one and only application context associated with the connection 81/* The one and only application context associated with the connection
@@ -91,18 +87,11 @@ XtAppContext Xt_app_con;
91Widget Xt_app_shell; 87Widget Xt_app_shell;
92 88
93extern void free_frame_menubar (); 89extern void free_frame_menubar ();
94extern void free_frame_menubar ();
95#endif /* USE_X_TOOLKIT */ 90#endif /* USE_X_TOOLKIT */
96 91
97#define min(a,b) ((a) < (b) ? (a) : (b)) 92#define min(a,b) ((a) < (b) ? (a) : (b))
98#define max(a,b) ((a) > (b) ? (a) : (b)) 93#define max(a,b) ((a) > (b) ? (a) : (b))
99 94
100/* X Resource data base */
101static XrmDatabase xrdb;
102
103/* The class of this X application. */
104#define EMACS_CLASS "Emacs"
105
106#ifdef HAVE_X11R4 95#ifdef HAVE_X11R4
107#define MAXREQUEST(dpy) (XMaxRequestSize (dpy)) 96#define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
108#else 97#else
@@ -112,70 +101,27 @@ static XrmDatabase xrdb;
112/* The name we're using in resource queries. */ 101/* The name we're using in resource queries. */
113Lisp_Object Vx_resource_name; 102Lisp_Object Vx_resource_name;
114 103
115/* Title name and application name for X stuff. */ 104/* Title name and application name for X stuff. */
116extern char *x_id_name; 105extern char *x_id_name;
117 106
118/* The background and shape of the mouse pointer, and shape when not 107/* The background and shape of the mouse pointer, and shape when not
119 over text or in the modeline. */ 108 over text or in the modeline. */
120Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; 109Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
121/* The shape when over mouse-sensitive text. */ 110/* The shape when over mouse-sensitive text. */
122Lisp_Object Vx_sensitive_text_pointer_shape; 111Lisp_Object Vx_sensitive_text_pointer_shape;
123 112
124/* Color of chars displayed in cursor box. */ 113/* Color of chars displayed in cursor box. */
125Lisp_Object Vx_cursor_fore_pixel; 114Lisp_Object Vx_cursor_fore_pixel;
126 115
127/* The screen being used. */ 116/* Nonzero if using X. */
128static Screen *x_screen; 117static int x_in_use;
129
130/* The X Visual we are using for X windows (the default) */
131Visual *screen_visual;
132
133/* Height of this X screen in pixels. */
134int x_screen_height;
135
136/* Width of this X screen in pixels. */
137int x_screen_width;
138
139/* Number of planes for this screen. */
140int x_screen_planes;
141 118
142/* Non nil if no window manager is in use. */ 119/* Non nil if no window manager is in use. */
143Lisp_Object Vx_no_window_manager; 120Lisp_Object Vx_no_window_manager;
144 121
145/* `t' if a mouse button is depressed. */
146
147Lisp_Object Vmouse_depressed;
148
149/* Search path for bitmap files. */ 122/* Search path for bitmap files. */
150Lisp_Object Vx_bitmap_file_path; 123Lisp_Object Vx_bitmap_file_path;
151 124
152/* For now, we have just one x_display structure since we only support
153 one X display. */
154static struct x_screen the_x_screen;
155
156extern unsigned int x_mouse_x, x_mouse_y, x_mouse_grabbed;
157
158/* Atom for indicating window state to the window manager. */
159extern Atom Xatom_wm_change_state;
160
161/* Communication with window managers. */
162extern Atom Xatom_wm_protocols;
163
164/* Kinds of protocol things we may receive. */
165extern Atom Xatom_wm_take_focus;
166extern Atom Xatom_wm_save_yourself;
167extern Atom Xatom_wm_delete_window;
168
169/* Other WM communication */
170extern Atom Xatom_wm_configure_denied; /* When our config request is denied */
171extern Atom Xatom_wm_window_moved; /* When the WM moves us. */
172
173/* EditRes protocol */
174extern Atom Xatom_editres_name;
175
176/* The last 23 bits of the timestamp of the last mouse button event. */
177Time mouse_timestamp;
178
179/* Evaluate this expression to rebuild the section of syms_of_xfns 125/* Evaluate this expression to rebuild the section of syms_of_xfns
180 that initializes and staticpros the symbols declared below. Note 126 that initializes and staticpros the symbols declared below. Note
181 that Emacs 18 has a bug that keeps C-x C-e from being able to 127 that Emacs 18 has a bug that keeps C-x C-e from being able to
@@ -242,8 +188,9 @@ Lisp_Object Qx_frame_parameter;
242Lisp_Object Qx_resource_name; 188Lisp_Object Qx_resource_name;
243Lisp_Object Quser_position; 189Lisp_Object Quser_position;
244Lisp_Object Quser_size; 190Lisp_Object Quser_size;
191Lisp_Object Qdisplay;
245 192
246/* The below are defined in frame.c. */ 193/* The below are defined in frame.c. */
247extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; 194extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
248extern Lisp_Object Qunsplittable, Qmenu_bar_lines; 195extern Lisp_Object Qunsplittable, Qmenu_bar_lines;
249 196
@@ -254,7 +201,7 @@ extern Lisp_Object Vwindow_system_version;
254void 201void
255check_x () 202check_x ()
256{ 203{
257 if (x_current_display == 0) 204 if (! x_in_use)
258 error ("X windows are not in use or not initialized"); 205 error ("X windows are not in use or not initialized");
259} 206}
260 207
@@ -263,9 +210,61 @@ check_x ()
263int 210int
264using_x_p () 211using_x_p ()
265{ 212{
266 return x_current_display != 0; 213 return x_in_use;
214}
215
216/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
217 and checking validity for X. */
218
219FRAME_PTR
220check_x_frame (frame)
221 Lisp_Object frame;
222{
223 FRAME_PTR f;
224
225 if (NILP (frame))
226 f = selected_frame;
227 else
228 {
229 CHECK_LIVE_FRAME (frame, 0);
230 f = XFRAME (frame);
231 }
232 if (! FRAME_X_P (f))
233 error ("non-X frame used");
234 return f;
267} 235}
268 236
237/* Let the user specify an X display with a frame.
238 nil stands for the selected frame--or, if that is not an X frame,
239 the first X display on the list. */
240
241static struct x_display_info *
242check_x_display_info (frame)
243 Lisp_Object frame;
244{
245 if (NILP (frame))
246 {
247 if (FRAME_X_P (selected_frame))
248 return FRAME_X_DISPLAY_INFO (selected_frame);
249 else if (x_display_list != 0)
250 return x_display_list;
251 else
252 error ("X windows are not in use or not initialized");
253 }
254 else if (STRINGP (frame))
255 return x_display_info_for_name (frame);
256 else
257 {
258 FRAME_PTR f;
259
260 CHECK_LIVE_FRAME (frame, 0);
261 f = XFRAME (frame);
262 if (! FRAME_X_P (f))
263 error ("non-X frame used");
264 return FRAME_X_DISPLAY_INFO (f);
265 }
266}
267
269/* Return the Emacs frame-object corresponding to an X window. 268/* Return the Emacs frame-object corresponding to an X window.
270 It could be the frame's main window or an icon window. */ 269 It could be the frame's main window or an icon window. */
271 270
@@ -379,7 +378,7 @@ x_top_window_to_frame (wdesc)
379 378
380 If you use x_create_bitmap_from_data, then you must keep track of 379 If you use x_create_bitmap_from_data, then you must keep track of
381 the bitmaps yourself. That is, creating a bitmap from the same 380 the bitmaps yourself. That is, creating a bitmap from the same
382 data more than once will not be caught. */ 381 data more than once will not be caught. */
383 382
384 383
385/* Structure recording X pixmap and reference count. 384/* Structure recording X pixmap and reference count.
@@ -489,7 +488,7 @@ x_create_bitmap_from_data (f, bits, width, height)
489 Pixmap bitmap; 488 Pixmap bitmap;
490 int id; 489 int id;
491 490
492 bitmap = XCreateBitmapFromData (x_current_display, FRAME_X_WINDOW (f), 491 bitmap = XCreateBitmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
493 bits, width, height); 492 bits, width, height);
494 493
495 if (! bitmap) 494 if (! bitmap)
@@ -540,7 +539,7 @@ x_create_bitmap_from_file (f, file)
540 539
541 filename = (char *) XSTRING (found)->data; 540 filename = (char *) XSTRING (found)->data;
542 541
543 result = XReadBitmapFile (x_current_display, FRAME_X_WINDOW (f), 542 result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
544 filename, &width, &height, &bitmap, &xhot, &yhot); 543 filename, &width, &height, &bitmap, &xhot, &yhot);
545 if (result != BitmapSuccess) 544 if (result != BitmapSuccess)
546 return -1; 545 return -1;
@@ -569,7 +568,7 @@ x_destroy_bitmap (f, id)
569 --x_bitmaps[id - 1].refcount; 568 --x_bitmaps[id - 1].refcount;
570 if (! x_bitmaps[id - 1].refcount) 569 if (! x_bitmaps[id - 1].refcount)
571 { 570 {
572 XFreePixmap (x_current_display, x_bitmaps[id - 1].pixmap); 571 XFreePixmap (FRAME_X_DISPLAY (f), x_bitmaps[id - 1].pixmap);
573 if (x_bitmaps[id - 1].file) 572 if (x_bitmaps[id - 1].file)
574 { 573 {
575 free (x_bitmaps[id - 1].file); 574 free (x_bitmaps[id - 1].file);
@@ -579,7 +578,7 @@ x_destroy_bitmap (f, id)
579 } 578 }
580} 579}
581 580
582/* Return pixmap given bitmap id. */ 581/* Return the actual X pixmap number for a given bitmap id. */
583 582
584Pixmap 583Pixmap
585x_lookup_pixmap (id) 584x_lookup_pixmap (id)
@@ -886,17 +885,17 @@ x_real_positions (f, xptr, yptr)
886 Window *tmp_children; 885 Window *tmp_children;
887 int tmp_nchildren; 886 int tmp_nchildren;
888 887
889 XQueryTree (x_current_display, outer, &tmp_root_window, 888 XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window,
890 &f->display.x->parent_desc, 889 &f->display.x->parent_desc,
891 &tmp_children, &tmp_nchildren); 890 &tmp_children, &tmp_nchildren);
892 xfree (tmp_children); 891 xfree (tmp_children);
893 892
894 /* Find the position of the outside upper-left corner of 893 /* Find the position of the outside upper-left corner of
895 the inner window, with respect to the outer window. */ 894 the inner window, with respect to the outer window. */
896 if (f->display.x->parent_desc != ROOT_WINDOW) 895 if (f->display.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window)
897 { 896 {
898 BLOCK_INPUT; 897 BLOCK_INPUT;
899 XTranslateCoordinates (x_current_display, 898 XTranslateCoordinates (FRAME_X_DISPLAY (f),
900 899
901 /* From-window, to-window. */ 900 /* From-window, to-window. */
902#ifdef USE_X_TOOLKIT 901#ifdef USE_X_TOOLKIT
@@ -952,9 +951,10 @@ x_report_frame_params (f, alistptr)
952 If ALLOC is nonzero, allocate a new colormap cell. */ 951 If ALLOC is nonzero, allocate a new colormap cell. */
953 952
954int 953int
955defined_color (color, color_def, alloc) 954defined_color (f, color, color_def, alloc)
955 FRAME_PTR f;
956 char *color; 956 char *color;
957 Color *color_def; 957 XColor *color_def;
958 int alloc; 958 int alloc;
959{ 959{
960 register int foo; 960 register int foo;
@@ -962,11 +962,12 @@ defined_color (color, color_def, alloc)
962 962
963 BLOCK_INPUT; 963 BLOCK_INPUT;
964 screen_colormap 964 screen_colormap
965 = DefaultColormap (x_current_display, XDefaultScreen (x_current_display)); 965 = DefaultColormap (FRAME_X_DISPLAY (f),
966 XDefaultScreen (FRAME_X_DISPLAY (f)));
966 967
967 foo = XParseColor (x_current_display, screen_colormap, color, color_def); 968 foo = XParseColor (FRAME_X_DISPLAY (f), screen_colormap, color, color_def);
968 if (foo && alloc) 969 if (foo && alloc)
969 foo = XAllocColor (x_current_display, screen_colormap, color_def); 970 foo = XAllocColor (FRAME_X_DISPLAY (f), screen_colormap, color_def);
970 UNBLOCK_INPUT; 971 UNBLOCK_INPUT;
971 972
972 if (foo) 973 if (foo)
@@ -981,23 +982,24 @@ defined_color (color, color_def, alloc)
981 ARG says. */ 982 ARG says. */
982 983
983int 984int
984x_decode_color (arg, def) 985x_decode_color (f, arg, def)
986 FRAME_PTR f;
985 Lisp_Object arg; 987 Lisp_Object arg;
986 int def; 988 int def;
987{ 989{
988 Color cdef; 990 XColor cdef;
989 991
990 CHECK_STRING (arg, 0); 992 CHECK_STRING (arg, 0);
991 993
992 if (strcmp (XSTRING (arg)->data, "black") == 0) 994 if (strcmp (XSTRING (arg)->data, "black") == 0)
993 return BLACK_PIX_DEFAULT; 995 return BLACK_PIX_DEFAULT (f);
994 else if (strcmp (XSTRING (arg)->data, "white") == 0) 996 else if (strcmp (XSTRING (arg)->data, "white") == 0)
995 return WHITE_PIX_DEFAULT; 997 return WHITE_PIX_DEFAULT (f);
996 998
997 if (x_screen_planes == 1) 999 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
998 return def; 1000 return def;
999 1001
1000 if (defined_color (XSTRING (arg)->data, &cdef, 1)) 1002 if (defined_color (f, XSTRING (arg)->data, &cdef, 1))
1001 return cdef.pixel; 1003 return cdef.pixel;
1002 else 1004 else
1003 Fsignal (Qundefined_color, Fcons (arg, Qnil)); 1005 Fsignal (Qundefined_color, Fcons (arg, Qnil));
@@ -1016,13 +1018,14 @@ x_set_foreground_color (f, arg, oldval)
1016 struct frame *f; 1018 struct frame *f;
1017 Lisp_Object arg, oldval; 1019 Lisp_Object arg, oldval;
1018{ 1020{
1019 f->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); 1021 f->display.x->foreground_pixel
1022 = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1020 if (FRAME_X_WINDOW (f) != 0) 1023 if (FRAME_X_WINDOW (f) != 0)
1021 { 1024 {
1022 BLOCK_INPUT; 1025 BLOCK_INPUT;
1023 XSetForeground (x_current_display, f->display.x->normal_gc, 1026 XSetForeground (FRAME_X_DISPLAY (f), f->display.x->normal_gc,
1024 f->display.x->foreground_pixel); 1027 f->display.x->foreground_pixel);
1025 XSetBackground (x_current_display, f->display.x->reverse_gc, 1028 XSetBackground (FRAME_X_DISPLAY (f), f->display.x->reverse_gc,
1026 f->display.x->foreground_pixel); 1029 f->display.x->foreground_pixel);
1027 UNBLOCK_INPUT; 1030 UNBLOCK_INPUT;
1028 recompute_basic_faces (f); 1031 recompute_basic_faces (f);
@@ -1039,25 +1042,26 @@ x_set_background_color (f, arg, oldval)
1039 Pixmap temp; 1042 Pixmap temp;
1040 int mask; 1043 int mask;
1041 1044
1042 f->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT); 1045 f->display.x->background_pixel
1046 = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
1043 1047
1044 if (FRAME_X_WINDOW (f) != 0) 1048 if (FRAME_X_WINDOW (f) != 0)
1045 { 1049 {
1046 BLOCK_INPUT; 1050 BLOCK_INPUT;
1047 /* The main frame area. */ 1051 /* The main frame area. */
1048 XSetBackground (x_current_display, f->display.x->normal_gc, 1052 XSetBackground (FRAME_X_DISPLAY (f), f->display.x->normal_gc,
1049 f->display.x->background_pixel); 1053 f->display.x->background_pixel);
1050 XSetForeground (x_current_display, f->display.x->reverse_gc, 1054 XSetForeground (FRAME_X_DISPLAY (f), f->display.x->reverse_gc,
1051 f->display.x->background_pixel); 1055 f->display.x->background_pixel);
1052 XSetForeground (x_current_display, f->display.x->cursor_gc, 1056 XSetForeground (FRAME_X_DISPLAY (f), f->display.x->cursor_gc,
1053 f->display.x->background_pixel); 1057 f->display.x->background_pixel);
1054 XSetWindowBackground (x_current_display, FRAME_X_WINDOW (f), 1058 XSetWindowBackground (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1055 f->display.x->background_pixel); 1059 f->display.x->background_pixel);
1056 { 1060 {
1057 Lisp_Object bar; 1061 Lisp_Object bar;
1058 for (bar = FRAME_SCROLL_BARS (f); !NILP (bar); 1062 for (bar = FRAME_SCROLL_BARS (f); !NILP (bar);
1059 bar = XSCROLL_BAR (bar)->next) 1063 bar = XSCROLL_BAR (bar)->next)
1060 XSetWindowBackground (x_current_display, 1064 XSetWindowBackground (FRAME_X_DISPLAY (f),
1061 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), 1065 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
1062 f->display.x->background_pixel); 1066 f->display.x->background_pixel);
1063 } 1067 }
@@ -1079,9 +1083,10 @@ x_set_mouse_color (f, arg, oldval)
1079 int mask_color; 1083 int mask_color;
1080 1084
1081 if (!EQ (Qnil, arg)) 1085 if (!EQ (Qnil, arg))
1082 f->display.x->mouse_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); 1086 f->display.x->mouse_pixel
1087 = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1083 mask_color = f->display.x->background_pixel; 1088 mask_color = f->display.x->background_pixel;
1084 /* No invisible pointers. */ 1089 /* No invisible pointers. */
1085 if (mask_color == f->display.x->mouse_pixel 1090 if (mask_color == f->display.x->mouse_pixel
1086 && mask_color == f->display.x->background_pixel) 1091 && mask_color == f->display.x->background_pixel)
1087 f->display.x->mouse_pixel = f->display.x->foreground_pixel; 1092 f->display.x->mouse_pixel = f->display.x->foreground_pixel;
@@ -1089,98 +1094,98 @@ x_set_mouse_color (f, arg, oldval)
1089 BLOCK_INPUT; 1094 BLOCK_INPUT;
1090 1095
1091 /* It's not okay to crash if the user selects a screwy cursor. */ 1096 /* It's not okay to crash if the user selects a screwy cursor. */
1092 x_catch_errors (); 1097 x_catch_errors (f);
1093 1098
1094 if (!EQ (Qnil, Vx_pointer_shape)) 1099 if (!EQ (Qnil, Vx_pointer_shape))
1095 { 1100 {
1096 CHECK_NUMBER (Vx_pointer_shape, 0); 1101 CHECK_NUMBER (Vx_pointer_shape, 0);
1097 cursor = XCreateFontCursor (x_current_display, XINT (Vx_pointer_shape)); 1102 cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XINT (Vx_pointer_shape));
1098 } 1103 }
1099 else 1104 else
1100 cursor = XCreateFontCursor (x_current_display, XC_xterm); 1105 cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_xterm);
1101 x_check_errors ("bad text pointer cursor: %s"); 1106 x_check_errors (f, "bad text pointer cursor: %s");
1102 1107
1103 if (!EQ (Qnil, Vx_nontext_pointer_shape)) 1108 if (!EQ (Qnil, Vx_nontext_pointer_shape))
1104 { 1109 {
1105 CHECK_NUMBER (Vx_nontext_pointer_shape, 0); 1110 CHECK_NUMBER (Vx_nontext_pointer_shape, 0);
1106 nontext_cursor = XCreateFontCursor (x_current_display, 1111 nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f),
1107 XINT (Vx_nontext_pointer_shape)); 1112 XINT (Vx_nontext_pointer_shape));
1108 } 1113 }
1109 else 1114 else
1110 nontext_cursor = XCreateFontCursor (x_current_display, XC_left_ptr); 1115 nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_left_ptr);
1111 x_check_errors ("bad nontext pointer cursor: %s"); 1116 x_check_errors (f, "bad nontext pointer cursor: %s");
1112 1117
1113 if (!EQ (Qnil, Vx_mode_pointer_shape)) 1118 if (!EQ (Qnil, Vx_mode_pointer_shape))
1114 { 1119 {
1115 CHECK_NUMBER (Vx_mode_pointer_shape, 0); 1120 CHECK_NUMBER (Vx_mode_pointer_shape, 0);
1116 mode_cursor = XCreateFontCursor (x_current_display, 1121 mode_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f),
1117 XINT (Vx_mode_pointer_shape)); 1122 XINT (Vx_mode_pointer_shape));
1118 } 1123 }
1119 else 1124 else
1120 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm); 1125 mode_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_xterm);
1121 x_check_errors ("bad modeline pointer cursor: %s"); 1126 x_check_errors (f, "bad modeline pointer cursor: %s");
1122 1127
1123 if (!EQ (Qnil, Vx_sensitive_text_pointer_shape)) 1128 if (!EQ (Qnil, Vx_sensitive_text_pointer_shape))
1124 { 1129 {
1125 CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0); 1130 CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0);
1126 cross_cursor 1131 cross_cursor
1127 = XCreateFontCursor (x_current_display, 1132 = XCreateFontCursor (FRAME_X_DISPLAY (f),
1128 XINT (Vx_sensitive_text_pointer_shape)); 1133 XINT (Vx_sensitive_text_pointer_shape));
1129 } 1134 }
1130 else 1135 else
1131 cross_cursor = XCreateFontCursor (x_current_display, XC_crosshair); 1136 cross_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_crosshair);
1132 1137
1133 /* Check and report errors with the above calls. */ 1138 /* Check and report errors with the above calls. */
1134 x_check_errors ("can't set cursor shape: %s"); 1139 x_check_errors (f, "can't set cursor shape: %s");
1135 x_uncatch_errors (); 1140 x_uncatch_errors (f);
1136 1141
1137 { 1142 {
1138 XColor fore_color, back_color; 1143 XColor fore_color, back_color;
1139 1144
1140 fore_color.pixel = f->display.x->mouse_pixel; 1145 fore_color.pixel = f->display.x->mouse_pixel;
1141 back_color.pixel = mask_color; 1146 back_color.pixel = mask_color;
1142 XQueryColor (x_current_display, 1147 XQueryColor (FRAME_X_DISPLAY (f),
1143 DefaultColormap (x_current_display, 1148 DefaultColormap (FRAME_X_DISPLAY (f),
1144 DefaultScreen (x_current_display)), 1149 DefaultScreen (FRAME_X_DISPLAY (f))),
1145 &fore_color); 1150 &fore_color);
1146 XQueryColor (x_current_display, 1151 XQueryColor (FRAME_X_DISPLAY (f),
1147 DefaultColormap (x_current_display, 1152 DefaultColormap (FRAME_X_DISPLAY (f),
1148 DefaultScreen (x_current_display)), 1153 DefaultScreen (FRAME_X_DISPLAY (f))),
1149 &back_color); 1154 &back_color);
1150 XRecolorCursor (x_current_display, cursor, 1155 XRecolorCursor (FRAME_X_DISPLAY (f), cursor,
1151 &fore_color, &back_color); 1156 &fore_color, &back_color);
1152 XRecolorCursor (x_current_display, nontext_cursor, 1157 XRecolorCursor (FRAME_X_DISPLAY (f), nontext_cursor,
1153 &fore_color, &back_color); 1158 &fore_color, &back_color);
1154 XRecolorCursor (x_current_display, mode_cursor, 1159 XRecolorCursor (FRAME_X_DISPLAY (f), mode_cursor,
1155 &fore_color, &back_color); 1160 &fore_color, &back_color);
1156 XRecolorCursor (x_current_display, cross_cursor, 1161 XRecolorCursor (FRAME_X_DISPLAY (f), cross_cursor,
1157 &fore_color, &back_color); 1162 &fore_color, &back_color);
1158 } 1163 }
1159 1164
1160 if (FRAME_X_WINDOW (f) != 0) 1165 if (FRAME_X_WINDOW (f) != 0)
1161 { 1166 {
1162 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), cursor); 1167 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
1163 } 1168 }
1164 1169
1165 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0) 1170 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0)
1166 XFreeCursor (XDISPLAY f->display.x->text_cursor); 1171 XFreeCursor (FRAME_X_DISPLAY (f), f->display.x->text_cursor);
1167 f->display.x->text_cursor = cursor; 1172 f->display.x->text_cursor = cursor;
1168 1173
1169 if (nontext_cursor != f->display.x->nontext_cursor 1174 if (nontext_cursor != f->display.x->nontext_cursor
1170 && f->display.x->nontext_cursor != 0) 1175 && f->display.x->nontext_cursor != 0)
1171 XFreeCursor (XDISPLAY f->display.x->nontext_cursor); 1176 XFreeCursor (FRAME_X_DISPLAY (f), f->display.x->nontext_cursor);
1172 f->display.x->nontext_cursor = nontext_cursor; 1177 f->display.x->nontext_cursor = nontext_cursor;
1173 1178
1174 if (mode_cursor != f->display.x->modeline_cursor 1179 if (mode_cursor != f->display.x->modeline_cursor
1175 && f->display.x->modeline_cursor != 0) 1180 && f->display.x->modeline_cursor != 0)
1176 XFreeCursor (XDISPLAY f->display.x->modeline_cursor); 1181 XFreeCursor (FRAME_X_DISPLAY (f), f->display.x->modeline_cursor);
1177 f->display.x->modeline_cursor = mode_cursor; 1182 f->display.x->modeline_cursor = mode_cursor;
1178 if (cross_cursor != f->display.x->cross_cursor 1183 if (cross_cursor != f->display.x->cross_cursor
1179 && f->display.x->cross_cursor != 0) 1184 && f->display.x->cross_cursor != 0)
1180 XFreeCursor (XDISPLAY f->display.x->cross_cursor); 1185 XFreeCursor (FRAME_X_DISPLAY (f), f->display.x->cross_cursor);
1181 f->display.x->cross_cursor = cross_cursor; 1186 f->display.x->cross_cursor = cross_cursor;
1182 1187
1183 XFlushQueue (); 1188 XFlush (FRAME_X_DISPLAY (f));
1184 UNBLOCK_INPUT; 1189 UNBLOCK_INPUT;
1185} 1190}
1186 1191
@@ -1192,10 +1197,11 @@ x_set_cursor_color (f, arg, oldval)
1192 unsigned long fore_pixel; 1197 unsigned long fore_pixel;
1193 1198
1194 if (!EQ (Vx_cursor_fore_pixel, Qnil)) 1199 if (!EQ (Vx_cursor_fore_pixel, Qnil))
1195 fore_pixel = x_decode_color (Vx_cursor_fore_pixel, WHITE_PIX_DEFAULT); 1200 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
1201 WHITE_PIX_DEFAULT (f));
1196 else 1202 else
1197 fore_pixel = f->display.x->background_pixel; 1203 fore_pixel = f->display.x->background_pixel;
1198 f->display.x->cursor_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); 1204 f->display.x->cursor_pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1199 1205
1200 /* Make sure that the cursor color differs from the background color. */ 1206 /* Make sure that the cursor color differs from the background color. */
1201 if (f->display.x->cursor_pixel == f->display.x->background_pixel) 1207 if (f->display.x->cursor_pixel == f->display.x->background_pixel)
@@ -1209,9 +1215,9 @@ x_set_cursor_color (f, arg, oldval)
1209 if (FRAME_X_WINDOW (f) != 0) 1215 if (FRAME_X_WINDOW (f) != 0)
1210 { 1216 {
1211 BLOCK_INPUT; 1217 BLOCK_INPUT;
1212 XSetBackground (x_current_display, f->display.x->cursor_gc, 1218 XSetBackground (FRAME_X_DISPLAY (f), f->display.x->cursor_gc,
1213 f->display.x->cursor_pixel); 1219 f->display.x->cursor_pixel);
1214 XSetForeground (x_current_display, f->display.x->cursor_gc, 1220 XSetForeground (FRAME_X_DISPLAY (f), f->display.x->cursor_gc,
1215 fore_pixel); 1221 fore_pixel);
1216 UNBLOCK_INPUT; 1222 UNBLOCK_INPUT;
1217 1223
@@ -1232,7 +1238,7 @@ x_set_cursor_color (f, arg, oldval)
1232 Note: this is done in two routines because of the way X10 works. 1238 Note: this is done in two routines because of the way X10 works.
1233 1239
1234 Note: under X11, this is normally the province of the window manager, 1240 Note: under X11, this is normally the province of the window manager,
1235 and so emacs' border colors may be overridden. */ 1241 and so emacs' border colors may be overridden. */
1236 1242
1237void 1243void
1238x_set_border_color (f, arg, oldval) 1244x_set_border_color (f, arg, oldval)
@@ -1245,7 +1251,7 @@ x_set_border_color (f, arg, oldval)
1245 CHECK_STRING (arg, 0); 1251 CHECK_STRING (arg, 0);
1246 str = XSTRING (arg)->data; 1252 str = XSTRING (arg)->data;
1247 1253
1248 pix = x_decode_color (arg, BLACK_PIX_DEFAULT); 1254 pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1249 1255
1250 x_set_border_pixel (f, pix); 1256 x_set_border_pixel (f, pix);
1251} 1257}
@@ -1266,7 +1272,7 @@ x_set_border_pixel (f, pix)
1266 int mask; 1272 int mask;
1267 1273
1268 BLOCK_INPUT; 1274 BLOCK_INPUT;
1269 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (f), 1275 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1270 pix); 1276 pix);
1271 UNBLOCK_INPUT; 1277 UNBLOCK_INPUT;
1272 1278
@@ -1331,12 +1337,14 @@ x_set_icon_type (f, arg, oldval)
1331 /* If the window was unmapped (and its icon was mapped), 1337 /* If the window was unmapped (and its icon was mapped),
1332 the new icon is not mapped, so map the window in its stead. */ 1338 the new icon is not mapped, so map the window in its stead. */
1333 if (FRAME_VISIBLE_P (f)) 1339 if (FRAME_VISIBLE_P (f))
1340 {
1334#ifdef USE_X_TOOLKIT 1341#ifdef USE_X_TOOLKIT
1335 XtPopup (f->display.x->widget, XtGrabNone); 1342 XtPopup (f->display.x->widget, XtGrabNone);
1336#endif 1343#endif
1337 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 1344 XMapWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
1345 }
1338 1346
1339 XFlushQueue (); 1347 XFlush (FRAME_X_DISPLAY (f));
1340 UNBLOCK_INPUT; 1348 UNBLOCK_INPUT;
1341} 1349}
1342 1350
@@ -1422,7 +1430,7 @@ x_set_internal_border_width (f, arg, oldval)
1422#if 0 1430#if 0
1423 x_set_resize_hint (f); 1431 x_set_resize_hint (f);
1424#endif 1432#endif
1425 XFlushQueue (); 1433 XFlush (FRAME_X_DISPLAY (f));
1426 UNBLOCK_INPUT; 1434 UNBLOCK_INPUT;
1427 SET_FRAME_GARBAGED (f); 1435 SET_FRAME_GARBAGED (f);
1428 } 1436 }
@@ -1561,18 +1569,19 @@ x_set_name (f, name, explicit)
1561 text.format = 8; 1569 text.format = 8;
1562 text.nitems = XSTRING (name)->size; 1570 text.nitems = XSTRING (name)->size;
1563#ifdef USE_X_TOOLKIT 1571#ifdef USE_X_TOOLKIT
1564 XSetWMName (x_current_display, XtWindow (f->display.x->widget), &text); 1572 XSetWMName (FRAME_X_DISPLAY (f),
1565 XSetWMIconName (x_current_display, XtWindow (f->display.x->widget), 1573 XtWindow (f->display.x->widget), &text);
1574 XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->display.x->widget),
1566 &text); 1575 &text);
1567#else /* not USE_X_TOOLKIT */ 1576#else /* not USE_X_TOOLKIT */
1568 XSetWMName (x_current_display, FRAME_X_WINDOW (f), &text); 1577 XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);
1569 XSetWMIconName (x_current_display, FRAME_X_WINDOW (f), &text); 1578 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);
1570#endif /* not USE_X_TOOLKIT */ 1579#endif /* not USE_X_TOOLKIT */
1571 } 1580 }
1572#else /* not HAVE_X11R4 */ 1581#else /* not HAVE_X11R4 */
1573 XSetIconName (XDISPLAY FRAME_X_WINDOW (f), 1582 XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1574 XSTRING (name)->data); 1583 XSTRING (name)->data);
1575 XStoreName (XDISPLAY FRAME_X_WINDOW (f), 1584 XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1576 XSTRING (name)->data); 1585 XSTRING (name)->data);
1577#endif /* not HAVE_X11R4 */ 1586#endif /* not HAVE_X11R4 */
1578 UNBLOCK_INPUT; 1587 UNBLOCK_INPUT;
@@ -1697,7 +1706,6 @@ validate_x_resource_name ()
1697 1706
1698 1707
1699extern char *x_get_string_resource (); 1708extern char *x_get_string_resource ();
1700extern XrmDatabase x_load_resources ();
1701 1709
1702DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0, 1710DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
1703 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\ 1711 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
@@ -1772,7 +1780,8 @@ and the class is `Emacs.CLASS.SUBCLASS'.")
1772 XSTRING (subclass)->data); 1780 XSTRING (subclass)->data);
1773 } 1781 }
1774 1782
1775 value = x_get_string_resource (xrdb, name_key, class_key); 1783 value = x_get_string_resource (check_x_display_info (Qnil)->xrdb,
1784 name_key, class_key);
1776 1785
1777 if (value != (char *) 0) 1786 if (value != (char *) 0)
1778 return build_string (value); 1787 return build_string (value);
@@ -1802,7 +1811,8 @@ x_get_resource_string (attribute, class)
1802 attribute); 1811 attribute);
1803 sprintf (class_key, "%s.%s", EMACS_CLASS, class); 1812 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
1804 1813
1805 return x_get_string_resource (xrdb, name_key, class_key); 1814 return x_get_string_resource (FRAME_X_DISPLAY_INFO (selected_frame)->xrdb,
1815 name_key, class_key);
1806} 1816}
1807 1817
1808/* Types we might convert a resource string into. */ 1818/* Types we might convert a resource string into. */
@@ -1992,7 +2002,7 @@ x_figure_window_size (f, parms)
1992 2002
1993 /* Default values if we fall through. 2003 /* Default values if we fall through.
1994 Actually, if that happens we should get 2004 Actually, if that happens we should get
1995 window manager prompting. */ 2005 window manager prompting. */
1996 f->width = DEFAULT_COLS; 2006 f->width = DEFAULT_COLS;
1997 f->height = DEFAULT_ROWS; 2007 f->height = DEFAULT_ROWS;
1998 /* Window managers expect that if program-specified 2008 /* Window managers expect that if program-specified
@@ -2126,7 +2136,8 @@ XSetWMProtocols (dpy, w, protocols, count)
2126 for example, but Xt doesn't). */ 2136 for example, but Xt doesn't). */
2127 2137
2128static void 2138static void
2129hack_wm_protocols (widget) 2139hack_wm_protocols (f, widget)
2140 FRAME_PTR f;
2130 Widget widget; 2141 Widget widget;
2131{ 2142{
2132 Display *dpy = XtDisplay (widget); 2143 Display *dpy = XtDisplay (widget);
@@ -2142,7 +2153,8 @@ hack_wm_protocols (widget)
2142 unsigned long nitems = 0; 2153 unsigned long nitems = 0;
2143 unsigned long bytes_after; 2154 unsigned long bytes_after;
2144 2155
2145 if (Success == XGetWindowProperty (dpy, w, Xatom_wm_protocols, 2156 if (Success == XGetWindowProperty (dpy, w,
2157 FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
2146 0, 100, False, XA_ATOM, 2158 0, 100, False, XA_ATOM,
2147 &type, &format, &nitems, &bytes_after, 2159 &type, &format, &nitems, &bytes_after,
2148 (unsigned char **) &atoms) 2160 (unsigned char **) &atoms)
@@ -2150,20 +2162,27 @@ hack_wm_protocols (widget)
2150 while (nitems > 0) 2162 while (nitems > 0)
2151 { 2163 {
2152 nitems--; 2164 nitems--;
2153 if (atoms[nitems] == Xatom_wm_delete_window) need_delete = 0; 2165 if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window)
2154 else if (atoms[nitems] == Xatom_wm_take_focus) need_focus = 0; 2166 need_delete = 0;
2155 else if (atoms[nitems] == Xatom_wm_save_yourself) need_save = 0; 2167 else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus)
2168 need_focus = 0;
2169 else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself)
2170 need_save = 0;
2156 } 2171 }
2157 if (atoms) XFree ((char *) atoms); 2172 if (atoms) XFree ((char *) atoms);
2158 } 2173 }
2159 { 2174 {
2160 Atom props [10]; 2175 Atom props [10];
2161 int count = 0; 2176 int count = 0;
2162 if (need_delete) props[count++] = Xatom_wm_delete_window; 2177 if (need_delete)
2163 if (need_focus) props[count++] = Xatom_wm_take_focus; 2178 props[count++] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window;
2164 if (need_save) props[count++] = Xatom_wm_save_yourself; 2179 if (need_focus)
2180 props[count++] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus;
2181 if (need_save)
2182 props[count++] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself;
2165 if (count) 2183 if (count)
2166 XChangeProperty (dpy, w, Xatom_wm_protocols, XA_ATOM, 32, PropModeAppend, 2184 XChangeProperty (dpy, w, FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
2185 XA_ATOM, 32, PropModeAppend,
2167 (unsigned char *) props, count); 2186 (unsigned char *) props, count);
2168 } 2187 }
2169 UNBLOCK_INPUT; 2188 UNBLOCK_INPUT;
@@ -2294,11 +2313,12 @@ x_window (f, window_prompting, minibuffer_only)
2294 validate_x_resource_name (); 2313 validate_x_resource_name ();
2295 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; 2314 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;
2296 class_hints.res_class = EMACS_CLASS; 2315 class_hints.res_class = EMACS_CLASS;
2297 XSetClassHint (x_current_display, XtWindow (shell_widget), &class_hints); 2316 XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
2298 2317
2299 f->display.x->wm_hints.input = True; 2318 f->display.x->wm_hints.input = True;
2300 f->display.x->wm_hints.flags |= InputHint; 2319 f->display.x->wm_hints.flags |= InputHint;
2301 XSetWMHints (x_current_display, FRAME_X_WINDOW (f), &f->display.x->wm_hints); 2320 XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2321 &f->display.x->wm_hints);
2302 2322
2303 hack_wm_protocols (shell_widget); 2323 hack_wm_protocols (shell_widget);
2304 2324
@@ -2311,7 +2331,8 @@ x_window (f, window_prompting, minibuffer_only)
2311 be initialized to something relevant to the time we created the window. 2331 be initialized to something relevant to the time we created the window.
2312 */ 2332 */
2313 XChangeProperty (XtDisplay (frame_widget), XtWindow (frame_widget), 2333 XChangeProperty (XtDisplay (frame_widget), XtWindow (frame_widget),
2314 Xatom_wm_protocols, XA_ATOM, 32, PropModeAppend, 2334 FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
2335 XA_ATOM, 32, PropModeAppend,
2315 (unsigned char*) NULL, 0); 2336 (unsigned char*) NULL, 0);
2316 2337
2317 /* Make all the standard events reach the Emacs frame. */ 2338 /* Make all the standard events reach the Emacs frame. */
@@ -2336,7 +2357,7 @@ x_window (f, window_prompting, minibuffer_only)
2336 x_set_name (f, name, explicit); 2357 x_set_name (f, name, explicit);
2337 } 2358 }
2338 2359
2339 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), 2360 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2340 f->display.x->text_cursor); 2361 f->display.x->text_cursor);
2341 2362
2342 UNBLOCK_INPUT; 2363 UNBLOCK_INPUT;
@@ -2371,36 +2392,38 @@ x_window (f)
2371 2392
2372 BLOCK_INPUT; 2393 BLOCK_INPUT;
2373 FRAME_X_WINDOW (f) 2394 FRAME_X_WINDOW (f)
2374 = XCreateWindow (x_current_display, ROOT_WINDOW, 2395 = XCreateWindow (FRAME_X_DISPLAY (f),
2396 FRAME_X_DISPLAY_INFO (f)->root_window,
2375 f->display.x->left_pos, 2397 f->display.x->left_pos,
2376 f->display.x->top_pos, 2398 f->display.x->top_pos,
2377 PIXEL_WIDTH (f), PIXEL_HEIGHT (f), 2399 PIXEL_WIDTH (f), PIXEL_HEIGHT (f),
2378 f->display.x->border_width, 2400 f->display.x->border_width,
2379 CopyFromParent, /* depth */ 2401 CopyFromParent, /* depth */
2380 InputOutput, /* class */ 2402 InputOutput, /* class */
2381 screen_visual, /* set in Fx_open_connection */ 2403 FRAME_X_DISPLAY_INFO (f)->visual,
2382 attribute_mask, &attributes); 2404 attribute_mask, &attributes);
2383 2405
2384 validate_x_resource_name (); 2406 validate_x_resource_name ();
2385 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; 2407 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;
2386 class_hints.res_class = EMACS_CLASS; 2408 class_hints.res_class = EMACS_CLASS;
2387 XSetClassHint (x_current_display, FRAME_X_WINDOW (f), &class_hints); 2409 XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints);
2388 2410
2389 /* This indicates that we use the "Passive Input" input model. 2411 /* This indicates that we use the "Passive Input" input model.
2390 Unless we do this, we don't get the Focus{In,Out} events that we 2412 Unless we do this, we don't get the Focus{In,Out} events that we
2391 need to draw the cursor correctly. Accursed bureaucrats. 2413 need to draw the cursor correctly. Accursed bureaucrats.
2392 XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */ 2414 XWhipsAndChains (FRAME_X_DISPLAY (f), IronMaiden, &TheRack); */
2393 2415
2394 f->display.x->wm_hints.input = True; 2416 f->display.x->wm_hints.input = True;
2395 f->display.x->wm_hints.flags |= InputHint; 2417 f->display.x->wm_hints.flags |= InputHint;
2396 XSetWMHints (x_current_display, FRAME_X_WINDOW (f), &f->display.x->wm_hints); 2418 XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2419 &f->display.x->wm_hints);
2397 2420
2398 /* Request "save yourself" and "delete window" commands from wm. */ 2421 /* Request "save yourself" and "delete window" commands from wm. */
2399 { 2422 {
2400 Atom protocols[2]; 2423 Atom protocols[2];
2401 protocols[0] = Xatom_wm_delete_window; 2424 protocols[0] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window;
2402 protocols[1] = Xatom_wm_save_yourself; 2425 protocols[1] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself;
2403 XSetWMProtocols (x_current_display, FRAME_X_WINDOW (f), protocols, 2); 2426 XSetWMProtocols (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), protocols, 2);
2404 } 2427 }
2405 2428
2406 /* x_set_name normally ignores requests to set the name if the 2429 /* x_set_name normally ignores requests to set the name if the
@@ -2417,7 +2440,7 @@ x_window (f)
2417 x_set_name (f, name, explicit); 2440 x_set_name (f, name, explicit);
2418 } 2441 }
2419 2442
2420 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), 2443 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2421 f->display.x->text_cursor); 2444 f->display.x->text_cursor);
2422 2445
2423 UNBLOCK_INPUT; 2446 UNBLOCK_INPUT;
@@ -2430,7 +2453,7 @@ x_window (f)
2430 2453
2431/* Handle the icon stuff for this window. Perhaps later we might 2454/* Handle the icon stuff for this window. Perhaps later we might
2432 want an x_set_icon_position which can be called interactively as 2455 want an x_set_icon_position which can be called interactively as
2433 well. */ 2456 well. */
2434 2457
2435static void 2458static void
2436x_icon (f, parms) 2459x_icon (f, parms)
@@ -2440,7 +2463,7 @@ x_icon (f, parms)
2440 Lisp_Object icon_x, icon_y; 2463 Lisp_Object icon_x, icon_y;
2441 2464
2442 /* Set the position of the icon. Note that twm groups all 2465 /* Set the position of the icon. Note that twm groups all
2443 icons in an icon window. */ 2466 icons in an icon window. */
2444 icon_x = x_get_arg (parms, Qicon_left, 0, 0, number); 2467 icon_x = x_get_arg (parms, Qicon_left, 0, 0, number);
2445 icon_y = x_get_arg (parms, Qicon_top, 0, 0, number); 2468 icon_y = x_get_arg (parms, Qicon_top, 0, 0, number);
2446 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound)) 2469 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
@@ -2495,16 +2518,16 @@ x_make_gc (f)
2495 gc_values.foreground = f->display.x->foreground_pixel; 2518 gc_values.foreground = f->display.x->foreground_pixel;
2496 gc_values.background = f->display.x->background_pixel; 2519 gc_values.background = f->display.x->background_pixel;
2497 gc_values.line_width = 0; /* Means 1 using fast algorithm. */ 2520 gc_values.line_width = 0; /* Means 1 using fast algorithm. */
2498 f->display.x->normal_gc = XCreateGC (x_current_display, 2521 f->display.x->normal_gc = XCreateGC (FRAME_X_DISPLAY (f),
2499 FRAME_X_WINDOW (f), 2522 FRAME_X_WINDOW (f),
2500 GCLineWidth | GCFont 2523 GCLineWidth | GCFont
2501 | GCForeground | GCBackground, 2524 | GCForeground | GCBackground,
2502 &gc_values); 2525 &gc_values);
2503 2526
2504 /* Reverse video style. */ 2527 /* Reverse video style. */
2505 gc_values.foreground = f->display.x->background_pixel; 2528 gc_values.foreground = f->display.x->background_pixel;
2506 gc_values.background = f->display.x->foreground_pixel; 2529 gc_values.background = f->display.x->foreground_pixel;
2507 f->display.x->reverse_gc = XCreateGC (x_current_display, 2530 f->display.x->reverse_gc = XCreateGC (FRAME_X_DISPLAY (f),
2508 FRAME_X_WINDOW (f), 2531 FRAME_X_WINDOW (f),
2509 GCFont | GCForeground | GCBackground 2532 GCFont | GCForeground | GCBackground
2510 | GCLineWidth, 2533 | GCLineWidth,
@@ -2515,10 +2538,11 @@ x_make_gc (f)
2515 gc_values.background = f->display.x->cursor_pixel; 2538 gc_values.background = f->display.x->cursor_pixel;
2516 gc_values.fill_style = FillOpaqueStippled; 2539 gc_values.fill_style = FillOpaqueStippled;
2517 gc_values.stipple 2540 gc_values.stipple
2518 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, 2541 = XCreateBitmapFromData (FRAME_X_DISPLAY (f),
2542 FRAME_X_DISPLAY_INFO (f)->root_window,
2519 cursor_bits, 16, 16); 2543 cursor_bits, 16, 16);
2520 f->display.x->cursor_gc 2544 f->display.x->cursor_gc
2521 = XCreateGC (x_current_display, FRAME_X_WINDOW (f), 2545 = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2522 (GCFont | GCForeground | GCBackground 2546 (GCFont | GCForeground | GCBackground
2523 | GCFillStyle | GCStipple | GCLineWidth), 2547 | GCFillStyle | GCStipple | GCLineWidth),
2524 &gc_values); 2548 &gc_values);
@@ -2528,11 +2552,12 @@ x_make_gc (f)
2528 this must be done on a per-frame basis. */ 2552 this must be done on a per-frame basis. */
2529 f->display.x->border_tile 2553 f->display.x->border_tile
2530 = (XCreatePixmapFromBitmapData 2554 = (XCreatePixmapFromBitmapData
2531 (x_current_display, ROOT_WINDOW, 2555 (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
2532 gray_bits, gray_width, gray_height, 2556 gray_bits, gray_width, gray_height,
2533 f->display.x->foreground_pixel, 2557 f->display.x->foreground_pixel,
2534 f->display.x->background_pixel, 2558 f->display.x->background_pixel,
2535 DefaultDepth (x_current_display, XDefaultScreen (x_current_display)))); 2559 DefaultDepth (FRAME_X_DISPLAY (f),
2560 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))));
2536 2561
2537 UNBLOCK_INPUT; 2562 UNBLOCK_INPUT;
2538} 2563}
@@ -2557,9 +2582,16 @@ be shared by the new frame.")
2557 int width, height; 2582 int width, height;
2558 int count = specpdl_ptr - specpdl; 2583 int count = specpdl_ptr - specpdl;
2559 struct gcpro gcpro1; 2584 struct gcpro gcpro1;
2585 Lisp_Object display;
2586 struct x_display_info *dpyinfo;
2560 2587
2561 check_x (); 2588 check_x ();
2562 2589
2590 display = x_get_arg (parms, Qdisplay, 0, 0, 0);
2591 if (EQ (display, Qunbound))
2592 display = Qnil;
2593 dpyinfo = check_x_display_info (display);
2594
2563 name = x_get_arg (parms, Qname, "title", "Title", string); 2595 name = x_get_arg (parms, Qname, "title", "Title", string);
2564 if (!STRINGP (name) 2596 if (!STRINGP (name)
2565 && ! EQ (name, Qunbound) 2597 && ! EQ (name, Qunbound)
@@ -2605,9 +2637,8 @@ be shared by the new frame.")
2605 bzero (f->display.x, sizeof (struct x_display)); 2637 bzero (f->display.x, sizeof (struct x_display));
2606 f->display.x->icon_bitmap = -1; 2638 f->display.x->icon_bitmap = -1;
2607 2639
2608 FRAME_X_SCREEN (f) = &the_x_screen; 2640 FRAME_X_DISPLAY_INFO (f) = dpyinfo;
2609 FRAME_X_SCREEN (f)->reference_count++; 2641 FRAME_X_DISPLAY_INFO (f)->reference_count++;
2610 the_x_screen.x_display_value = x_current_display;
2611 2642
2612 /* Note that the frame has no physical cursor right now. */ 2643 /* Note that the frame has no physical cursor right now. */
2613 f->phys_cursor_x = -1; 2644 f->phys_cursor_x = -1;
@@ -2662,7 +2693,7 @@ be shared by the new frame.")
2662 x_default_parameter (f, parms, Qvertical_scroll_bars, Qt, 2693 x_default_parameter (f, parms, Qvertical_scroll_bars, Qt,
2663 "verticalScrollBars", "ScrollBars", boolean); 2694 "verticalScrollBars", "ScrollBars", boolean);
2664 2695
2665 /* Also do the stuff which must be set before the window exists. */ 2696 /* Also do the stuff which must be set before the window exists. */
2666 x_default_parameter (f, parms, Qforeground_color, build_string ("black"), 2697 x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
2667 "foreground", "Foreground", string); 2698 "foreground", "Foreground", string);
2668 x_default_parameter (f, parms, Qbackground_color, build_string ("white"), 2699 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
@@ -2679,7 +2710,7 @@ be shared by the new frame.")
2679 x_default_parameter (f, parms, Qscroll_bar_width, Qnil, 2710 x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
2680 "scrollBarWidth", "ScrollBarWidth", number); 2711 "scrollBarWidth", "ScrollBarWidth", number);
2681 2712
2682 f->display.x->parent_desc = ROOT_WINDOW; 2713 f->display.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
2683 window_prompting = x_figure_window_size (f, parms); 2714 window_prompting = x_figure_window_size (f, parms);
2684 2715
2685 if (window_prompting & XNegative) 2716 if (window_prompting & XNegative)
@@ -2722,7 +2753,7 @@ be shared by the new frame.")
2722 2753
2723 /* Dimensions, especially f->height, must be done via change_frame_size. 2754 /* Dimensions, especially f->height, must be done via change_frame_size.
2724 Change will not be effected unless different from the current 2755 Change will not be effected unless different from the current
2725 f->height. */ 2756 f->height. */
2726 width = f->width; 2757 width = f->width;
2727 height = f->height; 2758 height = f->height;
2728 f->height = f->width = 0; 2759 f->height = f->width = 0;
@@ -2840,10 +2871,8 @@ even if they match PATTERN and FACE.")
2840 CHECK_STRING (pattern, 0); 2871 CHECK_STRING (pattern, 0);
2841 if (!NILP (face)) 2872 if (!NILP (face))
2842 CHECK_SYMBOL (face, 1); 2873 CHECK_SYMBOL (face, 1);
2843 if (!NILP (frame))
2844 CHECK_LIVE_FRAME (frame, 2);
2845 2874
2846 f = NILP (frame) ? selected_frame : XFRAME (frame); 2875 f = check_x_frame (frame);
2847 2876
2848 /* Determine the width standard for comparison with the fonts we find. */ 2877 /* Determine the width standard for comparison with the fonts we find. */
2849 2878
@@ -2871,7 +2900,7 @@ even if they match PATTERN and FACE.")
2871 } 2900 }
2872 2901
2873 /* See if we cached the result for this particular query. */ 2902 /* See if we cached the result for this particular query. */
2874 list = Fassoc (pattern, FRAME_X_SCREEN (f)->font_list_cache); 2903 list = Fassoc (pattern, FRAME_X_DISPLAY_INFO (f)->font_list_cache);
2875 2904
2876 /* We have info in the cache for this PATTERN. */ 2905 /* We have info in the cache for this PATTERN. */
2877 if (!NILP (list)) 2906 if (!NILP (list))
@@ -2892,13 +2921,13 @@ even if they match PATTERN and FACE.")
2892 { 2921 {
2893 XFontStruct *thisinfo; 2922 XFontStruct *thisinfo;
2894 2923
2895 thisinfo = XLoadQueryFont (x_current_display, 2924 thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f),
2896 XSTRING (XCONS (tem)->car)->data); 2925 XSTRING (XCONS (tem)->car)->data);
2897 2926
2898 if (thisinfo && same_size_fonts (thisinfo, size_ref)) 2927 if (thisinfo && same_size_fonts (thisinfo, size_ref))
2899 newlist = Fcons (XCONS (tem)->car, newlist); 2928 newlist = Fcons (XCONS (tem)->car, newlist);
2900 2929
2901 XFreeFont (x_current_display, thisinfo); 2930 XFreeFont (FRAME_X_DISPLAY (f), thisinfo);
2902 } 2931 }
2903 2932
2904 UNBLOCK_INPUT; 2933 UNBLOCK_INPUT;
@@ -2910,12 +2939,12 @@ even if they match PATTERN and FACE.")
2910 2939
2911 /* Solaris 2.3 has a bug in XListFontsWithInfo. */ 2940 /* Solaris 2.3 has a bug in XListFontsWithInfo. */
2912#ifdef BROKEN_XLISTFONTSWITHINFO 2941#ifdef BROKEN_XLISTFONTSWITHINFO
2913 names = XListFonts (x_current_display, 2942 names = XListFonts (FRAME_X_DISPLAY (f),
2914 XSTRING (pattern)->data, 2943 XSTRING (pattern)->data,
2915 2000, /* maxnames */ 2944 2000, /* maxnames */
2916 &num_fonts); /* count_return */ 2945 &num_fonts); /* count_return */
2917#else 2946#else
2918 names = XListFontsWithInfo (x_current_display, 2947 names = XListFontsWithInfo (FRAME_X_DISPLAY (f),
2919 XSTRING (pattern)->data, 2948 XSTRING (pattern)->data,
2920 2000, /* maxnames */ 2949 2000, /* maxnames */
2921 &num_fonts, /* count_return */ 2950 &num_fonts, /* count_return */
@@ -2935,9 +2964,9 @@ even if they match PATTERN and FACE.")
2935 full_list = Qnil; 2964 full_list = Qnil;
2936 for (i = 0; i < num_fonts; i++) 2965 for (i = 0; i < num_fonts; i++)
2937 full_list = Fcons (build_string (names[i]), full_list); 2966 full_list = Fcons (build_string (names[i]), full_list);
2938 FRAME_X_SCREEN (f)->font_list_cache 2967 FRAME_X_DISPLAY_INFO (f)->font_list_cache
2939 = Fcons (Fcons (pattern, full_list), 2968 = Fcons (Fcons (pattern, full_list),
2940 FRAME_X_SCREEN (f)->font_list_cache); 2969 FRAME_X_DISPLAY_INFO (f)->font_list_cache);
2941 2970
2942 /* Make a list of the fonts that have the right width. */ 2971 /* Make a list of the fonts that have the right width. */
2943 list = Qnil; 2972 list = Qnil;
@@ -2947,7 +2976,7 @@ even if they match PATTERN and FACE.")
2947 2976
2948#ifdef BROKEN_XLISTFONTSWITHINFO 2977#ifdef BROKEN_XLISTFONTSWITHINFO
2949 BLOCK_INPUT; 2978 BLOCK_INPUT;
2950 thisinfo = XLoadQueryFont (x_current_display, names[i]); 2979 thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f), names[i]);
2951 UNBLOCK_INPUT; 2980 UNBLOCK_INPUT;
2952#else 2981#else
2953 thisinfo = &info[i]; 2982 thisinfo = &info[i];
@@ -2971,35 +3000,35 @@ even if they match PATTERN and FACE.")
2971} 3000}
2972 3001
2973 3002
2974DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0, 3003DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0,
2975 "Return non-nil if the X display supports the color named COLOR.") 3004 "Return non-nil color COLOR is supported on frame FRAME.")
2976 (color) 3005 (color, frame)
2977 Lisp_Object color; 3006 Lisp_Object color, frame;
2978{ 3007{
2979 Color foo; 3008 XColor foo;
2980 3009 FRAME_PTR f = check_x_frame (frame);
2981 check_x ();
2982 CHECK_STRING (color, 0);
2983 3010
2984 if (defined_color (XSTRING (color)->data, &foo, 0)) 3011 CHECK_STRING (color, 1);
3012
3013 if (defined_color (f, XSTRING (color)->data, &foo, 0))
2985 return Qt; 3014 return Qt;
2986 else 3015 else
2987 return Qnil; 3016 return Qnil;
2988} 3017}
2989 3018
2990DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 1, 0, 3019DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0,
2991 "Return a description of the color named COLOR.\n\ 3020 "Return a description of the color named COLOR on frame FRAME.\n\
2992The value is a list of integer RGB values--(RED GREEN BLUE).\n\ 3021The value is a list of integer RGB values--(RED GREEN BLUE).\n\
2993These values appear to range from 0 to 65280; white is (65280 65280 65280).") 3022These values appear to range from 0 to 65280; white is (65280 65280 65280).")
2994 (color) 3023 (color, frame)
2995 Lisp_Object color; 3024 Lisp_Object color, frame;
2996{ 3025{
2997 Color foo; 3026 XColor foo;
2998 3027 FRAME_PTR f = check_x_frame (frame);
2999 check_x (); 3028
3000 CHECK_STRING (color, 0); 3029 CHECK_STRING (color, 1);
3001 3030
3002 if (defined_color (XSTRING (color)->data, &foo, 0)) 3031 if (defined_color (f, XSTRING (color)->data, &foo, 0))
3003 { 3032 {
3004 Lisp_Object rgb[3]; 3033 Lisp_Object rgb[3];
3005 3034
@@ -3012,16 +3041,17 @@ These values appear to range from 0 to 65280; white is (65280 65280 65280).")
3012 return Qnil; 3041 return Qnil;
3013} 3042}
3014 3043
3015DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 0, 0, 3044DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0,
3016 "Return t if the X screen currently in use supports color.") 3045 "Return t if the X screen FRAME is on supports color.")
3017 () 3046 (frame)
3047 Lisp_Object frame;
3018{ 3048{
3019 check_x (); 3049 struct x_display_info *dpyinfo = check_x_display_info (frame);
3020 3050
3021 if (x_screen_planes <= 2) 3051 if (dpyinfo->n_planes <= 2)
3022 return Qnil; 3052 return Qnil;
3023 3053
3024 switch (screen_visual->class) 3054 switch (dpyinfo->visual->class)
3025 { 3055 {
3026 case StaticColor: 3056 case StaticColor:
3027 case PseudoColor: 3057 case PseudoColor:
@@ -3035,15 +3065,19 @@ DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 0, 0,
3035} 3065}
3036 3066
3037DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, 3067DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
3038 0, 0, 0, 3068 0, 1, 0,
3039 "Return t if the X screen currently in use supports grayscale.") 3069 "Return t if the X screen FRAME is on supports grayscale.")
3040 () 3070 (frame)
3071 Lisp_Object frame;
3041{ 3072{
3042 check_x (); 3073 struct x_display_info *dpyinfo = check_x_display_info (frame);
3043 3074
3044 return (x_screen_planes > 1 3075 if (dpyinfo->n_planes <= 2)
3045 && (screen_visual->class == StaticGray 3076 return Qnil;
3046 || screen_visual->class == GrayScale)); 3077
3078 return (dpyinfo->n_planes > 1
3079 && (dpyinfo->visual->class == StaticGray
3080 || dpyinfo->visual->class == GrayScale));
3047} 3081}
3048 3082
3049DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 3083DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
@@ -3052,9 +3086,9 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
3052 (frame) 3086 (frame)
3053 Lisp_Object frame; 3087 Lisp_Object frame;
3054{ 3088{
3055 Display *dpy = x_current_display; 3089 struct x_display_info *dpyinfo = check_x_display_info (frame);
3056 check_x (); 3090
3057 return make_number (DisplayWidth (dpy, DefaultScreen (dpy))); 3091 return make_number (dpyinfo->width);
3058} 3092}
3059 3093
3060DEFUN ("x-display-pixel-height", Fx_display_pixel_height, 3094DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
@@ -3063,9 +3097,9 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
3063 (frame) 3097 (frame)
3064 Lisp_Object frame; 3098 Lisp_Object frame;
3065{ 3099{
3066 Display *dpy = x_current_display; 3100 struct x_display_info *dpyinfo = check_x_display_info (frame);
3067 check_x (); 3101
3068 return make_number (DisplayHeight (dpy, DefaultScreen (dpy))); 3102 return make_number (dpyinfo->height);
3069} 3103}
3070 3104
3071DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 3105DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
@@ -3074,9 +3108,9 @@ DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
3074 (frame) 3108 (frame)
3075 Lisp_Object frame; 3109 Lisp_Object frame;
3076{ 3110{
3077 Display *dpy = x_current_display; 3111 struct x_display_info *dpyinfo = check_x_display_info (frame);
3078 check_x (); 3112
3079 return make_number (DisplayPlanes (dpy, DefaultScreen (dpy))); 3113 return make_number (dpyinfo->n_planes);
3080} 3114}
3081 3115
3082DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 3116DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
@@ -3085,9 +3119,10 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
3085 (frame) 3119 (frame)
3086 Lisp_Object frame; 3120 Lisp_Object frame;
3087{ 3121{
3088 Display *dpy = x_current_display; 3122 struct x_display_info *dpyinfo = check_x_display_info (frame);
3089 check_x (); 3123
3090 return make_number (DisplayCells (dpy, DefaultScreen (dpy))); 3124 return make_number (DisplayCells (dpyinfo->display,
3125 XScreenNumberOfScreen (dpyinfo->screen)));
3091} 3126}
3092 3127
3093DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 3128DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
@@ -3097,9 +3132,9 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
3097 (frame) 3132 (frame)
3098 Lisp_Object frame; 3133 Lisp_Object frame;
3099{ 3134{
3100 Display *dpy = x_current_display; 3135 struct x_display_info *dpyinfo = check_x_display_info (frame);
3101 check_x (); 3136
3102 return make_number (MAXREQUEST (dpy)); 3137 return make_number (MAXREQUEST (dpyinfo->display));
3103} 3138}
3104 3139
3105DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 3140DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
@@ -3107,10 +3142,9 @@ DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
3107 (frame) 3142 (frame)
3108 Lisp_Object frame; 3143 Lisp_Object frame;
3109{ 3144{
3110 Display *dpy = x_current_display; 3145 struct x_display_info *dpyinfo = check_x_display_info (frame);
3111 char *vendor; 3146 char *vendor = ServerVendor (dpyinfo->display);
3112 check_x (); 3147
3113 vendor = ServerVendor (dpy);
3114 if (! vendor) vendor = ""; 3148 if (! vendor) vendor = "";
3115 return build_string (vendor); 3149 return build_string (vendor);
3116} 3150}
@@ -3123,9 +3157,9 @@ number. See also the variable `x-server-vendor'.")
3123 (frame) 3157 (frame)
3124 Lisp_Object frame; 3158 Lisp_Object frame;
3125{ 3159{
3126 Display *dpy = x_current_display; 3160 struct x_display_info *dpyinfo = check_x_display_info (frame);
3161 Display *dpy = dpyinfo->display;
3127 3162
3128 check_x ();
3129 return Fcons (make_number (ProtocolVersion (dpy)), 3163 return Fcons (make_number (ProtocolVersion (dpy)),
3130 Fcons (make_number (ProtocolRevision (dpy)), 3164 Fcons (make_number (ProtocolRevision (dpy)),
3131 Fcons (make_number (VendorRelease (dpy)), Qnil))); 3165 Fcons (make_number (VendorRelease (dpy)), Qnil)));
@@ -3136,8 +3170,9 @@ DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
3136 (frame) 3170 (frame)
3137 Lisp_Object frame; 3171 Lisp_Object frame;
3138{ 3172{
3139 check_x (); 3173 struct x_display_info *dpyinfo = check_x_display_info (frame);
3140 return make_number (ScreenCount (x_current_display)); 3174
3175 return make_number (ScreenCount (dpyinfo->display));
3141} 3176}
3142 3177
3143DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0, 3178DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
@@ -3145,8 +3180,9 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1,
3145 (frame) 3180 (frame)
3146 Lisp_Object frame; 3181 Lisp_Object frame;
3147{ 3182{
3148 check_x (); 3183 struct x_display_info *dpyinfo = check_x_display_info (frame);
3149 return make_number (HeightMMOfScreen (x_screen)); 3184
3185 return make_number (HeightMMOfScreen (dpyinfo->screen));
3150} 3186}
3151 3187
3152DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 3188DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -3154,8 +3190,9 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
3154 (frame) 3190 (frame)
3155 Lisp_Object frame; 3191 Lisp_Object frame;
3156{ 3192{
3157 check_x (); 3193 struct x_display_info *dpyinfo = check_x_display_info (frame);
3158 return make_number (WidthMMOfScreen (x_screen)); 3194
3195 return make_number (WidthMMOfScreen (dpyinfo->screen));
3159} 3196}
3160 3197
3161DEFUN ("x-display-backing-store", Fx_display_backing_store, 3198DEFUN ("x-display-backing-store", Fx_display_backing_store,
@@ -3165,9 +3202,9 @@ The value may be `always', `when-mapped', or `not-useful'.")
3165 (frame) 3202 (frame)
3166 Lisp_Object frame; 3203 Lisp_Object frame;
3167{ 3204{
3168 check_x (); 3205 struct x_display_info *dpyinfo = check_x_display_info (frame);
3169 3206
3170 switch (DoesBackingStore (x_screen)) 3207 switch (DoesBackingStore (dpyinfo->screen))
3171 { 3208 {
3172 case Always: 3209 case Always:
3173 return intern ("always"); 3210 return intern ("always");
@@ -3185,15 +3222,15 @@ The value may be `always', `when-mapped', or `not-useful'.")
3185 3222
3186DEFUN ("x-display-visual-class", Fx_display_visual_class, 3223DEFUN ("x-display-visual-class", Fx_display_visual_class,
3187 Sx_display_visual_class, 0, 1, 0, 3224 Sx_display_visual_class, 0, 1, 0,
3188 "Returns the visual class of the display `screen' is on.\n\ 3225 "Returns the visual class of the display FRAME is on.\n\
3189The value is one of the symbols `static-gray', `gray-scale',\n\ 3226The value is one of the symbols `static-gray', `gray-scale',\n\
3190`static-color', `pseudo-color', `true-color', or `direct-color'.") 3227`static-color', `pseudo-color', `true-color', or `direct-color'.")
3191 (screen) 3228 (frame)
3192 Lisp_Object screen; 3229 Lisp_Object frame;
3193{ 3230{
3194 check_x (); 3231 struct x_display_info *dpyinfo = check_x_display_info (frame);
3195 3232
3196 switch (screen_visual->class) 3233 switch (dpyinfo->visual->class)
3197 { 3234 {
3198 case StaticGray: return (intern ("static-gray")); 3235 case StaticGray: return (intern ("static-gray"));
3199 case GrayScale: return (intern ("gray-scale")); 3236 case GrayScale: return (intern ("gray-scale"));
@@ -3212,43 +3249,54 @@ DEFUN ("x-display-save-under", Fx_display_save_under,
3212 (frame) 3249 (frame)
3213 Lisp_Object frame; 3250 Lisp_Object frame;
3214{ 3251{
3215 check_x (); 3252 struct x_display_info *dpyinfo = check_x_display_info (frame);
3216 3253
3217 if (DoesSaveUnders (x_screen) == True) 3254 if (DoesSaveUnders (dpyinfo->screen) == True)
3218 return Qt; 3255 return Qt;
3219 else 3256 else
3220 return Qnil; 3257 return Qnil;
3221} 3258}
3222 3259
3260int
3223x_pixel_width (f) 3261x_pixel_width (f)
3224 register struct frame *f; 3262 register struct frame *f;
3225{ 3263{
3226 return PIXEL_WIDTH (f); 3264 return PIXEL_WIDTH (f);
3227} 3265}
3228 3266
3267int
3229x_pixel_height (f) 3268x_pixel_height (f)
3230 register struct frame *f; 3269 register struct frame *f;
3231{ 3270{
3232 return PIXEL_HEIGHT (f); 3271 return PIXEL_HEIGHT (f);
3233} 3272}
3234 3273
3274int
3235x_char_width (f) 3275x_char_width (f)
3236 register struct frame *f; 3276 register struct frame *f;
3237{ 3277{
3238 return FONT_WIDTH (f->display.x->font); 3278 return FONT_WIDTH (f->display.x->font);
3239} 3279}
3240 3280
3281int
3241x_char_height (f) 3282x_char_height (f)
3242 register struct frame *f; 3283 register struct frame *f;
3243{ 3284{
3244 return f->display.x->line_height; 3285 return f->display.x->line_height;
3245} 3286}
3287
3288int
3289x_screen_planes (frame)
3290 Lisp_Object frame;
3291{
3292 return FRAME_X_DISPLAY_INFO (XFRAME (frame))->n_planes;
3293}
3246 3294
3247#if 0 /* These no longer seem like the right way to do things. */ 3295#if 0 /* These no longer seem like the right way to do things. */
3248 3296
3249/* Draw a rectangle on the frame with left top corner including 3297/* Draw a rectangle on the frame with left top corner including
3250 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is 3298 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
3251 CHARS by LINES wide and long and is the color of the cursor. */ 3299 CHARS by LINES wide and long and is the color of the cursor. */
3252 3300
3253void 3301void
3254x_rectangle (f, gc, left_char, top_char, chars, lines) 3302x_rectangle (f, gc, left_char, top_char, chars, lines)
@@ -3272,7 +3320,7 @@ x_rectangle (f, gc, left_char, top_char, chars, lines)
3272 else 3320 else
3273 height = f->display.x->line_height * lines; 3321 height = f->display.x->line_height * lines;
3274 3322
3275 XDrawRectangle (x_current_display, FRAME_X_WINDOW (f), 3323 XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3276 gc, left, top, width, height); 3324 gc, left, top, width, height);
3277} 3325}
3278 3326
@@ -3333,7 +3381,7 @@ X0, Y0, X1, Y1 in the regular background-pixel.")
3333{ 3381{
3334 register int x0, y0, x1, y1, top, left, n_chars, n_lines; 3382 register int x0, y0, x1, y1, top, left, n_chars, n_lines;
3335 3383
3336 CHECK_FRAME (frame, 0); 3384 CHECK_LIVE_FRAME (frame, 0);
3337 CHECK_NUMBER (X0, 0); 3385 CHECK_NUMBER (X0, 0);
3338 CHECK_NUMBER (Y0, 1); 3386 CHECK_NUMBER (Y0, 1);
3339 CHECK_NUMBER (X1, 2); 3387 CHECK_NUMBER (X1, 2);
@@ -3376,7 +3424,7 @@ X0, Y0, X1, Y1 in the regular background-pixel.")
3376 3424
3377/* Draw lines around the text region beginning at the character position 3425/* Draw lines around the text region beginning at the character position
3378 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the 3426 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
3379 pixel and line characteristics. */ 3427 pixel and line characteristics. */
3380 3428
3381#define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)]) 3429#define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
3382 3430
@@ -3402,7 +3450,7 @@ outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
3402 this_point->y = ibw + (font_h * top_y); 3450 this_point->y = ibw + (font_h * top_y);
3403 this_point++; 3451 this_point++;
3404 if (x == 0) 3452 if (x == 0)
3405 this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */ 3453 this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */
3406 else 3454 else
3407 this_point->x = ibw + (font_w * x); 3455 this_point->x = ibw + (font_w * x);
3408 this_point->y = (this_point - 1)->y; 3456 this_point->y = (this_point - 1)->y;
@@ -3422,7 +3470,7 @@ outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
3422 this_point->y = (this_point - 1)->y; 3470 this_point->y = (this_point - 1)->y;
3423 } 3471 }
3424 3472
3425 /* Now do the right side. */ 3473 /* Now do the right side. */
3426 while (y < bottom_y) 3474 while (y < bottom_y)
3427 { /* Right vertical edge */ 3475 { /* Right vertical edge */
3428 this_point++; 3476 this_point++;
@@ -3440,7 +3488,7 @@ outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
3440 this_point->y = (this_point - 1)->y; 3488 this_point->y = (this_point - 1)->y;
3441 } 3489 }
3442 3490
3443 /* Now do the bottom and connect to the top left point. */ 3491 /* Now do the bottom and connect to the top left point. */
3444 this_point->x = ibw + (font_w * (bottom_x + 1)); 3492 this_point->x = ibw + (font_w * (bottom_x + 1));
3445 3493
3446 this_point++; 3494 this_point++;
@@ -3453,7 +3501,7 @@ outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
3453 this_point->x = pixel_points->x; 3501 this_point->x = pixel_points->x;
3454 this_point->y = pixel_points->y; 3502 this_point->y = pixel_points->y;
3455 3503
3456 XDrawLines (x_current_display, FRAME_X_WINDOW (f), 3504 XDrawLines (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3457 gc, pixel_points, 3505 gc, pixel_points,
3458 (this_point - pixel_points + 1), CoordModeOrigin); 3506 (this_point - pixel_points + 1), CoordModeOrigin);
3459} 3507}
@@ -3474,8 +3522,8 @@ selected frame.")
3474 x0 = XINT (Fcar (Fcar (event))); 3522 x0 = XINT (Fcar (Fcar (event)));
3475 y0 = XINT (Fcar (Fcdr (Fcar (event)))); 3523 y0 = XINT (Fcar (Fcdr (Fcar (event))));
3476 3524
3477 /* If the mouse is past the end of the line, don't that area. */ 3525 /* If the mouse is past the end of the line, don't that area. */
3478 /* ReWrite this... */ 3526 /* ReWrite this... */
3479 3527
3480 x1 = f->cursor_x; 3528 x1 = f->cursor_x;
3481 y1 = f->cursor_y; 3529 y1 = f->cursor_y;
@@ -3496,7 +3544,7 @@ selected frame.")
3496 x1, y1, (x0 - x1 + 1), 1); 3544 x1, y1, (x0 - x1 + 1), 1);
3497 } 3545 }
3498 3546
3499 XFlush (x_current_display); 3547 XFlush (FRAME_X_DISPLAY (f));
3500 UNBLOCK_INPUT; 3548 UNBLOCK_INPUT;
3501 3549
3502 return Qnil; 3550 return Qnil;
@@ -3544,7 +3592,7 @@ int contour_npoints;
3544 3592
3545/* Clip the top part of the contour lines down (and including) line Y_POS. 3593/* Clip the top part of the contour lines down (and including) line Y_POS.
3546 If X_POS is in the middle (rather than at the end) of the line, drop 3594 If X_POS is in the middle (rather than at the end) of the line, drop
3547 down a line at that character. */ 3595 down a line at that character. */
3548 3596
3549static void 3597static void
3550clip_contour_top (y_pos, x_pos) 3598clip_contour_top (y_pos, x_pos)
@@ -3554,7 +3602,7 @@ clip_contour_top (y_pos, x_pos)
3554 register int npoints; 3602 register int npoints;
3555 register struct display_line *line = selected_frame->phys_lines[y_pos + 1]; 3603 register struct display_line *line = selected_frame->phys_lines[y_pos + 1];
3556 3604
3557 if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */ 3605 if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */
3558 { 3606 {
3559 end = contour_lines[y_pos].top_right; 3607 end = contour_lines[y_pos].top_right;
3560 npoints = (end - begin + 1); 3608 npoints = (end - begin + 1);
@@ -3567,7 +3615,7 @@ clip_contour_top (y_pos, x_pos)
3567 contour_erase_gc, begin, 2, CoordModeOrigin); 3615 contour_erase_gc, begin, 2, CoordModeOrigin);
3568 XFlush (x_current_display); 3616 XFlush (x_current_display);
3569 3617
3570 /* Now, update contour_lines structure. */ 3618 /* Now, update contour_lines structure. */
3571 } 3619 }
3572 /* ______. */ 3620 /* ______. */
3573 else /* |________*/ 3621 else /* |________*/
@@ -3589,12 +3637,12 @@ clip_contour_top (y_pos, x_pos)
3589 contour_erase_gc, begin, 4, CoordModeOrigin); 3637 contour_erase_gc, begin, 4, CoordModeOrigin);
3590 XFlush (x_current_display); 3638 XFlush (x_current_display);
3591 3639
3592 /* Now, update contour_lines structure. */ 3640 /* Now, update contour_lines structure. */
3593 } 3641 }
3594} 3642}
3595 3643
3596/* Erase the top horizontal lines of the contour, and then extend 3644/* Erase the top horizontal lines of the contour, and then extend
3597 the contour upwards. */ 3645 the contour upwards. */
3598 3646
3599static void 3647static void
3600extend_contour_top (line) 3648extend_contour_top (line)
@@ -3648,7 +3696,7 @@ DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
3648 3696
3649 if (mouse_below_point) 3697 if (mouse_below_point)
3650 { 3698 {
3651 if (x_mouse_y <= point_y) /* Flipped. */ 3699 if (x_mouse_y <= point_y) /* Flipped. */
3652 { 3700 {
3653 mouse_below_point = 0; 3701 mouse_below_point = 0;
3654 3702
@@ -3657,11 +3705,11 @@ DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
3657 outline_region (f, f->display.x->cursor_gc, x_mouse_x, x_mouse_y, 3705 outline_region (f, f->display.x->cursor_gc, x_mouse_x, x_mouse_y,
3658 point_x, point_y); 3706 point_x, point_y);
3659 } 3707 }
3660 else if (x_mouse_y < x_contour_y) /* Bottom clipped. */ 3708 else if (x_mouse_y < x_contour_y) /* Bottom clipped. */
3661 { 3709 {
3662 clip_contour_bottom (x_mouse_y); 3710 clip_contour_bottom (x_mouse_y);
3663 } 3711 }
3664 else if (x_mouse_y > x_contour_y) /* Bottom extended. */ 3712 else if (x_mouse_y > x_contour_y) /* Bottom extended. */
3665 { 3713 {
3666 extend_bottom_contour (x_mouse_y); 3714 extend_bottom_contour (x_mouse_y);
3667 } 3715 }
@@ -3671,7 +3719,7 @@ DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
3671 } 3719 }
3672 else /* mouse above or same line as point */ 3720 else /* mouse above or same line as point */
3673 { 3721 {
3674 if (x_mouse_y >= point_y) /* Flipped. */ 3722 if (x_mouse_y >= point_y) /* Flipped. */
3675 { 3723 {
3676 mouse_below_point = 1; 3724 mouse_below_point = 1;
3677 3725
@@ -3680,11 +3728,11 @@ DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
3680 outline_region (f, f->display.x->cursor_gc, point_x, point_y, 3728 outline_region (f, f->display.x->cursor_gc, point_x, point_y,
3681 x_mouse_x, x_mouse_y); 3729 x_mouse_x, x_mouse_y);
3682 } 3730 }
3683 else if (x_mouse_y > x_contour_y) /* Top clipped. */ 3731 else if (x_mouse_y > x_contour_y) /* Top clipped. */
3684 { 3732 {
3685 clip_contour_top (x_mouse_y); 3733 clip_contour_top (x_mouse_y);
3686 } 3734 }
3687 else if (x_mouse_y < x_contour_y) /* Top extended. */ 3735 else if (x_mouse_y < x_contour_y) /* Top extended. */
3688 { 3736 {
3689 extend_contour_top (x_mouse_y); 3737 extend_contour_top (x_mouse_y);
3690 } 3738 }
@@ -3743,18 +3791,18 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
3743 gc_values.cap_style = CapRound; 3791 gc_values.cap_style = CapRound;
3744 gc_values.join_style = JoinRound; 3792 gc_values.join_style = JoinRound;
3745 3793
3746 line_gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), 3794 line_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3747 GCLineStyle | GCJoinStyle | GCCapStyle 3795 GCLineStyle | GCJoinStyle | GCCapStyle
3748 | GCLineWidth | GCForeground | GCBackground, 3796 | GCLineWidth | GCForeground | GCBackground,
3749 &gc_values); 3797 &gc_values);
3750 XSetDashes (x_current_display, line_gc, 0, dash_list, dashes); 3798 XSetDashes (FRAME_X_DISPLAY (f), line_gc, 0, dash_list, dashes);
3751 gc_values.foreground = f->display.x->background_pixel; 3799 gc_values.foreground = f->display.x->background_pixel;
3752 gc_values.background = f->display.x->foreground_pixel; 3800 gc_values.background = f->display.x->foreground_pixel;
3753 erase_gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), 3801 erase_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3754 GCLineStyle | GCJoinStyle | GCCapStyle 3802 GCLineStyle | GCJoinStyle | GCCapStyle
3755 | GCLineWidth | GCForeground | GCBackground, 3803 | GCLineWidth | GCForeground | GCBackground,
3756 &gc_values); 3804 &gc_values);
3757 XSetDashes (x_current_display, erase_gc, 0, dash_list, dashes); 3805 XSetDashes (FRAME_X_DISPLAY (f), erase_gc, 0, dash_list, dashes);
3758#endif 3806#endif
3759 3807
3760 while (1) 3808 while (1)
@@ -3766,10 +3814,10 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
3766 previous_y = x_mouse_y; 3814 previous_y = x_mouse_y;
3767 line = (x_mouse_y + 1) * f->display.x->line_height 3815 line = (x_mouse_y + 1) * f->display.x->line_height
3768 + f->display.x->internal_border_width; 3816 + f->display.x->internal_border_width;
3769 XDrawLine (x_current_display, FRAME_X_WINDOW (f), 3817 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3770 line_gc, left, line, right, line); 3818 line_gc, left, line, right, line);
3771 } 3819 }
3772 XFlushQueue (); 3820 XFlush (FRAME_X_DISPLAY (f));
3773 UNBLOCK_INPUT; 3821 UNBLOCK_INPUT;
3774 3822
3775 do 3823 do
@@ -3781,13 +3829,13 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
3781 || x_mouse_grabbed) 3829 || x_mouse_grabbed)
3782 { 3830 {
3783 BLOCK_INPUT; 3831 BLOCK_INPUT;
3784 XDrawLine (x_current_display, FRAME_X_WINDOW (f), 3832 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3785 erase_gc, left, line, right, line); 3833 erase_gc, left, line, right, line);
3786 UNBLOCK_INPUT; 3834 UNBLOCK_INPUT;
3787 unread_command_event = obj; 3835 unread_command_event = obj;
3788#if 0 3836#if 0
3789 XFreeGC (x_current_display, line_gc); 3837 XFreeGC (FRAME_X_DISPLAY (f), line_gc);
3790 XFreeGC (x_current_display, erase_gc); 3838 XFreeGC (FRAME_X_DISPLAY (f), erase_gc);
3791#endif 3839#endif
3792 return Qnil; 3840 return Qnil;
3793 } 3841 }
@@ -3795,20 +3843,20 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
3795 while (x_mouse_y == previous_y); 3843 while (x_mouse_y == previous_y);
3796 3844
3797 BLOCK_INPUT; 3845 BLOCK_INPUT;
3798 XDrawLine (x_current_display, FRAME_X_WINDOW (f), 3846 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3799 erase_gc, left, line, right, line); 3847 erase_gc, left, line, right, line);
3800 UNBLOCK_INPUT; 3848 UNBLOCK_INPUT;
3801 } 3849 }
3802} 3850}
3803#endif 3851#endif
3804 3852
3805/* Offset in buffer of character under the pointer, or 0. */
3806int mouse_buffer_offset;
3807
3808#if 0 3853#if 0
3809/* These keep track of the rectangle following the pointer. */ 3854/* These keep track of the rectangle following the pointer. */
3810int mouse_track_top, mouse_track_left, mouse_track_width; 3855int mouse_track_top, mouse_track_left, mouse_track_width;
3811 3856
3857/* Offset in buffer of character under the pointer, or 0. */
3858int mouse_buffer_offset;
3859
3812DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0, 3860DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
3813 "Track the pointer.") 3861 "Track the pointer.")
3814 () 3862 ()
@@ -3824,7 +3872,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
3824 struct buffer *buf; 3872 struct buffer *buf;
3825 3873
3826 current_pointer_shape = f->display.x->nontext_cursor; 3874 current_pointer_shape = f->display.x->nontext_cursor;
3827 XDefineCursor (x_current_display, 3875 XDefineCursor (FRAME_X_DISPLAY (f),
3828 FRAME_X_WINDOW (f), 3876 FRAME_X_WINDOW (f),
3829 current_pointer_shape); 3877 current_pointer_shape);
3830 3878
@@ -3835,12 +3883,12 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
3835 && (current_pointer_shape != f->display.x->modeline_cursor)) 3883 && (current_pointer_shape != f->display.x->modeline_cursor))
3836 { 3884 {
3837 current_pointer_shape = f->display.x->modeline_cursor; 3885 current_pointer_shape = f->display.x->modeline_cursor;
3838 XDefineCursor (x_current_display, 3886 XDefineCursor (FRAME_X_DISPLAY (f),
3839 FRAME_X_WINDOW (f), 3887 FRAME_X_WINDOW (f),
3840 current_pointer_shape); 3888 current_pointer_shape);
3841 } 3889 }
3842 3890
3843 XFlushQueue (); 3891 XFlush (FRAME_X_DISPLAY (f));
3844 UNBLOCK_INPUT; 3892 UNBLOCK_INPUT;
3845} 3893}
3846#endif 3894#endif
@@ -3889,7 +3937,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
3889 if (! FRAME_CURRENT_GLYPHS (f)->enable[x_mouse_y]) 3937 if (! FRAME_CURRENT_GLYPHS (f)->enable[x_mouse_y])
3890 break; 3938 break;
3891 3939
3892 /* Erase previous rectangle. */ 3940 /* Erase previous rectangle. */
3893 if (mouse_track_width) 3941 if (mouse_track_width)
3894 { 3942 {
3895 x_rectangle (f, f->display.x->reverse_gc, 3943 x_rectangle (f, f->display.x->reverse_gc,
@@ -3908,7 +3956,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
3908 mouse_track_top = x_mouse_y; 3956 mouse_track_top = x_mouse_y;
3909 mouse_track_width = 0; 3957 mouse_track_width = 0;
3910 3958
3911 if (mouse_track_left > len) /* Past the end of line. */ 3959 if (mouse_track_left > len) /* Past the end of line. */
3912 goto draw_or_not; 3960 goto draw_or_not;
3913 3961
3914 if (mouse_track_top == mode_line_vpos) 3962 if (mouse_track_top == mode_line_vpos)
@@ -3968,9 +4016,9 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
3968 while (hp <= x_mouse_x); 4016 while (hp <= x_mouse_x);
3969 4017
3970 draw_or_not: 4018 draw_or_not:
3971 if (mouse_track_width) /* Over text; use text pointer shape. */ 4019 if (mouse_track_width) /* Over text; use text pointer shape. */
3972 { 4020 {
3973 XDefineCursor (x_current_display, 4021 XDefineCursor (FRAME_X_DISPLAY (f),
3974 FRAME_X_WINDOW (f), 4022 FRAME_X_WINDOW (f),
3975 f->display.x->text_cursor); 4023 f->display.x->text_cursor);
3976 x_rectangle (f, f->display.x->cursor_gc, 4024 x_rectangle (f, f->display.x->cursor_gc,
@@ -3978,16 +4026,16 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
3978 mouse_track_width, 1); 4026 mouse_track_width, 1);
3979 } 4027 }
3980 else if (in_mode_line) 4028 else if (in_mode_line)
3981 XDefineCursor (x_current_display, 4029 XDefineCursor (FRAME_X_DISPLAY (f),
3982 FRAME_X_WINDOW (f), 4030 FRAME_X_WINDOW (f),
3983 f->display.x->modeline_cursor); 4031 f->display.x->modeline_cursor);
3984 else 4032 else
3985 XDefineCursor (x_current_display, 4033 XDefineCursor (FRAME_X_DISPLAY (f),
3986 FRAME_X_WINDOW (f), 4034 FRAME_X_WINDOW (f),
3987 f->display.x->nontext_cursor); 4035 f->display.x->nontext_cursor);
3988 } 4036 }
3989 4037
3990 XFlush (x_current_display); 4038 XFlush (FRAME_X_DISPLAY (f));
3991 UNBLOCK_INPUT; 4039 UNBLOCK_INPUT;
3992 4040
3993 obj = read_char (-1, 0, 0, Qnil, 0); 4041 obj = read_char (-1, 0, 0, Qnil, 0);
@@ -4014,10 +4062,10 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
4014 x_display_cursor (f, 1); 4062 x_display_cursor (f, 1);
4015 } 4063 }
4016 } 4064 }
4017 XDefineCursor (x_current_display, 4065 XDefineCursor (FRAME_X_DISPLAY (f),
4018 FRAME_X_WINDOW (f), 4066 FRAME_X_WINDOW (f),
4019 f->display.x->nontext_cursor); 4067 f->display.x->nontext_cursor);
4020 XFlush (x_current_display); 4068 XFlush (FRAME_X_DISPLAY (f));
4021 UNBLOCK_INPUT; 4069 UNBLOCK_INPUT;
4022 4070
4023 return Qnil; 4071 return Qnil;
@@ -4028,7 +4076,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
4028#include "glyphs.h" 4076#include "glyphs.h"
4029 4077
4030/* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT 4078/* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
4031 on the frame F at position X, Y. */ 4079 on the frame F at position X, Y. */
4032 4080
4033x_draw_pixmap (f, x, y, image_data, width, height) 4081x_draw_pixmap (f, x, y, image_data, width, height)
4034 struct frame *f; 4082 struct frame *f;
@@ -4037,10 +4085,10 @@ x_draw_pixmap (f, x, y, image_data, width, height)
4037{ 4085{
4038 Pixmap image; 4086 Pixmap image;
4039 4087
4040 image = XCreateBitmapFromData (x_current_display, 4088 image = XCreateBitmapFromData (FRAME_X_DISPLAY (f),
4041 FRAME_X_WINDOW (f), image_data, 4089 FRAME_X_WINDOW (f), image_data,
4042 width, height); 4090 width, height);
4043 XCopyPlane (x_current_display, image, FRAME_X_WINDOW (f), 4091 XCopyPlane (FRAME_X_DISPLAY (f), image, FRAME_X_WINDOW (f),
4044 f->display.x->normal_gc, 0, 0, width, height, x, y); 4092 f->display.x->normal_gc, 0, 0, width, height, x, y);
4045} 4093}
4046#endif 4094#endif
@@ -4167,7 +4215,8 @@ XScreenNumberOfScreen (scr)
4167#endif /* not HAVE_XSCREENNUMBEROFSCREEN */ 4215#endif /* not HAVE_XSCREENNUMBEROFSCREEN */
4168 4216
4169Visual * 4217Visual *
4170select_visual (screen, depth) 4218select_visual (dpy, screen, depth)
4219 Display *dpy;
4171 Screen *screen; 4220 Screen *screen;
4172 unsigned int *depth; 4221 unsigned int *depth;
4173{ 4222{
@@ -4185,7 +4234,7 @@ select_visual (screen, depth)
4185 4234
4186 vinfo_template.screen = XScreenNumberOfScreen (screen); 4235 vinfo_template.screen = XScreenNumberOfScreen (screen);
4187 4236
4188 vinfo = XGetVisualInfo (x_current_display, 4237 vinfo = XGetVisualInfo (dpy,
4189 VisualIDMask | VisualScreenMask, &vinfo_template, 4238 VisualIDMask | VisualScreenMask, &vinfo_template,
4190 &n_visuals); 4239 &n_visuals);
4191 if (n_visuals != 1) 4240 if (n_visuals != 1)
@@ -4209,6 +4258,36 @@ select_visual (screen, depth)
4209 return v; 4258 return v;
4210} 4259}
4211 4260
4261/* Return the X display structure for the display named NAME.
4262 Open a new connection if necessary. */
4263
4264struct x_display_info *
4265x_display_info_for_name (name)
4266 Lisp_Object name;
4267{
4268 struct x_display_info *dpyinfo;
4269
4270 CHECK_STRING (name, 0);
4271
4272 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
4273 {
4274 Lisp_Object tem;
4275 tem = Fstring_equal (dpyinfo->name, name);
4276 if (!NILP (name))
4277 return dpyinfo;
4278 }
4279
4280 validate_x_resource_name ();
4281
4282 dpyinfo = x_term_init (name, (unsigned char *)0,
4283 XSTRING (Vx_resource_name)->data);
4284
4285 x_in_use = 1;
4286 XSETFASTINT (Vwindow_system_version, 11);
4287
4288 return dpyinfo;
4289}
4290
4212DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, 4291DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
4213 1, 2, 0, "Open a connection to an X server.\n\ 4292 1, 2, 0, "Open a connection to an X server.\n\
4214DISPLAY is the name of the display to connect to.\n\ 4293DISPLAY is the name of the display to connect to.\n\
@@ -4218,10 +4297,9 @@ Optional second arg XRM_STRING is a string of resources in xrdb format.")
4218{ 4297{
4219 unsigned int n_planes; 4298 unsigned int n_planes;
4220 unsigned char *xrm_option; 4299 unsigned char *xrm_option;
4300 struct x_display_info *dpyinfo;
4221 4301
4222 CHECK_STRING (display, 0); 4302 CHECK_STRING (display, 0);
4223 if (x_current_display != 0)
4224 error ("X server connection is already initialized");
4225 if (! NILP (xrm_string)) 4303 if (! NILP (xrm_string))
4226 CHECK_STRING (xrm_string, 1); 4304 CHECK_STRING (xrm_string, 1);
4227 4305
@@ -4233,118 +4311,79 @@ Optional second arg XRM_STRING is a string of resources in xrdb format.")
4233 validate_x_resource_name (); 4311 validate_x_resource_name ();
4234 4312
4235 /* This is what opens the connection and sets x_current_display. 4313 /* This is what opens the connection and sets x_current_display.
4236 This also initializes many symbols, such as those used for input. */ 4314 This also initializes many symbols, such as those used for input. */
4237 x_term_init (XSTRING (display)->data, xrm_option, 4315 dpyinfo = x_term_init (display, xrm_option,
4238 XSTRING (Vx_resource_name)->data); 4316 XSTRING (Vx_resource_name)->data);
4239
4240 XSETFASTINT (Vwindow_system_version, 11);
4241
4242 BLOCK_INPUT;
4243 xrdb = x_load_resources (x_current_display, xrm_option,
4244 (char *) XSTRING (Vx_resource_name)->data,
4245 EMACS_CLASS);
4246 UNBLOCK_INPUT;
4247#ifdef HAVE_XRMSETDATABASE
4248 XrmSetDatabase (x_current_display, xrdb);
4249#else
4250 x_current_display->db = xrdb;
4251#endif
4252
4253 the_x_screen.name = display;
4254 4317
4255 x_screen = DefaultScreenOfDisplay (x_current_display); 4318 x_in_use = 1;
4256 4319
4257 screen_visual = select_visual (x_screen, &n_planes); 4320 XSETFASTINT (Vwindow_system_version, 11);
4258 x_screen_planes = n_planes;
4259 x_screen_height = HeightOfScreen (x_screen);
4260 x_screen_width = WidthOfScreen (x_screen);
4261
4262 /* X Atoms used by emacs. */
4263 Xatoms_of_xselect ();
4264 BLOCK_INPUT;
4265 Xatom_wm_protocols = XInternAtom (x_current_display, "WM_PROTOCOLS",
4266 False);
4267 Xatom_wm_take_focus = XInternAtom (x_current_display, "WM_TAKE_FOCUS",
4268 False);
4269 Xatom_wm_save_yourself = XInternAtom (x_current_display, "WM_SAVE_YOURSELF",
4270 False);
4271 Xatom_wm_delete_window = XInternAtom (x_current_display, "WM_DELETE_WINDOW",
4272 False);
4273 Xatom_wm_change_state = XInternAtom (x_current_display, "WM_CHANGE_STATE",
4274 False);
4275 Xatom_wm_configure_denied = XInternAtom (x_current_display,
4276 "WM_CONFIGURE_DENIED", False);
4277 Xatom_wm_window_moved = XInternAtom (x_current_display, "WM_MOVED",
4278 False);
4279 Xatom_editres_name = XInternAtom (x_current_display, "Editres", False);
4280 UNBLOCK_INPUT;
4281 return Qnil; 4321 return Qnil;
4282} 4322}
4283 4323
4284DEFUN ("x-close-current-connection", Fx_close_current_connection, 4324DEFUN ("x-close-current-connection", Fx_close_current_connection,
4285 Sx_close_current_connection, 4325 Sx_close_current_connection,
4286 0, 0, 0, "Close the connection to the current X server.") 4326 1, 1, 0, "Close the connection to frame FRAME's X server.")
4287 () 4327 (frame)
4328 Lisp_Object frame;
4288{ 4329{
4330 Display *dpy;
4289 /* Note: If we're going to call check_x here, then the fatal error 4331 /* Note: If we're going to call check_x here, then the fatal error
4290 can't happen. For the moment, this check is just for safety, 4332 can't happen. For the moment, this check is just for safety,
4291 so a user won't try out the function and get a crash. If it's 4333 so a user won't try out the function and get a crash. If it's
4292 really intended only to be called when killing emacs, then there's 4334 really intended only to be called when killing emacs, then there's
4293 no reason for it to have a lisp interface at all. */ 4335 no reason for it to have a lisp interface at all. */
4294 check_x(); 4336 check_x ();
4337 CHECK_LIVE_FRAME (frame, 0);
4338 dpy = FRAME_X_DISPLAY (XFRAME (frame));
4295 4339
4296 /* This is ONLY used when killing emacs; For switching displays 4340 /* This is ONLY used when killing emacs; For switching displays
4297 we'll have to take care of setting CloseDownMode elsewhere. */ 4341 we'll have to take care of setting CloseDownMode elsewhere. */
4298 4342
4299 if (x_current_display) 4343 if (dpy)
4300 { 4344 {
4301 BLOCK_INPUT; 4345 BLOCK_INPUT;
4302 XSetCloseDownMode (x_current_display, DestroyAll); 4346 XSetCloseDownMode (dpy, DestroyAll);
4303 XCloseDisplay (x_current_display); 4347 XCloseDisplay (dpy);
4304 x_current_display = 0; 4348 x_in_use = 0;
4305 } 4349 }
4306 else 4350 else
4307 fatal ("No current X display connection to close\n"); 4351 error ("No current X display connection to close");
4308 4352
4309 return Qnil; 4353 return Qnil;
4310} 4354}
4311 4355
4312DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 4356DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize,
4313 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\ 4357 1, 2, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
4314If ON is nil, allow buffering of requests.\n\ 4358If ON is nil, allow buffering of requests.\n\
4315Turning on synchronization prohibits the Xlib routines from buffering\n\ 4359Turning on synchronization prohibits the Xlib routines from buffering\n\
4316requests and seriously degrades performance, but makes debugging much\n\ 4360requests and seriously degrades performance, but makes debugging much\n\
4317easier.") 4361easier.")
4318 (on) 4362 (on, frame)
4319 Lisp_Object on; 4363 Lisp_Object frame, on;
4320{ 4364{
4321 check_x (); 4365 struct x_display_info *dpyinfo = check_x_display_info (frame);
4322 4366
4323 XSynchronize (x_current_display, !EQ (on, Qnil)); 4367 XSynchronize (dpyinfo->display, !EQ (on, Qnil));
4324 4368
4325 return Qnil; 4369 return Qnil;
4326} 4370}
4327 4371
4328/* Wait for responses to all X commands issued so far for FRAME. */ 4372/* Wait for responses to all X commands issued so far for frame F. */
4329 4373
4330void 4374void
4331x_sync (frame) 4375x_sync (f)
4332 Lisp_Object frame; 4376 FRAME_PTR f;
4333{ 4377{
4334 BLOCK_INPUT; 4378 BLOCK_INPUT;
4335 XSync (x_current_display, False); 4379 XSync (FRAME_X_DISPLAY (f), False);
4336 UNBLOCK_INPUT; 4380 UNBLOCK_INPUT;
4337} 4381}
4338 4382
4339syms_of_xfns () 4383syms_of_xfns ()
4340{ 4384{
4341 /* This is zero if not using X windows. */ 4385 /* This is zero if not using X windows. */
4342 x_current_display = 0; 4386 x_in_use = 0;
4343
4344 the_x_screen.font_list_cache = Qnil;
4345 the_x_screen.name = Qnil;
4346 staticpro (&the_x_screen.font_list_cache);
4347 staticpro (&the_x_screen.name);
4348 4387
4349 /* The section below is built by the lisp expression at the top of the file, 4388 /* The section below is built by the lisp expression at the top of the file,
4350 just above where these variables are declared. */ 4389 just above where these variables are declared. */
@@ -4411,6 +4450,8 @@ syms_of_xfns ()
4411 staticpro (&Quser_position); 4450 staticpro (&Quser_position);
4412 Quser_size = intern ("user-size"); 4451 Quser_size = intern ("user-size");
4413 staticpro (&Quser_size); 4452 staticpro (&Quser_size);
4453 Qdisplay = intern ("display");
4454 staticpro (&Qdisplay);
4414 /* This is the end of symbol initialization. */ 4455 /* This is the end of symbol initialization. */
4415 4456
4416 Fput (Qundefined_color, Qerror_conditions, 4457 Fput (Qundefined_color, Qerror_conditions,
@@ -4424,10 +4465,6 @@ syms_of_xfns ()
4424 "List of directories to search for bitmap files for X."); 4465 "List of directories to search for bitmap files for X.");
4425 Vx_bitmap_file_path = Fcons (build_string (PATH_BITMAPS), Qnil); 4466 Vx_bitmap_file_path = Fcons (build_string (PATH_BITMAPS), Qnil);
4426 4467
4427 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset,
4428 "The buffer offset of the character under the pointer.");
4429 mouse_buffer_offset = 0;
4430
4431 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, 4468 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
4432 "The shape of the pointer when over text.\n\ 4469 "The shape of the pointer when over text.\n\
4433Changing the value does not affect existing frames\n\ 4470Changing the value does not affect existing frames\n\
@@ -4470,10 +4507,6 @@ or when you set the mouse color.");
4470 "A string indicating the foreground color of the cursor box."); 4507 "A string indicating the foreground color of the cursor box.");
4471 Vx_cursor_fore_pixel = Qnil; 4508 Vx_cursor_fore_pixel = Qnil;
4472 4509
4473 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed,
4474 "Non-nil if a mouse button is currently depressed.");
4475 Vmouse_depressed = Qnil;
4476
4477 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, 4510 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
4478 "Non-nil if no X window manager is in use."); 4511 "Non-nil if no X window manager is in use.");
4479 4512