aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-22 04:34:16 +0000
committerRichard M. Stallman1994-10-22 04:34:16 +0000
commit334208b7722e29f15976ec3c974e20b35b5ad592 (patch)
treeb1435412da1099b726d4299c84cd7b71b58dd091 /src
parentb9dc44432a69fe6b69883752596b69d4131a8303 (diff)
downloademacs-334208b7722e29f15976ec3c974e20b35b5ad592.tar.gz
emacs-334208b7722e29f15976ec3c974e20b35b5ad592.zip
Use FRAME_X_DISPLAY instead of x_current_display and XDISPLAY.
(x_make_frame_visible, x_make_frame_invisible): Pass a frame ptr to x_sync. (x_term_init): Init all the components of dpyinfo. (x_display_info_for_display): New function. (x_*_mod_mask): Variables deleted. (x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): New arg dpyinfo; all callers changed. Store the masks in that structure. (icon_bitmap): Variable deleted. (x_bitmap_icon): Use icon_bitmap_id in x_display_info. (icon_font_info): Variable deleted. (x_term_init): Set up `connection' field. (x_find_modifier_meanings): Arg is now struct x_display_info *. (x_term_init): Return an x_display_info *. Store all the data in it, including X atoms and xrdb. Put the x_display_info structure on x_display_list. Pass name as Lisp_Object. (the_x_screen): Variable moved here. (syms_of_xterm): Staticpro parts of the_x_screen. (windowinfo): Variable deleted. (Xatom_*): Variables deleted. (x_iconify_frame, XTread_socket): Get atoms from the x_display_info, (XTread_socket): Don't update Vmouse_depressed. (x_mouse_grabbed): Variable deleted. (note_mouse_highlight): Use grabbed field instead. (XTmouse_position, XTread_socket): Likewise. (x_calc_absolute_position, x_wm_set_size_hint): Get screen height, width from the x_display_info structure.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c732
1 files changed, 407 insertions, 325 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 01b8986ffcc..173cecb0c7e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -144,16 +144,6 @@ static int expose_all_icons;
144int BLOCK_INPUT_mask; 144int BLOCK_INPUT_mask;
145#endif /* ! defined (SIGIO) && defined (FIONREAD) */ 145#endif /* ! defined (SIGIO) && defined (FIONREAD) */
146 146
147/* The id of a bitmap used for icon windows, in frames
148 for which no specific bitmap was specified.
149 This is 0 if we have not yet had a need to create the bitmap. */
150
151static int icon_bitmap;
152
153/* Font used for text icons. */
154
155static FONT_TYPE *icon_font_info;
156
157/* Stuff for dealing with the main icon title. */ 147/* Stuff for dealing with the main icon title. */
158 148
159extern Lisp_Object Vcommand_line_args, Vsystem_name; 149extern Lisp_Object Vcommand_line_args, Vsystem_name;
@@ -163,9 +153,12 @@ char *x_id_name;
163extern char **initial_argv; 153extern char **initial_argv;
164extern int initial_argc; 154extern int initial_argc;
165 155
166/* This is the X connection that we are using. */ 156/* For now, we have just one x_display structure since we only support
157 one X display. */
158static struct x_display_info the_x_screen;
167 159
168Display *x_current_display; 160/* This is a chain of structures for all the X displays currently in use. */
161struct x_display_info *x_display_list;
169 162
170/* The cursor to use for vertical scroll bars on x_current_display. */ 163/* The cursor to use for vertical scroll bars on x_current_display. */
171static Cursor x_vertical_scroll_bar_cursor; 164static Cursor x_vertical_scroll_bar_cursor;
@@ -255,9 +248,6 @@ static XRectangle last_mouse_glyph;
255 to Qnil, to tell XTmouse_position to return an ordinary motion event. */ 248 to Qnil, to tell XTmouse_position to return an ordinary motion event. */
256static Lisp_Object last_mouse_scroll_bar; 249static Lisp_Object last_mouse_scroll_bar;
257 250
258/* Record which buttons are currently pressed. */
259unsigned int x_mouse_grabbed;
260
261/* This is a hack. We would really prefer that XTmouse_position would 251/* This is a hack. We would really prefer that XTmouse_position would
262 return the time associated with the position it returns, but there 252 return the time associated with the position it returns, but there
263 doesn't seem to be any way to wrest the timestamp from the server 253 doesn't seem to be any way to wrest the timestamp from the server
@@ -295,10 +285,6 @@ static int volatile input_signal_count;
295static int input_signal_count; 285static int input_signal_count;
296#endif 286#endif
297 287
298/* `t' if a mouse button is depressed. */
299
300extern Lisp_Object Vmouse_depressed;
301
302/* Tells if a window manager is present or not. */ 288/* Tells if a window manager is present or not. */
303 289
304extern Lisp_Object Vx_no_window_manager; 290extern Lisp_Object Vx_no_window_manager;
@@ -316,11 +302,6 @@ extern Lisp_Object Qface, Qmouse_face;
316 302
317static int x_noop_count; 303static int x_noop_count;
318 304
319
320/* From time to time we get info on an Emacs window, here. */
321
322static WINDOWINFO_TYPE windowinfo;
323
324extern int errno; 305extern int errno;
325 306
326/* A mask of extra modifier bits to put into every keyboard char. */ 307/* A mask of extra modifier bits to put into every keyboard char. */
@@ -330,7 +311,8 @@ extern Display *XOpenDisplay ();
330extern Window XCreateWindow (); 311extern Window XCreateWindow ();
331 312
332extern Cursor XCreateCursor (); 313extern Cursor XCreateCursor ();
333extern FONT_TYPE *XOpenFont (); 314extern XFontStruct *XOpenFont ();
315extern XrmDatabase x_load_resources ();
334 316
335static void flashback (); 317static void flashback ();
336static void redraw_previous_char (); 318static void redraw_previous_char ();
@@ -346,7 +328,21 @@ static void do_line_dance ();
346void dumpborder (); 328void dumpborder ();
347static int XTcursor_to (); 329static int XTcursor_to ();
348static int XTclear_end_of_line (); 330static int XTclear_end_of_line ();
331
332/* Return the struct x_display_info corresponding to DPY. */
333
334struct x_display_info *
335x_display_info_for_display (dpy)
336 Display *dpy;
337{
338 struct x_display_info *dpyinfo;
339
340 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
341 if (dpyinfo->display == dpy)
342 return dpyinfo;
349 343
344 return 0;
345}
350 346
351/* Starting and ending updates. 347/* Starting and ending updates.
352 348
@@ -432,7 +428,7 @@ XTupdate_end (f)
432 note_mouse_highlight (f, mouse_face_mouse_x, mouse_face_mouse_y); 428 note_mouse_highlight (f, mouse_face_mouse_x, mouse_face_mouse_y);
433#endif 429#endif
434 430
435 XFlushQueue (); 431 XFlush (FRAME_X_DISPLAY (f));
436 UNBLOCK_INPUT; 432 UNBLOCK_INPUT;
437} 433}
438 434
@@ -509,7 +505,7 @@ XTcursor_to (row, col)
509 { 505 {
510 BLOCK_INPUT; 506 BLOCK_INPUT;
511 x_display_cursor (selected_frame, 1); 507 x_display_cursor (selected_frame, 1);
512 XFlushQueue (); 508 XFlush (FRAME_X_DISPLAY (selected_frame));
513 UNBLOCK_INPUT; 509 UNBLOCK_INPUT;
514 } 510 }
515} 511}
@@ -581,7 +577,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
581 determined by the face code CF. */ 577 determined by the face code CF. */
582 { 578 {
583 struct face *face = FRAME_DEFAULT_FACE (f); 579 struct face *face = FRAME_DEFAULT_FACE (f);
584 FONT_TYPE *font = FACE_FONT (face); 580 XFontStruct *font = FACE_FONT (face);
585 GC gc = FACE_GC (face); 581 GC gc = FACE_GC (face);
586 int stippled = 0; 582 int stippled = 0;
587 583
@@ -663,16 +659,16 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
663 xgcv.graphics_exposures = 0; 659 xgcv.graphics_exposures = 0;
664 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; 660 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
665 if (scratch_cursor_gc) 661 if (scratch_cursor_gc)
666 XChangeGC (x_current_display, scratch_cursor_gc, mask, &xgcv); 662 XChangeGC (FRAME_X_DISPLAY (f), scratch_cursor_gc, mask, &xgcv);
667 else 663 else
668 scratch_cursor_gc 664 scratch_cursor_gc
669 = XCreateGC (x_current_display, window, mask, &xgcv); 665 = XCreateGC (FRAME_X_DISPLAY (f), window, mask, &xgcv);
670 gc = scratch_cursor_gc; 666 gc = scratch_cursor_gc;
671#if 0 667#if 0
672/* If this code is restored, it must also reset to the default stipple 668/* If this code is restored, it must also reset to the default stipple
673 if necessary. */ 669 if necessary. */
674 if (face->stipple && face->stipple != FACE_DEFAULT) 670 if (face->stipple && face->stipple != FACE_DEFAULT)
675 XSetStipple (x_current_display, gc, face->stipple); 671 XSetStipple (FRAME_X_DISPLAY (f), gc, face->stipple);
676#endif 672#endif
677 } 673 }
678 } 674 }
@@ -681,7 +677,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
681 font = f->display.x->font; 677 font = f->display.x->font;
682 678
683 if (just_foreground) 679 if (just_foreground)
684 XDrawString (x_current_display, window, gc, 680 XDrawString (FRAME_X_DISPLAY (f), window, gc,
685 left, top + FONT_BASE (font), buf, len); 681 left, top + FONT_BASE (font), buf, len);
686 else 682 else
687 { 683 {
@@ -691,7 +687,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
691 XSetFillStyle (FRAME_X_DISPLAY (f), gc, FillOpaqueStippled); 687 XSetFillStyle (FRAME_X_DISPLAY (f), gc, FillOpaqueStippled);
692 688
693 /* Draw stipple on background. */ 689 /* Draw stipple on background. */
694 XFillRectangle (x_current_display, window, gc, 690 XFillRectangle (FRAME_X_DISPLAY (f), window, gc,
695 left, top, 691 left, top,
696 FONT_WIDTH (font) * len, 692 FONT_WIDTH (font) * len,
697 FONT_HEIGHT (font)); 693 FONT_HEIGHT (font));
@@ -700,16 +696,16 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
700 XSetFillStyle (FRAME_X_DISPLAY (f), gc, FillSolid); 696 XSetFillStyle (FRAME_X_DISPLAY (f), gc, FillSolid);
701 697
702 /* Draw the text, solidly, onto the stipple pattern. */ 698 /* Draw the text, solidly, onto the stipple pattern. */
703 XDrawString (x_current_display, window, gc, 699 XDrawString (FRAME_X_DISPLAY (f), window, gc,
704 left, top + FONT_BASE (font), buf, len); 700 left, top + FONT_BASE (font), buf, len);
705 } 701 }
706 else 702 else
707 XDrawImageString (x_current_display, window, gc, 703 XDrawImageString (FRAME_X_DISPLAY (f), window, gc,
708 left, top + FONT_BASE (font), buf, len); 704 left, top + FONT_BASE (font), buf, len);
709 705
710 /* Clear the rest of the line's height. */ 706 /* Clear the rest of the line's height. */
711 if (f->display.x->line_height != FONT_HEIGHT (font)) 707 if (f->display.x->line_height != FONT_HEIGHT (font))
712 XClearArea (x_current_display, window, left, 708 XClearArea (FRAME_X_DISPLAY (f), window, left,
713 top + FONT_HEIGHT (font), 709 top + FONT_HEIGHT (font),
714 FONT_WIDTH (font) * len, 710 FONT_WIDTH (font) * len,
715 /* This is how many pixels of height 711 /* This is how many pixels of height
@@ -741,7 +737,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
741 underline_position = font->descent - 1; 737 underline_position = font->descent - 1;
742 738
743 if (face->underline) 739 if (face->underline)
744 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), 740 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
745 FACE_GC (face), 741 FACE_GC (face),
746 left, (top 742 left, (top
747 + FONT_BASE (font) 743 + FONT_BASE (font)
@@ -765,7 +761,7 @@ dumpglyphs (f, left, top, gp, n, hl, font)
765 register GLYPH *gp; /* Points to first GLYPH. */ 761 register GLYPH *gp; /* Points to first GLYPH. */
766 register int n; /* Number of glyphs to display. */ 762 register int n; /* Number of glyphs to display. */
767 int hl; 763 int hl;
768 FONT_TYPE *font; 764 XFontStruct *font;
769{ 765{
770 register int len; 766 register int len;
771 Window window = FRAME_X_WINDOW (f); 767 Window window = FRAME_X_WINDOW (f);
@@ -774,10 +770,10 @@ dumpglyphs (f, left, top, gp, n, hl, font)
774 : f->display.x->normal_gc)); 770 : f->display.x->normal_gc));
775 771
776 if (sizeof (GLYPH) == sizeof (XChar2b)) 772 if (sizeof (GLYPH) == sizeof (XChar2b))
777 XDrawImageString16 (x_current_display, window, drawing_gc, 773 XDrawImageString16 (FRAME_X_DISPLAY (f), window, drawing_gc,
778 left, top + FONT_BASE (font), (XChar2b *) gp, n); 774 left, top + FONT_BASE (font), (XChar2b *) gp, n);
779 else if (sizeof (GLYPH) == sizeof (unsigned char)) 775 else if (sizeof (GLYPH) == sizeof (unsigned char))
780 XDrawImageString (x_current_display, window, drawing_gc, 776 XDrawImageString (FRAME_X_DISPLAY (f), window, drawing_gc,
781 left, top + FONT_BASE (font), (char *) gp, n); 777 left, top + FONT_BASE (font), (char *) gp, n);
782 else 778 else
783 /* What size of glyph ARE you using? And does X have a function to 779 /* What size of glyph ARE you using? And does X have a function to
@@ -869,7 +865,7 @@ XTclear_end_of_line (first_unused)
869 && f->phys_cursor_x < first_unused) 865 && f->phys_cursor_x < first_unused)
870 f->phys_cursor_x = -1; 866 f->phys_cursor_x = -1;
871 867
872 XClearArea (x_current_display, FRAME_X_WINDOW (f), 868 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
873 CHAR_TO_PIXEL_COL (f, curs_x), 869 CHAR_TO_PIXEL_COL (f, curs_x),
874 CHAR_TO_PIXEL_ROW (f, curs_y), 870 CHAR_TO_PIXEL_ROW (f, curs_y),
875 FONT_WIDTH (f->display.x->font) * (first_unused - curs_x), 871 FONT_WIDTH (f->display.x->font) * (first_unused - curs_x),
@@ -896,13 +892,13 @@ XTclear_frame ()
896 892
897 BLOCK_INPUT; 893 BLOCK_INPUT;
898 894
899 XClear (FRAME_X_WINDOW (f)); 895 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
900 896
901 /* We have to clear the scroll bars, too. If we have changed 897 /* We have to clear the scroll bars, too. If we have changed
902 colors or something like that, then they should be notified. */ 898 colors or something like that, then they should be notified. */
903 x_scroll_bar_clear (f); 899 x_scroll_bar_clear (f);
904 900
905 XFlushQueue (); 901 XFlush (FRAME_X_DISPLAY (f));
906 UNBLOCK_INPUT; 902 UNBLOCK_INPUT;
907} 903}
908 904
@@ -936,7 +932,7 @@ redraw_previous_char (f, x, y, highlight_flag)
936 int start_x = x - 2; 932 int start_x = x - 2;
937 if (start_x < 0) 933 if (start_x < 0)
938 start_x = 0; 934 start_x = 0;
939 XClearArea (x_current_display, FRAME_X_WINDOW (f), 935 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
940 CHAR_TO_PIXEL_COL (f, x - 1), 936 CHAR_TO_PIXEL_COL (f, x - 1),
941 CHAR_TO_PIXEL_ROW (f, y), 937 CHAR_TO_PIXEL_ROW (f, y),
942 FONT_WIDTH (f->display.x->font), 938 FONT_WIDTH (f->display.x->font),
@@ -972,7 +968,7 @@ redraw_following_char (f, x, y, highlight_flag)
972 int end_x = x + 2; 968 int end_x = x + 2;
973 if (end_x > limit) 969 if (end_x > limit)
974 end_x = limit; 970 end_x = limit;
975 XClearArea (x_current_display, FRAME_X_WINDOW (f), 971 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
976 CHAR_TO_PIXEL_COL (f, x), 972 CHAR_TO_PIXEL_COL (f, x),
977 CHAR_TO_PIXEL_ROW (f, y), 973 CHAR_TO_PIXEL_ROW (f, y),
978 FONT_WIDTH (f->display.x->font), 974 FONT_WIDTH (f->display.x->font),
@@ -1134,7 +1130,7 @@ XTflash (f)
1134 values.foreground = (f->display.x->foreground_pixel 1130 values.foreground = (f->display.x->foreground_pixel
1135 ^ f->display.x->background_pixel); 1131 ^ f->display.x->background_pixel);
1136 1132
1137 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), 1133 gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1138 GCFunction | GCForeground, &values); 1134 GCFunction | GCForeground, &values);
1139 } 1135 }
1140 1136
@@ -1142,9 +1138,9 @@ XTflash (f)
1142 int width = PIXEL_WIDTH (f); 1138 int width = PIXEL_WIDTH (f);
1143 int height = PIXEL_HEIGHT (f); 1139 int height = PIXEL_HEIGHT (f);
1144 1140
1145 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), gc, 1141 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
1146 width/4, height/4, width/2, height/2); 1142 width/4, height/4, width/2, height/2);
1147 XFlush (x_current_display); 1143 XFlush (FRAME_X_DISPLAY (f));
1148 1144
1149 { 1145 {
1150 struct timeval wakeup, now; 1146 struct timeval wakeup, now;
@@ -1173,10 +1169,10 @@ XTflash (f)
1173 } 1169 }
1174 } 1170 }
1175 1171
1176 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), gc, 1172 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
1177 width/4, height/4, width/2, height/2); 1173 width/4, height/4, width/2, height/2);
1178 XFreeGC (x_current_display, gc); 1174 XFreeGC (FRAME_X_DISPLAY (f), gc);
1179 XFlush (x_current_display); 1175 XFlush (FRAME_X_DISPLAY (f));
1180 } 1176 }
1181 } 1177 }
1182 1178
@@ -1188,11 +1184,11 @@ XTflash (f)
1188 1184
1189/* Make audible bell. */ 1185/* Make audible bell. */
1190 1186
1191#define XRINGBELL XBell (x_current_display, 0) 1187#define XRINGBELL XBell (FRAME_X_DISPLAY (selected_frame), 0)
1192 1188
1193XTring_bell () 1189XTring_bell ()
1194{ 1190{
1195 if (x_current_display == 0) 1191 if (FRAME_X_DISPLAY (selected_frame) == 0)
1196 return; 1192 return;
1197 1193
1198#if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) 1194#if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
@@ -1203,7 +1199,7 @@ XTring_bell ()
1203 { 1199 {
1204 BLOCK_INPUT; 1200 BLOCK_INPUT;
1205 XRINGBELL; 1201 XRINGBELL;
1206 XFlushQueue (); 1202 XFlush (FRAME_X_DISPLAY (selected_frame));
1207 UNBLOCK_INPUT; 1203 UNBLOCK_INPUT;
1208 } 1204 }
1209} 1205}
@@ -1330,7 +1326,7 @@ do_line_dance ()
1330 for (j = i; (j < ht && line_dance[j] != -1 1326 for (j = i; (j < ht && line_dance[j] != -1
1331 && line_dance[j]-j == distance); ++j); 1327 && line_dance[j]-j == distance); ++j);
1332 /* Copy [i,j) upward from [i+distance,j+distance) */ 1328 /* Copy [i,j) upward from [i+distance,j+distance) */
1333 XCopyArea (x_current_display, FRAME_X_WINDOW (f), 1329 XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1334 FRAME_X_WINDOW (f), f->display.x->normal_gc, 1330 FRAME_X_WINDOW (f), f->display.x->normal_gc,
1335 intborder, CHAR_TO_PIXEL_ROW (f, i+distance), 1331 intborder, CHAR_TO_PIXEL_ROW (f, i+distance),
1336 f->width * FONT_WIDTH (f->display.x->font), 1332 f->width * FONT_WIDTH (f->display.x->font),
@@ -1345,7 +1341,7 @@ do_line_dance ()
1345 for (j = i; (--j >= 0 && line_dance[j] != -1 1341 for (j = i; (--j >= 0 && line_dance[j] != -1
1346 && line_dance[j]-j == distance);); 1342 && line_dance[j]-j == distance););
1347 /* Copy (j,i] downward from (j+distance, i+distance] */ 1343 /* Copy (j,i] downward from (j+distance, i+distance] */
1348 XCopyArea (x_current_display, FRAME_X_WINDOW (f), 1344 XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1349 FRAME_X_WINDOW (f), f->display.x->normal_gc, 1345 FRAME_X_WINDOW (f), f->display.x->normal_gc,
1350 intborder, CHAR_TO_PIXEL_ROW (f, j+1+distance), 1346 intborder, CHAR_TO_PIXEL_ROW (f, j+1+distance),
1351 f->width * FONT_WIDTH (f->display.x->font), 1347 f->width * FONT_WIDTH (f->display.x->font),
@@ -1359,7 +1355,7 @@ do_line_dance ()
1359 { 1355 {
1360 for (j = i; j < ht && line_dance[j] == -1; ++j); 1356 for (j = i; j < ht && line_dance[j] == -1; ++j);
1361 /* Clear [i,j) */ 1357 /* Clear [i,j) */
1362 XClearArea (x_current_display, FRAME_X_WINDOW (f), 1358 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1363 intborder, CHAR_TO_PIXEL_ROW (f, i), 1359 intborder, CHAR_TO_PIXEL_ROW (f, i),
1364 f->width * FONT_WIDTH (f->display.x->font), 1360 f->width * FONT_WIDTH (f->display.x->font),
1365 (j-i) * f->display.x->line_height, False); 1361 (j-i) * f->display.x->line_height, False);
@@ -1453,33 +1449,33 @@ dumprectangle (f, left, top, cols, rows)
1453} 1449}
1454 1450
1455static void 1451static void
1456frame_highlight (frame) 1452frame_highlight (f)
1457 struct frame *frame; 1453 struct frame *f;
1458{ 1454{
1459 /* We used to only do this if Vx_no_window_manager was non-nil, but 1455 /* We used to only do this if Vx_no_window_manager was non-nil, but
1460 the ICCCM (section 4.1.6) says that the window's border pixmap 1456 the ICCCM (section 4.1.6) says that the window's border pixmap
1461 and border pixel are window attributes which are "private to the 1457 and border pixel are window attributes which are "private to the
1462 client", so we can always change it to whatever we want. */ 1458 client", so we can always change it to whatever we want. */
1463 BLOCK_INPUT; 1459 BLOCK_INPUT;
1464 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (frame), 1460 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1465 frame->display.x->border_pixel); 1461 f->display.x->border_pixel);
1466 UNBLOCK_INPUT; 1462 UNBLOCK_INPUT;
1467 x_display_cursor (frame, 1); 1463 x_display_cursor (f, 1);
1468} 1464}
1469 1465
1470static void 1466static void
1471frame_unhighlight (frame) 1467frame_unhighlight (f)
1472 struct frame *frame; 1468 struct frame *f;
1473{ 1469{
1474 /* We used to only do this if Vx_no_window_manager was non-nil, but 1470 /* We used to only do this if Vx_no_window_manager was non-nil, but
1475 the ICCCM (section 4.1.6) says that the window's border pixmap 1471 the ICCCM (section 4.1.6) says that the window's border pixmap
1476 and border pixel are window attributes which are "private to the 1472 and border pixel are window attributes which are "private to the
1477 client", so we can always change it to whatever we want. */ 1473 client", so we can always change it to whatever we want. */
1478 BLOCK_INPUT; 1474 BLOCK_INPUT;
1479 XSetWindowBorderPixmap (x_current_display, FRAME_X_WINDOW (frame), 1475 XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1480 frame->display.x->border_tile); 1476 f->display.x->border_tile);
1481 UNBLOCK_INPUT; 1477 UNBLOCK_INPUT;
1482 x_display_cursor (frame, 1); 1478 x_display_cursor (f, 1);
1483} 1479}
1484 1480
1485static void XTframe_rehighlight (); 1481static void XTframe_rehighlight ();
@@ -1558,56 +1554,33 @@ XTframe_rehighlight ()
1558 1554
1559/* Keyboard processing - modifier keys, vendor-specific keysyms, etc. */ 1555/* Keyboard processing - modifier keys, vendor-specific keysyms, etc. */
1560 1556
1561/* Which modifier keys are on which modifier bits?
1562
1563 With each keystroke, X returns eight bits indicating which modifier
1564 keys were held down when the key was pressed. The interpretation
1565 of the top five modifier bits depends on what keys are attached
1566 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
1567 is the meta bit.
1568
1569 x_meta_mod_mask is a mask containing the bits used for the meta key.
1570 It may have more than one bit set, if more than one modifier bit
1571 has meta keys on it. Basically, if EVENT is a KeyPress event,
1572 the meta key is pressed if (EVENT.state & x_meta_mod_mask) != 0.
1573
1574 x_shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
1575 lock modifier bit, or zero otherwise. Non-alphabetic keys should
1576 only be affected by the lock modifier bit if XK_Shift_Lock is in
1577 use; XK_Caps_Lock should only affect alphabetic keys. With this
1578 arrangement, the lock modifier should shift the character if
1579 (EVENT.state & x_shift_lock_mask) != 0. */
1580static int x_meta_mod_mask, x_shift_lock_mask;
1581
1582/* These are like x_meta_mod_mask, but for different modifiers. */
1583static int x_alt_mod_mask, x_super_mod_mask, x_hyper_mod_mask;
1584
1585/* Initialize mode_switch_bit and modifier_meaning. */ 1557/* Initialize mode_switch_bit and modifier_meaning. */
1586static void 1558static void
1587x_find_modifier_meanings () 1559x_find_modifier_meanings (dpyinfo)
1560 struct x_display_info *dpyinfo;
1588{ 1561{
1589 int min_code, max_code; 1562 int min_code, max_code;
1590 KeySym *syms; 1563 KeySym *syms;
1591 int syms_per_code; 1564 int syms_per_code;
1592 XModifierKeymap *mods; 1565 XModifierKeymap *mods;
1593 1566
1594 x_meta_mod_mask = 0; 1567 dpyinfo->meta_mod_mask = 0;
1595 x_shift_lock_mask = 0; 1568 dpyinfo->shift_lock_mask = 0;
1596 x_alt_mod_mask = 0; 1569 dpyinfo->alt_mod_mask = 0;
1597 x_super_mod_mask = 0; 1570 dpyinfo->super_mod_mask = 0;
1598 x_hyper_mod_mask = 0; 1571 dpyinfo->hyper_mod_mask = 0;
1599 1572
1600#ifdef HAVE_X11R4 1573#ifdef HAVE_X11R4
1601 XDisplayKeycodes (x_current_display, &min_code, &max_code); 1574 XDisplayKeycodes (dpyinfo->display, &min_code, &max_code);
1602#else 1575#else
1603 min_code = x_current_display->min_keycode; 1576 min_code = display->min_keycode;
1604 max_code = x_current_display->max_keycode; 1577 max_code = display->max_keycode;
1605#endif 1578#endif
1606 1579
1607 syms = XGetKeyboardMapping (x_current_display, 1580 syms = XGetKeyboardMapping (dpyinfo->display,
1608 min_code, max_code - min_code + 1, 1581 min_code, max_code - min_code + 1,
1609 &syms_per_code); 1582 &syms_per_code);
1610 mods = XGetModifierMapping (x_current_display); 1583 mods = XGetModifierMapping (dpyinfo->display);
1611 1584
1612 /* Scan the modifier table to see which modifier bits the Meta and 1585 /* Scan the modifier table to see which modifier bits the Meta and
1613 Alt keysyms are on. */ 1586 Alt keysyms are on. */
@@ -1636,28 +1609,28 @@ x_find_modifier_meanings ()
1636 { 1609 {
1637 case XK_Meta_L: 1610 case XK_Meta_L:
1638 case XK_Meta_R: 1611 case XK_Meta_R:
1639 x_meta_mod_mask |= (1 << row); 1612 dpyinfo->meta_mod_mask |= (1 << row);
1640 break; 1613 break;
1641 1614
1642 case XK_Alt_L: 1615 case XK_Alt_L:
1643 case XK_Alt_R: 1616 case XK_Alt_R:
1644 x_alt_mod_mask |= (1 << row); 1617 dpyinfo->alt_mod_mask |= (1 << row);
1645 break; 1618 break;
1646 1619
1647 case XK_Hyper_L: 1620 case XK_Hyper_L:
1648 case XK_Hyper_R: 1621 case XK_Hyper_R:
1649 x_hyper_mod_mask |= (1 << row); 1622 dpyinfo->hyper_mod_mask |= (1 << row);
1650 break; 1623 break;
1651 1624
1652 case XK_Super_L: 1625 case XK_Super_L:
1653 case XK_Super_R: 1626 case XK_Super_R:
1654 x_super_mod_mask |= (1 << row); 1627 dpyinfo->super_mod_mask |= (1 << row);
1655 break; 1628 break;
1656 1629
1657 case XK_Shift_Lock: 1630 case XK_Shift_Lock:
1658 /* Ignore this if it's not on the lock modifier. */ 1631 /* Ignore this if it's not on the lock modifier. */
1659 if ((1 << row) == LockMask) 1632 if ((1 << row) == LockMask)
1660 x_shift_lock_mask = LockMask; 1633 dpyinfo->shift_lock_mask = LockMask;
1661 break; 1634 break;
1662 } 1635 }
1663 } 1636 }
@@ -1666,17 +1639,17 @@ x_find_modifier_meanings ()
1666 } 1639 }
1667 1640
1668 /* If we couldn't find any meta keys, accept any alt keys as meta keys. */ 1641 /* If we couldn't find any meta keys, accept any alt keys as meta keys. */
1669 if (! x_meta_mod_mask) 1642 if (! dpyinfo->meta_mod_mask)
1670 { 1643 {
1671 x_meta_mod_mask = x_alt_mod_mask; 1644 dpyinfo->meta_mod_mask = dpyinfo->alt_mod_mask;
1672 x_alt_mod_mask = 0; 1645 dpyinfo->alt_mod_mask = 0;
1673 } 1646 }
1674 1647
1675 /* If some keys are both alt and meta, 1648 /* If some keys are both alt and meta,
1676 make them just meta, not alt. */ 1649 make them just meta, not alt. */
1677 if (x_alt_mod_mask & x_meta_mod_mask) 1650 if (dpyinfo->alt_mod_mask & dpyinfo->meta_mod_mask)
1678 { 1651 {
1679 x_alt_mod_mask &= ~x_meta_mod_mask; 1652 dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask;
1680 } 1653 }
1681 1654
1682 XFree ((char *) syms); 1655 XFree ((char *) syms);
@@ -1686,27 +1659,29 @@ x_find_modifier_meanings ()
1686/* Convert between the modifier bits X uses and the modifier bits 1659/* Convert between the modifier bits X uses and the modifier bits
1687 Emacs uses. */ 1660 Emacs uses. */
1688static unsigned int 1661static unsigned int
1689x_x_to_emacs_modifiers (state) 1662x_x_to_emacs_modifiers (dpyinfo, state)
1663 struct x_display_info *dpyinfo;
1690 unsigned int state; 1664 unsigned int state;
1691{ 1665{
1692 return ( ((state & (ShiftMask | x_shift_lock_mask)) ? shift_modifier : 0) 1666 return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0)
1693 | ((state & ControlMask) ? ctrl_modifier : 0) 1667 | ((state & ControlMask) ? ctrl_modifier : 0)
1694 | ((state & x_meta_mod_mask) ? meta_modifier : 0) 1668 | ((state & dpyinfo->meta_mod_mask) ? meta_modifier : 0)
1695 | ((state & x_alt_mod_mask) ? alt_modifier : 0) 1669 | ((state & dpyinfo->alt_mod_mask) ? alt_modifier : 0)
1696 | ((state & x_super_mod_mask) ? super_modifier : 0) 1670 | ((state & dpyinfo->super_mod_mask) ? super_modifier : 0)
1697 | ((state & x_hyper_mod_mask) ? hyper_modifier : 0)); 1671 | ((state & dpyinfo->hyper_mod_mask) ? hyper_modifier : 0));
1698} 1672}
1699 1673
1700static unsigned int 1674static unsigned int
1701x_emacs_to_x_modifiers (state) 1675x_emacs_to_x_modifiers (dpyinfo, state)
1676 struct x_display_info *dpyinfo;
1702 unsigned int state; 1677 unsigned int state;
1703{ 1678{
1704 return ( ((state & alt_modifier) ? x_alt_mod_mask : 0) 1679 return ( ((state & alt_modifier) ? dpyinfo->alt_mod_mask : 0)
1705 | ((state & super_modifier) ? x_super_mod_mask : 0) 1680 | ((state & super_modifier) ? dpyinfo->super_mod_mask : 0)
1706 | ((state & hyper_modifier) ? x_hyper_mod_mask : 0) 1681 | ((state & hyper_modifier) ? dpyinfo->hyper_mod_mask : 0)
1707 | ((state & shift_modifier) ? ShiftMask : 0) 1682 | ((state & shift_modifier) ? ShiftMask : 0)
1708 | ((state & ctrl_modifier) ? ControlMask : 0) 1683 | ((state & ctrl_modifier) ? ControlMask : 0)
1709 | ((state & meta_modifier) ? x_meta_mod_mask : 0)); 1684 | ((state & meta_modifier) ? dpyinfo->meta_mod_mask : 0));
1710} 1685}
1711 1686
1712/* Mouse clicks and mouse movement. Rah. */ 1687/* Mouse clicks and mouse movement. Rah. */
@@ -1785,7 +1760,8 @@ construct_mouse_click (result, event, f)
1785 result->kind = mouse_click; 1760 result->kind = mouse_click;
1786 result->code = event->button - Button1; 1761 result->code = event->button - Button1;
1787 result->timestamp = event->time; 1762 result->timestamp = event->time;
1788 result->modifiers = (x_x_to_emacs_modifiers (event->state) 1763 result->modifiers = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f),
1764 event->state)
1789 | (event->type == ButtonRelease 1765 | (event->type == ButtonRelease
1790 ? up_modifier 1766 ? up_modifier
1791 : down_modifier)); 1767 : down_modifier));
@@ -1817,7 +1793,8 @@ construct_menu_click (result, event, f)
1817 result->kind = mouse_click; 1793 result->kind = mouse_click;
1818 XSETINT (result->code, event->button - Button1); 1794 XSETINT (result->code, event->button - Button1);
1819 result->timestamp = event->time; 1795 result->timestamp = event->time;
1820 result->modifiers = (x_x_to_emacs_modifiers (event->state) 1796 result->modifiers = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f),
1797 event->state)
1821 | (event->type == ButtonRelease 1798 | (event->type == ButtonRelease
1822 ? up_modifier 1799 ? up_modifier
1823 : down_modifier)); 1800 : down_modifier));
@@ -1934,7 +1911,7 @@ note_mouse_highlight (f, x, y)
1934 1911
1935 /* Find out which glyph the mouse is on. */ 1912 /* Find out which glyph the mouse is on. */
1936 pixel_to_glyph_coords (f, x, y, &column, &row, 1913 pixel_to_glyph_coords (f, x, y, &column, &row,
1937 &new_glyph, x_mouse_grabbed); 1914 &new_glyph, FRAME_X_DISPLAY_INFO (f)->grabbed);
1938 1915
1939 /* Which window is that in? */ 1916 /* Which window is that in? */
1940 window = window_from_coordinates (f, column, row, &portion); 1917 window = window_from_coordinates (f, column, row, &portion);
@@ -2195,9 +2172,11 @@ show_mouse_face (hl)
2195 2172
2196 /* Change the mouse cursor according to the value of HL. */ 2173 /* Change the mouse cursor according to the value of HL. */
2197 if (hl > 0) 2174 if (hl > 0)
2198 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), f->display.x->cross_cursor); 2175 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2176 f->display.x->cross_cursor);
2199 else 2177 else
2200 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), f->display.x->text_cursor); 2178 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2179 f->display.x->text_cursor);
2201} 2180}
2202 2181
2203/* Clear out the mouse-highlighted active region. 2182/* Clear out the mouse-highlighted active region.
@@ -2239,8 +2218,8 @@ static void x_scroll_bar_report_motion ();
2239 again. */ 2218 again. */
2240 2219
2241static void 2220static void
2242XTmouse_position (f, bar_window, part, x, y, time) 2221XTmouse_position (fp, bar_window, part, x, y, time)
2243 FRAME_PTR *f; 2222 FRAME_PTR *fp;
2244 Lisp_Object *bar_window; 2223 Lisp_Object *bar_window;
2245 enum scroll_bar_part *part; 2224 enum scroll_bar_part *part;
2246 Lisp_Object *x, *y; 2225 Lisp_Object *x, *y;
@@ -2251,7 +2230,7 @@ XTmouse_position (f, bar_window, part, x, y, time)
2251 BLOCK_INPUT; 2230 BLOCK_INPUT;
2252 2231
2253 if (! NILP (last_mouse_scroll_bar)) 2232 if (! NILP (last_mouse_scroll_bar))
2254 x_scroll_bar_report_motion (f, bar_window, part, x, y, time); 2233 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
2255 else 2234 else
2256 { 2235 {
2257 Window root; 2236 Window root;
@@ -2264,8 +2243,8 @@ XTmouse_position (f, bar_window, part, x, y, time)
2264 last_mouse_scroll_bar = Qnil; 2243 last_mouse_scroll_bar = Qnil;
2265 2244
2266 /* Figure out which root window we're on. */ 2245 /* Figure out which root window we're on. */
2267 XQueryPointer (x_current_display, 2246 XQueryPointer (FRAME_X_DISPLAY (*fp),
2268 DefaultRootWindow (x_current_display), 2247 DefaultRootWindow (FRAME_X_DISPLAY (*fp)),
2269 2248
2270 /* The root window which contains the pointer. */ 2249 /* The root window which contains the pointer. */
2271 &root, 2250 &root,
@@ -2293,12 +2272,12 @@ XTmouse_position (f, bar_window, part, x, y, time)
2293 2272
2294 win = root; 2273 win = root;
2295 2274
2296 if (x_mouse_grabbed && last_mouse_frame 2275 if (FRAME_X_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
2297 && FRAME_LIVE_P (last_mouse_frame)) 2276 && FRAME_LIVE_P (last_mouse_frame))
2298 { 2277 {
2299 /* If mouse was grabbed on a frame, give coords for that frame 2278 /* If mouse was grabbed on a frame, give coords for that frame
2300 even if the mouse is now outside it. */ 2279 even if the mouse is now outside it. */
2301 XTranslateCoordinates (x_current_display, 2280 XTranslateCoordinates (FRAME_X_DISPLAY (*fp),
2302 2281
2303 /* From-window, to-window. */ 2282 /* From-window, to-window. */
2304 root, FRAME_X_WINDOW (last_mouse_frame), 2283 root, FRAME_X_WINDOW (last_mouse_frame),
@@ -2314,7 +2293,7 @@ XTmouse_position (f, bar_window, part, x, y, time)
2314 { 2293 {
2315 while (1) 2294 while (1)
2316 { 2295 {
2317 XTranslateCoordinates (x_current_display, 2296 XTranslateCoordinates (FRAME_X_DISPLAY (*fp),
2318 2297
2319 /* From-window, to-window. */ 2298 /* From-window, to-window. */
2320 root, win, 2299 root, win,
@@ -2368,11 +2347,12 @@ XTmouse_position (f, bar_window, part, x, y, time)
2368 /* Ok, we found a frame. Store all the values. */ 2347 /* Ok, we found a frame. Store all the values. */
2369 2348
2370 pixel_to_glyph_coords (f1, win_x, win_y, &ignore1, &ignore2, 2349 pixel_to_glyph_coords (f1, win_x, win_y, &ignore1, &ignore2,
2371 &last_mouse_glyph, x_mouse_grabbed); 2350 &last_mouse_glyph,
2351 FRAME_X_DISPLAY_INFO (f1)->grabbed);
2372 2352
2373 *bar_window = Qnil; 2353 *bar_window = Qnil;
2374 *part = 0; 2354 *part = 0;
2375 *f = f1; 2355 *fp = f1;
2376 XSETINT (*x, win_x); 2356 XSETINT (*x, win_x);
2377 XSETINT (*y, win_y); 2357 XSETINT (*y, win_y);
2378 *time = last_mouse_movement_time; 2358 *time = last_mouse_movement_time;
@@ -2429,16 +2409,16 @@ x_scroll_bar_create (window, top, left, width, height)
2429 struct window *window; 2409 struct window *window;
2430 int top, left, width, height; 2410 int top, left, width, height;
2431{ 2411{
2432 FRAME_PTR frame = XFRAME (WINDOW_FRAME (window)); 2412 FRAME_PTR f = XFRAME (WINDOW_FRAME (window));
2433 struct scroll_bar *bar = 2413 struct scroll_bar *bar
2434 XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 2414 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
2435 2415
2436 BLOCK_INPUT; 2416 BLOCK_INPUT;
2437 2417
2438 { 2418 {
2439 XSetWindowAttributes a; 2419 XSetWindowAttributes a;
2440 unsigned long mask; 2420 unsigned long mask;
2441 a.background_pixel = frame->display.x->background_pixel; 2421 a.background_pixel = f->display.x->background_pixel;
2442 a.event_mask = (ButtonPressMask | ButtonReleaseMask 2422 a.event_mask = (ButtonPressMask | ButtonReleaseMask
2443 | ButtonMotionMask | PointerMotionHintMask 2423 | ButtonMotionMask | PointerMotionHintMask
2444 | ExposureMask); 2424 | ExposureMask);
@@ -2456,13 +2436,13 @@ x_scroll_bar_create (window, top, left, width, height)
2456 XtSetArg (al[ac], XtNborderWidth, 0); ac++; 2436 XtSetArg (al[ac], XtNborderWidth, 0); ac++;
2457 sb_widget = XtCreateManagedWidget ("box", 2437 sb_widget = XtCreateManagedWidget ("box",
2458 boxWidgetClass, 2438 boxWidgetClass,
2459 frame->display.x->edit_widget, al, ac); 2439 f->display.x->edit_widget, al, ac);
2460 SET_SCROLL_BAR_X_WINDOW 2440 SET_SCROLL_BAR_X_WINDOW
2461 (bar, sb_widget->core.window); 2441 (bar, sb_widget->core.window);
2462#endif 2442#endif
2463 SET_SCROLL_BAR_X_WINDOW 2443 SET_SCROLL_BAR_X_WINDOW
2464 (bar, 2444 (bar,
2465 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame), 2445 XCreateWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2466 2446
2467 /* Position and size of scroll bar. */ 2447 /* Position and size of scroll bar. */
2468 left, top, width, height, 2448 left, top, width, height,
@@ -2484,13 +2464,13 @@ x_scroll_bar_create (window, top, left, width, height)
2484 bar->dragging = Qnil; 2464 bar->dragging = Qnil;
2485 2465
2486 /* Add bar to its frame's list of scroll bars. */ 2466 /* Add bar to its frame's list of scroll bars. */
2487 bar->next = FRAME_SCROLL_BARS (frame); 2467 bar->next = FRAME_SCROLL_BARS (f);
2488 bar->prev = Qnil; 2468 bar->prev = Qnil;
2489 XSETVECTOR (FRAME_SCROLL_BARS (frame), bar); 2469 XSETVECTOR (FRAME_SCROLL_BARS (f), bar);
2490 if (! NILP (bar->next)) 2470 if (! NILP (bar->next))
2491 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); 2471 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
2492 2472
2493 XMapWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar)); 2473 XMapWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar));
2494 2474
2495 UNBLOCK_INPUT; 2475 UNBLOCK_INPUT;
2496 2476
@@ -2516,7 +2496,8 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
2516{ 2496{
2517 int dragging = ! NILP (bar->dragging); 2497 int dragging = ! NILP (bar->dragging);
2518 Window w = SCROLL_BAR_X_WINDOW (bar); 2498 Window w = SCROLL_BAR_X_WINDOW (bar);
2519 GC gc = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))->display.x->normal_gc; 2499 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
2500 GC gc = f->display.x->normal_gc;
2520 2501
2521 /* If the display is already accurate, do nothing. */ 2502 /* If the display is already accurate, do nothing. */
2522 if (! rebuild 2503 if (! rebuild
@@ -2564,7 +2545,7 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
2564 /* Draw the empty space above the handle. Note that we can't clear 2545 /* Draw the empty space above the handle. Note that we can't clear
2565 zero-height areas; that means "clear to end of window." */ 2546 zero-height areas; that means "clear to end of window." */
2566 if (0 < start) 2547 if (0 < start)
2567 XClearArea (x_current_display, w, 2548 XClearArea (FRAME_X_DISPLAY (f), w,
2568 2549
2569 /* x, y, width, height, and exposures. */ 2550 /* x, y, width, height, and exposures. */
2570 VERTICAL_SCROLL_BAR_LEFT_BORDER, 2551 VERTICAL_SCROLL_BAR_LEFT_BORDER,
@@ -2573,7 +2554,7 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
2573 False); 2554 False);
2574 2555
2575 /* Draw the handle itself. */ 2556 /* Draw the handle itself. */
2576 XFillRectangle (x_current_display, w, gc, 2557 XFillRectangle (FRAME_X_DISPLAY (f), w, gc,
2577 2558
2578 /* x, y, width, height */ 2559 /* x, y, width, height */
2579 VERTICAL_SCROLL_BAR_LEFT_BORDER, 2560 VERTICAL_SCROLL_BAR_LEFT_BORDER,
@@ -2584,7 +2565,7 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
2584 /* Draw the empty space below the handle. Note that we can't 2565 /* Draw the empty space below the handle. Note that we can't
2585 clear zero-height areas; that means "clear to end of window." */ 2566 clear zero-height areas; that means "clear to end of window." */
2586 if (end < inside_height) 2567 if (end < inside_height)
2587 XClearArea (x_current_display, w, 2568 XClearArea (FRAME_X_DISPLAY (f), w,
2588 2569
2589 /* x, y, width, height, and exposures. */ 2570 /* x, y, width, height, and exposures. */
2590 VERTICAL_SCROLL_BAR_LEFT_BORDER, 2571 VERTICAL_SCROLL_BAR_LEFT_BORDER,
@@ -2604,6 +2585,9 @@ x_scroll_bar_move (bar, top, left, width, height)
2604 struct scroll_bar *bar; 2585 struct scroll_bar *bar;
2605 int top, left, width, height; 2586 int top, left, width, height;
2606{ 2587{
2588 Window w = SCROLL_BAR_X_WINDOW (bar);
2589 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
2590
2607 BLOCK_INPUT; 2591 BLOCK_INPUT;
2608 2592
2609 { 2593 {
@@ -2621,7 +2605,7 @@ x_scroll_bar_move (bar, top, left, width, height)
2621 if (height != XINT (bar->height)) mask |= CWHeight; 2605 if (height != XINT (bar->height)) mask |= CWHeight;
2622 2606
2623 if (mask) 2607 if (mask)
2624 XConfigureWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar), 2608 XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar),
2625 mask, &wc); 2609 mask, &wc);
2626 } 2610 }
2627 2611
@@ -2644,7 +2628,7 @@ x_scroll_bar_remove (bar)
2644 BLOCK_INPUT; 2628 BLOCK_INPUT;
2645 2629
2646 /* Destroy the window. */ 2630 /* Destroy the window. */
2647 XDestroyWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar)); 2631 XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar));
2648 2632
2649 /* Disassociate this scroll bar from its window. */ 2633 /* Disassociate this scroll bar from its window. */
2650 XWINDOW (bar->window)->vertical_scroll_bar = Qnil; 2634 XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
@@ -2823,14 +2807,15 @@ x_scroll_bar_expose (bar, event)
2823 XEvent *event; 2807 XEvent *event;
2824{ 2808{
2825 Window w = SCROLL_BAR_X_WINDOW (bar); 2809 Window w = SCROLL_BAR_X_WINDOW (bar);
2826 GC gc = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))->display.x->normal_gc; 2810 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
2811 GC gc = f->display.x->normal_gc;
2827 2812
2828 BLOCK_INPUT; 2813 BLOCK_INPUT;
2829 2814
2830 x_scroll_bar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1); 2815 x_scroll_bar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1);
2831 2816
2832 /* Draw a one-pixel border just inside the edges of the scroll bar. */ 2817 /* Draw a one-pixel border just inside the edges of the scroll bar. */
2833 XDrawRectangle (x_current_display, w, gc, 2818 XDrawRectangle (FRAME_X_DISPLAY (f), w, gc,
2834 2819
2835 /* x, y, width, height */ 2820 /* x, y, width, height */
2836 0, 0, XINT (bar->width) - 1, XINT (bar->height) - 1); 2821 0, 0, XINT (bar->width) - 1, XINT (bar->height) - 1);
@@ -2855,7 +2840,8 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
2855 emacs_event->kind = scroll_bar_click; 2840 emacs_event->kind = scroll_bar_click;
2856 emacs_event->code = event->xbutton.button - Button1; 2841 emacs_event->code = event->xbutton.button - Button1;
2857 emacs_event->modifiers = 2842 emacs_event->modifiers =
2858 (x_x_to_emacs_modifiers (event->xbutton.state) 2843 (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))),
2844 event->xbutton.state)
2859 | (event->type == ButtonRelease 2845 | (event->type == ButtonRelease
2860 ? up_modifier 2846 ? up_modifier
2861 : down_modifier)); 2847 : down_modifier));
@@ -2960,14 +2946,16 @@ x_scroll_bar_note_movement (bar, event)
2960/* Return information to the user about the current position of the mouse 2946/* Return information to the user about the current position of the mouse
2961 on the scroll bar. */ 2947 on the scroll bar. */
2962static void 2948static void
2963x_scroll_bar_report_motion (f, bar_window, part, x, y, time) 2949x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
2964 FRAME_PTR *f; 2950 FRAME_PTR *fp;
2965 Lisp_Object *bar_window; 2951 Lisp_Object *bar_window;
2966 enum scroll_bar_part *part; 2952 enum scroll_bar_part *part;
2967 Lisp_Object *x, *y; 2953 Lisp_Object *x, *y;
2968 unsigned long *time; 2954 unsigned long *time;
2969{ 2955{
2970 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 2956 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
2957 Window w = SCROLL_BAR_X_WINDOW (bar);
2958 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
2971 int win_x, win_y; 2959 int win_x, win_y;
2972 Window dummy_window; 2960 Window dummy_window;
2973 int dummy_coord; 2961 int dummy_coord;
@@ -2977,8 +2965,7 @@ x_scroll_bar_report_motion (f, bar_window, part, x, y, time)
2977 2965
2978 /* Get the mouse's position relative to the scroll bar window, and 2966 /* Get the mouse's position relative to the scroll bar window, and
2979 report that. */ 2967 report that. */
2980 if (! XQueryPointer (x_current_display, 2968 if (! XQueryPointer (FRAME_X_DISPLAY (f), w,
2981 SCROLL_BAR_X_WINDOW (bar),
2982 2969
2983 /* Root, child, root x and root y. */ 2970 /* Root, child, root x and root y. */
2984 &dummy_window, &dummy_window, 2971 &dummy_window, &dummy_window,
@@ -2989,7 +2976,7 @@ x_scroll_bar_report_motion (f, bar_window, part, x, y, time)
2989 2976
2990 /* Mouse buttons and modifier keys. */ 2977 /* Mouse buttons and modifier keys. */
2991 &dummy_mask)) 2978 &dummy_mask))
2992 *f = 0; 2979 *fp = 0;
2993 else 2980 else
2994 { 2981 {
2995 int inside_height 2982 int inside_height
@@ -3007,8 +2994,8 @@ x_scroll_bar_report_motion (f, bar_window, part, x, y, time)
3007 if (win_y > top_range) 2994 if (win_y > top_range)
3008 win_y = top_range; 2995 win_y = top_range;
3009 2996
3010 *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 2997 *fp = f;
3011 *bar_window = bar->window; 2998 *bar_window = w;
3012 2999
3013 if (! NILP (bar->dragging)) 3000 if (! NILP (bar->dragging))
3014 *part = scroll_bar_handle; 3001 *part = scroll_bar_handle;
@@ -3044,7 +3031,7 @@ x_scroll_bar_clear (f)
3044 3031
3045 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); 3032 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
3046 bar = XSCROLL_BAR (bar)->next) 3033 bar = XSCROLL_BAR (bar)->next)
3047 XClearArea (x_current_display, SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), 3034 XClearArea (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
3048 0, 0, 0, 0, True); 3035 0, 0, 0, 0, True);
3049} 3036}
3050 3037
@@ -3104,7 +3091,8 @@ static int x_queue_selection_requests;
3104/* Queue up an X event *EVENT, to be processed later. */ 3091/* Queue up an X event *EVENT, to be processed later. */
3105 3092
3106static void 3093static void
3107x_queue_event (event) 3094x_queue_event (f, event)
3095 FRAME_PTR f;
3108 XEvent *event; 3096 XEvent *event;
3109{ 3097{
3110 struct selection_event_queue *queue_tmp 3098 struct selection_event_queue *queue_tmp
@@ -3122,12 +3110,13 @@ x_queue_event (event)
3122 so that they get processed afresh. */ 3110 so that they get processed afresh. */
3123 3111
3124static void 3112static void
3125x_unqueue_events () 3113x_unqueue_events (f)
3114 FRAME_PTR f;
3126{ 3115{
3127 while (queue != NULL) 3116 while (queue != NULL)
3128 { 3117 {
3129 struct selection_event_queue *queue_tmp = queue; 3118 struct selection_event_queue *queue_tmp = queue;
3130 XPutBackEvent (XDISPLAY &queue_tmp->event); 3119 XPutBackEvent (FRAME_X_DISPLAY (f), &queue_tmp->event);
3131 queue = queue_tmp->next; 3120 queue = queue_tmp->next;
3132 free ((char *)queue_tmp); 3121 free ((char *)queue_tmp);
3133 } 3122 }
@@ -3136,7 +3125,8 @@ x_unqueue_events ()
3136/* Start queuing SelectionRequest events. */ 3125/* Start queuing SelectionRequest events. */
3137 3126
3138void 3127void
3139x_start_queuing_selection_requests () 3128x_start_queuing_selection_requests (f)
3129 FRAME_PTR f;
3140{ 3130{
3141 x_queue_selection_requests++; 3131 x_queue_selection_requests++;
3142} 3132}
@@ -3144,10 +3134,11 @@ x_start_queuing_selection_requests ()
3144/* Stop queuing SelectionRequest events. */ 3134/* Stop queuing SelectionRequest events. */
3145 3135
3146void 3136void
3147x_stop_queuing_selection_requests () 3137x_stop_queuing_selection_requests (f)
3138 FRAME_PTR f;
3148{ 3139{
3149 x_queue_selection_requests--; 3140 x_queue_selection_requests--;
3150 x_unqueue_events (); 3141 x_unqueue_events (f);
3151} 3142}
3152 3143
3153/* The main X event-reading loop - XTread_socket. */ 3144/* The main X event-reading loop - XTread_socket. */
@@ -3166,24 +3157,6 @@ static Time enter_timestamp;
3166 given for enter_timestamp, above. */ 3157 given for enter_timestamp, above. */
3167static XComposeStatus compose_status; 3158static XComposeStatus compose_status;
3168 3159
3169/* Communication with window managers. */
3170Atom Xatom_wm_protocols;
3171
3172/* Kinds of protocol things we may receive. */
3173Atom Xatom_wm_take_focus;
3174Atom Xatom_wm_save_yourself;
3175Atom Xatom_wm_delete_window;
3176
3177/* Other WM communication */
3178Atom Xatom_wm_configure_denied; /* When our config request is denied */
3179Atom Xatom_wm_window_moved; /* When the WM moves us. */
3180
3181/* Window manager communication. */
3182Atom Xatom_wm_change_state;
3183
3184/* EditRes protocol */
3185Atom Xatom_editres_name;
3186
3187/* Record the last 100 characters stored 3160/* Record the last 100 characters stored
3188 to help debug the loss-of-chars-during-GC problem. */ 3161 to help debug the loss-of-chars-during-GC problem. */
3189int temp_index; 3162int temp_index;
@@ -3218,6 +3191,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3218 int event_found = 0; 3191 int event_found = 0;
3219 int prefix; 3192 int prefix;
3220 Lisp_Object part; 3193 Lisp_Object part;
3194 struct x_display_info *dpyinfo;
3221 3195
3222 if (interrupt_input_blocked) 3196 if (interrupt_input_blocked)
3223 { 3197 {
@@ -3228,6 +3202,14 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3228 interrupt_input_pending = 0; 3202 interrupt_input_pending = 0;
3229 BLOCK_INPUT; 3203 BLOCK_INPUT;
3230 3204
3205 /* Find the display we are supposed to read input for.
3206 It's the one communicating on descriptor SD. */
3207 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
3208 if (dpyinfo->connection == sd)
3209 break;
3210 if (dpyinfo == 0)
3211 abort ();
3212
3231 /* So people can tell when we have read the available input. */ 3213 /* So people can tell when we have read the available input. */
3232 input_signal_count++; 3214 input_signal_count++;
3233 3215
@@ -3239,34 +3221,36 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3239 non-blocking, and then looks for EWOULDBLOCK. If O_NDELAY is set, 3221 non-blocking, and then looks for EWOULDBLOCK. If O_NDELAY is set,
3240 FIOSNBIO is ignored, and instead of signalling EWOULDBLOCK, 3222 FIOSNBIO is ignored, and instead of signalling EWOULDBLOCK,
3241 a read returns 0, which Xlib interprets as equivalent to EPIPE. */ 3223 a read returns 0, which Xlib interprets as equivalent to EPIPE. */
3242 fcntl (fileno (stdin), F_SETFL, 0); 3224 fcntl (sd, F_SETFL, 0);
3243#endif /* ! defined (FIOSNBIO) */ 3225#endif /* ! defined (FIOSNBIO) */
3244 3226
3245#ifndef SIGIO 3227#ifndef SIGIO
3246#ifndef HAVE_SELECT 3228#ifndef HAVE_SELECT
3247 if (! (fcntl (fileno (stdin), F_GETFL, 0) & O_NDELAY)) 3229 if (! (fcntl (sd, F_GETFL, 0) & O_NDELAY))
3248 { 3230 {
3249 extern int read_alarm_should_throw; 3231 extern int read_alarm_should_throw;
3250 read_alarm_should_throw = 1; 3232 read_alarm_should_throw = 1;
3251 XPeekEvent (XDISPLAY &event); 3233 XPeekEvent (dpyinfo->display, &event);
3252 read_alarm_should_throw = 0; 3234 read_alarm_should_throw = 0;
3253 } 3235 }
3254#endif /* HAVE_SELECT */ 3236#endif /* HAVE_SELECT */
3255#endif /* SIGIO */ 3237#endif /* SIGIO */
3256 3238
3257 while (XStuffPending () != 0) 3239 while (XPending (dpyinfo->display) != 0)
3258 { 3240 {
3259 XNextEvent (XDISPLAY &event); 3241 XNextEvent (dpyinfo->display, &event);
3260 event_found = 1; 3242 event_found = 1;
3261 3243
3262 switch (event.type) 3244 switch (event.type)
3263 { 3245 {
3264 case ClientMessage: 3246 case ClientMessage:
3265 { 3247 {
3266 if (event.xclient.message_type == Xatom_wm_protocols 3248 if (event.xclient.message_type
3249 == dpyinfo->Xatom_wm_protocols
3267 && event.xclient.format == 32) 3250 && event.xclient.format == 32)
3268 { 3251 {
3269 if (event.xclient.data.l[0] == Xatom_wm_take_focus) 3252 if (event.xclient.data.l[0]
3253 == dpyinfo->Xatom_wm_take_focus)
3270 { 3254 {
3271 f = x_window_to_frame (event.xclient.window); 3255 f = x_window_to_frame (event.xclient.window);
3272 /* Since we set WM_TAKE_FOCUS, we must call 3256 /* Since we set WM_TAKE_FOCUS, we must call
@@ -3279,7 +3263,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3279 event.xclient.data.l[1]); 3263 event.xclient.data.l[1]);
3280 /* Not certain about handling scroll bars here */ 3264 /* Not certain about handling scroll bars here */
3281 } 3265 }
3282 else if (event.xclient.data.l[0] == Xatom_wm_save_yourself) 3266 else if (event.xclient.data.l[0]
3267 == dpyinfo->Xatom_wm_save_yourself)
3283 { 3268 {
3284 /* Save state modify the WM_COMMAND property to 3269 /* Save state modify the WM_COMMAND property to
3285 something which can reinstate us. This notifies 3270 something which can reinstate us. This notifies
@@ -3288,20 +3273,22 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3288 a keyboard or mouse event arrives. */ 3273 a keyboard or mouse event arrives. */
3289 if (numchars > 0) 3274 if (numchars > 0)
3290 { 3275 {
3276 f = x_top_window_to_frame (event.xclient.window);
3277
3291 /* This is just so we only give real data once 3278 /* This is just so we only give real data once
3292 for a single Emacs process. */ 3279 for a single Emacs process. */
3293 if (x_top_window_to_frame (event.xclient.window) 3280 if (f == selected_frame)
3294 == selected_frame) 3281 XSetCommand (FRAME_X_DISPLAY (f),
3295 XSetCommand (x_current_display,
3296 event.xclient.window, 3282 event.xclient.window,
3297 initial_argv, initial_argc); 3283 initial_argv, initial_argc);
3298 else 3284 else
3299 XSetCommand (x_current_display, 3285 XSetCommand (FRAME_X_DISPLAY (f),
3300 event.xclient.window, 3286 event.xclient.window,
3301 0, 0); 3287 0, 0);
3302 } 3288 }
3303 } 3289 }
3304 else if (event.xclient.data.l[0] == Xatom_wm_delete_window) 3290 else if (event.xclient.data.l[0]
3291 == dpyinfo->Xatom_wm_delete_window)
3305 { 3292 {
3306 struct frame *f = x_any_window_to_frame (event.xclient.window); 3293 struct frame *f = x_any_window_to_frame (event.xclient.window);
3307 3294
@@ -3319,10 +3306,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3319 } 3306 }
3320 } 3307 }
3321 } 3308 }
3322 else if (event.xclient.message_type == Xatom_wm_configure_denied) 3309 else if (event.xclient.message_type
3310 == dpyinfo->Xatom_wm_configure_denied)
3323 { 3311 {
3324 } 3312 }
3325 else if (event.xclient.message_type == Xatom_wm_window_moved) 3313 else if (event.xclient.message_type
3314 == dpyinfo->Xatom_wm_window_moved)
3326 { 3315 {
3327 int new_x, new_y; 3316 int new_x, new_y;
3328 struct frame *f = x_window_to_frame (event.xclient.window); 3317 struct frame *f = x_window_to_frame (event.xclient.window);
@@ -3337,7 +3326,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3337 } 3326 }
3338 } 3327 }
3339#if defined (USE_X_TOOLKIT) && defined (HAVE_X11R5) 3328#if defined (USE_X_TOOLKIT) && defined (HAVE_X11R5)
3340 else if (event.xclient.message_type == Xatom_editres_name) 3329 else if (event.xclient.message_type
3330 == dpyinfo->Xatom_editres)
3341 { 3331 {
3342 struct frame *f = x_any_window_to_frame (event.xclient.window); 3332 struct frame *f = x_any_window_to_frame (event.xclient.window);
3343 _XEditResCheckMessages (f->display.x->widget, NULL, &event, NULL); 3333 _XEditResCheckMessages (f->display.x->widget, NULL, &event, NULL);
@@ -3382,7 +3372,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3382 goto OTHER; 3372 goto OTHER;
3383#endif /* USE_X_TOOLKIT */ 3373#endif /* USE_X_TOOLKIT */
3384 if (x_queue_selection_requests) 3374 if (x_queue_selection_requests)
3385 x_queue_event (&event); 3375 x_queue_event (x_window_to_frame (event.xselectionrequest.owner),
3376 &event);
3386 else 3377 else
3387 { 3378 {
3388 XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event; 3379 XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event;
@@ -3530,7 +3521,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3530 int modifiers; 3521 int modifiers;
3531 3522
3532 event.xkey.state 3523 event.xkey.state
3533 |= x_emacs_to_x_modifiers (extra_keyboard_modifiers); 3524 |= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f),
3525 extra_keyboard_modifiers);
3534 modifiers = event.xkey.state; 3526 modifiers = event.xkey.state;
3535 3527
3536 /* This will have to go some day... */ 3528 /* This will have to go some day... */
@@ -3618,7 +3610,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3618 bufp->kind = non_ascii_keystroke; 3610 bufp->kind = non_ascii_keystroke;
3619 bufp->code = keysym; 3611 bufp->code = keysym;
3620 XSETFRAME (bufp->frame_or_window, f); 3612 XSETFRAME (bufp->frame_or_window, f);
3621 bufp->modifiers = x_x_to_emacs_modifiers (modifiers); 3613 bufp->modifiers
3614 = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f),
3615 modifiers);
3622 bufp->timestamp = event.xkey.time; 3616 bufp->timestamp = event.xkey.time;
3623 bufp++; 3617 bufp++;
3624 count++; 3618 count++;
@@ -3636,7 +3630,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3636 bufp->kind = ascii_keystroke; 3630 bufp->kind = ascii_keystroke;
3637 bufp->code = copy_buffer[i]; 3631 bufp->code = copy_buffer[i];
3638 XSETFRAME (bufp->frame_or_window, f); 3632 XSETFRAME (bufp->frame_or_window, f);
3639 bufp->modifiers = x_x_to_emacs_modifiers (modifiers); 3633 bufp->modifiers
3634 = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f),
3635 modifiers);
3640 bufp->timestamp = event.xkey.time; 3636 bufp->timestamp = event.xkey.time;
3641 bufp++; 3637 bufp++;
3642 } 3638 }
@@ -3738,7 +3734,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3738 3734
3739 case MotionNotify: 3735 case MotionNotify:
3740 { 3736 {
3741 if (x_mouse_grabbed && last_mouse_frame 3737 if (dpyinfo->grabbed && last_mouse_frame
3742 && FRAME_LIVE_P (last_mouse_frame)) 3738 && FRAME_LIVE_P (last_mouse_frame))
3743 f = last_mouse_frame; 3739 f = last_mouse_frame;
3744 else 3740 else
@@ -3785,11 +3781,11 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3785 refer to the parent window here; we may be processing 3781 refer to the parent window here; we may be processing
3786 this event after the window manager has changed our 3782 this event after the window manager has changed our
3787 parent, but before we have reached the ReparentNotify. */ 3783 parent, but before we have reached the ReparentNotify. */
3788 XTranslateCoordinates (x_current_display, 3784 XTranslateCoordinates (FRAME_X_DISPLAY (f),
3789 3785
3790 /* From-window, to-window. */ 3786 /* From-window, to-window. */
3791 XtWindow (f->display.x->widget), 3787 XtWindow (f->display.x->widget),
3792 ROOT_WINDOW, 3788 FRAME_X_DISPLAY_INFO (f)->root_window,
3793 3789
3794 /* From-position, to-position. */ 3790 /* From-position, to-position. */
3795 -event.xconfigure.border_width, 3791 -event.xconfigure.border_width,
@@ -3844,11 +3840,11 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3844 refer to the parent window here; we may be processing 3840 refer to the parent window here; we may be processing
3845 this event after the window manager has changed our 3841 this event after the window manager has changed our
3846 parent, but before we have reached the ReparentNotify. */ 3842 parent, but before we have reached the ReparentNotify. */
3847 XTranslateCoordinates (x_current_display, 3843 XTranslateCoordinates (FRAME_X_DISPLAY (f),
3848 3844
3849 /* From-window, to-window. */ 3845 /* From-window, to-window. */
3850 f->display.x->window_desc, 3846 f->display.x->window_desc,
3851 ROOT_WINDOW, 3847 FRAME_X_DISPLAY_INFO (f)->root_window,
3852 3848
3853 /* From-position, to-position. */ 3849 /* From-position, to-position. */
3854 -event.xconfigure.border_width, 3850 -event.xconfigure.border_width,
@@ -3921,15 +3917,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3921 3917
3922 if (event.type == ButtonPress) 3918 if (event.type == ButtonPress)
3923 { 3919 {
3924 x_mouse_grabbed |= (1 << event.xbutton.button); 3920 dpyinfo->grabbed |= (1 << event.xbutton.button);
3925 Vmouse_depressed = Qt;
3926 last_mouse_frame = f; 3921 last_mouse_frame = f;
3927 } 3922 }
3928 else 3923 else
3929 { 3924 {
3930 x_mouse_grabbed &= ~(1 << event.xbutton.button); 3925 dpyinfo->grabbed &= ~(1 << event.xbutton.button);
3931 if (!x_mouse_grabbed)
3932 Vmouse_depressed = Qnil;
3933 } 3926 }
3934 3927
3935 if (numchars >= 1 && emacs_event.kind != no_event) 3928 if (numchars >= 1 && emacs_event.kind != no_event)
@@ -3957,7 +3950,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3957 switch (event.xmapping.request) 3950 switch (event.xmapping.request)
3958 { 3951 {
3959 case MappingModifier: 3952 case MappingModifier:
3960 x_find_modifier_meanings (); 3953 x_find_modifier_meanings (dpyinfo);
3961 /* This is meant to fall through. */ 3954 /* This is meant to fall through. */
3962 case MappingKeyboard: 3955 case MappingKeyboard:
3963 XRefreshKeyboardMapping (&event.xmapping); 3956 XRefreshKeyboardMapping (&event.xmapping);
@@ -3989,7 +3982,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3989 if (x_noop_count >= 100) 3982 if (x_noop_count >= 100)
3990 { 3983 {
3991 x_noop_count=0; 3984 x_noop_count=0;
3992 XNoOp (x_current_display); 3985 XNoOp (dpyinfo->display);
3993 } 3986 }
3994 } 3987 }
3995 3988
@@ -4004,7 +3997,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
4004 /* AOJ 880406: if select returns true but XPending doesn't, it means that 3997 /* AOJ 880406: if select returns true but XPending doesn't, it means that
4005 there is an EOF condition; in other words, that X has died. 3998 there is an EOF condition; in other words, that X has died.
4006 Act as if there had been a hangup. */ 3999 Act as if there had been a hangup. */
4007 int fd = ConnectionNumber (x_current_display); 4000 int fd = ConnectionNumber (dpyinfo->display);
4008 SELECT_TYPE mask, junk1, junk2; 4001 SELECT_TYPE mask, junk1, junk2;
4009 EMACS_TIME timeout; 4002 EMACS_TIME timeout;
4010 4003
@@ -4014,7 +4007,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
4014 FD_ZERO (&junk1); 4007 FD_ZERO (&junk1);
4015 FD_ZERO (&junk2); 4008 FD_ZERO (&junk2);
4016 if (0 != select (fd + 1, &mask, &junk1, &junk2, &timeout) 4009 if (0 != select (fd + 1, &mask, &junk1, &junk2, &timeout)
4017 && !XStuffPending ()) 4010 && !XPending (dpyinfo->display))
4018 kill (getpid (), SIGHUP); 4011 kill (getpid (), SIGHUP);
4019 } 4012 }
4020#endif /* HAVE_SELECT */ 4013#endif /* HAVE_SELECT */
@@ -4046,7 +4039,7 @@ x_draw_box (f)
4046 int width = FONT_WIDTH (f->display.x->font); 4039 int width = FONT_WIDTH (f->display.x->font);
4047 int height = f->display.x->line_height; 4040 int height = f->display.x->line_height;
4048 4041
4049 XDrawRectangle (x_current_display, FRAME_X_WINDOW (f), 4042 XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4050 f->display.x->cursor_gc, 4043 f->display.x->cursor_gc,
4051 left, top, width - 1, height - 1); 4044 left, top, width - 1, height - 1);
4052} 4045}
@@ -4135,7 +4128,7 @@ x_display_bar_cursor (f, on)
4135 && curs_x < current_glyphs->used[curs_y]) 4128 && curs_x < current_glyphs->used[curs_y])
4136 ? current_glyphs->glyphs[curs_y][curs_x] 4129 ? current_glyphs->glyphs[curs_y][curs_x]
4137 : SPACEGLYPH); 4130 : SPACEGLYPH);
4138 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), 4131 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4139 f->display.x->cursor_gc, 4132 f->display.x->cursor_gc,
4140 CHAR_TO_PIXEL_COL (f, curs_x), 4133 CHAR_TO_PIXEL_COL (f, curs_x),
4141 CHAR_TO_PIXEL_ROW (f, curs_y), 4134 CHAR_TO_PIXEL_ROW (f, curs_y),
@@ -4148,7 +4141,7 @@ x_display_bar_cursor (f, on)
4148 } 4141 }
4149 4142
4150 if (updating_frame != f) 4143 if (updating_frame != f)
4151 XFlushQueue (); 4144 XFlush (FRAME_X_DISPLAY (f));
4152} 4145}
4153 4146
4154 4147
@@ -4210,7 +4203,7 @@ x_display_box_cursor (f, on)
4210 /* If the font is not as tall as a whole line, 4203 /* If the font is not as tall as a whole line,
4211 we must explicitly clear the line's whole height. */ 4204 we must explicitly clear the line's whole height. */
4212 if (FONT_HEIGHT (f->display.x->font) != f->display.x->line_height) 4205 if (FONT_HEIGHT (f->display.x->font) != f->display.x->line_height)
4213 XClearArea (x_current_display, FRAME_X_WINDOW (f), 4206 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4214 CHAR_TO_PIXEL_COL (f, f->phys_cursor_x), 4207 CHAR_TO_PIXEL_COL (f, f->phys_cursor_x),
4215 CHAR_TO_PIXEL_ROW (f, f->phys_cursor_y), 4208 CHAR_TO_PIXEL_ROW (f, f->phys_cursor_y),
4216 FONT_WIDTH (f->display.x->font), 4209 FONT_WIDTH (f->display.x->font),
@@ -4254,7 +4247,7 @@ x_display_box_cursor (f, on)
4254 } 4247 }
4255 4248
4256 if (updating_frame != f) 4249 if (updating_frame != f)
4257 XFlushQueue (); 4250 XFlush (FRAME_X_DISPLAY (f));
4258} 4251}
4259 4252
4260x_display_cursor (f, on) 4253x_display_cursor (f, on)
@@ -4308,17 +4301,18 @@ x_bitmap_icon (f, file)
4308 else 4301 else
4309 { 4302 {
4310 /* Create the GNU bitmap if necessary. */ 4303 /* Create the GNU bitmap if necessary. */
4311 if (!icon_bitmap) 4304 if (!FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
4312 icon_bitmap = x_create_bitmap_from_data (f, gnu_bits, 4305 FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id
4313 gnu_width, gnu_height); 4306 = x_create_bitmap_from_data (f, gnu_bits,
4307 gnu_width, gnu_height);
4314 4308
4315 /* The first time we create the GNU bitmap, 4309 /* The first time we create the GNU bitmap,
4316 this increments the refcount one extra time. 4310 this increments the refcount one extra time.
4317 As a result, the GNU bitmap is never freed. 4311 As a result, the GNU bitmap is never freed.
4318 That way, we don't have to worry about allocating it again. */ 4312 That way, we don't have to worry about allocating it again. */
4319 x_reference_bitmap (f, icon_bitmap); 4313 x_reference_bitmap (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
4320 4314
4321 bitmap_id = icon_bitmap; 4315 bitmap_id = FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id;
4322 } 4316 }
4323 4317
4324 x_wm_set_icon_pixmap (f, bitmap_id); 4318 x_wm_set_icon_pixmap (f, bitmap_id);
@@ -4345,7 +4339,7 @@ x_text_icon (f, icon_name)
4345 f->display.x->icon_label = " *emacs* "; 4339 f->display.x->icon_label = " *emacs* ";
4346 4340
4347#if 0 4341#if 0
4348 XSetIconName (x_current_display, FRAME_X_WINDOW (f), 4342 XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4349 (char *) f->display.x->icon_label); 4343 (char *) f->display.x->icon_label);
4350#endif 4344#endif
4351 4345
@@ -4435,7 +4429,9 @@ x_error_catcher (display, error)
4435} 4429}
4436 4430
4437 4431
4438/* Begin trapping X errors. 4432/* Begin trapping X errors for frame F.
4433 Actually we trap X errors for all frames, but F should be the frame
4434 you are actually operating on.
4439 4435
4440 After calling this function, X protocol errors no longer cause 4436 After calling this function, X protocol errors no longer cause
4441 Emacs to exit; instead, they are recorded in x_cfc_error_message. 4437 Emacs to exit; instead, they are recorded in x_cfc_error_message.
@@ -4448,10 +4444,11 @@ x_error_catcher (display, error)
4448void x_catch_errors (), x_check_errors (), x_uncatch_errors (); 4444void x_catch_errors (), x_check_errors (), x_uncatch_errors ();
4449 4445
4450void 4446void
4451x_catch_errors () 4447x_catch_errors (f)
4448 FRAME_PTR f;
4452{ 4449{
4453 /* Make sure any errors from previous requests have been dealt with. */ 4450 /* Make sure any errors from previous requests have been dealt with. */
4454 XSync (x_current_display, False); 4451 XSync (FRAME_X_DISPLAY (f), False);
4455 4452
4456 /* Set up the error buffer. */ 4453 /* Set up the error buffer. */
4457 x_caught_error_message 4454 x_caught_error_message
@@ -4459,7 +4456,7 @@ x_catch_errors ()
4459 x_caught_error_message[0] = '\0'; 4456 x_caught_error_message[0] = '\0';
4460 4457
4461 /* Install our little error handler. */ 4458 /* Install our little error handler. */
4462 XHandleError (x_error_catcher); 4459 XSetErrorHandler (x_error_catcher);
4463} 4460}
4464 4461
4465/* If any X protocol errors have arrived since the last call to 4462/* If any X protocol errors have arrived since the last call to
@@ -4467,18 +4464,19 @@ x_catch_errors ()
4467 sprintf (a buffer, FORMAT, the x error message text) as the text. */ 4464 sprintf (a buffer, FORMAT, the x error message text) as the text. */
4468 4465
4469void 4466void
4470x_check_errors (format) 4467x_check_errors (f, format)
4468 FRAME_PTR f;
4471 char *format; 4469 char *format;
4472{ 4470{
4473 /* Make sure to catch any errors incurred so far. */ 4471 /* Make sure to catch any errors incurred so far. */
4474 XSync (x_current_display, False); 4472 XSync (FRAME_X_DISPLAY (f), False);
4475 4473
4476 if (x_caught_error_message[0]) 4474 if (x_caught_error_message[0])
4477 { 4475 {
4478 char buf[X_CAUGHT_ERROR_MESSAGE_SIZE + 56]; 4476 char buf[X_CAUGHT_ERROR_MESSAGE_SIZE + 56];
4479 4477
4480 sprintf (buf, format, x_caught_error_message); 4478 sprintf (buf, format, x_caught_error_message);
4481 x_uncatch_errors (); 4479 x_uncatch_errors (f);
4482 error (buf); 4480 error (buf);
4483 } 4481 }
4484} 4482}
@@ -4486,10 +4484,11 @@ x_check_errors (format)
4486/* Nonzero if we had any X protocol errors since we did x_catch_errors. */ 4484/* Nonzero if we had any X protocol errors since we did x_catch_errors. */
4487 4485
4488int 4486int
4489x_had_errors_p () 4487x_had_errors_p (f)
4488 FRAME_PTR f;
4490{ 4489{
4491 /* Make sure to catch any errors incurred so far. */ 4490 /* Make sure to catch any errors incurred so far. */
4492 XSync (x_current_display, False); 4491 XSync (FRAME_X_DISPLAY (f), False);
4493 4492
4494 return x_caught_error_message[0] != 0; 4493 return x_caught_error_message[0] != 0;
4495} 4494}
@@ -4497,11 +4496,12 @@ x_had_errors_p ()
4497/* Stop catching X protocol errors and let them make Emacs die. */ 4496/* Stop catching X protocol errors and let them make Emacs die. */
4498 4497
4499void 4498void
4500x_uncatch_errors () 4499x_uncatch_errors (f)
4500 FRAME_PTR f;
4501{ 4501{
4502 xfree (x_caught_error_message); 4502 xfree (x_caught_error_message);
4503 x_caught_error_message = 0; 4503 x_caught_error_message = 0;
4504 XHandleError (x_error_quitter); 4504 XSetErrorHandler (x_error_quitter);
4505} 4505}
4506 4506
4507#if 0 4507#if 0
@@ -4555,7 +4555,7 @@ x_new_font (f, fontname)
4555 /* Get a list of all the fonts that match this name. Once we 4555 /* Get a list of all the fonts that match this name. Once we
4556 have a list of matching fonts, we compare them against the fonts 4556 have a list of matching fonts, we compare them against the fonts
4557 we already have by comparing font ids. */ 4557 we already have by comparing font ids. */
4558 font_names = (char **) XListFonts (x_current_display, fontname, 4558 font_names = (char **) XListFonts (FRAME_X_DISPLAY (f), fontname,
4559 1024, &n_matching_fonts); 4559 1024, &n_matching_fonts);
4560 /* Apparently it doesn't set n_matching_fonts to zero when it can't 4560 /* Apparently it doesn't set n_matching_fonts to zero when it can't
4561 find any matches; font_names == 0 is the only clue. */ 4561 find any matches; font_names == 0 is the only clue. */
@@ -4608,7 +4608,7 @@ x_new_font (f, fontname)
4608 if (n_matching_fonts != 0) 4608 if (n_matching_fonts != 0)
4609 fontname = font_names[i]; 4609 fontname = font_names[i];
4610 4610
4611 font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname); 4611 font = (XFontStruct *) XLoadQueryFont (FRAME_X_DISPLAY (f), fontname);
4612 if (! font) 4612 if (! font)
4613 { 4613 {
4614 /* Free the information from XListFonts. */ 4614 /* Free the information from XListFonts. */
@@ -4640,10 +4640,10 @@ x_new_font (f, fontname)
4640 for (i = 0; i < font->n_properties; i++) 4640 for (i = 0; i < font->n_properties; i++)
4641 { 4641 {
4642 char *atom 4642 char *atom
4643 = XGetAtomName (x_current_display, font->properties[i].name); 4643 = XGetAtomName (FRAME_X_DISPLAY (f), font->properties[i].name);
4644 if (!strcmp (atom, "FONT")) 4644 if (!strcmp (atom, "FONT"))
4645 { 4645 {
4646 char *name = XGetAtomName (x_current_display, 4646 char *name = XGetAtomName (FRAME_X_DISPLAY (f),
4647 (Atom) (font->properties[i].card32)); 4647 (Atom) (font->properties[i].card32));
4648 char *p = name; 4648 char *p = name;
4649 int dashes = 0; 4649 int dashes = 0;
@@ -4693,11 +4693,11 @@ x_new_font (f, fontname)
4693 /* Now make the frame display the given font. */ 4693 /* Now make the frame display the given font. */
4694 if (FRAME_X_WINDOW (f) != 0) 4694 if (FRAME_X_WINDOW (f) != 0)
4695 { 4695 {
4696 XSetFont (x_current_display, f->display.x->normal_gc, 4696 XSetFont (FRAME_X_DISPLAY (f), f->display.x->normal_gc,
4697 f->display.x->font->fid); 4697 f->display.x->font->fid);
4698 XSetFont (x_current_display, f->display.x->reverse_gc, 4698 XSetFont (FRAME_X_DISPLAY (f), f->display.x->reverse_gc,
4699 f->display.x->font->fid); 4699 f->display.x->font->fid);
4700 XSetFont (x_current_display, f->display.x->cursor_gc, 4700 XSetFont (FRAME_X_DISPLAY (f), f->display.x->cursor_gc,
4701 f->display.x->font->fid); 4701 f->display.x->font->fid);
4702 4702
4703 frame_update_line_height (f); 4703 frame_update_line_height (f);
@@ -4730,10 +4730,10 @@ x_calc_absolute_position (f)
4730 4730
4731 /* Find the position of the outside upper-left corner of 4731 /* Find the position of the outside upper-left corner of
4732 the inner window, with respect to the outer window. */ 4732 the inner window, with respect to the outer window. */
4733 if (f->display.x->parent_desc != ROOT_WINDOW) 4733 if (f->display.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window)
4734 { 4734 {
4735 BLOCK_INPUT; 4735 BLOCK_INPUT;
4736 XTranslateCoordinates (x_current_display, 4736 XTranslateCoordinates (FRAME_X_DISPLAY (f),
4737 4737
4738 /* From-window, to-window. */ 4738 /* From-window, to-window. */
4739 f->display.x->window_desc, 4739 f->display.x->window_desc,
@@ -4750,13 +4750,13 @@ x_calc_absolute_position (f)
4750 /* Treat negative positions as relative to the leftmost bottommost 4750 /* Treat negative positions as relative to the leftmost bottommost
4751 position that fits on the screen. */ 4751 position that fits on the screen. */
4752 if (flags & XNegative) 4752 if (flags & XNegative)
4753 f->display.x->left_pos = (x_screen_width 4753 f->display.x->left_pos = (FRAME_X_DISPLAY_INFO (f)->width
4754 - 2 * f->display.x->border_width - win_x 4754 - 2 * f->display.x->border_width - win_x
4755 - PIXEL_WIDTH (f) 4755 - PIXEL_WIDTH (f)
4756 + f->display.x->left_pos); 4756 + f->display.x->left_pos);
4757 4757
4758 if (flags & YNegative) 4758 if (flags & YNegative)
4759 f->display.x->top_pos = (x_screen_height 4759 f->display.x->top_pos = (FRAME_X_DISPLAY_INFO (f)->height
4760 - 2 * f->display.x->border_width - win_y 4760 - 2 * f->display.x->border_width - win_y
4761 - PIXEL_HEIGHT (f) 4761 - PIXEL_HEIGHT (f)
4762 + f->display.x->top_pos); 4762 + f->display.x->top_pos);
@@ -4793,10 +4793,10 @@ x_set_offset (f, xoff, yoff, change_gravity)
4793 x_wm_set_size_hint (f, 0, 0); 4793 x_wm_set_size_hint (f, 0, 0);
4794 4794
4795#ifdef USE_X_TOOLKIT 4795#ifdef USE_X_TOOLKIT
4796 XMoveWindow (XDISPLAY XtWindow (f->display.x->widget), 4796 XMoveWindow (FRAME_X_DISPLAY (f), XtWindow (f->display.x->widget),
4797 f->display.x->left_pos, f->display.x->top_pos); 4797 f->display.x->left_pos, f->display.x->top_pos);
4798#else /* not USE_X_TOOLKIT */ 4798#else /* not USE_X_TOOLKIT */
4799 XMoveWindow (XDISPLAY FRAME_X_WINDOW (f), 4799 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4800 f->display.x->left_pos, f->display.x->top_pos); 4800 f->display.x->left_pos, f->display.x->top_pos);
4801#endif /* not USE_X_TOOLKIT */ 4801#endif /* not USE_X_TOOLKIT */
4802 UNBLOCK_INPUT; 4802 UNBLOCK_INPUT;
@@ -4847,8 +4847,9 @@ x_set_window_size (f, change_gravity, cols, rows)
4847 f->display.x->win_gravity = NorthWestGravity; 4847 f->display.x->win_gravity = NorthWestGravity;
4848 x_wm_set_size_hint (f, 0, 0); 4848 x_wm_set_size_hint (f, 0, 0);
4849 4849
4850 XSync (x_current_display, False); 4850 XSync (FRAME_X_DISPLAY (f), False);
4851 XChangeWindowSize (FRAME_X_WINDOW (f), pixelwidth, pixelheight); 4851 XResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4852 pixelwidth, pixelheight);
4852 4853
4853 /* Now, strictly speaking, we can't be sure that this is accurate, 4854 /* Now, strictly speaking, we can't be sure that this is accurate,
4854 but the window manager will get around to dealing with the size 4855 but the window manager will get around to dealing with the size
@@ -4878,7 +4879,7 @@ x_set_window_size (f, change_gravity, cols, rows)
4878 we have to make sure to do it here. */ 4879 we have to make sure to do it here. */
4879 SET_FRAME_GARBAGED (f); 4880 SET_FRAME_GARBAGED (f);
4880 4881
4881 XFlushQueue (); 4882 XFlush (FRAME_X_DISPLAY (f));
4882 UNBLOCK_INPUT; 4883 UNBLOCK_INPUT;
4883#endif /* not USE_X_TOOLKIT */ 4884#endif /* not USE_X_TOOLKIT */
4884} 4885}
@@ -4903,7 +4904,8 @@ x_set_mouse_position (f, x, y)
4903 4904
4904 BLOCK_INPUT; 4905 BLOCK_INPUT;
4905 4906
4906 XWarpMousePointer (FRAME_X_WINDOW (f), pix_x, pix_y); 4907 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
4908 0, 0, 0, 0, pix_x, pix_y);
4907 UNBLOCK_INPUT; 4909 UNBLOCK_INPUT;
4908} 4910}
4909 4911
@@ -4916,7 +4918,8 @@ x_set_mouse_pixel_position (f, pix_x, pix_y)
4916{ 4918{
4917 BLOCK_INPUT; 4919 BLOCK_INPUT;
4918 4920
4919 XWarpMousePointer (FRAME_X_WINDOW (f), pix_x, pix_y); 4921 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
4922 0, 0, 0, 0, pix_x, pix_y);
4920 UNBLOCK_INPUT; 4923 UNBLOCK_INPUT;
4921} 4924}
4922 4925
@@ -4930,7 +4933,7 @@ x_focus_on_frame (f)
4930 /* I don't think that the ICCCM allows programs to do things like this 4933 /* I don't think that the ICCCM allows programs to do things like this
4931 without the interaction of the window manager. Whatever you end up 4934 without the interaction of the window manager. Whatever you end up
4932 doing with this code, do it to x_unfocus_frame too. */ 4935 doing with this code, do it to x_unfocus_frame too. */
4933 XSetInputFocus (x_current_display, FRAME_X_WINDOW (f), 4936 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4934 RevertToPointerRoot, CurrentTime); 4937 RevertToPointerRoot, CurrentTime);
4935#endif /* ! 0 */ 4938#endif /* ! 0 */
4936} 4939}
@@ -4941,7 +4944,7 @@ x_unfocus_frame (f)
4941#if 0 4944#if 0
4942 /* Look at the remarks in x_focus_on_frame. */ 4945 /* Look at the remarks in x_focus_on_frame. */
4943 if (x_focus_frame == f) 4946 if (x_focus_frame == f)
4944 XSetInputFocus (x_current_display, PointerRoot, 4947 XSetInputFocus (FRAME_X_DISPLAY (f), PointerRoot,
4945 RevertToPointerRoot, CurrentTime); 4948 RevertToPointerRoot, CurrentTime);
4946#endif /* ! 0 */ 4949#endif /* ! 0 */
4947} 4950}
@@ -4955,11 +4958,11 @@ x_raise_frame (f)
4955 { 4958 {
4956 BLOCK_INPUT; 4959 BLOCK_INPUT;
4957#ifdef USE_X_TOOLKIT 4960#ifdef USE_X_TOOLKIT
4958 XRaiseWindow (XDISPLAY XtWindow (f->display.x->widget)); 4961 XRaiseWindow (FRAME_X_DISPLAY (f), XtWindow (f->display.x->widget));
4959#else /* not USE_X_TOOLKIT */ 4962#else /* not USE_X_TOOLKIT */
4960 XRaiseWindow (XDISPLAY FRAME_X_WINDOW (f)); 4963 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
4961#endif /* not USE_X_TOOLKIT */ 4964#endif /* not USE_X_TOOLKIT */
4962 XFlushQueue (); 4965 XFlush (FRAME_X_DISPLAY (f));
4963 UNBLOCK_INPUT; 4966 UNBLOCK_INPUT;
4964 } 4967 }
4965} 4968}
@@ -4973,11 +4976,11 @@ x_lower_frame (f)
4973 { 4976 {
4974 BLOCK_INPUT; 4977 BLOCK_INPUT;
4975#ifdef USE_X_TOOLKIT 4978#ifdef USE_X_TOOLKIT
4976 XLowerWindow (XDISPLAY XtWindow (f->display.x->widget)); 4979 XLowerWindow (FRAME_X_DISPLAY (f), XtWindow (f->display.x->widget));
4977#else /* not USE_X_TOOLKIT */ 4980#else /* not USE_X_TOOLKIT */
4978 XLowerWindow (XDISPLAY FRAME_X_WINDOW (f)); 4981 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
4979#endif /* not USE_X_TOOLKIT */ 4982#endif /* not USE_X_TOOLKIT */
4980 XFlushQueue (); 4983 XFlush (FRAME_X_DISPLAY (f));
4981 UNBLOCK_INPUT; 4984 UNBLOCK_INPUT;
4982 } 4985 }
4983} 4986}
@@ -5021,17 +5024,17 @@ x_make_frame_visible (f)
5021 /* This was XtPopup, but that did nothing for an iconified frame. */ 5024 /* This was XtPopup, but that did nothing for an iconified frame. */
5022 XtMapWidget (f->display.x->widget); 5025 XtMapWidget (f->display.x->widget);
5023#else /* not USE_X_TOOLKIT */ 5026#else /* not USE_X_TOOLKIT */
5024 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 5027 XMapWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
5025#endif /* not USE_X_TOOLKIT */ 5028#endif /* not USE_X_TOOLKIT */
5026#if 0 /* This seems to bring back scroll bars in the wrong places 5029#if 0 /* This seems to bring back scroll bars in the wrong places
5027 if the window configuration has changed. They seem 5030 if the window configuration has changed. They seem
5028 to come back ok without this. */ 5031 to come back ok without this. */
5029 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 5032 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
5030 XMapSubwindows (x_current_display, FRAME_X_WINDOW (f)); 5033 XMapSubwindows (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
5031#endif 5034#endif
5032 } 5035 }
5033 5036
5034 XFlushQueue (); 5037 XFlush (FRAME_X_DISPLAY (f));
5035 5038
5036 /* Synchronize to ensure Emacs knows the frame is visible 5039 /* Synchronize to ensure Emacs knows the frame is visible
5037 before we do anything else. We do this loop with input not blocked 5040 before we do anything else. We do this loop with input not blocked
@@ -5047,7 +5050,7 @@ x_make_frame_visible (f)
5047 5050
5048 while (1) 5051 while (1)
5049 { 5052 {
5050 x_sync (frame); 5053 x_sync (f);
5051 /* Once we have handled input events, 5054 /* Once we have handled input events,
5052 we should have received the MapNotify if one is coming. 5055 we should have received the MapNotify if one is coming.
5053 So if we have not got it yet, stop looping. 5056 So if we have not got it yet, stop looping.
@@ -5114,8 +5117,8 @@ x_make_frame_invisible (f)
5114 5117
5115#ifdef HAVE_X11R4 5118#ifdef HAVE_X11R4
5116 5119
5117 if (! XWithdrawWindow (x_current_display, window, 5120 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window,
5118 DefaultScreen (x_current_display))) 5121 DefaultScreen (FRAME_X_DISPLAY (f))))
5119 { 5122 {
5120 UNBLOCK_INPUT_RESIGNAL; 5123 UNBLOCK_INPUT_RESIGNAL;
5121 error ("Can't notify window manager of window withdrawal"); 5124 error ("Can't notify window manager of window withdrawal");
@@ -5129,10 +5132,10 @@ x_make_frame_invisible (f)
5129 5132
5130 unmap.xunmap.type = UnmapNotify; 5133 unmap.xunmap.type = UnmapNotify;
5131 unmap.xunmap.window = window; 5134 unmap.xunmap.window = window;
5132 unmap.xunmap.event = DefaultRootWindow (x_current_display); 5135 unmap.xunmap.event = DefaultRootWindow (FRAME_X_DISPLAY (f));
5133 unmap.xunmap.from_configure = False; 5136 unmap.xunmap.from_configure = False;
5134 if (! XSendEvent (x_current_display, 5137 if (! XSendEvent (FRAME_X_DISPLAY (f),
5135 DefaultRootWindow (x_current_display), 5138 DefaultRootWindow (FRAME_X_DISPLAY (f)),
5136 False, 5139 False,
5137 SubstructureRedirectMask|SubstructureNotifyMask, 5140 SubstructureRedirectMask|SubstructureNotifyMask,
5138 &unmap)) 5141 &unmap))
@@ -5143,7 +5146,7 @@ x_make_frame_invisible (f)
5143 } 5146 }
5144 5147
5145 /* Unmap the window ourselves. Cheeky! */ 5148 /* Unmap the window ourselves. Cheeky! */
5146 XUnmapWindow (x_current_display, window); 5149 XUnmapWindow (FRAME_X_DISPLAY (f), window);
5147#endif /* ! defined (HAVE_X11R4) */ 5150#endif /* ! defined (HAVE_X11R4) */
5148 5151
5149 /* We can't distinguish this from iconification 5152 /* We can't distinguish this from iconification
@@ -5156,7 +5159,7 @@ x_make_frame_invisible (f)
5156 f->async_visible = 0; 5159 f->async_visible = 0;
5157 f->async_iconified = 0; 5160 f->async_iconified = 0;
5158 5161
5159 x_sync (); 5162 x_sync (f);
5160 5163
5161 UNBLOCK_INPUT; 5164 UNBLOCK_INPUT;
5162} 5165}
@@ -5195,9 +5198,9 @@ x_iconify_frame (f)
5195 return; 5198 return;
5196 } 5199 }
5197 5200
5198 result = XIconifyWindow (x_current_display, 5201 result = XIconifyWindow (FRAME_X_DISPLAY (f),
5199 XtWindow (f->display.x->widget), 5202 XtWindow (f->display.x->widget),
5200 DefaultScreen (x_current_display)); 5203 DefaultScreen (FRAME_X_DISPLAY (f)));
5201 UNBLOCK_INPUT; 5204 UNBLOCK_INPUT;
5202 5205
5203 if (!result) 5206 if (!result)
@@ -5206,7 +5209,7 @@ x_iconify_frame (f)
5206 f->async_iconified = 1; 5209 f->async_iconified = 1;
5207 5210
5208 BLOCK_INPUT; 5211 BLOCK_INPUT;
5209 XFlushQueue (); 5212 XFlush (FRAME_X_DISPLAY (f));
5210 UNBLOCK_INPUT; 5213 UNBLOCK_INPUT;
5211#else /* not USE_X_TOOLKIT */ 5214#else /* not USE_X_TOOLKIT */
5212 5215
@@ -5225,12 +5228,12 @@ x_iconify_frame (f)
5225 5228
5226 message.xclient.window = FRAME_X_WINDOW (f); 5229 message.xclient.window = FRAME_X_WINDOW (f);
5227 message.xclient.type = ClientMessage; 5230 message.xclient.type = ClientMessage;
5228 message.xclient.message_type = Xatom_wm_change_state; 5231 message.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_change_state;
5229 message.xclient.format = 32; 5232 message.xclient.format = 32;
5230 message.xclient.data.l[0] = IconicState; 5233 message.xclient.data.l[0] = IconicState;
5231 5234
5232 if (! XSendEvent (x_current_display, 5235 if (! XSendEvent (FRAME_X_DISPLAY (f),
5233 DefaultRootWindow (x_current_display), 5236 DefaultRootWindow (FRAME_X_DISPLAY (f)),
5234 False, 5237 False,
5235 SubstructureRedirectMask | SubstructureNotifyMask, 5238 SubstructureRedirectMask | SubstructureNotifyMask,
5236 &message)) 5239 &message))
@@ -5247,16 +5250,16 @@ x_iconify_frame (f)
5247 if (!FRAME_VISIBLE_P (f)) 5250 if (!FRAME_VISIBLE_P (f))
5248 { 5251 {
5249 /* If the frame was withdrawn, before, we must map it. */ 5252 /* If the frame was withdrawn, before, we must map it. */
5250 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 5253 XMapWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
5251#if 0 /* We don't have subwindows in the icon. */ 5254#if 0 /* We don't have subwindows in the icon. */
5252 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 5255 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
5253 XMapSubwindows (x_current_display, FRAME_X_WINDOW (f)); 5256 XMapSubwindows (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
5254#endif 5257#endif
5255 } 5258 }
5256 5259
5257 f->async_iconified = 1; 5260 f->async_iconified = 1;
5258 5261
5259 XFlushQueue (); 5262 XFlush (FRAME_X_DISPLAY (f));
5260 UNBLOCK_INPUT; 5263 UNBLOCK_INPUT;
5261#endif /* not USE_X_TOOLKIT */ 5264#endif /* not USE_X_TOOLKIT */
5262} 5265}
@@ -5269,20 +5272,20 @@ x_destroy_window (f)
5269 BLOCK_INPUT; 5272 BLOCK_INPUT;
5270 5273
5271 if (f->display.x->icon_desc != 0) 5274 if (f->display.x->icon_desc != 0)
5272 XDestroyWindow (XDISPLAY f->display.x->icon_desc); 5275 XDestroyWindow (FRAME_X_DISPLAY (f), f->display.x->icon_desc);
5273 XDestroyWindow (XDISPLAY f->display.x->window_desc); 5276 XDestroyWindow (FRAME_X_DISPLAY (f), f->display.x->window_desc);
5274#ifdef USE_X_TOOLKIT 5277#ifdef USE_X_TOOLKIT
5275 XtDestroyWidget (f->display.x->widget); 5278 XtDestroyWidget (f->display.x->widget);
5276 free_frame_menubar (f); 5279 free_frame_menubar (f);
5277#endif /* USE_X_TOOLKIT */ 5280#endif /* USE_X_TOOLKIT */
5278 5281
5279 free_frame_faces (f); 5282 free_frame_faces (f);
5280 XFlushQueue (); 5283 XFlush (FRAME_X_DISPLAY (f));
5281 5284
5282 FRAME_X_SCREEN (f)->reference_count--; 5285 FRAME_X_DISPLAY_INFO (f)->reference_count--;
5283#if 0 5286#if 0
5284 if (FRAME_X_SCREEN (f)->reference_count == 0) 5287 if (FRAME_X_DISPLAY_INFO (f)->reference_count == 0)
5285 free (FRAME_X_SCREEN (f)); 5288 free (FRAME_X_DISPLAY_INFO (f));
5286#endif 5289#endif
5287 5290
5288 xfree (f->display.x); 5291 xfree (f->display.x);
@@ -5347,8 +5350,10 @@ x_wm_set_size_hint (f, flags, user_position)
5347 5350
5348 size_hints.width_inc = FONT_WIDTH (f->display.x->font); 5351 size_hints.width_inc = FONT_WIDTH (f->display.x->font);
5349 size_hints.height_inc = f->display.x->line_height; 5352 size_hints.height_inc = f->display.x->line_height;
5350 size_hints.max_width = x_screen_width - CHAR_TO_PIXEL_WIDTH (f, 0); 5353 size_hints.max_width
5351 size_hints.max_height = x_screen_height - CHAR_TO_PIXEL_HEIGHT (f, 0); 5354 = FRAME_X_DISPLAY_INFO (f)->width - CHAR_TO_PIXEL_WIDTH (f, 0);
5355 size_hints.max_height
5356 = FRAME_X_DISPLAY_INFO (f)->height - CHAR_TO_PIXEL_HEIGHT (f, 0);
5352 5357
5353 { 5358 {
5354 int base_width, base_height; 5359 int base_width, base_height;
@@ -5390,10 +5395,10 @@ x_wm_set_size_hint (f, flags, user_position)
5390 int value; 5395 int value;
5391 5396
5392#ifdef HAVE_X11R4 5397#ifdef HAVE_X11R4
5393 value = XGetWMNormalHints (x_current_display, window, &hints, 5398 value = XGetWMNormalHints (FRAME_X_DISPLAY (f), window, &hints,
5394 &supplied_return); 5399 &supplied_return);
5395#else 5400#else
5396 value = XGetNormalHints (x_current_display, window, &hints); 5401 value = XGetNormalHints (FRAME_X_DISPLAY (f), window, &hints);
5397#endif 5402#endif
5398 5403
5399 if (value == 0) 5404 if (value == 0)
@@ -5420,9 +5425,9 @@ x_wm_set_size_hint (f, flags, user_position)
5420#endif /* PWinGravity */ 5425#endif /* PWinGravity */
5421 5426
5422#ifdef HAVE_X11R4 5427#ifdef HAVE_X11R4
5423 XSetWMNormalHints (x_current_display, window, &size_hints); 5428 XSetWMNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);
5424#else 5429#else
5425 XSetNormalHints (x_current_display, window, &size_hints); 5430 XSetNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);
5426#endif 5431#endif
5427} 5432}
5428 5433
@@ -5442,7 +5447,7 @@ x_wm_set_window_state (f, state)
5442 f->display.x->wm_hints.flags |= StateHint; 5447 f->display.x->wm_hints.flags |= StateHint;
5443 f->display.x->wm_hints.initial_state = state; 5448 f->display.x->wm_hints.initial_state = state;
5444 5449
5445 XSetWMHints (x_current_display, window, &f->display.x->wm_hints); 5450 XSetWMHints (FRAME_X_DISPLAY (f), window, &f->display.x->wm_hints);
5446#endif /* not USE_X_TOOLKIT */ 5451#endif /* not USE_X_TOOLKIT */
5447} 5452}
5448 5453
@@ -5468,7 +5473,7 @@ x_wm_set_icon_pixmap (f, pixmap_id)
5468 f->display.x->wm_hints.flags &= ~IconPixmapHint; 5473 f->display.x->wm_hints.flags &= ~IconPixmapHint;
5469 } 5474 }
5470 5475
5471 XSetWMHints (x_current_display, window, &f->display.x->wm_hints); 5476 XSetWMHints (FRAME_X_DISPLAY (f), window, &f->display.x->wm_hints);
5472} 5477}
5473 5478
5474x_wm_set_icon_position (f, icon_x, icon_y) 5479x_wm_set_icon_position (f, icon_x, icon_y)
@@ -5485,7 +5490,7 @@ x_wm_set_icon_position (f, icon_x, icon_y)
5485 f->display.x->wm_hints.icon_x = icon_x; 5490 f->display.x->wm_hints.icon_x = icon_x;
5486 f->display.x->wm_hints.icon_y = icon_y; 5491 f->display.x->wm_hints.icon_y = icon_y;
5487 5492
5488 XSetWMHints (x_current_display, window, &f->display.x->wm_hints); 5493 XSetWMHints (FRAME_X_DISPLAY (f), window, &f->display.x->wm_hints);
5489} 5494}
5490 5495
5491 5496
@@ -5510,9 +5515,9 @@ static XrmOptionDescRec emacs_options[] = {
5510}; 5515};
5511#endif /* USE_X_TOOLKIT */ 5516#endif /* USE_X_TOOLKIT */
5512 5517
5513void 5518struct x_display_info *
5514x_term_init (display_name, xrm_option, resource_name) 5519x_term_init (display_name, xrm_option, resource_name)
5515 char *display_name; 5520 Lisp_Object display_name;
5516 char *xrm_option; 5521 char *xrm_option;
5517 char *resource_name; 5522 char *resource_name;
5518{ 5523{
@@ -5520,12 +5525,24 @@ x_term_init (display_name, xrm_option, resource_name)
5520 char *defaultvalue; 5525 char *defaultvalue;
5521 int argc = 0; 5526 int argc = 0;
5522 char** argv = 0; 5527 char** argv = 0;
5528 int connection;
5529 struct x_display_info *dpyinfo;
5530 XrmDatabase xrdb;
5531
5523#ifndef F_SETOWN_BUG 5532#ifndef F_SETOWN_BUG
5524#ifdef F_SETOWN 5533#ifdef F_SETOWN
5525 extern int old_fcntl_owner; 5534 extern int old_fcntl_owner;
5526#endif /* ! defined (F_SETOWN) */ 5535#endif /* ! defined (F_SETOWN) */
5527#endif /* F_SETOWN_BUG */ 5536#endif /* F_SETOWN_BUG */
5528 5537
5538 dpyinfo = &the_x_screen;
5539
5540 /* Put our one and only display on the chain. */
5541 x_display_list = dpyinfo;
5542 dpyinfo->next = 0;
5543
5544 dpyinfo->name = display_name;
5545
5529 x_noop_count = 0; 5546 x_noop_count = 0;
5530 5547
5531 x_focus_frame = x_highlight_frame = 0; 5548 x_focus_frame = x_highlight_frame = 0;
@@ -5538,7 +5555,7 @@ x_term_init (display_name, xrm_option, resource_name)
5538 argv = (char **) XtMalloc (7 * sizeof (char *)); 5555 argv = (char **) XtMalloc (7 * sizeof (char *));
5539 argv[0] = ""; 5556 argv[0] = "";
5540 argv[1] = "-display"; 5557 argv[1] = "-display";
5541 argv[2] = display_name; 5558 argv[2] = XSTRING (display_name)->data;
5542 argv[3] = "-name"; 5559 argv[3] = "-name";
5543 /* Usually `emacs', but not always. */ 5560 /* Usually `emacs', but not always. */
5544 argv[4] = resource_name; 5561 argv[4] = resource_name;
@@ -5553,18 +5570,19 @@ x_term_init (display_name, xrm_option, resource_name)
5553 &argc, argv, 5570 &argc, argv,
5554 NULL, NULL, 0); 5571 NULL, NULL, 0);
5555 XtFree ((char *)argv); 5572 XtFree ((char *)argv);
5556 x_current_display = XtDisplay (Xt_app_shell); 5573 dpyinfo->display = XtDisplay (Xt_app_shell);
5557 5574
5558#else /* not USE_X_TOOLKIT */ 5575#else /* not USE_X_TOOLKIT */
5559#ifdef HAVE_X11R5 5576#ifdef HAVE_X11R5
5560 XSetLocaleModifiers (""); 5577 XSetLocaleModifiers ("");
5561#endif 5578#endif
5562 x_current_display = XOpenDisplay (display_name); 5579 dpyinfo->display = XOpenDisplay (XSTRING (display_name)->data);
5563#endif /* not USE_X_TOOLKIT */ 5580#endif /* not USE_X_TOOLKIT */
5564 if (x_current_display == 0) 5581
5582 if (dpyinfo->display == 0)
5565 fatal ("X server %s not responding.\n\ 5583 fatal ("X server %s not responding.\n\
5566Check the DISPLAY environment variable or use \"-d\"\n", 5584Check the DISPLAY environment variable or use \"-d\"\n",
5567 display_name); 5585 XSTRING (display_name)->data);
5568 5586
5569 { 5587 {
5570#if 0 5588#if 0
@@ -5578,11 +5596,11 @@ Check the DISPLAY environment variable or use \"-d\"\n",
5578 } 5596 }
5579 5597
5580 /* Figure out which modifier bits mean what. */ 5598 /* Figure out which modifier bits mean what. */
5581 x_find_modifier_meanings (); 5599 x_find_modifier_meanings (dpyinfo);
5582 5600
5583 /* Get the scroll bar cursor. */ 5601 /* Get the scroll bar cursor. */
5584 x_vertical_scroll_bar_cursor 5602 x_vertical_scroll_bar_cursor
5585 = XCreateFontCursor (x_current_display, XC_sb_v_double_arrow); 5603 = XCreateFontCursor (dpyinfo->display, XC_sb_v_double_arrow);
5586 5604
5587#if 0 5605#if 0
5588 /* Watch for PropertyNotify events on the root window; we use them 5606 /* Watch for PropertyNotify events on the root window; we use them
@@ -5590,21 +5608,80 @@ Check the DISPLAY environment variable or use \"-d\"\n",
5590 x_watch_cut_buffer_cache (); 5608 x_watch_cut_buffer_cache ();
5591#endif 5609#endif
5592 5610
5611 xrdb = x_load_resources (dpyinfo->display, xrm_option,
5612 resource_name, EMACS_CLASS);
5613#ifdef HAVE_XRMSETDATABASE
5614 XrmSetDatabase (dpyinfo->display, xrdb);
5615#else
5616 dpyinfo->display->db = xrdb;
5617#endif
5618
5619 dpyinfo->screen = ScreenOfDisplay (dpyinfo->display,
5620 DefaultScreen (dpyinfo->display));
5621 dpyinfo->visual = select_visual (dpyinfo->display, dpyinfo->screen,
5622 &dpyinfo->n_planes);
5623 dpyinfo->height = HeightOfScreen (dpyinfo->screen);
5624 dpyinfo->width = WidthOfScreen (dpyinfo->screen);
5625 dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen);
5626 dpyinfo->grabbed = 0;
5627 dpyinfo->reference_count = 0;
5628 dpyinfo->icon_bitmap_id = -1;
5629
5630 dpyinfo->Xatom_wm_protocols
5631 = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False);
5632 dpyinfo->Xatom_wm_take_focus
5633 = XInternAtom (dpyinfo->display, "WM_TAKE_FOCUS", False);
5634 dpyinfo->Xatom_wm_save_yourself
5635 = XInternAtom (dpyinfo->display, "WM_SAVE_YOURSELF", False);
5636 dpyinfo->Xatom_wm_delete_window
5637 = XInternAtom (dpyinfo->display, "WM_DELETE_WINDOW", False);
5638 dpyinfo->Xatom_wm_change_state
5639 = XInternAtom (dpyinfo->display, "WM_CHANGE_STATE", False);
5640 dpyinfo->Xatom_wm_configure_denied
5641 = XInternAtom (dpyinfo->display, "WM_CONFIGURE_DENIED", False);
5642 dpyinfo->Xatom_wm_window_moved
5643 = XInternAtom (dpyinfo->display, "WM_MOVED", False);
5644 dpyinfo->Xatom_editres
5645 = XInternAtom (dpyinfo->display, "Editres", False);
5646 dpyinfo->Xatom_CLIPBOARD
5647 = XInternAtom (dpyinfo->display, "CLIPBOARD", False);
5648 dpyinfo->Xatom_TIMESTAMP
5649 = XInternAtom (dpyinfo->display, "TIMESTAMP", False);
5650 dpyinfo->Xatom_TEXT
5651 = XInternAtom (dpyinfo->display, "TEXT", False);
5652 dpyinfo->Xatom_DELETE
5653 = XInternAtom (dpyinfo->display, "DELETE", False);
5654 dpyinfo->Xatom_MULTIPLE
5655 = XInternAtom (dpyinfo->display, "MULTIPLE", False);
5656 dpyinfo->Xatom_INCR
5657 = XInternAtom (dpyinfo->display, "INCR", False);
5658 dpyinfo->Xatom_EMACS_TMP
5659 = XInternAtom (dpyinfo->display, "_EMACS_TMP_", False);
5660 dpyinfo->Xatom_TARGETS
5661 = XInternAtom (dpyinfo->display, "TARGETS", False);
5662 dpyinfo->Xatom_NULL
5663 = XInternAtom (dpyinfo->display, "NULL", False);
5664 dpyinfo->Xatom_ATOM_PAIR
5665 = XInternAtom (dpyinfo->display, "ATOM_PAIR", False);
5666
5667 connection = ConnectionNumber (dpyinfo->display);
5668 dpyinfo->connection = connection;
5669
5593#ifdef subprocesses 5670#ifdef subprocesses
5594 /* This is only needed for distinguishing keyboard and process input. */ 5671 /* This is only needed for distinguishing keyboard and process input. */
5595 if (ConnectionNumber (x_current_display) != 0) 5672 if (connection != 0)
5596 change_keyboard_wait_descriptor (ConnectionNumber (x_current_display)); 5673 change_keyboard_wait_descriptor (connection);
5597#endif 5674#endif
5598 change_input_fd (ConnectionNumber (x_current_display)); 5675 change_input_fd (connection);
5599 5676
5600#ifndef F_SETOWN_BUG 5677#ifndef F_SETOWN_BUG
5601#ifdef F_SETOWN 5678#ifdef F_SETOWN
5602 old_fcntl_owner = fcntl (ConnectionNumber (x_current_display), F_GETOWN, 0); 5679 old_fcntl_owner = fcntl (connection, F_GETOWN, 0);
5603#ifdef F_SETOWN_SOCK_NEG 5680#ifdef F_SETOWN_SOCK_NEG
5604 /* stdin is a socket here */ 5681 /* stdin is a socket here */
5605 fcntl (ConnectionNumber (x_current_display), F_SETOWN, -getpid ()); 5682 fcntl (connection, F_SETOWN, -getpid ());
5606#else /* ! defined (F_SETOWN_SOCK_NEG) */ 5683#else /* ! defined (F_SETOWN_SOCK_NEG) */
5607 fcntl (ConnectionNumber (x_current_display), F_SETOWN, getpid ()); 5684 fcntl (connection, F_SETOWN, getpid ());
5608#endif /* ! defined (F_SETOWN_SOCK_NEG) */ 5685#endif /* ! defined (F_SETOWN_SOCK_NEG) */
5609#endif /* ! defined (F_SETOWN) */ 5686#endif /* ! defined (F_SETOWN) */
5610#endif /* F_SETOWN_BUG */ 5687#endif /* F_SETOWN_BUG */
@@ -5653,8 +5730,8 @@ Check the DISPLAY environment variable or use \"-d\"\n",
5653 5730
5654 /* Note that there is no real way portable across R3/R4 to get the 5731 /* Note that there is no real way portable across R3/R4 to get the
5655 original error handler. */ 5732 original error handler. */
5656 XHandleError (x_error_quitter); 5733 XSetErrorHandler (x_error_quitter);
5657 XHandleIOError (x_io_error_quitter); 5734 XSetIOErrorHandler (x_io_error_quitter);
5658 5735
5659 /* Disable Window Change signals; they are handled by X events. */ 5736 /* Disable Window Change signals; they are handled by X events. */
5660#ifdef SIGWINCH 5737#ifdef SIGWINCH
@@ -5667,6 +5744,11 @@ Check the DISPLAY environment variable or use \"-d\"\n",
5667void 5744void
5668syms_of_xterm () 5745syms_of_xterm ()
5669{ 5746{
5747 the_x_screen.font_list_cache = Qnil;
5748 the_x_screen.name = Qnil;
5749 staticpro (&the_x_screen.font_list_cache);
5750 staticpro (&the_x_screen.name);
5751
5670 staticpro (&last_mouse_scroll_bar); 5752 staticpro (&last_mouse_scroll_bar);
5671 last_mouse_scroll_bar = Qnil; 5753 last_mouse_scroll_bar = Qnil;
5672 staticpro (&mouse_face_window); 5754 staticpro (&mouse_face_window);