diff options
| author | Po Lu | 2022-07-07 02:48:19 +0000 |
|---|---|---|
| committer | Po Lu | 2022-07-07 02:48:19 +0000 |
| commit | fd016ea99724f7abedfddbb470ab96ece6ddf4ae (patch) | |
| tree | e874e42b2a69d1c22411e2a78c1fa9d2a4270284 /src/haikuselect.c | |
| parent | 8575962d46d1f1d08836bf00cb74ccd344953bcb (diff) | |
| download | emacs-fd016ea99724f7abedfddbb470ab96ece6ddf4ae.tar.gz emacs-fd016ea99724f7abedfddbb470ab96ece6ddf4ae.zip | |
Port `x-lost-selection-functions' to Haiku
* src/haiku_io.c (haiku_len): Add `CLIPBOARD_CHANGED_EVENT'.
* src/haiku_select.cc (be_update_clipboard_count): Set ownership
flags.
(be_handle_clipboard_changed_message):
(be_start_watching_selection): New functions.
* src/haiku_support.cc (class Emacs): Handle
B_CLIPBOARD_CHANGED.
* src/haiku_support.h (enum haiku_event_type): New event
`CLIPBOARD_CHANGED_EVENT'.
(struct haiku_clipboard_changed_event): New struct.
* src/haikuselect.c (haiku_handle_selection_clear)
(haiku_selection_disowned, haiku_start_watching_selections): New
functions.
(syms_of_haikuselect): New defsym and defvar.
* src/haikuselect.h: Update prototypes.
* src/haikuterm.c (haiku_read_socket): Handle selection events.
(haiku_term_init): Start watching selections.
* src/haikuterm.h: Update prototypes.
* src/keyboard.c (kbd_buffer_get_event, process_special_events)
(mark_kboards): Handle SELECTON_CLEAR_EVENTs correctly on Haiku.
Diffstat (limited to 'src/haikuselect.c')
| -rw-r--r-- | src/haikuselect.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/haikuselect.c b/src/haikuselect.c index fe76e09810c..999a0f5ac29 100644 --- a/src/haikuselect.c +++ b/src/haikuselect.c | |||
| @@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 24 | #include "haikuselect.h" | 24 | #include "haikuselect.h" |
| 25 | #include "haikuterm.h" | 25 | #include "haikuterm.h" |
| 26 | #include "haiku_support.h" | 26 | #include "haiku_support.h" |
| 27 | #include "keyboard.h" | ||
| 27 | 28 | ||
| 28 | #include <stdlib.h> | 29 | #include <stdlib.h> |
| 29 | 30 | ||
| @@ -1021,6 +1022,47 @@ init_haiku_select (void) | |||
| 1021 | } | 1022 | } |
| 1022 | 1023 | ||
| 1023 | void | 1024 | void |
| 1025 | haiku_handle_selection_clear (struct input_event *ie) | ||
| 1026 | { | ||
| 1027 | CALLN (Frun_hook_with_args, | ||
| 1028 | Qhaiku_lost_selection_functions, ie->arg); | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | void | ||
| 1032 | haiku_selection_disowned (enum haiku_clipboard id) | ||
| 1033 | { | ||
| 1034 | struct input_event ie; | ||
| 1035 | |||
| 1036 | EVENT_INIT (ie); | ||
| 1037 | ie.kind = SELECTION_CLEAR_EVENT; | ||
| 1038 | |||
| 1039 | switch (id) | ||
| 1040 | { | ||
| 1041 | case CLIPBOARD_CLIPBOARD: | ||
| 1042 | ie.arg = QCLIPBOARD; | ||
| 1043 | break; | ||
| 1044 | |||
| 1045 | case CLIPBOARD_PRIMARY: | ||
| 1046 | ie.arg = QPRIMARY; | ||
| 1047 | break; | ||
| 1048 | |||
| 1049 | case CLIPBOARD_SECONDARY: | ||
| 1050 | ie.arg = QSECONDARY; | ||
| 1051 | break; | ||
| 1052 | } | ||
| 1053 | |||
| 1054 | kbd_buffer_store_event (&ie); | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | void | ||
| 1058 | haiku_start_watching_selections (void) | ||
| 1059 | { | ||
| 1060 | be_start_watching_selection (CLIPBOARD_CLIPBOARD); | ||
| 1061 | be_start_watching_selection (CLIPBOARD_PRIMARY); | ||
| 1062 | be_start_watching_selection (CLIPBOARD_SECONDARY); | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | void | ||
| 1024 | syms_of_haikuselect (void) | 1066 | syms_of_haikuselect (void) |
| 1025 | { | 1067 | { |
| 1026 | DEFVAR_BOOL ("haiku-signal-invalid-refs", haiku_signal_invalid_refs, | 1068 | DEFVAR_BOOL ("haiku-signal-invalid-refs", haiku_signal_invalid_refs, |
| @@ -1035,12 +1077,21 @@ The function is called without any arguments. `mouse-position' can be | |||
| 1035 | used to retrieve the current position of the mouse. */); | 1077 | used to retrieve the current position of the mouse. */); |
| 1036 | Vhaiku_drag_track_function = Qnil; | 1078 | Vhaiku_drag_track_function = Qnil; |
| 1037 | 1079 | ||
| 1080 | DEFVAR_LISP ("haiku-lost-selection-functions", Vhaiku_lost_selection_functions, | ||
| 1081 | doc: /* A list of functions to be called when Emacs loses an X selection. | ||
| 1082 | These are only called if a connection to the Haiku display was opened. */); | ||
| 1083 | Vhaiku_lost_selection_functions = Qnil; | ||
| 1084 | |||
| 1038 | DEFSYM (QSECONDARY, "SECONDARY"); | 1085 | DEFSYM (QSECONDARY, "SECONDARY"); |
| 1039 | DEFSYM (QCLIPBOARD, "CLIPBOARD"); | 1086 | DEFSYM (QCLIPBOARD, "CLIPBOARD"); |
| 1040 | DEFSYM (QSTRING, "STRING"); | 1087 | DEFSYM (QSTRING, "STRING"); |
| 1041 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); | 1088 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); |
| 1042 | DEFSYM (Qforeign_selection, "foreign-selection"); | 1089 | DEFSYM (Qforeign_selection, "foreign-selection"); |
| 1043 | DEFSYM (QTARGETS, "TARGETS"); | 1090 | DEFSYM (QTARGETS, "TARGETS"); |
| 1091 | |||
| 1092 | DEFSYM (Qhaiku_lost_selection_functions, | ||
| 1093 | "haiku-lost-selection-functions"); | ||
| 1094 | |||
| 1044 | DEFSYM (Qmessage, "message"); | 1095 | DEFSYM (Qmessage, "message"); |
| 1045 | DEFSYM (Qstring, "string"); | 1096 | DEFSYM (Qstring, "string"); |
| 1046 | DEFSYM (Qref, "ref"); | 1097 | DEFSYM (Qref, "ref"); |