Mercurial > emacs
comparison src/xmenu.c @ 105936:45191c90be7e
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.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Tue, 10 Nov 2009 19:06:40 +0000 |
parents | a5db20cb0a5a |
children | b3bd00b680bb |
comparison
equal
deleted
inserted
replaced
105935:228c9c492970 | 105936:45191c90be7e |
---|---|
403 /* Wait for an X event to arrive or for a timer to expire. */ | 403 /* Wait for an X event to arrive or for a timer to expire. */ |
404 | 404 |
405 void | 405 void |
406 x_menu_wait_for_event (void *data) | 406 x_menu_wait_for_event (void *data) |
407 { | 407 { |
408 extern EMACS_TIME timer_check P_ ((int)); | |
409 | |
410 /* Another way to do this is to register a timer callback, that can be | 408 /* Another way to do this is to register a timer callback, that can be |
411 done in GTK and Xt. But we have to do it like this when using only X | 409 done in GTK and Xt. But we have to do it like this when using only X |
412 anyway, and with callbacks we would have three variants for timer handling | 410 anyway, and with callbacks we would have three variants for timer handling |
413 instead of the small ifdefs below. */ | 411 instead of the small ifdefs below. */ |
414 | 412 |
420 #else | 418 #else |
421 ! XPending ((Display*) data) | 419 ! XPending ((Display*) data) |
422 #endif | 420 #endif |
423 ) | 421 ) |
424 { | 422 { |
425 EMACS_TIME next_time = timer_check (1); | 423 EMACS_TIME next_time = timer_check (1), *ntp; |
426 long secs = EMACS_SECS (next_time); | 424 long secs = EMACS_SECS (next_time); |
427 long usecs = EMACS_USECS (next_time); | 425 long usecs = EMACS_USECS (next_time); |
428 SELECT_TYPE read_fds; | 426 SELECT_TYPE read_fds; |
429 struct x_display_info *dpyinfo; | 427 struct x_display_info *dpyinfo; |
430 int n = 0; | 428 int n = 0; |
435 int fd = ConnectionNumber (dpyinfo->display); | 433 int fd = ConnectionNumber (dpyinfo->display); |
436 FD_SET (fd, &read_fds); | 434 FD_SET (fd, &read_fds); |
437 if (fd > n) n = fd; | 435 if (fd > n) n = fd; |
438 } | 436 } |
439 | 437 |
440 if (secs < 0 || (secs == 0 && usecs == 0)) | 438 if (secs < 0 && usecs < 0) |
441 { | 439 ntp = 0; |
442 /* Sometimes timer_check returns -1 (no timers) even if there are | 440 else |
443 timers. So do a timeout anyway. */ | 441 ntp = &next_time; |
444 EMACS_SET_SECS (next_time, 1); | 442 |
445 EMACS_SET_USECS (next_time, 0); | 443 select (n + 1, &read_fds, (SELECT_TYPE *)0, (SELECT_TYPE *)0, ntp); |
446 } | |
447 | |
448 select (n + 1, &read_fds, (SELECT_TYPE *)0, (SELECT_TYPE *)0, &next_time); | |
449 } | 444 } |
450 } | 445 } |
451 #endif /* ! MSDOS */ | 446 #endif /* ! MSDOS */ |
452 | 447 |
453 | 448 |