diff options
author | Po Lu <luangruo@yahoo.com> | 2022-06-08 15:08:09 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-06-08 15:08:27 +0800 |
commit | 22d3f0e95a5602b2bde763cff185f5b4fed6e53e (patch) | |
tree | 1a20706bfe3ad7228209ad2ed783753534caac5e /src/xmenu.c | |
parent | 90f3da0ccdb4c58265e9f8c3d9465198d8a2092a (diff) | |
download | emacs-22d3f0e95a5602b2bde763cff185f5b4fed6e53e.tar.gz |
Make responding to selection requests work inside popups
* src/xfns.c (Fx_file_dialog):
* src/xmenu.c (x_menu_wait_for_event, create_and_show_popup_menu)
(create_and_show_dialog, x_menu_show): Defer selection requests.
* src/xselect.c (x_get_foreign_selection)
(x_handle_selection_notify): Add some more info to selection
trace.
* src/xterm.c (x_defer_selection_requests): Make non-static.
(x_release_selection_requests_and_flush): New function.
(x_dnd_begin_drag_and_drop): Use DEFER_SELECTIONS instead.
(x_wait_for_cell_change): Fix initial value of rc for pushed
back events.
(handle_one_xevent): Allow GTK to respond to selections in its
windows too.
* src/xterm.h (DEFER_SELECTIONS): New slug of code.
Diffstat (limited to 'src/xmenu.c')
-rw-r--r-- | src/xmenu.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index e9601981edd..7134bf22c83 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -198,6 +198,10 @@ x_menu_wait_for_event (void *data) struct x_display_info *dpyinfo; int n = 0; + /* ISTM that if timer_check is okay, this should be too, since + both can run random Lisp. */ + x_handle_pending_selection_requests (); + FD_ZERO (&read_fds); for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) { @@ -1579,6 +1583,8 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, } #endif + DEFER_SELECTIONS; + /* Display the menu. */ gtk_widget_show_all (menu); @@ -1868,6 +1874,8 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, { specpdl_ref specpdl_count = SPECPDL_INDEX (); + DEFER_SELECTIONS; + record_unwind_protect_int (pop_down_menu, (int) menu_id); #ifdef HAVE_XINPUT2 record_unwind_protect_ptr (leave_toolkit_menu, f); @@ -2199,6 +2207,8 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv) if (menu) { specpdl_ref specpdl_count = SPECPDL_INDEX (); + + DEFER_SELECTIONS; record_unwind_protect_ptr (pop_down_menu, menu); /* Display the menu. */ @@ -2255,6 +2265,8 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv) { specpdl_ref count = SPECPDL_INDEX (); + DEFER_SELECTIONS; + /* xdialog_show_unwind is responsible for popping the dialog box down. */ record_unwind_protect_int (pop_down_menu, (int) dialog_id); @@ -2715,18 +2727,18 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, y = max (y, 1); XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y, &ulx, &uly, &width, &height); - if (ulx+width > dispwidth) + if (ulx + width > dispwidth) { x -= (ulx + width) - dispwidth; ulx = dispwidth - width; } - if (uly+height > dispheight) + if (uly + height > dispheight) { y -= (uly + height) - dispheight; uly = dispheight - height; } #ifndef HAVE_X_WINDOWS - if (FRAME_HAS_MINIBUF_P (f) && uly+height > dispheight - 1) + if (FRAME_HAS_MINIBUF_P (f) && uly + height > dispheight - 1) { /* Move the menu away of the echo area, to avoid overwriting the menu with help echo messages or vice versa. */ @@ -2750,8 +2762,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, /* If position was not given by a mouse click, adjust so upper left corner of the menu as a whole ends up at given coordinates. This is what x-popup-menu says in its documentation. */ - x += width/2; - y += 1.5*height/(maxlines+2); + x += width / 2; + y += 1.5 * height/ (maxlines + 2); } XMenuSetAEQ (menu, true); @@ -2759,6 +2771,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, pane = selidx = 0; #ifndef MSDOS + DEFER_SELECTIONS; + XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); #ifdef HAVE_XINPUT2 XMenuActivateSetTranslateFunction (x_menu_translate_generic_event); |