diff options
| author | Yuuki Harano | 2021-05-09 17:53:20 +0900 |
|---|---|---|
| committer | Yuuki Harano | 2021-05-09 17:53:20 +0900 |
| commit | ca0b1b9fe5a9eb225d4cfd1fd52f9e6e56d5fa5f (patch) | |
| tree | f76c4ad582dde2b6c56691ecd34ab6ab0e90f6fb /src | |
| parent | 647e4a92bbb771e248c640b9ea4737f928ba187e (diff) | |
| download | emacs-ca0b1b9fe5a9eb225d4cfd1fd52f9e6e56d5fa5f.tar.gz emacs-ca0b1b9fe5a9eb225d4cfd1fd52f9e6e56d5fa5f.zip | |
Fix pgtk_make_frame_visible doesn't work
* src/pgtkterm.c (pgtk_wait_for_map_event): New function to wait for
map events. The content is moved from pgtk_make_frame_visible.
(pgtk_make_frame_visible): Call pgtk_wait_for_map_event, instead of
process here directly.
(pgtk_make_frame_invisible): Call pgtk_wait_for_map_event to wait
for multiple map events.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pgtkterm.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 3839b2b3fc4..5331b67e331 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -591,6 +591,42 @@ pgtk_make_frame_visible_wait_for_map_event_timeout (gpointer user_data) | |||
| 591 | return FALSE; | 591 | return FALSE; |
| 592 | } | 592 | } |
| 593 | 593 | ||
| 594 | static void | ||
| 595 | pgtk_wait_for_map_event (struct frame *f, bool multiple_times) | ||
| 596 | { | ||
| 597 | if (FLOATP (Vpgtk_wait_for_event_timeout)) | ||
| 598 | { | ||
| 599 | guint msec = | ||
| 600 | (guint) (XFLOAT_DATA (Vpgtk_wait_for_event_timeout) * 1000); | ||
| 601 | int found = 0; | ||
| 602 | int timed_out = 0; | ||
| 603 | gulong id = | ||
| 604 | g_signal_connect (FRAME_WIDGET (f), "map-event", | ||
| 605 | G_CALLBACK | ||
| 606 | (pgtk_make_frame_visible_wait_for_map_event_cb), | ||
| 607 | &found); | ||
| 608 | guint src = | ||
| 609 | g_timeout_add (msec, | ||
| 610 | pgtk_make_frame_visible_wait_for_map_event_timeout, | ||
| 611 | &timed_out); | ||
| 612 | |||
| 613 | if (!multiple_times) | ||
| 614 | { | ||
| 615 | while (!found && !timed_out) | ||
| 616 | gtk_main_iteration (); | ||
| 617 | } | ||
| 618 | else | ||
| 619 | { | ||
| 620 | while (!timed_out) | ||
| 621 | gtk_main_iteration (); | ||
| 622 | } | ||
| 623 | |||
| 624 | g_signal_handler_disconnect (FRAME_WIDGET (f), id); | ||
| 625 | if (!timed_out) | ||
| 626 | g_source_remove (src); | ||
| 627 | } | ||
| 628 | } | ||
| 629 | |||
| 594 | void | 630 | void |
| 595 | pgtk_make_frame_visible (struct frame *f) | 631 | pgtk_make_frame_visible (struct frame *f) |
| 596 | /* -------------------------------------------------------------------------- | 632 | /* -------------------------------------------------------------------------- |
| @@ -607,27 +643,7 @@ pgtk_make_frame_visible (struct frame *f) | |||
| 607 | if (win) | 643 | if (win) |
| 608 | gtk_window_deiconify (GTK_WINDOW (win)); | 644 | gtk_window_deiconify (GTK_WINDOW (win)); |
| 609 | 645 | ||
| 610 | if (FLOATP (Vpgtk_wait_for_event_timeout)) | 646 | pgtk_wait_for_map_event (f, false); |
| 611 | { | ||
| 612 | guint msec = | ||
| 613 | (guint) (XFLOAT_DATA (Vpgtk_wait_for_event_timeout) * 1000); | ||
| 614 | int found = 0; | ||
| 615 | int timed_out = 0; | ||
| 616 | gulong id = | ||
| 617 | g_signal_connect (FRAME_WIDGET (f), "map-event", | ||
| 618 | G_CALLBACK | ||
| 619 | (pgtk_make_frame_visible_wait_for_map_event_cb), | ||
| 620 | &found); | ||
| 621 | guint src = | ||
| 622 | g_timeout_add (msec, | ||
| 623 | pgtk_make_frame_visible_wait_for_map_event_timeout, | ||
| 624 | &timed_out); | ||
| 625 | while (!found && !timed_out) | ||
| 626 | gtk_main_iteration (); | ||
| 627 | g_signal_handler_disconnect (FRAME_WIDGET (f), id); | ||
| 628 | if (!timed_out) | ||
| 629 | g_source_remove (src); | ||
| 630 | } | ||
| 631 | } | 647 | } |
| 632 | } | 648 | } |
| 633 | 649 | ||
| @@ -642,6 +658,13 @@ pgtk_make_frame_invisible (struct frame *f) | |||
| 642 | 658 | ||
| 643 | gtk_widget_hide (FRAME_WIDGET (f)); | 659 | gtk_widget_hide (FRAME_WIDGET (f)); |
| 644 | 660 | ||
| 661 | /* Map events are emitted many times, and | ||
| 662 | * map_event() do SET_FRAME_VISIBLE(f, 1). | ||
| 663 | * I expect visible = 0, so process those map events here and | ||
| 664 | * SET_FRAME_VISIBLE(f, 0) after that. | ||
| 665 | */ | ||
| 666 | pgtk_wait_for_map_event (f, true); | ||
| 667 | |||
| 645 | SET_FRAME_VISIBLE (f, 0); | 668 | SET_FRAME_VISIBLE (f, 0); |
| 646 | SET_FRAME_ICONIFIED (f, false); | 669 | SET_FRAME_ICONIFIED (f, false); |
| 647 | } | 670 | } |