aboutsummaryrefslogtreecommitdiffstats
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorPo Lu2022-06-08 15:08:09 +0800
committerPo Lu2022-06-08 15:08:27 +0800
commit22d3f0e95a5602b2bde763cff185f5b4fed6e53e (patch)
tree1a20706bfe3ad7228209ad2ed783753534caac5e /src/xmenu.c
parent90f3da0ccdb4c58265e9f8c3d9465198d8a2092a (diff)
downloademacs-22d3f0e95a5602b2bde763cff185f5b4fed6e53e.tar.gz
emacs-22d3f0e95a5602b2bde763cff185f5b4fed6e53e.zip
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.c24
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)
198 struct x_display_info *dpyinfo; 198 struct x_display_info *dpyinfo;
199 int n = 0; 199 int n = 0;
200 200
201 /* ISTM that if timer_check is okay, this should be too, since
202 both can run random Lisp. */
203 x_handle_pending_selection_requests ();
204
201 FD_ZERO (&read_fds); 205 FD_ZERO (&read_fds);
202 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) 206 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
203 { 207 {
@@ -1579,6 +1583,8 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
1579 } 1583 }
1580#endif 1584#endif
1581 1585
1586 DEFER_SELECTIONS;
1587
1582 /* Display the menu. */ 1588 /* Display the menu. */
1583 gtk_widget_show_all (menu); 1589 gtk_widget_show_all (menu);
1584 1590
@@ -1868,6 +1874,8 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
1868 { 1874 {
1869 specpdl_ref specpdl_count = SPECPDL_INDEX (); 1875 specpdl_ref specpdl_count = SPECPDL_INDEX ();
1870 1876
1877 DEFER_SELECTIONS;
1878
1871 record_unwind_protect_int (pop_down_menu, (int) menu_id); 1879 record_unwind_protect_int (pop_down_menu, (int) menu_id);
1872#ifdef HAVE_XINPUT2 1880#ifdef HAVE_XINPUT2
1873 record_unwind_protect_ptr (leave_toolkit_menu, f); 1881 record_unwind_protect_ptr (leave_toolkit_menu, f);
@@ -2199,6 +2207,8 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv)
2199 if (menu) 2207 if (menu)
2200 { 2208 {
2201 specpdl_ref specpdl_count = SPECPDL_INDEX (); 2209 specpdl_ref specpdl_count = SPECPDL_INDEX ();
2210
2211 DEFER_SELECTIONS;
2202 record_unwind_protect_ptr (pop_down_menu, menu); 2212 record_unwind_protect_ptr (pop_down_menu, menu);
2203 2213
2204 /* Display the menu. */ 2214 /* Display the menu. */
@@ -2255,6 +2265,8 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv)
2255 { 2265 {
2256 specpdl_ref count = SPECPDL_INDEX (); 2266 specpdl_ref count = SPECPDL_INDEX ();
2257 2267
2268 DEFER_SELECTIONS;
2269
2258 /* xdialog_show_unwind is responsible for popping the dialog box down. */ 2270 /* xdialog_show_unwind is responsible for popping the dialog box down. */
2259 2271
2260 record_unwind_protect_int (pop_down_menu, (int) dialog_id); 2272 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,
2715 y = max (y, 1); 2727 y = max (y, 1);
2716 XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y, 2728 XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y,
2717 &ulx, &uly, &width, &height); 2729 &ulx, &uly, &width, &height);
2718 if (ulx+width > dispwidth) 2730 if (ulx + width > dispwidth)
2719 { 2731 {
2720 x -= (ulx + width) - dispwidth; 2732 x -= (ulx + width) - dispwidth;
2721 ulx = dispwidth - width; 2733 ulx = dispwidth - width;
2722 } 2734 }
2723 if (uly+height > dispheight) 2735 if (uly + height > dispheight)
2724 { 2736 {
2725 y -= (uly + height) - dispheight; 2737 y -= (uly + height) - dispheight;
2726 uly = dispheight - height; 2738 uly = dispheight - height;
2727 } 2739 }
2728#ifndef HAVE_X_WINDOWS 2740#ifndef HAVE_X_WINDOWS
2729 if (FRAME_HAS_MINIBUF_P (f) && uly+height > dispheight - 1) 2741 if (FRAME_HAS_MINIBUF_P (f) && uly + height > dispheight - 1)
2730 { 2742 {
2731 /* Move the menu away of the echo area, to avoid overwriting the 2743 /* Move the menu away of the echo area, to avoid overwriting the
2732 menu with help echo messages or vice versa. */ 2744 menu with help echo messages or vice versa. */
@@ -2750,8 +2762,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
2750 /* If position was not given by a mouse click, adjust so upper left 2762 /* If position was not given by a mouse click, adjust so upper left
2751 corner of the menu as a whole ends up at given coordinates. This 2763 corner of the menu as a whole ends up at given coordinates. This
2752 is what x-popup-menu says in its documentation. */ 2764 is what x-popup-menu says in its documentation. */
2753 x += width/2; 2765 x += width / 2;
2754 y += 1.5*height/(maxlines+2); 2766 y += 1.5 * height/ (maxlines + 2);
2755 } 2767 }
2756 2768
2757 XMenuSetAEQ (menu, true); 2769 XMenuSetAEQ (menu, true);
@@ -2759,6 +2771,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
2759 pane = selidx = 0; 2771 pane = selidx = 0;
2760 2772
2761#ifndef MSDOS 2773#ifndef MSDOS
2774 DEFER_SELECTIONS;
2775
2762 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); 2776 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
2763#ifdef HAVE_XINPUT2 2777#ifdef HAVE_XINPUT2
2764 XMenuActivateSetTranslateFunction (x_menu_translate_generic_event); 2778 XMenuActivateSetTranslateFunction (x_menu_translate_generic_event);