aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c112
1 files changed, 51 insertions, 61 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 2f3d5ca7a01..c28ca824063 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -230,10 +230,6 @@ static Lisp_Object last_mouse_scroll_bar;
230 230
231static Time last_mouse_movement_time; 231static Time last_mouse_movement_time;
232 232
233/* Time for last user interaction as returned in X events. */
234
235static Time last_user_time;
236
237/* Incremented by XTread_socket whenever it really tries to read 233/* Incremented by XTread_socket whenever it really tries to read
238 events. */ 234 events. */
239 235
@@ -334,29 +330,19 @@ static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t);
334static void x_initialize (void); 330static void x_initialize (void);
335 331
336 332
337/* Flush display of frame F, or of all frames if F is null. */ 333/* Flush display of frame F. */
338 334
339static void 335static void
340x_flush (struct frame *f) 336x_flush (struct frame *f)
341{ 337{
338 eassert (f && FRAME_X_P (f));
342 /* Don't call XFlush when it is not safe to redisplay; the X 339 /* Don't call XFlush when it is not safe to redisplay; the X
343 connection may be broken. */ 340 connection may be broken. */
344 if (!NILP (Vinhibit_redisplay)) 341 if (!NILP (Vinhibit_redisplay))
345 return; 342 return;
346 343
347 block_input (); 344 block_input ();
348 if (f) 345 XFlush (FRAME_X_DISPLAY (f));
349 {
350 eassert (FRAME_X_P (f));
351 XFlush (FRAME_X_DISPLAY (f));
352 }
353 else
354 {
355 /* Flush all displays and so all frames on them. */
356 struct x_display_info *xdi;
357 for (xdi = x_display_list; xdi; xdi = xdi->next)
358 XFlush (xdi->display);
359 }
360 unblock_input (); 346 unblock_input ();
361} 347}
362 348
@@ -4091,10 +4077,6 @@ static void x_set_toolkit_scroll_bar_thumb (struct scroll_bar *,
4091 4077
4092static Lisp_Object window_being_scrolled; 4078static Lisp_Object window_being_scrolled;
4093 4079
4094/* Last scroll bar part sent in xm_scroll_callback. */
4095
4096static int last_scroll_bar_part;
4097
4098/* Whether this is an Xaw with arrow-scrollbars. This should imply 4080/* Whether this is an Xaw with arrow-scrollbars. This should imply
4099 that movements of 1/20 of the screen size are mapped to up/down. */ 4081 that movements of 1/20 of the screen size are mapped to up/down. */
4100 4082
@@ -4136,20 +4118,23 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name,
4136 && WINDOWP (window_being_scrolled)) 4118 && WINDOWP (window_being_scrolled))
4137 { 4119 {
4138 struct window *w; 4120 struct window *w;
4121 struct scroll_bar *bar;
4139 4122
4140 x_send_scroll_bar_event (window_being_scrolled, 4123 x_send_scroll_bar_event (window_being_scrolled,
4141 scroll_bar_end_scroll, 0, 0); 4124 scroll_bar_end_scroll, 0, 0);
4142 w = XWINDOW (window_being_scrolled); 4125 w = XWINDOW (window_being_scrolled);
4126 bar = XSCROLL_BAR (w->vertical_scroll_bar);
4143 4127
4144 if (XSCROLL_BAR (w->vertical_scroll_bar)->dragging != -1) 4128 if (bar->dragging != -1)
4145 { 4129 {
4146 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = -1; 4130 bar->dragging = -1;
4147 /* The thumb size is incorrect while dragging: fix it. */ 4131 /* The thumb size is incorrect while dragging: fix it. */
4148 set_vertical_scroll_bar (w); 4132 set_vertical_scroll_bar (w);
4149 } 4133 }
4150 window_being_scrolled = Qnil; 4134 window_being_scrolled = Qnil;
4151 last_scroll_bar_part = -1; 4135#if defined (USE_LUCID)
4152 4136 bar->last_seen_part = scroll_bar_nowhere;
4137#endif
4153 /* Xt timeouts no longer needed. */ 4138 /* Xt timeouts no longer needed. */
4154 toolkit_scroll_bar_interaction = 0; 4139 toolkit_scroll_bar_interaction = 0;
4155 } 4140 }
@@ -4333,7 +4318,6 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4333 if (part >= 0) 4318 if (part >= 0)
4334 { 4319 {
4335 window_being_scrolled = bar->window; 4320 window_being_scrolled = bar->window;
4336 last_scroll_bar_part = part;
4337 x_send_scroll_bar_event (bar->window, part, portion, whole); 4321 x_send_scroll_bar_event (bar->window, part, portion, whole);
4338 } 4322 }
4339} 4323}
@@ -4394,7 +4378,6 @@ xg_scroll_callback (GtkRange *range,
4394 if (part >= 0) 4378 if (part >= 0)
4395 { 4379 {
4396 window_being_scrolled = bar->window; 4380 window_being_scrolled = bar->window;
4397 last_scroll_bar_part = part;
4398 x_send_scroll_bar_event (bar->window, part, portion, whole); 4381 x_send_scroll_bar_event (bar->window, part, portion, whole);
4399 } 4382 }
4400 4383
@@ -4436,7 +4419,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4436 float top = *top_addr; 4419 float top = *top_addr;
4437 float shown; 4420 float shown;
4438 int whole, portion, height; 4421 int whole, portion, height;
4439 int part; 4422 enum scroll_bar_part part;
4440 4423
4441 /* Get the size of the thumb, a value between 0 and 1. */ 4424 /* Get the size of the thumb, a value between 0 and 1. */
4442 block_input (); 4425 block_input ();
@@ -4458,7 +4441,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4458 4441
4459 window_being_scrolled = bar->window; 4442 window_being_scrolled = bar->window;
4460 bar->dragging = portion; 4443 bar->dragging = portion;
4461 last_scroll_bar_part = part; 4444 bar->last_seen_part = part;
4462 x_send_scroll_bar_event (bar->window, part, portion, whole); 4445 x_send_scroll_bar_event (bar->window, part, portion, whole);
4463} 4446}
4464 4447
@@ -4478,7 +4461,7 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4478 /* The position really is stored cast to a pointer. */ 4461 /* The position really is stored cast to a pointer. */
4479 int position = (intptr_t) call_data; 4462 int position = (intptr_t) call_data;
4480 Dimension height; 4463 Dimension height;
4481 int part; 4464 enum scroll_bar_part part;
4482 4465
4483 /* Get the height of the scroll bar. */ 4466 /* Get the height of the scroll bar. */
4484 block_input (); 4467 block_input ();
@@ -4497,7 +4480,7 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4497 4480
4498 window_being_scrolled = bar->window; 4481 window_being_scrolled = bar->window;
4499 bar->dragging = -1; 4482 bar->dragging = -1;
4500 last_scroll_bar_part = part; 4483 bar->last_seen_part = part;
4501 x_send_scroll_bar_event (bar->window, part, position, height); 4484 x_send_scroll_bar_event (bar->window, part, position, height);
4502} 4485}
4503 4486
@@ -4807,16 +4790,25 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4807 NULL); 4790 NULL);
4808 4791
4809 /* Massage the top+shown values. */ 4792 /* Massage the top+shown values. */
4810 if (bar->dragging == -1 || last_scroll_bar_part == scroll_bar_down_arrow) 4793 if (bar->dragging == -1 || bar->last_seen_part == scroll_bar_down_arrow)
4811 top = max (0, min (1, top)); 4794 top = max (0, min (1, top));
4812 else 4795 else
4813 top = old_top; 4796 top = old_top;
4797#if ! defined (HAVE_XAW3D)
4798 /* With Xaw, 'top' values too closer to 1.0 may
4799 cause the thumb to disappear. Fix that. */
4800 top = min (top, 0.99f);
4801#endif
4814 /* Keep two pixels available for moving the thumb down. */ 4802 /* Keep two pixels available for moving the thumb down. */
4815 shown = max (0, min (1 - top - (2.0f / height), shown)); 4803 shown = max (0, min (1 - top - (2.0f / height), shown));
4804#if ! defined (HAVE_XAW3D)
4805 /* Likewise with too small 'shown'. */
4806 shown = max (shown, 0.01f);
4807#endif
4816 4808
4817 /* If the call to XawScrollbarSetThumb below doesn't seem to work, 4809 /* If the call to XawScrollbarSetThumb below doesn't seem to
4818 check that your system's configuration file contains a define 4810 work, check that 'NARROWPROTO' is defined in src/config.h.
4819 for `NARROWPROTO'. See s/freebsd.h for an example. */ 4811 If this is not so, most likely you need to fix configure. */
4820 if (top != old_top || shown != old_shown) 4812 if (top != old_top || shown != old_shown)
4821 { 4813 {
4822 if (bar->dragging == -1) 4814 if (bar->dragging == -1)
@@ -4912,6 +4904,9 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4912 bar->end = 0; 4904 bar->end = 0;
4913 bar->dragging = -1; 4905 bar->dragging = -1;
4914 bar->fringe_extended_p = 0; 4906 bar->fringe_extended_p = 0;
4907#if defined (USE_TOOLKIT_SCROLL_BARS) && defined (USE_LUCID)
4908 bar->last_seen_part = scroll_bar_nowhere;
4909#endif
4915 4910
4916 /* Add bar to its frame's list of scroll bars. */ 4911 /* Add bar to its frame's list of scroll bars. */
4917 bar->next = FRAME_SCROLL_BARS (f); 4912 bar->next = FRAME_SCROLL_BARS (f);
@@ -5980,7 +5975,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5980 break; 5975 break;
5981 5976
5982 case SelectionNotify: 5977 case SelectionNotify:
5983 last_user_time = event.xselection.time; 5978 dpyinfo->last_user_time = event.xselection.time;
5984#ifdef USE_X_TOOLKIT 5979#ifdef USE_X_TOOLKIT
5985 if (! x_window_to_frame (dpyinfo, event.xselection.requestor)) 5980 if (! x_window_to_frame (dpyinfo, event.xselection.requestor))
5986 goto OTHER; 5981 goto OTHER;
@@ -5989,7 +5984,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5989 break; 5984 break;
5990 5985
5991 case SelectionClear: /* Someone has grabbed ownership. */ 5986 case SelectionClear: /* Someone has grabbed ownership. */
5992 last_user_time = event.xselectionclear.time; 5987 dpyinfo->last_user_time = event.xselectionclear.time;
5993#ifdef USE_X_TOOLKIT 5988#ifdef USE_X_TOOLKIT
5994 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window)) 5989 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window))
5995 goto OTHER; 5990 goto OTHER;
@@ -6005,7 +6000,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6005 break; 6000 break;
6006 6001
6007 case SelectionRequest: /* Someone wants our selection. */ 6002 case SelectionRequest: /* Someone wants our selection. */
6008 last_user_time = event.xselectionrequest.time; 6003 dpyinfo->last_user_time = event.xselectionrequest.time;
6009#ifdef USE_X_TOOLKIT 6004#ifdef USE_X_TOOLKIT
6010 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner)) 6005 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner))
6011 goto OTHER; 6006 goto OTHER;
@@ -6024,7 +6019,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6024 break; 6019 break;
6025 6020
6026 case PropertyNotify: 6021 case PropertyNotify:
6027 last_user_time = event.xproperty.time; 6022 dpyinfo->last_user_time = event.xproperty.time;
6028 f = x_top_window_to_frame (dpyinfo, event.xproperty.window); 6023 f = x_top_window_to_frame (dpyinfo, event.xproperty.window);
6029 if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state) 6024 if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state)
6030 if (x_handle_net_wm_state (f, &event.xproperty) 6025 if (x_handle_net_wm_state (f, &event.xproperty)
@@ -6224,7 +6219,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6224 6219
6225 case KeyPress: 6220 case KeyPress:
6226 6221
6227 last_user_time = event.xkey.time; 6222 dpyinfo->last_user_time = event.xkey.time;
6228 ignore_next_mouse_click_timeout = 0; 6223 ignore_next_mouse_click_timeout = 0;
6229 6224
6230#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6225#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
@@ -6235,6 +6230,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6235 6230
6236 f = x_any_window_to_frame (dpyinfo, event.xkey.window); 6231 f = x_any_window_to_frame (dpyinfo, event.xkey.window);
6237 6232
6233#if ! defined (USE_GTK)
6238 /* If mouse-highlight is an integer, input clears out 6234 /* If mouse-highlight is an integer, input clears out
6239 mouse highlighting. */ 6235 mouse highlighting. */
6240 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 6236 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
@@ -6244,6 +6240,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6244 clear_mouse_face (hlinfo); 6240 clear_mouse_face (hlinfo);
6245 hlinfo->mouse_face_hidden = 1; 6241 hlinfo->mouse_face_hidden = 1;
6246 } 6242 }
6243#endif
6247 6244
6248#if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS 6245#if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS
6249 if (f == 0) 6246 if (f == 0)
@@ -6553,7 +6550,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6553#endif 6550#endif
6554 6551
6555 case KeyRelease: 6552 case KeyRelease:
6556 last_user_time = event.xkey.time; 6553 dpyinfo->last_user_time = event.xkey.time;
6557#ifdef HAVE_X_I18N 6554#ifdef HAVE_X_I18N
6558 /* Don't dispatch this event since XtDispatchEvent calls 6555 /* Don't dispatch this event since XtDispatchEvent calls
6559 XFilterEvent, and two calls in a row may freeze the 6556 XFilterEvent, and two calls in a row may freeze the
@@ -6564,7 +6561,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6564#endif 6561#endif
6565 6562
6566 case EnterNotify: 6563 case EnterNotify:
6567 last_user_time = event.xcrossing.time; 6564 dpyinfo->last_user_time = event.xcrossing.time;
6568 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6565 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6569 6566
6570 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); 6567 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
@@ -6589,7 +6586,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6589 goto OTHER; 6586 goto OTHER;
6590 6587
6591 case LeaveNotify: 6588 case LeaveNotify:
6592 last_user_time = event.xcrossing.time; 6589 dpyinfo->last_user_time = event.xcrossing.time;
6593 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6590 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6594 6591
6595 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6592 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
@@ -6623,7 +6620,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6623 6620
6624 case MotionNotify: 6621 case MotionNotify:
6625 { 6622 {
6626 last_user_time = event.xmotion.time; 6623 dpyinfo->last_user_time = event.xmotion.time;
6627 previous_help_echo_string = help_echo_string; 6624 previous_help_echo_string = help_echo_string;
6628 help_echo_string = Qnil; 6625 help_echo_string = Qnil;
6629 6626
@@ -6766,9 +6763,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6766 by the rest of Emacs, we put it here. */ 6763 by the rest of Emacs, we put it here. */
6767 bool tool_bar_p = 0; 6764 bool tool_bar_p = 0;
6768 6765
6769 memset (&compose_status, 0, sizeof (compose_status)); 6766 memset (&compose_status, 0, sizeof (compose_status));
6770 last_mouse_glyph_frame = 0; 6767 last_mouse_glyph_frame = 0;
6771 last_user_time = event.xbutton.time; 6768 dpyinfo->last_user_time = event.xbutton.time;
6772 6769
6773 if (dpyinfo->grabbed 6770 if (dpyinfo->grabbed
6774 && last_mouse_frame 6771 && last_mouse_frame
@@ -6783,6 +6780,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6783#endif 6780#endif
6784 if (f) 6781 if (f)
6785 { 6782 {
6783#if ! defined (USE_GTK)
6786 /* Is this in the tool-bar? */ 6784 /* Is this in the tool-bar? */
6787 if (WINDOWP (f->tool_bar_window) 6785 if (WINDOWP (f->tool_bar_window)
6788 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) 6786 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
@@ -6795,13 +6793,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6795 tool_bar_p = EQ (window, f->tool_bar_window); 6793 tool_bar_p = EQ (window, f->tool_bar_window);
6796 6794
6797 if (tool_bar_p && event.xbutton.button < 4) 6795 if (tool_bar_p && event.xbutton.button < 4)
6798 { 6796 handle_tool_bar_click
6799 handle_tool_bar_click (f, x, y, 6797 (f, x, y, event.xbutton.type == ButtonPress,
6800 event.xbutton.type == ButtonPress, 6798 x_x_to_emacs_modifiers (dpyinfo, event.xbutton.state));
6801 x_x_to_emacs_modifiers (dpyinfo,
6802 event.xbutton.state));
6803 }
6804 } 6799 }
6800#endif /* !USE_GTK */
6805 6801
6806 if (!tool_bar_p) 6802 if (!tool_bar_p)
6807#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6803#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
@@ -7361,9 +7357,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
7361#endif 7357#endif
7362 } 7358 }
7363 7359
7364#ifndef XFlush
7365 XFlush (FRAME_X_DISPLAY (f)); 7360 XFlush (FRAME_X_DISPLAY (f));
7366#endif
7367} 7361}
7368 7362
7369 7363
@@ -8861,8 +8855,9 @@ x_ewmh_activate_frame (struct frame *f)
8861 Lisp_Object frame; 8855 Lisp_Object frame;
8862 XSETFRAME (frame, f); 8856 XSETFRAME (frame, f);
8863 x_send_client_event (frame, make_number (0), frame, 8857 x_send_client_event (frame, make_number (0), frame,
8864 dpyinfo->Xatom_net_active_window, 8858 dpyinfo->Xatom_net_active_window,
8865 make_number (32), list2i (1, last_user_time)); 8859 make_number (32),
8860 list2i (1, dpyinfo->last_user_time));
8866 } 8861 }
8867} 8862}
8868 8863
@@ -10384,11 +10379,6 @@ static struct redisplay_interface x_redisplay_interface =
10384 x_update_window_begin, 10379 x_update_window_begin,
10385 x_update_window_end, 10380 x_update_window_end,
10386 x_flush, 10381 x_flush,
10387#ifdef XFlush
10388 x_flush,
10389#else
10390 0, /* flush_display_optional */
10391#endif
10392 x_clear_window_mouse_face, 10382 x_clear_window_mouse_face,
10393 x_get_glyph_overhangs, 10383 x_get_glyph_overhangs,
10394 x_fix_overlapping_area, 10384 x_fix_overlapping_area,