aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c304
1 files changed, 114 insertions, 190 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 548975c635a..3e05ba6fed2 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -143,16 +143,11 @@ int use_xim = 1;
143int use_xim = 0; /* configure --without-xim */ 143int use_xim = 0; /* configure --without-xim */
144#endif 144#endif
145 145
146
147
148/* Non-zero means that a HELP_EVENT has been generated since Emacs 146/* Non-zero means that a HELP_EVENT has been generated since Emacs
149 start. */ 147 start. */
150 148
151static bool any_help_event_p; 149static bool any_help_event_p;
152 150
153/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
154static Lisp_Object last_window;
155
156/* This is a chain of structures for all the X displays currently in 151/* This is a chain of structures for all the X displays currently in
157 use. */ 152 use. */
158 153
@@ -300,8 +295,6 @@ static struct terminal *x_create_terminal (struct x_display_info *);
300void x_delete_terminal (struct terminal *); 295void x_delete_terminal (struct terminal *);
301static void x_update_end (struct frame *); 296static void x_update_end (struct frame *);
302static void XTframe_up_to_date (struct frame *); 297static void XTframe_up_to_date (struct frame *);
303static void XTset_terminal_modes (struct terminal *);
304static void XTreset_terminal_modes (struct terminal *);
305static void x_clear_frame (struct frame *); 298static void x_clear_frame (struct frame *);
306static _Noreturn void x_ins_del_lines (struct frame *, int, int); 299static _Noreturn void x_ins_del_lines (struct frame *, int, int);
307static void frame_highlight (struct frame *); 300static void frame_highlight (struct frame *);
@@ -317,7 +310,8 @@ static void x_draw_hollow_cursor (struct window *, struct glyph_row *);
317static void x_draw_bar_cursor (struct window *, struct glyph_row *, int, 310static void x_draw_bar_cursor (struct window *, struct glyph_row *, int,
318 enum text_cursor_kinds); 311 enum text_cursor_kinds);
319 312
320static void x_clip_to_row (struct window *, struct glyph_row *, int, GC); 313static void x_clip_to_row (struct window *, struct glyph_row *,
314 enum glyph_row_area, GC);
321static void x_flush (struct frame *f); 315static void x_flush (struct frame *f);
322static void x_update_begin (struct frame *); 316static void x_update_begin (struct frame *);
323static void x_update_window_begin (struct window *); 317static void x_update_window_begin (struct window *);
@@ -343,29 +337,19 @@ static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t);
343static void x_initialize (void); 337static void x_initialize (void);
344 338
345 339
346/* Flush display of frame F, or of all frames if F is null. */ 340/* Flush display of frame F. */
347 341
348static void 342static void
349x_flush (struct frame *f) 343x_flush (struct frame *f)
350{ 344{
345 eassert (f && FRAME_X_P (f));
351 /* Don't call XFlush when it is not safe to redisplay; the X 346 /* Don't call XFlush when it is not safe to redisplay; the X
352 connection may be broken. */ 347 connection may be broken. */
353 if (!NILP (Vinhibit_redisplay)) 348 if (!NILP (Vinhibit_redisplay))
354 return; 349 return;
355 350
356 block_input (); 351 block_input ();
357 if (f) 352 XFlush (FRAME_X_DISPLAY (f));
358 {
359 eassert (FRAME_X_P (f));
360 XFlush (FRAME_X_DISPLAY (f));
361 }
362 else
363 {
364 /* Flush all displays and so all frames on them. */
365 struct x_display_info *xdi;
366 for (xdi = x_display_list; xdi; xdi = xdi->next)
367 XFlush (xdi->display);
368 }
369 unblock_input (); 353 unblock_input ();
370} 354}
371 355
@@ -554,8 +538,7 @@ x_update_begin (struct frame *f)
554} 538}
555 539
556 540
557/* Start update of window W. Set output_cursor to the cursor 541/* Start update of window W. */
558 position of W. */
559 542
560static void 543static void
561x_update_window_begin (struct window *w) 544x_update_window_begin (struct window *w)
@@ -563,7 +546,7 @@ x_update_window_begin (struct window *w)
563 struct frame *f = XFRAME (WINDOW_FRAME (w)); 546 struct frame *f = XFRAME (WINDOW_FRAME (w));
564 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 547 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
565 548
566 set_output_cursor (&w->cursor); 549 w->output_cursor = w->cursor;
567 550
568 block_input (); 551 block_input ();
569 552
@@ -621,9 +604,9 @@ x_update_window_end (struct window *w, bool cursor_on_p,
621 block_input (); 604 block_input ();
622 605
623 if (cursor_on_p) 606 if (cursor_on_p)
624 display_and_set_cursor (w, 1, output_cursor.hpos, 607 display_and_set_cursor (w, 1,
625 output_cursor.vpos, 608 w->output_cursor.hpos, w->output_cursor.vpos,
626 output_cursor.x, output_cursor.y); 609 w->output_cursor.x, w->output_cursor.y);
627 610
628 if (draw_window_fringes (w, 1)) 611 if (draw_window_fringes (w, 1))
629 x_draw_vertical_border (w); 612 x_draw_vertical_border (w);
@@ -701,10 +684,10 @@ x_after_update_window_line (struct window *w, struct glyph_row *desired_row)
701 684
702 block_input (); 685 block_input ();
703 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 686 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
704 0, y, width, height, False); 687 0, y, width, height);
705 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 688 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
706 FRAME_PIXEL_WIDTH (f) - width, 689 FRAME_PIXEL_WIDTH (f) - width,
707 y, width, height, False); 690 y, width, height);
708 unblock_input (); 691 unblock_input ();
709 } 692 }
710} 693}
@@ -719,7 +702,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
719 struct face *face = p->face; 702 struct face *face = p->face;
720 703
721 /* Must clip because of partially visible lines. */ 704 /* Must clip because of partially visible lines. */
722 x_clip_to_row (w, row, -1, gc); 705 x_clip_to_row (w, row, ANY_AREA, gc);
723 706
724 if (!p->overlay_p) 707 if (!p->overlay_p)
725 { 708 {
@@ -836,27 +819,6 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
836 XSetClipMask (display, gc, None); 819 XSetClipMask (display, gc, None);
837} 820}
838 821
839
840
841/* This is called when starting Emacs and when restarting after
842 suspend. When starting Emacs, no X window is mapped. And nothing
843 must be done to Emacs's own window if it is suspended (though that
844 rarely happens). */
845
846static void
847XTset_terminal_modes (struct terminal *terminal)
848{
849}
850
851/* This is called when exiting or suspending Emacs. Exiting will make
852 the X-windows go away, and suspending requires no action. */
853
854static void
855XTreset_terminal_modes (struct terminal *terminal)
856{
857}
858
859
860/*********************************************************************** 822/***********************************************************************
861 Glyph display 823 Glyph display
862 ***********************************************************************/ 824 ***********************************************************************/
@@ -2977,10 +2939,10 @@ x_delete_glyphs (struct frame *f, register int n)
2977 If they are <= 0, this is probably an error. */ 2939 If they are <= 0, this is probably an error. */
2978 2940
2979void 2941void
2980x_clear_area (Display *dpy, Window window, int x, int y, int width, int height, int exposures) 2942x_clear_area (Display *dpy, Window window, int x, int y, int width, int height)
2981{ 2943{
2982 eassert (width > 0 && height > 0); 2944 eassert (width > 0 && height > 0);
2983 XClearArea (dpy, window, x, y, width, height, exposures); 2945 XClearArea (dpy, window, x, y, width, height, False);
2984} 2946}
2985 2947
2986 2948
@@ -2992,11 +2954,7 @@ x_clear_frame (struct frame *f)
2992 /* Clearing the frame will erase any cursor, so mark them all as no 2954 /* Clearing the frame will erase any cursor, so mark them all as no
2993 longer visible. */ 2955 longer visible. */
2994 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); 2956 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
2995 output_cursor.hpos = output_cursor.vpos = 0;
2996 output_cursor.x = -1;
2997 2957
2998 /* We don't set the output cursor here because there will always
2999 follow an explicit cursor_to. */
3000 block_input (); 2958 block_input ();
3001 2959
3002 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 2960 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
@@ -3222,20 +3180,6 @@ XTring_bell (struct frame *f)
3222 } 3180 }
3223} 3181}
3224 3182
3225
3226/* Specify how many text lines, from the top of the window,
3227 should be affected by insert-lines and delete-lines operations.
3228 This, and those operations, are used only within an update
3229 that is bounded by calls to x_update_begin and x_update_end. */
3230
3231static void
3232XTset_terminal_window (struct frame *f, int n)
3233{
3234 /* This function intentionally left blank. */
3235}
3236
3237
3238
3239/*********************************************************************** 3183/***********************************************************************
3240 Line Dance 3184 Line Dance
3241 ***********************************************************************/ 3185 ***********************************************************************/
@@ -3261,7 +3205,7 @@ x_scroll_run (struct window *w, struct run *run)
3261 /* Get frame-relative bounding box of the text display area of W, 3205 /* Get frame-relative bounding box of the text display area of W,
3262 without mode lines. Include in this box the left and right 3206 without mode lines. Include in this box the left and right
3263 fringe of W. */ 3207 fringe of W. */
3264 window_box (w, -1, &x, &y, &width, &height); 3208 window_box (w, ANY_AREA, &x, &y, &width, &height);
3265 3209
3266#ifdef USE_TOOLKIT_SCROLL_BARS 3210#ifdef USE_TOOLKIT_SCROLL_BARS
3267 /* If the fringe is adjacent to the left (right) scroll bar of a 3211 /* If the fringe is adjacent to the left (right) scroll bar of a
@@ -3777,7 +3721,6 @@ construct_mouse_click (struct input_event *result, XButtonEvent *event, struct f
3777 return Qnil; 3721 return Qnil;
3778} 3722}
3779 3723
3780
3781/* Function to report a mouse movement to the mainstream Emacs code. 3724/* Function to report a mouse movement to the mainstream Emacs code.
3782 The input handler calls this. 3725 The input handler calls this.
3783 3726
@@ -4197,9 +4140,9 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name,
4197 scroll_bar_end_scroll, 0, 0); 4140 scroll_bar_end_scroll, 0, 0);
4198 w = XWINDOW (window_being_scrolled); 4141 w = XWINDOW (window_being_scrolled);
4199 4142
4200 if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging)) 4143 if (XSCROLL_BAR (w->vertical_scroll_bar)->dragging != -1)
4201 { 4144 {
4202 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil; 4145 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = -1;
4203 /* The thumb size is incorrect while dragging: fix it. */ 4146 /* The thumb size is incorrect while dragging: fix it. */
4204 set_vertical_scroll_bar (w); 4147 set_vertical_scroll_bar (w);
4205 } 4148 }
@@ -4337,32 +4280,32 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4337 switch (cs->reason) 4280 switch (cs->reason)
4338 { 4281 {
4339 case XmCR_DECREMENT: 4282 case XmCR_DECREMENT:
4340 bar->dragging = Qnil; 4283 bar->dragging = -1;
4341 part = scroll_bar_up_arrow; 4284 part = scroll_bar_up_arrow;
4342 break; 4285 break;
4343 4286
4344 case XmCR_INCREMENT: 4287 case XmCR_INCREMENT:
4345 bar->dragging = Qnil; 4288 bar->dragging = -1;
4346 part = scroll_bar_down_arrow; 4289 part = scroll_bar_down_arrow;
4347 break; 4290 break;
4348 4291
4349 case XmCR_PAGE_DECREMENT: 4292 case XmCR_PAGE_DECREMENT:
4350 bar->dragging = Qnil; 4293 bar->dragging = -1;
4351 part = scroll_bar_above_handle; 4294 part = scroll_bar_above_handle;
4352 break; 4295 break;
4353 4296
4354 case XmCR_PAGE_INCREMENT: 4297 case XmCR_PAGE_INCREMENT:
4355 bar->dragging = Qnil; 4298 bar->dragging = -1;
4356 part = scroll_bar_below_handle; 4299 part = scroll_bar_below_handle;
4357 break; 4300 break;
4358 4301
4359 case XmCR_TO_TOP: 4302 case XmCR_TO_TOP:
4360 bar->dragging = Qnil; 4303 bar->dragging = -1;
4361 part = scroll_bar_to_top; 4304 part = scroll_bar_to_top;
4362 break; 4305 break;
4363 4306
4364 case XmCR_TO_BOTTOM: 4307 case XmCR_TO_BOTTOM:
4365 bar->dragging = Qnil; 4308 bar->dragging = -1;
4366 part = scroll_bar_to_bottom; 4309 part = scroll_bar_to_bottom;
4367 break; 4310 break;
4368 4311
@@ -4378,7 +4321,7 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4378 whole = XM_SB_MAX - slider_size; 4321 whole = XM_SB_MAX - slider_size;
4379 portion = min (cs->value, whole); 4322 portion = min (cs->value, whole);
4380 part = scroll_bar_handle; 4323 part = scroll_bar_handle;
4381 bar->dragging = make_number (cs->value); 4324 bar->dragging = cs->value;
4382 } 4325 }
4383 break; 4326 break;
4384 4327
@@ -4426,24 +4369,24 @@ xg_scroll_callback (GtkRange *range,
4426 whole = gtk_adjustment_get_upper (adj) - 4369 whole = gtk_adjustment_get_upper (adj) -
4427 gtk_adjustment_get_page_size (adj); 4370 gtk_adjustment_get_page_size (adj);
4428 portion = min ((int)position, whole); 4371 portion = min ((int)position, whole);
4429 bar->dragging = make_number ((int)portion); 4372 bar->dragging = portion;
4430 } 4373 }
4431 break; 4374 break;
4432 case GTK_SCROLL_STEP_BACKWARD: 4375 case GTK_SCROLL_STEP_BACKWARD:
4433 part = scroll_bar_up_arrow; 4376 part = scroll_bar_up_arrow;
4434 bar->dragging = Qnil; 4377 bar->dragging = -1;
4435 break; 4378 break;
4436 case GTK_SCROLL_STEP_FORWARD: 4379 case GTK_SCROLL_STEP_FORWARD:
4437 part = scroll_bar_down_arrow; 4380 part = scroll_bar_down_arrow;
4438 bar->dragging = Qnil; 4381 bar->dragging = -1;
4439 break; 4382 break;
4440 case GTK_SCROLL_PAGE_BACKWARD: 4383 case GTK_SCROLL_PAGE_BACKWARD:
4441 part = scroll_bar_above_handle; 4384 part = scroll_bar_above_handle;
4442 bar->dragging = Qnil; 4385 bar->dragging = -1;
4443 break; 4386 break;
4444 case GTK_SCROLL_PAGE_FORWARD: 4387 case GTK_SCROLL_PAGE_FORWARD:
4445 part = scroll_bar_below_handle; 4388 part = scroll_bar_below_handle;
4446 bar->dragging = Qnil; 4389 bar->dragging = -1;
4447 break; 4390 break;
4448 } 4391 }
4449 4392
@@ -4457,7 +4400,7 @@ xg_scroll_callback (GtkRange *range,
4457 return FALSE; 4400 return FALSE;
4458} 4401}
4459 4402
4460/* Callback for button release. Sets dragging to Qnil when dragging is done. */ 4403/* Callback for button release. Sets dragging to -1 when dragging is done. */
4461 4404
4462static gboolean 4405static gboolean
4463xg_end_scroll_callback (GtkWidget *widget, 4406xg_end_scroll_callback (GtkWidget *widget,
@@ -4465,7 +4408,7 @@ xg_end_scroll_callback (GtkWidget *widget,
4465 gpointer user_data) 4408 gpointer user_data)
4466{ 4409{
4467 struct scroll_bar *bar = user_data; 4410 struct scroll_bar *bar = user_data;
4468 bar->dragging = Qnil; 4411 bar->dragging = -1;
4469 if (WINDOWP (window_being_scrolled)) 4412 if (WINDOWP (window_being_scrolled))
4470 { 4413 {
4471 x_send_scroll_bar_event (window_being_scrolled, 4414 x_send_scroll_bar_event (window_being_scrolled,
@@ -4513,7 +4456,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4513 part = scroll_bar_handle; 4456 part = scroll_bar_handle;
4514 4457
4515 window_being_scrolled = bar->window; 4458 window_being_scrolled = bar->window;
4516 bar->dragging = make_number (portion); 4459 bar->dragging = portion;
4517 last_scroll_bar_part = part; 4460 last_scroll_bar_part = part;
4518 x_send_scroll_bar_event (bar->window, part, portion, whole); 4461 x_send_scroll_bar_event (bar->window, part, portion, whole);
4519} 4462}
@@ -4552,7 +4495,7 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4552 part = scroll_bar_move_ratio; 4495 part = scroll_bar_move_ratio;
4553 4496
4554 window_being_scrolled = bar->window; 4497 window_being_scrolled = bar->window;
4555 bar->dragging = Qnil; 4498 bar->dragging = -1;
4556 last_scroll_bar_part = part; 4499 last_scroll_bar_part = part;
4557 x_send_scroll_bar_event (bar->window, part, position, height); 4500 x_send_scroll_bar_event (bar->window, part, position, height);
4558} 4501}
@@ -4828,7 +4771,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4828 shown = (float) portion / whole; 4771 shown = (float) portion / whole;
4829 } 4772 }
4830 4773
4831 if (NILP (bar->dragging)) 4774 if (bar->dragging == -1)
4832 { 4775 {
4833 int size, value; 4776 int size, value;
4834 4777
@@ -4863,7 +4806,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4863 NULL); 4806 NULL);
4864 4807
4865 /* Massage the top+shown values. */ 4808 /* Massage the top+shown values. */
4866 if (NILP (bar->dragging) || last_scroll_bar_part == scroll_bar_down_arrow) 4809 if (bar->dragging == -1 || last_scroll_bar_part == scroll_bar_down_arrow)
4867 top = max (0, min (1, top)); 4810 top = max (0, min (1, top));
4868 else 4811 else
4869 top = old_top; 4812 top = old_top;
@@ -4875,7 +4818,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4875 for `NARROWPROTO'. See s/freebsd.h for an example. */ 4818 for `NARROWPROTO'. See s/freebsd.h for an example. */
4876 if (top != old_top || shown != old_shown) 4819 if (top != old_top || shown != old_shown)
4877 { 4820 {
4878 if (NILP (bar->dragging)) 4821 if (bar->dragging == -1)
4879 XawScrollbarSetThumb (widget, top, shown); 4822 XawScrollbarSetThumb (widget, top, shown);
4880 else 4823 else
4881 { 4824 {
@@ -4940,8 +4883,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4940 this case, no clear_frame is generated to reduce flickering. */ 4883 this case, no clear_frame is generated to reduce flickering. */
4941 if (width > 0 && height > 0) 4884 if (width > 0 && height > 0)
4942 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4885 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4943 left, top, width, 4886 left, top, width, window_box_height (w));
4944 window_box_height (w), False);
4945 4887
4946 window = XCreateWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4888 window = XCreateWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4947 /* Position and size of scroll bar. */ 4889 /* Position and size of scroll bar. */
@@ -4967,7 +4909,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4967 bar->height = height; 4909 bar->height = height;
4968 bar->start = 0; 4910 bar->start = 0;
4969 bar->end = 0; 4911 bar->end = 0;
4970 bar->dragging = Qnil; 4912 bar->dragging = -1;
4971 bar->fringe_extended_p = 0; 4913 bar->fringe_extended_p = 0;
4972 4914
4973 /* Add bar to its frame's list of scroll bars. */ 4915 /* Add bar to its frame's list of scroll bars. */
@@ -5025,7 +4967,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
5025static void 4967static void
5026x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild) 4968x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild)
5027{ 4969{
5028 int dragging = ! NILP (bar->dragging); 4970 bool dragging = bar->dragging != -1;
5029 Window w = bar->x_window; 4971 Window w = bar->x_window;
5030 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4972 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5031 GC gc = f->output_data.x->normal_gc; 4973 GC gc = f->output_data.x->normal_gc;
@@ -5077,11 +5019,9 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5077 zero-height areas; that means "clear to end of window." */ 5019 zero-height areas; that means "clear to end of window." */
5078 if (start > 0) 5020 if (start > 0)
5079 x_clear_area (FRAME_X_DISPLAY (f), w, 5021 x_clear_area (FRAME_X_DISPLAY (f), w,
5080 /* x, y, width, height, and exposures. */
5081 VERTICAL_SCROLL_BAR_LEFT_BORDER, 5022 VERTICAL_SCROLL_BAR_LEFT_BORDER,
5082 VERTICAL_SCROLL_BAR_TOP_BORDER, 5023 VERTICAL_SCROLL_BAR_TOP_BORDER,
5083 inside_width, start, 5024 inside_width, start);
5084 False);
5085 5025
5086 /* Change to proper foreground color if one is specified. */ 5026 /* Change to proper foreground color if one is specified. */
5087 if (f->output_data.x->scroll_bar_foreground_pixel != -1) 5027 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
@@ -5104,12 +5044,9 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5104 clear zero-height areas; that means "clear to end of window." */ 5044 clear zero-height areas; that means "clear to end of window." */
5105 if (end < inside_height) 5045 if (end < inside_height)
5106 x_clear_area (FRAME_X_DISPLAY (f), w, 5046 x_clear_area (FRAME_X_DISPLAY (f), w,
5107 /* x, y, width, height, and exposures. */
5108 VERTICAL_SCROLL_BAR_LEFT_BORDER, 5047 VERTICAL_SCROLL_BAR_LEFT_BORDER,
5109 VERTICAL_SCROLL_BAR_TOP_BORDER + end, 5048 VERTICAL_SCROLL_BAR_TOP_BORDER + end,
5110 inside_width, inside_height - end, 5049 inside_width, inside_height - end);
5111 False);
5112
5113 } 5050 }
5114 5051
5115 unblock_input (); 5052 unblock_input ();
@@ -5161,7 +5098,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5161#endif 5098#endif
5162 5099
5163 /* Get window dimensions. */ 5100 /* Get window dimensions. */
5164 window_box (w, -1, 0, &window_y, 0, &window_height); 5101 window_box (w, ANY_AREA, 0, &window_y, 0, &window_height);
5165 top = window_y; 5102 top = window_y;
5166 width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f); 5103 width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
5167 height = window_height; 5104 height = window_height;
@@ -5202,11 +5139,11 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5202#ifdef USE_TOOLKIT_SCROLL_BARS 5139#ifdef USE_TOOLKIT_SCROLL_BARS
5203 if (fringe_extended_p) 5140 if (fringe_extended_p)
5204 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5141 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5205 sb_left, top, sb_width, height, False); 5142 sb_left, top, sb_width, height);
5206 else 5143 else
5207#endif 5144#endif
5208 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5145 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5209 left, top, width, height, False); 5146 left, top, width, height);
5210 unblock_input (); 5147 unblock_input ();
5211 } 5148 }
5212 5149
@@ -5241,10 +5178,10 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5241 { 5178 {
5242 if (fringe_extended_p) 5179 if (fringe_extended_p)
5243 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5180 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5244 sb_left, top, sb_width, height, False); 5181 sb_left, top, sb_width, height);
5245 else 5182 else
5246 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5183 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5247 left, top, width, height, False); 5184 left, top, width, height);
5248 } 5185 }
5249#ifdef USE_GTK 5186#ifdef USE_GTK
5250 xg_update_scrollbar_pos (f, 5187 xg_update_scrollbar_pos (f,
@@ -5268,12 +5205,10 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5268 if (VERTICAL_SCROLL_BAR_WIDTH_TRIM) 5205 if (VERTICAL_SCROLL_BAR_WIDTH_TRIM)
5269 { 5206 {
5270 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5207 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5271 left, top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5208 left, top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, height);
5272 height, False);
5273 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5209 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5274 left + width - VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5210 left + width - VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5275 top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5211 top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, height);
5276 height, False);
5277 } 5212 }
5278 5213
5279 /* Clear areas not covered by the scroll bar because it's not as 5214 /* Clear areas not covered by the scroll bar because it's not as
@@ -5287,11 +5222,10 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5287 { 5222 {
5288 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)) 5223 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
5289 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5224 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5290 left + area_width - rest, top, 5225 left + area_width - rest, top, rest, height);
5291 rest, height, False);
5292 else 5226 else
5293 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5227 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5294 left, top, rest, height, False); 5228 left, top, rest, height);
5295 } 5229 }
5296 } 5230 }
5297 5231
@@ -5326,7 +5260,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5326#else /* not USE_TOOLKIT_SCROLL_BARS */ 5260#else /* not USE_TOOLKIT_SCROLL_BARS */
5327 /* Set the scroll bar's current state, unless we're currently being 5261 /* Set the scroll bar's current state, unless we're currently being
5328 dragged. */ 5262 dragged. */
5329 if (NILP (bar->dragging)) 5263 if (bar->dragging == -1)
5330 { 5264 {
5331 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height); 5265 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height);
5332 5266
@@ -5536,14 +5470,13 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e
5536 5470
5537#ifndef USE_TOOLKIT_SCROLL_BARS 5471#ifndef USE_TOOLKIT_SCROLL_BARS
5538 /* If the user has released the handle, set it to its final position. */ 5472 /* If the user has released the handle, set it to its final position. */
5539 if (event->type == ButtonRelease 5473 if (event->type == ButtonRelease && bar->dragging != -1)
5540 && ! NILP (bar->dragging))
5541 { 5474 {
5542 int new_start = y - XINT (bar->dragging); 5475 int new_start = y - bar->dragging;
5543 int new_end = new_start + bar->end - bar->start; 5476 int new_end = new_start + bar->end - bar->start;
5544 5477
5545 x_scroll_bar_set_handle (bar, new_start, new_end, 0); 5478 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
5546 bar->dragging = Qnil; 5479 bar->dragging = -1;
5547 } 5480 }
5548#endif 5481#endif
5549 5482
@@ -5560,20 +5493,20 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e
5560 mark bits. */ 5493 mark bits. */
5561 5494
5562static void 5495static void
5563x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) 5496x_scroll_bar_note_movement (struct scroll_bar *bar, XMotionEvent *event)
5564{ 5497{
5565 struct frame *f = XFRAME (XWINDOW (bar->window)->frame); 5498 struct frame *f = XFRAME (XWINDOW (bar->window)->frame);
5566 5499
5567 last_mouse_movement_time = event->xmotion.time; 5500 last_mouse_movement_time = event->time;
5568 5501
5569 f->mouse_moved = 1; 5502 f->mouse_moved = 1;
5570 XSETVECTOR (last_mouse_scroll_bar, bar); 5503 XSETVECTOR (last_mouse_scroll_bar, bar);
5571 5504
5572 /* If we're dragging the bar, display it. */ 5505 /* If we're dragging the bar, display it. */
5573 if (! NILP (bar->dragging)) 5506 if (bar->dragging != -1)
5574 { 5507 {
5575 /* Where should the handle be now? */ 5508 /* Where should the handle be now? */
5576 int new_start = event->xmotion.y - XINT (bar->dragging); 5509 int new_start = event->y - bar->dragging;
5577 5510
5578 if (new_start != bar->start) 5511 if (new_start != bar->start)
5579 { 5512 {
@@ -5625,8 +5558,8 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window,
5625 5558
5626 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; 5559 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
5627 5560
5628 if (! NILP (bar->dragging)) 5561 if (bar->dragging != -1)
5629 win_y -= XINT (bar->dragging); 5562 win_y -= bar->dragging;
5630 5563
5631 if (win_y < 0) 5564 if (win_y < 0)
5632 win_y = 0; 5565 win_y = 0;
@@ -5636,7 +5569,7 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window,
5636 *fp = f; 5569 *fp = f;
5637 *bar_window = bar->window; 5570 *bar_window = bar->window;
5638 5571
5639 if (! NILP (bar->dragging)) 5572 if (bar->dragging != -1)
5640 *part = scroll_bar_handle; 5573 *part = scroll_bar_handle;
5641 else if (win_y < bar->start) 5574 else if (win_y < bar->start)
5642 *part = scroll_bar_above_handle; 5575 *part = scroll_bar_above_handle;
@@ -5681,18 +5614,7 @@ x_scroll_bar_clear (struct frame *f)
5681#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5614#endif /* not USE_TOOLKIT_SCROLL_BARS */
5682} 5615}
5683 5616
5684 5617#ifdef ENABLE_CHECKING
5685/* The main X event-reading loop - XTread_socket. */
5686
5687/* This holds the state XLookupString needs to implement dead keys
5688 and other tricks known as "compose processing". _X Window System_
5689 says that a portable program can't use this, but Stephen Gildea assures
5690 me that letting the compiler initialize it to zeros will work okay.
5691
5692 This must be defined outside of XTread_socket, for the same reasons
5693 given for enter_timestamp, above. */
5694
5695static XComposeStatus compose_status;
5696 5618
5697/* Record the last 100 characters stored 5619/* Record the last 100 characters stored
5698 to help debug the loss-of-chars-during-GC problem. */ 5620 to help debug the loss-of-chars-during-GC problem. */
@@ -5705,6 +5627,12 @@ static short temp_buffer[100];
5705 temp_index = 0; \ 5627 temp_index = 0; \
5706 temp_buffer[temp_index++] = (keysym) 5628 temp_buffer[temp_index++] = (keysym)
5707 5629
5630#else /* not ENABLE_CHECKING */
5631
5632#define STORE_KEYSYM_FOR_DEBUG(keysym) ((void)0)
5633
5634#endif /* ENABLE_CHECKING */
5635
5708/* Set this to nonzero to fake an "X I/O error" 5636/* Set this to nonzero to fake an "X I/O error"
5709 on a particular display. */ 5637 on a particular display. */
5710 5638
@@ -5842,6 +5770,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5842 struct coding_system coding; 5770 struct coding_system coding;
5843 XEvent event = *eventptr; 5771 XEvent event = *eventptr;
5844 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 5772 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
5773 /* This holds the state XLookupString needs to implement dead keys
5774 and other tricks known as "compose processing". _X Window System_
5775 says that a portable program can't use this, but Stephen Gildea assures
5776 me that letting the compiler initialize it to zeros will work okay. */
5777 static XComposeStatus compose_status;
5778
5845 USE_SAFE_ALLOCA; 5779 USE_SAFE_ALLOCA;
5846 5780
5847 *finish = X_EVENT_NORMAL; 5781 *finish = X_EVENT_NORMAL;
@@ -6135,11 +6069,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6135 { 6069 {
6136#ifdef USE_GTK 6070#ifdef USE_GTK
6137 /* This seems to be needed for GTK 2.6. */ 6071 /* This seems to be needed for GTK 2.6. */
6138 x_clear_area (event.xexpose.display, 6072 x_clear_area (event.xexpose.display,
6139 event.xexpose.window, 6073 event.xexpose.window,
6140 event.xexpose.x, event.xexpose.y, 6074 event.xexpose.x, event.xexpose.y,
6141 event.xexpose.width, event.xexpose.height, 6075 event.xexpose.width, event.xexpose.height);
6142 FALSE);
6143#endif 6076#endif
6144 if (!FRAME_VISIBLE_P (f)) 6077 if (!FRAME_VISIBLE_P (f))
6145 { 6078 {
@@ -6211,7 +6144,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6211 6144
6212 case UnmapNotify: 6145 case UnmapNotify:
6213 /* Redo the mouse-highlight after the tooltip has gone. */ 6146 /* Redo the mouse-highlight after the tooltip has gone. */
6214 if (event.xmap.window == tip_window) 6147 if (event.xunmap.window == tip_window)
6215 { 6148 {
6216 tip_window = 0; 6149 tip_window = 0;
6217 redo_mouse_highlight (); 6150 redo_mouse_highlight ();
@@ -6715,18 +6648,16 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6715 /* Generate SELECT_WINDOW_EVENTs when needed. 6648 /* Generate SELECT_WINDOW_EVENTs when needed.
6716 Don't let popup menus influence things (bug#1261). */ 6649 Don't let popup menus influence things (bug#1261). */
6717 if (!NILP (Vmouse_autoselect_window) && !popup_activated ()) 6650 if (!NILP (Vmouse_autoselect_window) && !popup_activated ())
6718 { 6651 {
6719 Lisp_Object window; 6652 static Lisp_Object last_mouse_window;
6720 6653 Lisp_Object window = window_from_coordinates
6721 window = window_from_coordinates (f, 6654 (f, event.xmotion.x, event.xmotion.y, 0, 0);
6722 event.xmotion.x, event.xmotion.y, 6655
6723 0, 0); 6656 /* Window will be selected only when it is not selected now and
6724 6657 last mouse movement event was not in it. Minibuffer window
6725 /* Window will be selected only when it is not selected now and 6658 will be selected only when it is active. */
6726 last mouse movement event was not in it. Minibuffer window 6659 if (WINDOWP (window)
6727 will be selected only when it is active. */ 6660 && !EQ (window, last_mouse_window)
6728 if (WINDOWP (window)
6729 && !EQ (window, last_window)
6730 && !EQ (window, selected_window) 6661 && !EQ (window, selected_window)
6731 /* For click-to-focus window managers 6662 /* For click-to-focus window managers
6732 create event iff we don't leave the 6663 create event iff we don't leave the
@@ -6734,13 +6665,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6734 && (focus_follows_mouse 6665 && (focus_follows_mouse
6735 || (EQ (XWINDOW (window)->frame, 6666 || (EQ (XWINDOW (window)->frame,
6736 XWINDOW (selected_window)->frame)))) 6667 XWINDOW (selected_window)->frame))))
6737 { 6668 {
6738 inev.ie.kind = SELECT_WINDOW_EVENT; 6669 inev.ie.kind = SELECT_WINDOW_EVENT;
6739 inev.ie.frame_or_window = window; 6670 inev.ie.frame_or_window = window;
6740 } 6671 }
6741 6672 /* Remember the last window where we saw the mouse. */
6742 last_window=window; 6673 last_mouse_window = window;
6743 } 6674 }
6744 if (!note_mouse_movement (f, &event.xmotion)) 6675 if (!note_mouse_movement (f, &event.xmotion))
6745 help_echo_string = previous_help_echo_string; 6676 help_echo_string = previous_help_echo_string;
6746 } 6677 }
@@ -6752,7 +6683,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6752 event.xmotion.window); 6683 event.xmotion.window);
6753 6684
6754 if (bar) 6685 if (bar)
6755 x_scroll_bar_note_movement (bar, &event); 6686 x_scroll_bar_note_movement (bar, &event.xmotion);
6756#endif /* USE_TOOLKIT_SCROLL_BARS */ 6687#endif /* USE_TOOLKIT_SCROLL_BARS */
6757 6688
6758 /* If we move outside the frame, then we're 6689 /* If we move outside the frame, then we're
@@ -7184,7 +7115,8 @@ XTread_socket (struct terminal *terminal, struct input_event *hold_quit)
7184 mode lines must be clipped to the whole window. */ 7115 mode lines must be clipped to the whole window. */
7185 7116
7186static void 7117static void
7187x_clip_to_row (struct window *w, struct glyph_row *row, int area, GC gc) 7118x_clip_to_row (struct window *w, struct glyph_row *row,
7119 enum glyph_row_area area, GC gc)
7188{ 7120{
7189 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7121 struct frame *f = XFRAME (WINDOW_FRAME (w));
7190 XRectangle clip_rect; 7122 XRectangle clip_rect;
@@ -7366,8 +7298,7 @@ x_define_frame_cursor (struct frame *f, Cursor cursor)
7366static void 7298static void
7367x_clear_frame_area (struct frame *f, int x, int y, int width, int height) 7299x_clear_frame_area (struct frame *f, int x, int y, int width, int height)
7368{ 7300{
7369 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7301 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), x, y, width, height);
7370 x, y, width, height, False);
7371#ifdef USE_GTK 7302#ifdef USE_GTK
7372 /* Must queue a redraw, because scroll bars might have been cleared. */ 7303 /* Must queue a redraw, because scroll bars might have been cleared. */
7373 if (FRAME_GTK_WIDGET (f)) 7304 if (FRAME_GTK_WIDGET (f))
@@ -7434,9 +7365,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
7434#endif 7365#endif
7435 } 7366 }
7436 7367
7437#ifndef XFlush
7438 XFlush (FRAME_X_DISPLAY (f)); 7368 XFlush (FRAME_X_DISPLAY (f));
7439#endif
7440} 7369}
7441 7370
7442 7371
@@ -8189,9 +8118,6 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
8189 8118
8190 if (change_gravity > 0) 8119 if (change_gravity > 0)
8191 { 8120 {
8192 FRAME_X_OUTPUT (f)->left_before_move = f->left_pos;
8193 FRAME_X_OUTPUT (f)->top_before_move = f->top_pos;
8194
8195 f->top_pos = yoff; 8121 f->top_pos = yoff;
8196 f->left_pos = xoff; 8122 f->left_pos = xoff;
8197 f->size_hint_flags &= ~ (XNegative | YNegative); 8123 f->size_hint_flags &= ~ (XNegative | YNegative);
@@ -8690,7 +8616,7 @@ x_wait_for_event (struct frame *f, int eventtype)
8690{ 8616{
8691 int level = interrupt_input_blocked; 8617 int level = interrupt_input_blocked;
8692 8618
8693 SELECT_TYPE fds; 8619 fd_set fds;
8694 struct timespec tmo, tmo_at, time_now; 8620 struct timespec tmo, tmo_at, time_now;
8695 int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); 8621 int fd = ConnectionNumber (FRAME_X_DISPLAY (f));
8696 8622
@@ -10250,9 +10176,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10250 dpyinfo->x_dnd_atoms_size = 8; 10176 dpyinfo->x_dnd_atoms_size = 8;
10251 dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms 10177 dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms
10252 * dpyinfo->x_dnd_atoms_size); 10178 * dpyinfo->x_dnd_atoms_size);
10253
10254 connection = ConnectionNumber (dpyinfo->display);
10255 dpyinfo->connection = connection;
10256 dpyinfo->gray 10179 dpyinfo->gray
10257 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, 10180 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
10258 gray_bits, gray_width, gray_height, 10181 gray_bits, gray_width, gray_height,
@@ -10264,6 +10187,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10264 10187
10265 xsettings_initialize (dpyinfo); 10188 xsettings_initialize (dpyinfo);
10266 10189
10190 connection = ConnectionNumber (dpyinfo->display);
10191
10267 /* This is only needed for distinguishing keyboard and process input. */ 10192 /* This is only needed for distinguishing keyboard and process input. */
10268 if (connection != 0) 10193 if (connection != 0)
10269 add_keyboard_wait_descriptor (connection); 10194 add_keyboard_wait_descriptor (connection);
@@ -10364,8 +10289,6 @@ x_delete_display (struct x_display_info *dpyinfo)
10364 break; 10289 break;
10365 } 10290 }
10366 10291
10367 delete_keyboard_wait_descriptor (dpyinfo->connection);
10368
10369 /* Discard this display from x_display_name_list and x_display_list. 10292 /* Discard this display from x_display_name_list and x_display_list.
10370 We can't use Fdelq because that can quit. */ 10293 We can't use Fdelq because that can quit. */
10371 if (! NILP (x_display_name_list) 10294 if (! NILP (x_display_name_list)
@@ -10466,13 +10389,7 @@ static struct redisplay_interface x_redisplay_interface =
10466 x_after_update_window_line, 10389 x_after_update_window_line,
10467 x_update_window_begin, 10390 x_update_window_begin,
10468 x_update_window_end, 10391 x_update_window_end,
10469 x_cursor_to,
10470 x_flush,
10471#ifdef XFlush
10472 x_flush, 10392 x_flush,
10473#else
10474 0, /* flush_display_optional */
10475#endif
10476 x_clear_window_mouse_face, 10393 x_clear_window_mouse_face,
10477 x_get_glyph_overhangs, 10394 x_get_glyph_overhangs,
10478 x_fix_overlapping_area, 10395 x_fix_overlapping_area,
@@ -10494,6 +10411,7 @@ void
10494x_delete_terminal (struct terminal *terminal) 10411x_delete_terminal (struct terminal *terminal)
10495{ 10412{
10496 struct x_display_info *dpyinfo = terminal->display_info.x; 10413 struct x_display_info *dpyinfo = terminal->display_info.x;
10414 int connection = -1;
10497 10415
10498 /* Protect against recursive calls. delete_frame in 10416 /* Protect against recursive calls. delete_frame in
10499 delete_terminal calls us back when it deletes our last frame. */ 10417 delete_terminal calls us back when it deletes our last frame. */
@@ -10512,6 +10430,8 @@ x_delete_terminal (struct terminal *terminal)
10512 and dpyinfo->display was set to 0 to indicate that. */ 10430 and dpyinfo->display was set to 0 to indicate that. */
10513 if (dpyinfo->display) 10431 if (dpyinfo->display)
10514 { 10432 {
10433 connection = ConnectionNumber (dpyinfo->display);
10434
10515 x_destroy_all_bitmaps (dpyinfo); 10435 x_destroy_all_bitmaps (dpyinfo);
10516 XSetCloseDownMode (dpyinfo->display, DestroyAll); 10436 XSetCloseDownMode (dpyinfo->display, DestroyAll);
10517 10437
@@ -10552,6 +10472,10 @@ x_delete_terminal (struct terminal *terminal)
10552#endif /* ! USE_GTK */ 10472#endif /* ! USE_GTK */
10553 } 10473 }
10554 10474
10475 /* No more input on this descriptor. */
10476 if (connection != -1)
10477 delete_keyboard_wait_descriptor (connection);
10478
10555 /* Mark as dead. */ 10479 /* Mark as dead. */
10556 dpyinfo->display = NULL; 10480 dpyinfo->display = NULL;
10557 x_delete_display (dpyinfo); 10481 x_delete_display (dpyinfo);
@@ -10579,11 +10503,11 @@ x_create_terminal (struct x_display_info *dpyinfo)
10579 terminal->delete_glyphs_hook = x_delete_glyphs; 10503 terminal->delete_glyphs_hook = x_delete_glyphs;
10580 terminal->ring_bell_hook = XTring_bell; 10504 terminal->ring_bell_hook = XTring_bell;
10581 terminal->toggle_invisible_pointer_hook = XTtoggle_invisible_pointer; 10505 terminal->toggle_invisible_pointer_hook = XTtoggle_invisible_pointer;
10582 terminal->reset_terminal_modes_hook = XTreset_terminal_modes; 10506 terminal->reset_terminal_modes_hook = NULL;
10583 terminal->set_terminal_modes_hook = XTset_terminal_modes; 10507 terminal->set_terminal_modes_hook = NULL;
10584 terminal->update_begin_hook = x_update_begin; 10508 terminal->update_begin_hook = x_update_begin;
10585 terminal->update_end_hook = x_update_end; 10509 terminal->update_end_hook = x_update_end;
10586 terminal->set_terminal_window_hook = XTset_terminal_window; 10510 terminal->set_terminal_window_hook = NULL;
10587 terminal->read_socket_hook = XTread_socket; 10511 terminal->read_socket_hook = XTread_socket;
10588 terminal->frame_up_to_date_hook = XTframe_up_to_date; 10512 terminal->frame_up_to_date_hook = XTframe_up_to_date;
10589 terminal->mouse_position_hook = XTmouse_position; 10513 terminal->mouse_position_hook = XTmouse_position;