aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-04-14 19:02:13 +0800
committerPo Lu2022-04-14 19:02:13 +0800
commite5ef0fe832a0514f83fea47fa16aab4b1a5d11a4 (patch)
treee34023cf5d63445e6c9b00f6b70254a54a76e6f7 /src
parent203c503ff22e6c3c7b75d0e30d1974bb0ca9e60a (diff)
downloademacs-e5ef0fe832a0514f83fea47fa16aab4b1a5d11a4.tar.gz
emacs-e5ef0fe832a0514f83fea47fa16aab4b1a5d11a4.zip
Keep track of keyboard state during drag and drop
* src/xterm.c (x_dnd_cleanup_drag_and_drop): Deselect for keyboard state changes. (x_dnd_begin_drag_and_drop): Select for keyboard state changes when XKB is available. (x_dnd_update_state, handle_one_xevent): Use current XKB state if it is available. (x_term_init): Reformat code a little.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 94f8ce33bb0..da4af8bff75 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -986,6 +986,11 @@ static struct frame *x_dnd_movement_frame;
986 with. */ 986 with. */
987static int x_dnd_movement_x, x_dnd_movement_y; 987static int x_dnd_movement_x, x_dnd_movement_y;
988 988
989#ifdef HAVE_XKB
990/* The keyboard state during the drag-and-drop operation. */
991static unsigned int x_dnd_keyboard_state;
992#endif
993
989struct x_client_list_window 994struct x_client_list_window
990{ 995{
991 Window window; 996 Window window;
@@ -3608,6 +3613,11 @@ x_dnd_cleanup_drag_and_drop (void *frame)
3608 XSelectInput (FRAME_X_DISPLAY (f), 3613 XSelectInput (FRAME_X_DISPLAY (f),
3609 FRAME_DISPLAY_INFO (f)->root_window, 3614 FRAME_DISPLAY_INFO (f)->root_window,
3610 x_dnd_old_window_attrs.your_event_mask); 3615 x_dnd_old_window_attrs.your_event_mask);
3616
3617#ifdef HAVE_XKB
3618 XkbSelectEvents (FRAME_X_DISPLAY (f), XkbUseCoreKbd,
3619 XkbStateNotifyMask, 0);
3620#endif
3611 unblock_input (); 3621 unblock_input ();
3612 3622
3613 x_dnd_frame = NULL; 3623 x_dnd_frame = NULL;
@@ -9447,6 +9457,9 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9447 XTextProperty prop; 9457 XTextProperty prop;
9448 xm_drop_start_message dmsg; 9458 xm_drop_start_message dmsg;
9449 Lisp_Object frame_object, x, y, frame, local_value; 9459 Lisp_Object frame_object, x, y, frame, local_value;
9460#ifdef HAVE_XKB
9461 XkbStateRec keyboard_state;
9462#endif
9450 9463
9451 if (!FRAME_VISIBLE_P (f)) 9464 if (!FRAME_VISIBLE_P (f))
9452 { 9465 {
@@ -9557,6 +9570,20 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9557 x_dnd_toplevels = NULL; 9570 x_dnd_toplevels = NULL;
9558 x_dnd_allow_current_frame = allow_current_frame; 9571 x_dnd_allow_current_frame = allow_current_frame;
9559 x_dnd_movement_frame = NULL; 9572 x_dnd_movement_frame = NULL;
9573#ifdef HAVE_XKB
9574 x_dnd_keyboard_state = 0;
9575
9576 if (FRAME_DISPLAY_INFO (f)->supports_xkb)
9577 {
9578 XkbSelectEvents (FRAME_X_DISPLAY (f), XkbUseCoreKbd,
9579 XkbStateNotifyMask, XkbStateNotifyMask);
9580 XkbGetState (FRAME_X_DISPLAY (f), XkbUseCoreKbd,
9581 &keyboard_state);
9582
9583 x_dnd_keyboard_state = (keyboard_state.mods
9584 | keyboard_state.ptr_buttons);
9585 }
9586#endif
9560 9587
9561 if (x_dnd_use_toplevels) 9588 if (x_dnd_use_toplevels)
9562 { 9589 {
@@ -9573,10 +9600,6 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9573 if (EQ (return_frame, Qnow)) 9600 if (EQ (return_frame, Qnow))
9574 x_dnd_return_frame = 2; 9601 x_dnd_return_frame = 2;
9575 9602
9576#ifdef USE_GTK
9577 current_count = 0;
9578#endif
9579
9580 /* Now select for SubstructureNotifyMask and PropertyNotifyMask on 9603 /* Now select for SubstructureNotifyMask and PropertyNotifyMask on
9581 the root window, so we can get notified when window stacking 9604 the root window, so we can get notified when window stacking
9582 changes, a common operation during drag-and-drop. */ 9605 changes, a common operation during drag-and-drop. */
@@ -9600,6 +9623,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9600#ifdef USE_GTK 9623#ifdef USE_GTK
9601 current_finish = X_EVENT_NORMAL; 9624 current_finish = X_EVENT_NORMAL;
9602 current_hold_quit = &hold_quit; 9625 current_hold_quit = &hold_quit;
9626 current_count = 0;
9603#endif 9627#endif
9604 9628
9605 block_input (); 9629 block_input ();
@@ -9735,6 +9759,10 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9735 XSelectInput (FRAME_X_DISPLAY (f), 9759 XSelectInput (FRAME_X_DISPLAY (f),
9736 FRAME_DISPLAY_INFO (f)->root_window, 9760 FRAME_DISPLAY_INFO (f)->root_window,
9737 root_window_attrs.your_event_mask); 9761 root_window_attrs.your_event_mask);
9762#ifdef HAVE_XKB
9763 XkbSelectEvents (FRAME_X_DISPLAY (f), XkbUseCoreKbd,
9764 XkbStateNotifyMask, 0);
9765#endif
9738 quit (); 9766 quit ();
9739 } 9767 }
9740 } 9768 }
@@ -9752,6 +9780,10 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9752 XSelectInput (FRAME_X_DISPLAY (f), 9780 XSelectInput (FRAME_X_DISPLAY (f),
9753 FRAME_DISPLAY_INFO (f)->root_window, 9781 FRAME_DISPLAY_INFO (f)->root_window,
9754 root_window_attrs.your_event_mask); 9782 root_window_attrs.your_event_mask);
9783#ifdef HAVE_XKB
9784 XkbSelectEvents (FRAME_X_DISPLAY (f), XkbUseCoreKbd,
9785 XkbStateNotifyMask, 0);
9786#endif
9755 unblock_input (); 9787 unblock_input ();
9756 9788
9757 if (x_dnd_return_frame == 3 9789 if (x_dnd_return_frame == 3
@@ -13506,7 +13538,13 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
13506 x_dnd_last_protocol_version, 13538 x_dnd_last_protocol_version,
13507 root_x, root_y, 13539 root_x, root_y,
13508 x_dnd_selection_timestamp, 13540 x_dnd_selection_timestamp,
13509 x_dnd_wanted_action, 0, 0); 13541 x_dnd_wanted_action, 0,
13542#ifdef HAVE_XKB
13543 x_dnd_keyboard_state
13544#else
13545 0
13546#endif
13547 );
13510 else if (XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style) && target != None) 13548 else if (XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style) && target != None)
13511 { 13549 {
13512 if (!x_dnd_motif_setup_p) 13550 if (!x_dnd_motif_setup_p)
@@ -18531,6 +18569,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18531 XkbRefreshKeyboardMapping (&xkbevent->map); 18569 XkbRefreshKeyboardMapping (&xkbevent->map);
18532 x_find_modifier_meanings (dpyinfo); 18570 x_find_modifier_meanings (dpyinfo);
18533 } 18571 }
18572 else if (x_dnd_in_progress
18573 && xkbevent->any.xkb_type == XkbStateNotify)
18574 x_dnd_keyboard_state = (xkbevent->state.mods
18575 | xkbevent->state.ptr_buttons);
18534 } 18576 }
18535#endif 18577#endif
18536#ifdef HAVE_XSHAPE 18578#ifdef HAVE_XSHAPE
@@ -23001,8 +23043,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
23001 XkbGroupNamesMask | XkbVirtualModNamesMask, 23043 XkbGroupNamesMask | XkbVirtualModNamesMask,
23002 dpyinfo->xkb_desc); 23044 dpyinfo->xkb_desc);
23003 23045
23004 XkbSelectEvents (dpyinfo->display, 23046 XkbSelectEvents (dpyinfo->display, XkbUseCoreKbd,
23005 XkbUseCoreKbd,
23006 XkbNewKeyboardNotifyMask | XkbMapNotifyMask, 23047 XkbNewKeyboardNotifyMask | XkbMapNotifyMask,
23007 XkbNewKeyboardNotifyMask | XkbMapNotifyMask); 23048 XkbNewKeyboardNotifyMask | XkbMapNotifyMask);
23008 } 23049 }