aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-06-11 14:11:28 +0800
committerPo Lu2022-06-11 14:15:44 +0800
commit46b9bfb9fc925b8cf20b0a35469f8ff6c3be5a70 (patch)
tree9b42b02fc5bf599ac67384e58a04e584c9519ba6 /src
parent84a588e02846966262be1ea4d0106d9936ccd3b5 (diff)
downloademacs-46b9bfb9fc925b8cf20b0a35469f8ff6c3be5a70.tar.gz
emacs-46b9bfb9fc925b8cf20b0a35469f8ff6c3be5a70.zip
Fix queuing already-present selection requests
* src/xterm.c (x_defer_selection_requests): Move kbd_fetch_ptr if possible and fix counter increment order.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 74716dfe408..55cd5286fe1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -795,9 +795,9 @@ static int x_use_pending_selection_requests;
795 795
796static void x_push_selection_request (struct selection_input_event *); 796static void x_push_selection_request (struct selection_input_event *);
797 797
798/* Defer selection requests. Any selection requests generated after 798/* Defer selection requests. Between this and
799 this can then be processed by calling 799 x_release_selection_requests, any selection requests can be
800 `x_handle_pending_selection_requests'. 800 processed by calling `x_handle_pending_selection_requests'.
801 801
802 Also run through and queue all the selection events already in the 802 Also run through and queue all the selection events already in the
803 keyboard buffer. */ 803 keyboard buffer. */
@@ -805,10 +805,11 @@ void
805x_defer_selection_requests (void) 805x_defer_selection_requests (void)
806{ 806{
807 union buffered_input_event *event; 807 union buffered_input_event *event;
808 bool between;
808 809
809 block_input (); 810 between = false;
810 x_use_pending_selection_requests++;
811 811
812 block_input ();
812 if (!x_use_pending_selection_requests) 813 if (!x_use_pending_selection_requests)
813 { 814 {
814 event = kbd_fetch_ptr; 815 event = kbd_fetch_ptr;
@@ -822,13 +823,24 @@ x_defer_selection_requests (void)
822 823
823 /* Mark this selection event as invalid. */ 824 /* Mark this selection event as invalid. */
824 SELECTION_EVENT_DPYINFO (&event->sie) = NULL; 825 SELECTION_EVENT_DPYINFO (&event->sie) = NULL;
826
827 /* Move the kbd_fetch_ptr along if doing so would not
828 result in any other events being skipped. This
829 avoids exhausting the keyboard buffer with some
830 over-enthusiastic clipboard managers. */
831 if (!between)
832 kbd_fetch_ptr = (event == kbd_buffer + KBD_BUFFER_SIZE - 1
833 ? kbd_buffer : event + 1);
825 } 834 }
835 else
836 between = true;
826 837
827 event = (event == kbd_buffer + KBD_BUFFER_SIZE - 1 838 event = (event == kbd_buffer + KBD_BUFFER_SIZE - 1
828 ? kbd_buffer : event + 1); 839 ? kbd_buffer : event + 1);
829 } 840 }
830 } 841 }
831 842
843 x_use_pending_selection_requests++;
832 unblock_input (); 844 unblock_input ();
833} 845}
834 846