diff options
| author | Po Lu | 2022-03-20 21:19:31 +0800 |
|---|---|---|
| committer | Po Lu | 2022-03-20 21:21:43 +0800 |
| commit | 0afef91fa1ee667d8797318011cd8eabc998f4e1 (patch) | |
| tree | 01e3e9cc462da099512df0694e20dc63d65e570b | |
| parent | 978681e78295d1f3457afb944d7ad4049039397f (diff) | |
| download | emacs-0afef91fa1ee667d8797318011cd8eabc998f4e1.tar.gz emacs-0afef91fa1ee667d8797318011cd8eabc998f4e1.zip | |
Fix confusion of wanted action with actual action on X
* src/xterm.c (x_dnd_begin_drag_and_drop)
(x_dnd_update_state, handle_one_xevent): Differentiate between
wanted action and chosen action correctly.
| -rw-r--r-- | src/xterm.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/xterm.c b/src/xterm.c index d094224952a..7928f4fafb5 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1349,11 +1349,11 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, | |||
| 1349 | 1349 | ||
| 1350 | FRAME_DISPLAY_INFO (f)->grabbed = 0; | 1350 | FRAME_DISPLAY_INFO (f)->grabbed = 0; |
| 1351 | 1351 | ||
| 1352 | if (x_dnd_wanted_action != None) | 1352 | if (x_dnd_action != None) |
| 1353 | { | 1353 | { |
| 1354 | block_input (); | 1354 | block_input (); |
| 1355 | atom_name = XGetAtomName (FRAME_X_DISPLAY (f), | 1355 | atom_name = XGetAtomName (FRAME_X_DISPLAY (f), |
| 1356 | x_dnd_wanted_action); | 1356 | x_dnd_action); |
| 1357 | action = intern (atom_name); | 1357 | action = intern (atom_name); |
| 1358 | XFree (atom_name); | 1358 | XFree (atom_name); |
| 1359 | unblock_input (); | 1359 | unblock_input (); |
| @@ -10699,6 +10699,7 @@ x_dnd_update_state (struct x_display_info *dpyinfo) | |||
| 10699 | x_dnd_return_frame = 3; | 10699 | x_dnd_return_frame = 3; |
| 10700 | } | 10700 | } |
| 10701 | 10701 | ||
| 10702 | x_dnd_action = None; | ||
| 10702 | x_dnd_last_seen_window = target; | 10703 | x_dnd_last_seen_window = target; |
| 10703 | x_dnd_last_protocol_version = target_proto; | 10704 | x_dnd_last_protocol_version = target_proto; |
| 10704 | 10705 | ||
| @@ -10710,8 +10711,9 @@ x_dnd_update_state (struct x_display_info *dpyinfo) | |||
| 10710 | if (x_dnd_last_protocol_version != -1 && target != None) | 10711 | if (x_dnd_last_protocol_version != -1 && target != None) |
| 10711 | x_dnd_send_position (x_dnd_frame, target, | 10712 | x_dnd_send_position (x_dnd_frame, target, |
| 10712 | x_dnd_last_protocol_version, | 10713 | x_dnd_last_protocol_version, |
| 10713 | root_x, root_y, x_dnd_selection_timestamp, | 10714 | root_x, root_y, |
| 10714 | dpyinfo->Xatom_XdndActionCopy); | 10715 | x_dnd_selection_timestamp, |
| 10716 | x_dnd_wanted_action); | ||
| 10715 | } | 10717 | } |
| 10716 | /* The pointer moved out of the screen. */ | 10718 | /* The pointer moved out of the screen. */ |
| 10717 | else if (x_dnd_last_protocol_version) | 10719 | else if (x_dnd_last_protocol_version) |
| @@ -10825,12 +10827,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10825 | if (event->xclient.data.l[1] & 1) | 10827 | if (event->xclient.data.l[1] & 1) |
| 10826 | { | 10828 | { |
| 10827 | if (x_dnd_last_protocol_version >= 2) | 10829 | if (x_dnd_last_protocol_version >= 2) |
| 10828 | x_dnd_wanted_action = event->xclient.data.l[4]; | 10830 | x_dnd_action = event->xclient.data.l[4]; |
| 10829 | else | 10831 | else |
| 10830 | x_dnd_wanted_action = dpyinfo->Xatom_XdndActionCopy; | 10832 | x_dnd_action = dpyinfo->Xatom_XdndActionCopy; |
| 10831 | } | 10833 | } |
| 10832 | else | 10834 | else |
| 10833 | x_dnd_wanted_action = None; | 10835 | x_dnd_action = None; |
| 10834 | } | 10836 | } |
| 10835 | } | 10837 | } |
| 10836 | 10838 | ||
| @@ -10841,11 +10843,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10841 | x_dnd_waiting_for_finish = false; | 10843 | x_dnd_waiting_for_finish = false; |
| 10842 | 10844 | ||
| 10843 | if (x_dnd_waiting_for_finish_proto >= 5) | 10845 | if (x_dnd_waiting_for_finish_proto >= 5) |
| 10844 | x_dnd_wanted_action = event->xclient.data.l[2]; | 10846 | x_dnd_action = event->xclient.data.l[2]; |
| 10845 | 10847 | ||
| 10846 | if (x_dnd_waiting_for_finish_proto >= 5 | 10848 | if (x_dnd_waiting_for_finish_proto >= 5 |
| 10847 | && !(event->xclient.data.l[1] & 1)) | 10849 | && !(event->xclient.data.l[1] & 1)) |
| 10848 | x_dnd_wanted_action = None; | 10850 | x_dnd_action = None; |
| 10849 | } | 10851 | } |
| 10850 | 10852 | ||
| 10851 | if (event->xclient.message_type == dpyinfo->Xatom_wm_protocols | 10853 | if (event->xclient.message_type == dpyinfo->Xatom_wm_protocols |
| @@ -12005,12 +12007,22 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 12005 | clear_mouse_face (hlinfo); | 12007 | clear_mouse_face (hlinfo); |
| 12006 | } | 12008 | } |
| 12007 | 12009 | ||
| 12010 | f = mouse_or_wdesc_frame (dpyinfo, event->xmotion.window); | ||
| 12011 | |||
| 12008 | if (x_dnd_in_progress | 12012 | if (x_dnd_in_progress |
| 12009 | && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame)) | 12013 | && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame)) |
| 12010 | { | 12014 | { |
| 12011 | Window target; | 12015 | Window target; |
| 12012 | int target_proto; | 12016 | int target_proto; |
| 12013 | 12017 | ||
| 12018 | /* Sometimes the drag-and-drop operation starts with the | ||
| 12019 | pointer of a frame invisible due to input. Since | ||
| 12020 | motion events are ignored during that, make the pointer | ||
| 12021 | visible manually. */ | ||
| 12022 | |||
| 12023 | if (f) | ||
| 12024 | XTtoggle_invisible_pointer (f, false); | ||
| 12025 | |||
| 12014 | target = x_dnd_get_target_window (dpyinfo, | 12026 | target = x_dnd_get_target_window (dpyinfo, |
| 12015 | event->xmotion.x_root, | 12027 | event->xmotion.x_root, |
| 12016 | event->xmotion.y_root, | 12028 | event->xmotion.y_root, |
| @@ -12036,7 +12048,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 12036 | x_dnd_return_frame = 3; | 12048 | x_dnd_return_frame = 3; |
| 12037 | } | 12049 | } |
| 12038 | 12050 | ||
| 12039 | x_dnd_wanted_action = None; | 12051 | x_dnd_action = None; |
| 12040 | x_dnd_last_seen_window = target; | 12052 | x_dnd_last_seen_window = target; |
| 12041 | x_dnd_last_protocol_version = target_proto; | 12053 | x_dnd_last_protocol_version = target_proto; |
| 12042 | 12054 | ||
| @@ -12051,13 +12063,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 12051 | event->xmotion.x_root, | 12063 | event->xmotion.x_root, |
| 12052 | event->xmotion.y_root, | 12064 | event->xmotion.y_root, |
| 12053 | x_dnd_selection_timestamp, | 12065 | x_dnd_selection_timestamp, |
| 12054 | dpyinfo->Xatom_XdndActionCopy); | 12066 | x_dnd_wanted_action); |
| 12055 | 12067 | ||
| 12056 | goto OTHER; | 12068 | goto OTHER; |
| 12057 | } | 12069 | } |
| 12058 | 12070 | ||
| 12059 | f = mouse_or_wdesc_frame (dpyinfo, event->xmotion.window); | ||
| 12060 | |||
| 12061 | #ifdef USE_GTK | 12071 | #ifdef USE_GTK |
| 12062 | if (f && xg_event_is_for_scrollbar (f, event, false)) | 12072 | if (f && xg_event_is_for_scrollbar (f, event, false)) |
| 12063 | f = 0; | 12073 | f = 0; |
| @@ -13254,12 +13264,22 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 13254 | clear_mouse_face (hlinfo); | 13264 | clear_mouse_face (hlinfo); |
| 13255 | } | 13265 | } |
| 13256 | 13266 | ||
| 13267 | f = mouse_or_wdesc_frame (dpyinfo, xev->event); | ||
| 13268 | |||
| 13257 | if (x_dnd_in_progress | 13269 | if (x_dnd_in_progress |
| 13258 | && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame)) | 13270 | && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame)) |
| 13259 | { | 13271 | { |
| 13260 | Window target; | 13272 | Window target; |
| 13261 | int target_proto; | 13273 | int target_proto; |
| 13262 | 13274 | ||
| 13275 | /* Sometimes the drag-and-drop operation starts with the | ||
| 13276 | pointer of a frame invisible due to input. Since | ||
| 13277 | motion events are ignored during that, make the pointer | ||
| 13278 | visible manually. */ | ||
| 13279 | |||
| 13280 | if (f) | ||
| 13281 | XTtoggle_invisible_pointer (f, false); | ||
| 13282 | |||
| 13263 | target = x_dnd_get_target_window (dpyinfo, | 13283 | target = x_dnd_get_target_window (dpyinfo, |
| 13264 | xev->root_x, | 13284 | xev->root_x, |
| 13265 | xev->root_y, | 13285 | xev->root_y, |
| @@ -13285,6 +13305,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 13285 | x_dnd_return_frame = 3; | 13305 | x_dnd_return_frame = 3; |
| 13286 | } | 13306 | } |
| 13287 | 13307 | ||
| 13308 | x_dnd_action = None; | ||
| 13288 | x_dnd_last_seen_window = target; | 13309 | x_dnd_last_seen_window = target; |
| 13289 | x_dnd_last_protocol_version = target_proto; | 13310 | x_dnd_last_protocol_version = target_proto; |
| 13290 | 13311 | ||
| @@ -13298,13 +13319,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 13298 | x_dnd_last_protocol_version, | 13319 | x_dnd_last_protocol_version, |
| 13299 | xev->root_x, xev->root_y, | 13320 | xev->root_x, xev->root_y, |
| 13300 | x_dnd_selection_timestamp, | 13321 | x_dnd_selection_timestamp, |
| 13301 | dpyinfo->Xatom_XdndActionCopy); | 13322 | x_dnd_wanted_action); |
| 13302 | 13323 | ||
| 13303 | goto XI_OTHER; | 13324 | goto XI_OTHER; |
| 13304 | } | 13325 | } |
| 13305 | 13326 | ||
| 13306 | f = mouse_or_wdesc_frame (dpyinfo, xev->event); | ||
| 13307 | |||
| 13308 | #ifdef USE_GTK | 13327 | #ifdef USE_GTK |
| 13309 | if (f && xg_event_is_for_scrollbar (f, event, false)) | 13328 | if (f && xg_event_is_for_scrollbar (f, event, false)) |
| 13310 | f = 0; | 13329 | f = 0; |