diff options
| author | Yuuki Harano | 2021-05-15 22:50:06 +0900 |
|---|---|---|
| committer | Yuuki Harano | 2021-05-15 22:50:06 +0900 |
| commit | 8a649cba44cc637b5326cee9fe3febc55c653719 (patch) | |
| tree | 30995b4998e1ba9bfe52ad914b5fdcd18ad9fcb6 /src | |
| parent | 3f8f3a9027a1de28899725f0fecdc4f1f33c1479 (diff) | |
| download | emacs-8a649cba44cc637b5326cee9fe3febc55c653719.tar.gz emacs-8a649cba44cc637b5326cee9fe3febc55c653719.zip | |
Update texts while busy
Pgtk didn't update text and C-g didn't take effect while it is busy.
By timer interrupts, we can call pgtk_read_socket, and update texts
and handle C-g.
* src/pgtkterm.c (start_timer): New function to start timer.
(pgtk_show_hourglass): Remove code to start timer.
(pgtk_hide_hourglass): Remove code to stop timer.
(pgtk_term_init): Call start_timer().
Diffstat (limited to 'src')
| -rw-r--r-- | src/pgtkterm.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 533b9ea894a..194a2551c94 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -3551,12 +3551,31 @@ pgtk_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 3551 | } | 3551 | } |
| 3552 | 3552 | ||
| 3553 | static struct atimer *hourglass_atimer = NULL; | 3553 | static struct atimer *hourglass_atimer = NULL; |
| 3554 | static int hourglass_enter_count = 0; | ||
| 3555 | 3554 | ||
| 3556 | static void | 3555 | static void |
| 3557 | hourglass_cb (struct atimer *timer) | 3556 | hourglass_cb (struct atimer *timer) |
| 3558 | { | 3557 | { |
| 3559 | /*NOP*/} | 3558 | /*NOP*/ |
| 3559 | } | ||
| 3560 | |||
| 3561 | static void | ||
| 3562 | start_timer (void) | ||
| 3563 | { | ||
| 3564 | static bool hourglass_inited = false; | ||
| 3565 | |||
| 3566 | /* For cursor animation, we receive signals, set pending_signals, and dispatch. */ | ||
| 3567 | /* This is useful for drawing text while busy, and C-g takes effect while busy. */ | ||
| 3568 | if (!hourglass_inited) | ||
| 3569 | { | ||
| 3570 | struct timespec ts = make_timespec (0, 50 * 1000 * 1000); | ||
| 3571 | if (hourglass_atimer != NULL) | ||
| 3572 | cancel_atimer (hourglass_atimer); | ||
| 3573 | hourglass_atimer = | ||
| 3574 | start_atimer (ATIMER_CONTINUOUS, ts, hourglass_cb, NULL); | ||
| 3575 | |||
| 3576 | hourglass_inited = true; | ||
| 3577 | } | ||
| 3578 | } | ||
| 3560 | 3579 | ||
| 3561 | static void | 3580 | static void |
| 3562 | pgtk_show_hourglass (struct frame *f) | 3581 | pgtk_show_hourglass (struct frame *f) |
| @@ -3572,32 +3591,13 @@ pgtk_show_hourglass (struct frame *f) | |||
| 3572 | gdk_window_raise (gtk_widget_get_window (x->hourglass_widget)); | 3591 | gdk_window_raise (gtk_widget_get_window (x->hourglass_widget)); |
| 3573 | gdk_window_set_cursor (gtk_widget_get_window (x->hourglass_widget), | 3592 | gdk_window_set_cursor (gtk_widget_get_window (x->hourglass_widget), |
| 3574 | x->hourglass_cursor); | 3593 | x->hourglass_cursor); |
| 3575 | |||
| 3576 | /* For cursor animation, we receive signals, set pending_signals, and dispatch. */ | ||
| 3577 | if (hourglass_enter_count++ == 0) | ||
| 3578 | { | ||
| 3579 | struct timespec ts = make_timespec (0, 50 * 1000 * 1000); | ||
| 3580 | if (hourglass_atimer != NULL) | ||
| 3581 | cancel_atimer (hourglass_atimer); | ||
| 3582 | hourglass_atimer = | ||
| 3583 | start_atimer (ATIMER_CONTINUOUS, ts, hourglass_cb, NULL); | ||
| 3584 | } | ||
| 3585 | |||
| 3586 | /* Cursor frequently stops animation. gtk's bug? */ | ||
| 3587 | } | 3594 | } |
| 3588 | 3595 | ||
| 3589 | static void | 3596 | static void |
| 3590 | pgtk_hide_hourglass (struct frame *f) | 3597 | pgtk_hide_hourglass (struct frame *f) |
| 3591 | { | 3598 | { |
| 3592 | struct pgtk_output *x = FRAME_X_OUTPUT (f); | 3599 | struct pgtk_output *x = FRAME_X_OUTPUT (f); |
| 3593 | if (--hourglass_enter_count == 0) | 3600 | |
| 3594 | { | ||
| 3595 | if (hourglass_atimer != NULL) | ||
| 3596 | { | ||
| 3597 | cancel_atimer (hourglass_atimer); | ||
| 3598 | hourglass_atimer = NULL; | ||
| 3599 | } | ||
| 3600 | } | ||
| 3601 | if (x->hourglass_widget != NULL) | 3601 | if (x->hourglass_widget != NULL) |
| 3602 | { | 3602 | { |
| 3603 | gtk_widget_destroy (x->hourglass_widget); | 3603 | gtk_widget_destroy (x->hourglass_widget); |
| @@ -6995,6 +6995,8 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) | |||
| 6995 | 6995 | ||
| 6996 | unblock_input (); | 6996 | unblock_input (); |
| 6997 | 6997 | ||
| 6998 | start_timer(); | ||
| 6999 | |||
| 6998 | return dpyinfo; | 7000 | return dpyinfo; |
| 6999 | } | 7001 | } |
| 7000 | 7002 | ||