diff options
| author | Po Lu | 2022-01-02 00:43:54 +0000 |
|---|---|---|
| committer | Po Lu | 2022-01-02 00:43:54 +0000 |
| commit | af729b1dfd235de400f6a0998a968222417596bf (patch) | |
| tree | 9f21e388e63b02dc2f0742dc0beab7088bb6da55 | |
| parent | 1d3020908b4e4ff398c3faed9321aa4932fbaad1 (diff) | |
| download | emacs-af729b1dfd235de400f6a0998a968222417596bf.tar.gz emacs-af729b1dfd235de400f6a0998a968222417596bf.zip | |
Make quitting actually work in Haiku file dialogs
* src/haiku_support.h: (be_popup_file_dialog)
* src/haiku_support.cc (be_popup_file_dialog): New parameter
`maybe_quit_function'.
* src/haikufns.c (Fhaiku_read_file_name): Pass `maybe_quit' as
the maybe_quit_function.
| -rw-r--r-- | src/haiku_support.cc | 14 | ||||
| -rw-r--r-- | src/haiku_support.h | 3 | ||||
| -rw-r--r-- | src/haikufns.c | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 211d37b8e1a..8bd7c04ee89 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc | |||
| @@ -2624,7 +2624,8 @@ char * | |||
| 2624 | be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, int dir_only_p, | 2624 | be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, int dir_only_p, |
| 2625 | void *window, const char *save_text, const char *prompt, | 2625 | void *window, const char *save_text, const char *prompt, |
| 2626 | void (*block_input_function) (void), | 2626 | void (*block_input_function) (void), |
| 2627 | void (*unblock_input_function) (void)) | 2627 | void (*unblock_input_function) (void), |
| 2628 | void (*maybe_quit_function) (void)) | ||
| 2628 | { | 2629 | { |
| 2629 | ptrdiff_t idx = c_specpdl_idx_from_cxx (); | 2630 | ptrdiff_t idx = c_specpdl_idx_from_cxx (); |
| 2630 | /* setjmp/longjmp is UB with automatic objects. */ | 2631 | /* setjmp/longjmp is UB with automatic objects. */ |
| @@ -2635,7 +2636,6 @@ be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, int | |||
| 2635 | BMessage *msg = new BMessage ('FPSE'); | 2636 | BMessage *msg = new BMessage ('FPSE'); |
| 2636 | BFilePanel *panel = new BFilePanel (open_p ? B_OPEN_PANEL : B_SAVE_PANEL, | 2637 | BFilePanel *panel = new BFilePanel (open_p ? B_OPEN_PANEL : B_SAVE_PANEL, |
| 2637 | NULL, NULL, mode); | 2638 | NULL, NULL, mode); |
| 2638 | unblock_input_function (); | ||
| 2639 | 2639 | ||
| 2640 | struct popup_file_dialog_data dat; | 2640 | struct popup_file_dialog_data dat; |
| 2641 | dat.entry = path; | 2641 | dat.entry = path; |
| @@ -2660,6 +2660,7 @@ be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, int | |||
| 2660 | 2660 | ||
| 2661 | panel->Show (); | 2661 | panel->Show (); |
| 2662 | panel->Window ()->Show (); | 2662 | panel->Window ()->Show (); |
| 2663 | unblock_input_function (); | ||
| 2663 | 2664 | ||
| 2664 | void *buf = alloca (200); | 2665 | void *buf = alloca (200); |
| 2665 | while (1) | 2666 | while (1) |
| @@ -2669,19 +2670,26 @@ be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, int | |||
| 2669 | 2670 | ||
| 2670 | if (!haiku_read_with_timeout (&type, buf, 200, 100000)) | 2671 | if (!haiku_read_with_timeout (&type, buf, 200, 100000)) |
| 2671 | { | 2672 | { |
| 2673 | block_input_function (); | ||
| 2672 | if (type != FILE_PANEL_EVENT) | 2674 | if (type != FILE_PANEL_EVENT) |
| 2673 | haiku_write (type, buf); | 2675 | haiku_write (type, buf); |
| 2674 | else if (!ptr) | 2676 | else if (!ptr) |
| 2675 | ptr = (char *) ((struct haiku_file_panel_event *) buf)->ptr; | 2677 | ptr = (char *) ((struct haiku_file_panel_event *) buf)->ptr; |
| 2678 | unblock_input_function (); | ||
| 2679 | |||
| 2680 | maybe_quit_function (); | ||
| 2676 | } | 2681 | } |
| 2677 | 2682 | ||
| 2678 | ssize_t b_s; | 2683 | ssize_t b_s; |
| 2684 | block_input_function (); | ||
| 2679 | haiku_read_size (&b_s); | 2685 | haiku_read_size (&b_s); |
| 2680 | if (!b_s || b_s == -1 || ptr || panel->Window ()->IsHidden ()) | 2686 | if (!b_s || ptr || panel->Window ()->IsHidden ()) |
| 2681 | { | 2687 | { |
| 2682 | c_unbind_to_nil_from_cxx (idx); | 2688 | c_unbind_to_nil_from_cxx (idx); |
| 2689 | unblock_input_function (); | ||
| 2683 | return ptr; | 2690 | return ptr; |
| 2684 | } | 2691 | } |
| 2692 | unblock_input_function (); | ||
| 2685 | } | 2693 | } |
| 2686 | } | 2694 | } |
| 2687 | 2695 | ||
diff --git a/src/haiku_support.h b/src/haiku_support.h index 0377376a02c..dd5e168d140 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h | |||
| @@ -740,7 +740,8 @@ extern "C" | |||
| 740 | int dir_only_p, void *window, const char *save_text, | 740 | int dir_only_p, void *window, const char *save_text, |
| 741 | const char *prompt, | 741 | const char *prompt, |
| 742 | void (*block_input_function) (void), | 742 | void (*block_input_function) (void), |
| 743 | void (*unblock_input_function) (void)); | 743 | void (*unblock_input_function) (void), |
| 744 | void (*maybe_quit_function) (void)); | ||
| 744 | 745 | ||
| 745 | extern void | 746 | extern void |
| 746 | record_c_unwind_protect_from_cxx (void (*) (void *), void *); | 747 | record_c_unwind_protect_from_cxx (void (*) (void *), void *); |
diff --git a/src/haikufns.c b/src/haikufns.c index bf0bf8e5253..743ecf1aef5 100644 --- a/src/haikufns.c +++ b/src/haikufns.c | |||
| @@ -2236,7 +2236,7 @@ Optional arg SAVE_TEXT, if non-nil, specifies some text to show in the entry fie | |||
| 2236 | FRAME_HAIKU_WINDOW (f), | 2236 | FRAME_HAIKU_WINDOW (f), |
| 2237 | !NILP (save_text) ? SSDATA (ENCODE_UTF_8 (save_text)) : NULL, | 2237 | !NILP (save_text) ? SSDATA (ENCODE_UTF_8 (save_text)) : NULL, |
| 2238 | SSDATA (ENCODE_UTF_8 (prompt)), | 2238 | SSDATA (ENCODE_UTF_8 (prompt)), |
| 2239 | block_input, unblock_input); | 2239 | block_input, unblock_input, maybe_quit); |
| 2240 | 2240 | ||
| 2241 | unbind_to (idx, Qnil); | 2241 | unbind_to (idx, Qnil); |
| 2242 | 2242 | ||