aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorJan Djärv2009-11-10 19:06:40 +0000
committerJan Djärv2009-11-10 19:06:40 +0000
commite90292a90cdb9a3b4d28b21db39f5f44ad3de805 (patch)
tree2bf6f977a64392335dd3365c845b6d589bfc6726 /src/keyboard.c
parent045b83c00aabaaaa5d4e363f848a1826f8f27338 (diff)
downloademacs-e90292a90cdb9a3b4d28b21db39f5f44ad3de805.tar.gz
emacs-e90292a90cdb9a3b4d28b21db39f5f44ad3de805.zip
Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
* keyboard.h: Declare timer_check. * keyboard.c (timer_check_2): New function that does what the old timer_check did. (timer_check): Call timer_check_2 until -1 or a non-zero time is returned, i.e. don't return -1 with timers pending. * process.c: Remove extern declaration of timer_check. * xmenu.c (x_menu_wait_for_event): Remove code that did a timeout even if timer_check returned -1. * gtkutil.c (xg_dialog_response_cb): data is now a struct xg_dialog_data (pop_down_dialog): Destroy widget (if any), cancel timer and unref the event loop. (xg_maybe_add_timer, xg_dialog_run): New functions (bug #4574). (xg_get_file_name, xg_get_font_name): Call xg_dialog_run (bug #4574). Destroy the dialog after xg_dialog_run.
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 4157d1ebfb3..872bd81ed40 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -4509,19 +4509,16 @@ extern Lisp_Object Qapply;
4509 disregard elements that are not proper timers. Do not make a circular 4509 disregard elements that are not proper timers. Do not make a circular
4510 timer list for the time being. 4510 timer list for the time being.
4511 4511
4512 Returns the number of seconds to wait until the next timer fires. If a 4512 Returns the time to wait until the next timer fires. If a
4513 timer is triggering now, return zero seconds. 4513 timer is triggering now, return zero.
4514 If no timer is active, return -1 seconds. 4514 If no timer is active, return -1.
4515 4515
4516 If a timer is ripe, we run it, with quitting turned off. 4516 If a timer is ripe, we run it, with quitting turned off.
4517 In that case we return 0 to indicate that a new timer_check_2 call
4518 should be done. */
4517 4519
4518 DO_IT_NOW is now ignored. It used to mean that we should 4520static EMACS_TIME
4519 run the timer directly instead of queueing a timer-event. 4521timer_check_2 ()
4520 Now we always run timers directly. */
4521
4522EMACS_TIME
4523timer_check (do_it_now)
4524 int do_it_now;
4525{ 4522{
4526 EMACS_TIME nexttime; 4523 EMACS_TIME nexttime;
4527 EMACS_TIME now, idleness_now; 4524 EMACS_TIME now, idleness_now;
@@ -4685,7 +4682,12 @@ timer_check (do_it_now)
4685 4682
4686 /* Since we have handled the event, 4683 /* Since we have handled the event,
4687 we don't need to tell the caller to wake up and do it. */ 4684 we don't need to tell the caller to wake up and do it. */
4685 /* But the caller must still wait for the next timer, so
4686 return 0 to indicate that. */
4688 } 4687 }
4688
4689 EMACS_SET_SECS (nexttime, 0);
4690 EMACS_SET_USECS (nexttime, 0);
4689 } 4691 }
4690 else 4692 else
4691 /* When we encounter a timer that is still waiting, 4693 /* When we encounter a timer that is still waiting,
@@ -4702,6 +4704,35 @@ timer_check (do_it_now)
4702 return nexttime; 4704 return nexttime;
4703} 4705}
4704 4706
4707
4708/* Check whether a timer has fired. To prevent larger problems we simply
4709 disregard elements that are not proper timers. Do not make a circular
4710 timer list for the time being.
4711
4712 Returns the time to wait until the next timer fires.
4713 If no timer is active, return -1.
4714
4715 As long as any timer is ripe, we run it.
4716
4717 DO_IT_NOW is now ignored. It used to mean that we should
4718 run the timer directly instead of queueing a timer-event.
4719 Now we always run timers directly. */
4720
4721EMACS_TIME
4722timer_check (do_it_now)
4723 int do_it_now;
4724{
4725 EMACS_TIME nexttime;
4726
4727 do
4728 {
4729 nexttime = timer_check_2 ();
4730 }
4731 while (EMACS_SECS (nexttime) == 0 && EMACS_USECS (nexttime) == 0);
4732
4733 return nexttime;
4734}
4735
4705DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0, 4736DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0,
4706 doc: /* Return the current length of Emacs idleness, or nil. 4737 doc: /* Return the current length of Emacs idleness, or nil.
4707The value when Emacs is idle is a list of three integers. The first has 4738The value when Emacs is idle is a list of three integers. The first has