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/keyboard.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/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index bed8307b6f2..76dc3732b54 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -4012,6 +4012,7 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4012 | We return nil for them. */ | 4012 | We return nil for them. */ |
| 4013 | switch (event->kind) | 4013 | switch (event->kind) |
| 4014 | { | 4014 | { |
| 4015 | #ifndef HAVE_HAIKU | ||
| 4015 | case SELECTION_REQUEST_EVENT: | 4016 | case SELECTION_REQUEST_EVENT: |
| 4016 | case SELECTION_CLEAR_EVENT: | 4017 | case SELECTION_CLEAR_EVENT: |
| 4017 | { | 4018 | { |
| @@ -4035,6 +4036,20 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4035 | #endif | 4036 | #endif |
| 4036 | } | 4037 | } |
| 4037 | break; | 4038 | break; |
| 4039 | #else | ||
| 4040 | case SELECTION_REQUEST_EVENT: | ||
| 4041 | emacs_abort (); | ||
| 4042 | |||
| 4043 | case SELECTION_CLEAR_EVENT: | ||
| 4044 | { | ||
| 4045 | struct input_event copy = event->ie; | ||
| 4046 | |||
| 4047 | kbd_fetch_ptr = next_kbd_event (event); | ||
| 4048 | input_pending = readable_events (0); | ||
| 4049 | haiku_handle_selection_clear (©); | ||
| 4050 | } | ||
| 4051 | break; | ||
| 4052 | #endif | ||
| 4038 | 4053 | ||
| 4039 | case MONITORS_CHANGED_EVENT: | 4054 | case MONITORS_CHANGED_EVENT: |
| 4040 | { | 4055 | { |
| @@ -4345,8 +4360,16 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4345 | static void | 4360 | static void |
| 4346 | process_special_events (void) | 4361 | process_special_events (void) |
| 4347 | { | 4362 | { |
| 4348 | for (union buffered_input_event *event = kbd_fetch_ptr; | 4363 | union buffered_input_event *event; |
| 4349 | event != kbd_store_ptr; event = next_kbd_event (event)) | 4364 | #ifndef HAVE_HAIKU |
| 4365 | struct selection_input_event copy; | ||
| 4366 | #else | ||
| 4367 | struct input_event copy; | ||
| 4368 | #endif | ||
| 4369 | int moved_events; | ||
| 4370 | |||
| 4371 | for (event = kbd_fetch_ptr; event != kbd_store_ptr; | ||
| 4372 | event = next_kbd_event (event)) | ||
| 4350 | { | 4373 | { |
| 4351 | /* If we find a stored X selection request, handle it now. */ | 4374 | /* If we find a stored X selection request, handle it now. */ |
| 4352 | if (event->kind == SELECTION_REQUEST_EVENT | 4375 | if (event->kind == SELECTION_REQUEST_EVENT |
| @@ -4360,8 +4383,7 @@ process_special_events (void) | |||
| 4360 | between kbd_fetch_ptr and EVENT one slot to the right, | 4383 | between kbd_fetch_ptr and EVENT one slot to the right, |
| 4361 | cyclically. */ | 4384 | cyclically. */ |
| 4362 | 4385 | ||
| 4363 | struct selection_input_event copy = event->sie; | 4386 | copy = event->sie; |
| 4364 | int moved_events; | ||
| 4365 | 4387 | ||
| 4366 | if (event < kbd_fetch_ptr) | 4388 | if (event < kbd_fetch_ptr) |
| 4367 | { | 4389 | { |
| @@ -4383,6 +4405,27 @@ process_special_events (void) | |||
| 4383 | #else | 4405 | #else |
| 4384 | pgtk_handle_selection_event (©); | 4406 | pgtk_handle_selection_event (©); |
| 4385 | #endif | 4407 | #endif |
| 4408 | #elif defined HAVE_HAIKU | ||
| 4409 | if (event->ie.kind != SELECTION_CLEAR_EVENT) | ||
| 4410 | emacs_abort (); | ||
| 4411 | |||
| 4412 | copy = event->ie; | ||
| 4413 | |||
| 4414 | if (event < kbd_fetch_ptr) | ||
| 4415 | { | ||
| 4416 | memmove (kbd_buffer + 1, kbd_buffer, | ||
| 4417 | (event - kbd_buffer) * sizeof *kbd_buffer); | ||
| 4418 | kbd_buffer[0] = kbd_buffer[KBD_BUFFER_SIZE - 1]; | ||
| 4419 | moved_events = kbd_buffer + KBD_BUFFER_SIZE - 1 - kbd_fetch_ptr; | ||
| 4420 | } | ||
| 4421 | else | ||
| 4422 | moved_events = event - kbd_fetch_ptr; | ||
| 4423 | |||
| 4424 | memmove (kbd_fetch_ptr + 1, kbd_fetch_ptr, | ||
| 4425 | moved_events * sizeof *kbd_fetch_ptr); | ||
| 4426 | kbd_fetch_ptr = next_kbd_event (kbd_fetch_ptr); | ||
| 4427 | input_pending = readable_events (0); | ||
| 4428 | haiku_handle_selection_clear (©); | ||
| 4386 | #else | 4429 | #else |
| 4387 | /* We're getting selection request events, but we don't have | 4430 | /* We're getting selection request events, but we don't have |
| 4388 | a window system. */ | 4431 | a window system. */ |
| @@ -13149,7 +13192,10 @@ mark_kboards (void) | |||
| 13149 | { | 13192 | { |
| 13150 | /* These two special event types have no Lisp_Objects to mark. */ | 13193 | /* These two special event types have no Lisp_Objects to mark. */ |
| 13151 | if (event->kind != SELECTION_REQUEST_EVENT | 13194 | if (event->kind != SELECTION_REQUEST_EVENT |
| 13152 | && event->kind != SELECTION_CLEAR_EVENT) | 13195 | #ifndef HAVE_HAIKU |
| 13196 | && event->kind != SELECTION_CLEAR_EVENT | ||
| 13197 | #endif | ||
| 13198 | ) | ||
| 13153 | { | 13199 | { |
| 13154 | mark_object (event->ie.x); | 13200 | mark_object (event->ie.x); |
| 13155 | mark_object (event->ie.y); | 13201 | mark_object (event->ie.y); |