]> git.eshelyaron.com Git - emacs.git/commitdiff
* xterm.c (x_initialize): Don't install Xt event timer here.
authorChong Yidong <cyd@stupidchicken.com>
Wed, 13 Sep 2006 22:39:23 +0000 (22:39 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Wed, 13 Sep 2006 22:39:23 +0000 (22:39 +0000)
(x_timeout_atimer_activated_flag): New var.
(x_activate_timeout_atimer): New function to install Xt timer.
(x_send_scroll_bar_event, x_process_timeouts): Use it.

* xmenu.c (x_menu_set_in_use, popup_activate_callback)
(create_and_show_popup_menu, create_and_show_dialog): Use it.

* xterm.h (x_activate_timeout_atimer): prototype.

src/ChangeLog
src/xmenu.c
src/xterm.c
src/xterm.h

index f2125895c2c2f5798f9769c3900417ffffd614f7..4f026bac9b9dce1dac979d86abc208a39b91dd81 100644 (file)
@@ -1,3 +1,15 @@
+2006-09-13  YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+       * xterm.c (x_initialize): Don't install Xt event timer here.
+       (x_timeout_atimer_activated_flag): New var.
+       (x_activate_timeout_atimer): New function to install Xt timer.
+       (x_send_scroll_bar_event, x_process_timeouts): Use it.
+
+       * xmenu.c (x_menu_set_in_use, popup_activate_callback)
+       (create_and_show_popup_menu, create_and_show_dialog): Use it.
+
+       * xterm.h (x_activate_timeout_atimer): prototype.
+
 2006-09-13  Richard Stallman  <rms@gnu.org>
 
        * print.c (print_string): When printcharfun is t,
index 574240a45606167ce94baf910b06b89d70d175c8..63dfb5102bd93b670401c4bbd2704538f757df9d 100644 (file)
@@ -1182,6 +1182,10 @@ x_menu_set_in_use (in_use)
 {
   menu_items_inuse = in_use ? Qt : Qnil;
   popup_activated_flag = in_use;
+#ifdef USE_X_TOOLKIT
+  if (popup_activated_flag)
+    x_activate_timeout_atimer ();
+#endif
 }
 
 /* Wait for an X event to arrive or for a timer to expire.  */
@@ -1498,6 +1502,9 @@ popup_activate_callback (widget, id, client_data)
      XtPointer client_data;
 {
   popup_activated_flag = 1;
+#ifdef USE_X_TOOLKIT
+  x_activate_timeout_atimer ();
+#endif
 }
 #endif
 
@@ -2798,6 +2805,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
   /* Display the menu.  */
   lw_popup_menu (menu, (XEvent *) &dummy);
   popup_activated_flag = 1;
+  x_activate_timeout_atimer ();
 
   {
     int fact = 4 * sizeof (LWLIB_ID);
@@ -3175,6 +3183,7 @@ create_and_show_dialog (f, first_wv)
   /* Display the dialog box.  */
   lw_pop_up_all_widgets (dialog_id);
   popup_activated_flag = 1;
+  x_activate_timeout_atimer ();
 
   /* Process events that apply to the dialog box.
      Also handle timers.  */
index e7a462aef58786490836670725c35fc8ab5128bd..9858d55f4d59c9e755b66a4d7750fd698d4bc7ae 100644 (file)
@@ -4091,6 +4091,9 @@ x_send_scroll_bar_event (window, part, portion, whole)
 
   /* Make Xt timeouts work while the scroll bar is active.  */
   toolkit_scroll_bar_interaction = 1;
+#ifdef USE_X_TOOLKIT
+  x_activate_timeout_atimer ();
+#endif
 
   /* Setting the event mask to zero means that the message will
      be sent to the client that created the window, and if that
@@ -10134,6 +10137,11 @@ static XrmOptionDescRec emacs_options[] = {
   {"-mc",      "*pointerColor", XrmoptionSepArg, (XtPointer) NULL},
   {"-cr",      "*cursorColor", XrmoptionSepArg, (XtPointer) NULL}
 };
+
+/* Whether atimer for Xt timeouts is activated or not.  */
+
+static int x_timeout_atimer_activated_flag;
+
 #endif /* USE_X_TOOLKIT */
 
 static int x_initialized;
@@ -10815,13 +10823,39 @@ static void
 x_process_timeouts (timer)
      struct atimer *timer;
 {
+  BLOCK_INPUT;
+  x_timeout_atimer_activated_flag = 0;
   if (toolkit_scroll_bar_interaction || popup_activated ())
     {
-      BLOCK_INPUT;
       while (XtAppPending (Xt_app_con) & XtIMTimer)
        XtAppProcessEvent (Xt_app_con, XtIMTimer);
-      UNBLOCK_INPUT;
+      /* Reactivate the atimer for next time.  */
+      x_activate_timeout_atimer ();
+    }
+  UNBLOCK_INPUT;
+}
+
+/* Install an asynchronous timer that processes Xt timeout events
+   every 0.1s as long as either `toolkit_scroll_bar_interaction' or
+   `popup_activated_flag' (in xmenu.c) is set.  Make sure to call this
+   function whenever these variables are set.  This is necessary
+   because some widget sets use timeouts internally, for example the
+   LessTif menu bar, or the Xaw3d scroll bar.  When Xt timeouts aren't
+   processed, these widgets don't behave normally.  */
+
+void
+x_activate_timeout_atimer ()
+{
+  BLOCK_INPUT;
+  if (!x_timeout_atimer_activated_flag)
+    {
+      EMACS_TIME interval;
+
+      EMACS_SET_SECS_USECS (interval, 0, 100000);
+      start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0);
+      x_timeout_atimer_activated_flag = 1;
     }
+  UNBLOCK_INPUT;
 }
 
 #endif /* USE_X_TOOLKIT */
@@ -10927,17 +10961,6 @@ x_initialize ()
                         XtCacheByDisplay, cvt_pixel_dtor);
 
   XtAppSetFallbackResources (Xt_app_con, Xt_default_resources);
-
-  /* Install an asynchronous timer that processes Xt timeout events
-     every 0.1s.  This is necessary because some widget sets use
-     timeouts internally, for example the LessTif menu bar, or the
-     Xaw3d scroll bar.  When Xt timouts aren't processed, these
-     widgets don't behave normally.  */
-  {
-    EMACS_TIME interval;
-    EMACS_SET_SECS_USECS (interval, 0, 100000);
-    start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);
-  }
 #endif
 
 #ifdef USE_TOOLKIT_SCROLL_BARS
index 9aa1d8fcacb4ade2af78aeffbf484d3c1fc61ba6..94ae9472200880cd0fb362705fad090ec4c0e3c5 100644 (file)
@@ -1001,6 +1001,7 @@ extern XtAppContext Xt_app_con;
 extern int x_alloc_lighter_color_for_widget __P ((Widget, Display*, Colormap,
                                                  unsigned long *,
                                                  double, int));
+extern void x_activate_timeout_atimer P_ ((void));
 #endif
 extern void x_query_colors P_ ((struct frame *f, XColor *, int));
 extern void x_query_color P_ ((struct frame *f, XColor *));