comparison src/xterm.c @ 27428:c8b20597f0fd

(toplevel): Include atimer.h. (toolkit_scroll_bar_interaction): New variable. (Fxt_process_timeouts): Removed. (x_process_timeouts): New function. (xt_action_hook): Clear toolkit_scroll_bar_interaction. (x_send_scroll_bar_event): Set toolkit_scroll_bar_interaction. (x_make_frame_visible): Call poll_for_input_1 instead of input_poll_signal. Don't call alarm. (x_initialize): Install timer calling x_process_timeouts.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 25 Jan 2000 15:55:13 +0000
parents 900a02429efa
children d33b4becc3ca
comparison
equal deleted inserted replaced
27427:0036f90725f6 27428:c8b20597f0fd
86 #include "buffer.h" 86 #include "buffer.h"
87 #include "window.h" 87 #include "window.h"
88 #include "keyboard.h" 88 #include "keyboard.h"
89 #include "intervals.h" 89 #include "intervals.h"
90 #include "process.h" 90 #include "process.h"
91 #include "atimer.h"
91 92
92 #ifdef USE_X_TOOLKIT 93 #ifdef USE_X_TOOLKIT
93 #include <X11/Shell.h> 94 #include <X11/Shell.h>
94 #endif 95 #endif
95 96
296 HPOS and VPOS are window relative glyph matrix coordinates. 297 HPOS and VPOS are window relative glyph matrix coordinates.
297 X and Y are window relative pixel coordinates. */ 298 X and Y are window relative pixel coordinates. */
298 299
299 struct cursor_pos output_cursor; 300 struct cursor_pos output_cursor;
300 301
302 /* Non-zero means user is interacting with a toolkit scroll bar. */
303
304 static int toolkit_scroll_bar_interaction;
301 305
302 /* Mouse movement. 306 /* Mouse movement.
303 307
304 Formerly, we used PointerMotionHintMask (in standard_event_mask) 308 Formerly, we used PointerMotionHintMask (in standard_event_mask)
305 so that we would have to call XQueryPointer after each MotionNotify 309 so that we would have to call XQueryPointer after each MotionNotify
7176 7180
7177 UNBLOCK_INPUT; 7181 UNBLOCK_INPUT;
7178 } 7182 }
7179 7183
7180 7184
7181 DEFUN ("xt-process-timeouts", Fxt_process_timeouts, Sxt_process_timeouts,
7182 0, 0, 0,
7183 "Arrange for Xt timeout callbacks to be called.")
7184 ()
7185 {
7186 #ifdef USE_X_TOOLKIT 7185 #ifdef USE_X_TOOLKIT
7187 BLOCK_INPUT; 7186
7188 while (XtAppPending (Xt_app_con) & XtIMTimer) 7187 /* Atimer callback function for TIMER. Called every 0.1s to process
7189 XtAppProcessEvent (Xt_app_con, XtIMTimer); 7188 Xt timeouts, if needed. We must avoid calling XtAppPending as
7190 UNBLOCK_INPUT; 7189 much as possible because that function does an implicit XFlush
7190 that slows us down. */
7191
7192 static void
7193 x_process_timeouts (timer)
7194 struct atimer *timer;
7195 {
7196 if (toolkit_scroll_bar_interaction || popup_activated_flag)
7197 {
7198 BLOCK_INPUT;
7199 while (XtAppPending (Xt_app_con) & XtIMTimer)
7200 XtAppProcessEvent (Xt_app_con, XtIMTimer);
7201 UNBLOCK_INPUT;
7202 }
7203 }
7204
7191 #endif /* USE_X_TOOLKIT */ 7205 #endif /* USE_X_TOOLKIT */
7192
7193 return Qnil;
7194 }
7195
7196 7206
7197 7207
7198 /* Scroll bar support. */ 7208 /* Scroll bar support. */
7199 7209
7200 /* Given an X window ID, find the struct scroll_bar which manages it. 7210 /* Given an X window ID, find the struct scroll_bar which manages it.
7201 This can be called in GC, so we have to make sure to strip off mark 7211 This can be called in GC, so we have to make sure to strip off mark
7202 bits. */ 7212 bits. */
7213
7203 static struct scroll_bar * 7214 static struct scroll_bar *
7204 x_window_to_scroll_bar (window_id) 7215 x_window_to_scroll_bar (window_id)
7205 Window window_id; 7216 Window window_id;
7206 { 7217 {
7207 Lisp_Object tail; 7218 Lisp_Object tail;
7299 #else /* !USE_MOTIF i.e. use Xaw */ 7310 #else /* !USE_MOTIF i.e. use Xaw */
7300 scroll_bar_p = XtIsSubclass (widget, scrollbarWidgetClass); 7311 scroll_bar_p = XtIsSubclass (widget, scrollbarWidgetClass);
7301 end_action = "EndScroll"; 7312 end_action = "EndScroll";
7302 #endif /* USE_MOTIF */ 7313 #endif /* USE_MOTIF */
7303 7314
7304 /* Although LessTif uses XtTimeouts like Xaw3d, the timer hack to
7305 let Xt timeouts be processed doesn't work. */
7306 if (scroll_bar_p 7315 if (scroll_bar_p
7307 && strcmp (action_name, end_action) == 0 7316 && strcmp (action_name, end_action) == 0
7308 && WINDOWP (window_being_scrolled)) 7317 && WINDOWP (window_being_scrolled))
7309 { 7318 {
7310 struct window *w; 7319 struct window *w;
7313 scroll_bar_end_scroll, 0, 0); 7322 scroll_bar_end_scroll, 0, 0);
7314 w = XWINDOW (window_being_scrolled); 7323 w = XWINDOW (window_being_scrolled);
7315 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil; 7324 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil;
7316 window_being_scrolled = Qnil; 7325 window_being_scrolled = Qnil;
7317 last_scroll_bar_part = -1; 7326 last_scroll_bar_part = -1;
7327
7328 /* Xt timeouts no longer needed. */
7329 toolkit_scroll_bar_interaction = 0;
7318 } 7330 }
7319 } 7331 }
7320 7332
7321 7333
7322 /* Send a client message with message type Xatom_Scrollbar for a 7334 /* Send a client message with message type Xatom_Scrollbar for a
7342 ev->data.l[0] = (long) window; 7354 ev->data.l[0] = (long) window;
7343 ev->data.l[1] = (long) part; 7355 ev->data.l[1] = (long) part;
7344 ev->data.l[2] = (long) 0; 7356 ev->data.l[2] = (long) 0;
7345 ev->data.l[3] = (long) portion; 7357 ev->data.l[3] = (long) portion;
7346 ev->data.l[4] = (long) whole; 7358 ev->data.l[4] = (long) whole;
7359
7360 /* Make Xt timeouts work while the scroll bar is active. */
7361 toolkit_scroll_bar_interaction = 1;
7347 7362
7348 /* Setting the event mask to zero means that the message will 7363 /* Setting the event mask to zero means that the message will
7349 be sent to the client that created the window, and if that 7364 be sent to the client that created the window, and if that
7350 window no longer exists, no event will be sent. */ 7365 window no longer exists, no event will be sent. */
7351 BLOCK_INPUT; 7366 BLOCK_INPUT;
11368 if (input_polling_used ()) 11383 if (input_polling_used ())
11369 { 11384 {
11370 /* It could be confusing if a real alarm arrives while 11385 /* It could be confusing if a real alarm arrives while
11371 processing the fake one. Turn it off and let the 11386 processing the fake one. Turn it off and let the
11372 handler reset it. */ 11387 handler reset it. */
11373 alarm (0); 11388 int old_poll_suppress_count = poll_suppress_count;
11374 input_poll_signal (0); 11389 poll_suppress_count = 1;
11390 poll_for_input_1 ();
11391 poll_suppress_count = old_poll_suppress_count;
11375 } 11392 }
11376 11393
11377 /* See if a MapNotify event has been processed. */ 11394 /* See if a MapNotify event has been processed. */
11378 FRAME_SAMPLE_VISIBILITY (f); 11395 FRAME_SAMPLE_VISIBILITY (f);
11379 } 11396 }
12916 Lisp_Object tail; 12933 Lisp_Object tail;
12917 12934
12918 tail = x_display_name_list; 12935 tail = x_display_name_list;
12919 while (CONSP (tail) && CONSP (XCDR (tail))) 12936 while (CONSP (tail) && CONSP (XCDR (tail)))
12920 { 12937 {
12921 if (EQ (XCAR (XCDR (tail)), 12938 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
12922 dpyinfo->name_list_element))
12923 { 12939 {
12924 XCDR (tail) = XCDR (XCDR (tail)); 12940 XCDR (tail) = XCDR (XCDR (tail));
12925 break; 12941 break;
12926 } 12942 }
12927 tail = XCDR (tail); 12943 tail = XCDR (tail);
13015 13031
13016 #ifdef USE_X_TOOLKIT 13032 #ifdef USE_X_TOOLKIT
13017 XtToolkitInitialize (); 13033 XtToolkitInitialize ();
13018 Xt_app_con = XtCreateApplicationContext (); 13034 Xt_app_con = XtCreateApplicationContext ();
13019 XtAppSetFallbackResources (Xt_app_con, Xt_default_resources); 13035 XtAppSetFallbackResources (Xt_app_con, Xt_default_resources);
13036
13037 /* Install an asynchronous timer that processes Xt timeout events
13038 every 0.1s. This is necessary because some widget sets use
13039 timeouts internally, for example the LessTif menu bar, or the
13040 Xaw3d scroll bar. When Xt timouts aren't processed, these
13041 widgets don't behave normally. */
13042 {
13043 EMACS_TIME interval;
13044 EMACS_SET_SECS_USECS (interval, 0, 100000);
13045 start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);
13046 }
13020 #endif 13047 #endif
13048
13021 #if USE_TOOLKIT_SCROLL_BARS 13049 #if USE_TOOLKIT_SCROLL_BARS
13022 xaw3d_arrow_scroll = False; 13050 xaw3d_arrow_scroll = False;
13023 xaw3d_pick_top = True; 13051 xaw3d_pick_top = True;
13024 #endif 13052 #endif
13025 13053
13072 x_toolkit_scroll_bars_p = 1; 13100 x_toolkit_scroll_bars_p = 1;
13073 #else 13101 #else
13074 x_toolkit_scroll_bars_p = 0; 13102 x_toolkit_scroll_bars_p = 0;
13075 #endif 13103 #endif
13076 13104
13077 defsubr (&Sxt_process_timeouts);
13078 staticpro (&last_mouse_motion_frame); 13105 staticpro (&last_mouse_motion_frame);
13079 last_mouse_motion_frame = Qnil; 13106 last_mouse_motion_frame = Qnil;
13080 } 13107 }
13081 13108
13082 #endif /* not HAVE_X_WINDOWS */ 13109 #endif /* not HAVE_X_WINDOWS */