aboutsummaryrefslogtreecommitdiffstats
path: root/src/haikuselect.c
diff options
context:
space:
mode:
authorPo Lu2022-07-09 04:50:06 +0000
committerPo Lu2022-07-09 04:50:35 +0000
commitedabfe4ff66090b3b2c433962df4cfe1a68259fd (patch)
tree89d27a45082768a61bdcbcb49bfb25a7f4637b98 /src/haikuselect.c
parentf400c60237f04781b60423492c583beea6c77e8e (diff)
downloademacs-edabfe4ff66090b3b2c433962df4cfe1a68259fd.tar.gz
emacs-edabfe4ff66090b3b2c433962df4cfe1a68259fd.zip
Fix race conditions handling selection clear events on Haiku
* src/haiku_select.cc (be_handle_clipboard_changed_message): Include current clipboard count. (be_selection_outdated_p): New function. * src/haikuselect.c (haiku_handle_selection_clear): Ignore outdated events. (haiku_selection_disowned): New argument `count'. Include it in the timestamp field of the selection clear event. * src/haikuselect.h: Update prototypes. * src/systime.h: Define `Time' to an appropriate value on Haiku.
Diffstat (limited to 'src/haikuselect.c')
-rw-r--r--src/haikuselect.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/haikuselect.c b/src/haikuselect.c
index 03aba1f9baa..9d8c4a2cd16 100644
--- a/src/haikuselect.c
+++ b/src/haikuselect.c
@@ -1024,6 +1024,13 @@ init_haiku_select (void)
1024void 1024void
1025haiku_handle_selection_clear (struct input_event *ie) 1025haiku_handle_selection_clear (struct input_event *ie)
1026{ 1026{
1027 enum haiku_clipboard id;
1028
1029 id = haiku_get_clipboard_name (ie->arg);
1030
1031 if (be_selection_outdated_p (id, ie->timestamp))
1032 return;
1033
1027 CALLN (Frun_hook_with_args, 1034 CALLN (Frun_hook_with_args,
1028 Qhaiku_lost_selection_functions, ie->arg); 1035 Qhaiku_lost_selection_functions, ie->arg);
1029 1036
@@ -1033,7 +1040,7 @@ haiku_handle_selection_clear (struct input_event *ie)
1033} 1040}
1034 1041
1035void 1042void
1036haiku_selection_disowned (enum haiku_clipboard id) 1043haiku_selection_disowned (enum haiku_clipboard id, int64 count)
1037{ 1044{
1038 struct input_event ie; 1045 struct input_event ie;
1039 1046
@@ -1055,6 +1062,7 @@ haiku_selection_disowned (enum haiku_clipboard id)
1055 break; 1062 break;
1056 } 1063 }
1057 1064
1065 ie.timestamp = count;
1058 kbd_buffer_store_event (&ie); 1066 kbd_buffer_store_event (&ie);
1059} 1067}
1060 1068