diff options
| author | Po Lu | 2022-03-21 09:00:38 +0000 |
|---|---|---|
| committer | Po Lu | 2022-03-21 09:01:31 +0000 |
| commit | efb76604c49c9277f8091da31aa75beb85e8c9fa (patch) | |
| tree | 25bf77ad71b9ffd1fd03a2906143960c3e8c0dda /src | |
| parent | 7cee79655656f02c36fb2858eccce477b7d90b6b (diff) | |
| download | emacs-efb76604c49c9277f8091da31aa75beb85e8c9fa.tar.gz emacs-efb76604c49c9277f8091da31aa75beb85e8c9fa.zip | |
Minor fixes to Haiku DND support
* src/haiku_support.cc (MessageReceived): If source is remote,
don't test window ID.
(MouseMoved): Don't send mouse motion if dragging.
(be_drag_message): Return true if quit-flag.
* src/haiku_support.h: Update prototypes.
* src/haikuselect.c (haiku_should_quit_drag): New function.
(Fhaiku_drag_message): If rc is true, quit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/haiku_support.cc | 18 | ||||
| -rw-r--r-- | src/haiku_support.h | 5 | ||||
| -rw-r--r-- | src/haikuselect.c | 17 |
3 files changed, 30 insertions, 10 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 26b7ebed246..5d0385f6d9d 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc | |||
| @@ -645,6 +645,7 @@ public: | |||
| 645 | struct haiku_drag_and_drop_event rq; | 645 | struct haiku_drag_and_drop_event rq; |
| 646 | 646 | ||
| 647 | if (msg->FindInt32 ("emacs:window_id", &windowid) == B_OK | 647 | if (msg->FindInt32 ("emacs:window_id", &windowid) == B_OK |
| 648 | && !msg->IsSourceRemote () | ||
| 648 | && windowid == this->window_id) | 649 | && windowid == this->window_id) |
| 649 | return; | 650 | return; |
| 650 | 651 | ||
| @@ -1449,7 +1450,7 @@ public: | |||
| 1449 | } | 1450 | } |
| 1450 | 1451 | ||
| 1451 | void | 1452 | void |
| 1452 | MouseMoved (BPoint point, uint32 transit, const BMessage *msg) | 1453 | MouseMoved (BPoint point, uint32 transit, const BMessage *drag_msg) |
| 1453 | { | 1454 | { |
| 1454 | struct haiku_mouse_motion_event rq; | 1455 | struct haiku_mouse_motion_event rq; |
| 1455 | 1456 | ||
| @@ -1459,6 +1460,9 @@ public: | |||
| 1459 | rq.window = this->Window (); | 1460 | rq.window = this->Window (); |
| 1460 | rq.time = system_time (); | 1461 | rq.time = system_time (); |
| 1461 | 1462 | ||
| 1463 | if (drag_msg && transit != B_EXITED_VIEW) | ||
| 1464 | return; | ||
| 1465 | |||
| 1462 | if (ToolTip ()) | 1466 | if (ToolTip ()) |
| 1463 | ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), | 1467 | ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), |
| 1464 | -(point.y - tt_absl_pos.y))); | 1468 | -(point.y - tt_absl_pos.y))); |
| @@ -3960,11 +3964,12 @@ be_drag_message_thread_entry (void *thread_data) | |||
| 3960 | return 0; | 3964 | return 0; |
| 3961 | } | 3965 | } |
| 3962 | 3966 | ||
| 3963 | void | 3967 | bool |
| 3964 | be_drag_message (void *view, void *message, | 3968 | be_drag_message (void *view, void *message, |
| 3965 | void (*block_input_function) (void), | 3969 | void (*block_input_function) (void), |
| 3966 | void (*unblock_input_function) (void), | 3970 | void (*unblock_input_function) (void), |
| 3967 | void (*process_pending_signals_function) (void)) | 3971 | void (*process_pending_signals_function) (void), |
| 3972 | bool (*should_quit_function) (void)) | ||
| 3968 | { | 3973 | { |
| 3969 | EmacsView *vw = (EmacsView *) view; | 3974 | EmacsView *vw = (EmacsView *) view; |
| 3970 | EmacsWindow *window = (EmacsWindow *) vw->Window (); | 3975 | EmacsWindow *window = (EmacsWindow *) vw->Window (); |
| @@ -3995,7 +4000,7 @@ be_drag_message (void *view, void *message, | |||
| 3995 | unblock_input_function (); | 4000 | unblock_input_function (); |
| 3996 | 4001 | ||
| 3997 | if (infos[1].object < B_OK) | 4002 | if (infos[1].object < B_OK) |
| 3998 | return; | 4003 | return false; |
| 3999 | 4004 | ||
| 4000 | block_input_function (); | 4005 | block_input_function (); |
| 4001 | resume_thread (infos[1].object); | 4006 | resume_thread (infos[1].object); |
| @@ -4017,8 +4022,11 @@ be_drag_message (void *view, void *message, | |||
| 4017 | if (infos[0].events & B_EVENT_READ) | 4022 | if (infos[0].events & B_EVENT_READ) |
| 4018 | process_pending_signals_function (); | 4023 | process_pending_signals_function (); |
| 4019 | 4024 | ||
| 4025 | if (should_quit_function ()) | ||
| 4026 | return true; | ||
| 4027 | |||
| 4020 | if (infos[1].events & B_EVENT_INVALID) | 4028 | if (infos[1].events & B_EVENT_INVALID) |
| 4021 | return; | 4029 | return false; |
| 4022 | 4030 | ||
| 4023 | infos[0].events = B_EVENT_READ; | 4031 | infos[0].events = B_EVENT_READ; |
| 4024 | infos[1].events = B_EVENT_INVALID; | 4032 | infos[1].events = B_EVENT_INVALID; |
diff --git a/src/haiku_support.h b/src/haiku_support.h index af7216286a7..9c21a80e20d 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h | |||
| @@ -945,11 +945,12 @@ extern "C" | |||
| 945 | extern void | 945 | extern void |
| 946 | BMessage_delete (void *message); | 946 | BMessage_delete (void *message); |
| 947 | 947 | ||
| 948 | extern void | 948 | extern bool |
| 949 | be_drag_message (void *view, void *message, | 949 | be_drag_message (void *view, void *message, |
| 950 | void (*block_input_function) (void), | 950 | void (*block_input_function) (void), |
| 951 | void (*unblock_input_function) (void), | 951 | void (*unblock_input_function) (void), |
| 952 | void (*process_pending_signals_function) (void)); | 952 | void (*process_pending_signals_function) (void), |
| 953 | bool (*should_quit_function) (void)); | ||
| 953 | 954 | ||
| 954 | #ifdef __cplusplus | 955 | #ifdef __cplusplus |
| 955 | extern void * | 956 | extern void * |
diff --git a/src/haikuselect.c b/src/haikuselect.c index 8192a1ad5b9..21407eedf0e 100644 --- a/src/haikuselect.c +++ b/src/haikuselect.c | |||
| @@ -506,6 +506,12 @@ haiku_lisp_to_message (Lisp_Object obj, void *message) | |||
| 506 | CHECK_LIST_END (tem, obj); | 506 | CHECK_LIST_END (tem, obj); |
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | static bool | ||
| 510 | haiku_should_quit_drag (void) | ||
| 511 | { | ||
| 512 | return !NILP (Vquit_flag); | ||
| 513 | } | ||
| 514 | |||
| 509 | DEFUN ("haiku-drag-message", Fhaiku_drag_message, Shaiku_drag_message, | 515 | DEFUN ("haiku-drag-message", Fhaiku_drag_message, Shaiku_drag_message, |
| 510 | 2, 2, 0, | 516 | 2, 2, 0, |
| 511 | doc: /* Begin dragging MESSAGE from FRAME. | 517 | doc: /* Begin dragging MESSAGE from FRAME. |
| @@ -530,6 +536,7 @@ drag will originate. */) | |||
| 530 | specpdl_ref idx; | 536 | specpdl_ref idx; |
| 531 | void *be_message; | 537 | void *be_message; |
| 532 | struct frame *f; | 538 | struct frame *f; |
| 539 | bool rc; | ||
| 533 | 540 | ||
| 534 | idx = SPECPDL_INDEX (); | 541 | idx = SPECPDL_INDEX (); |
| 535 | f = decode_window_system_frame (frame); | 542 | f = decode_window_system_frame (frame); |
| @@ -541,11 +548,15 @@ drag will originate. */) | |||
| 541 | 548 | ||
| 542 | record_unwind_protect_ptr (BMessage_delete, be_message); | 549 | record_unwind_protect_ptr (BMessage_delete, be_message); |
| 543 | haiku_lisp_to_message (message, be_message); | 550 | haiku_lisp_to_message (message, be_message); |
| 544 | be_drag_message (FRAME_HAIKU_VIEW (f), be_message, | 551 | rc = be_drag_message (FRAME_HAIKU_VIEW (f), be_message, |
| 545 | block_input, unblock_input, | 552 | block_input, unblock_input, |
| 546 | process_pending_signals); | 553 | process_pending_signals, |
| 554 | haiku_should_quit_drag); | ||
| 547 | FRAME_DISPLAY_INFO (f)->grabbed = 0; | 555 | FRAME_DISPLAY_INFO (f)->grabbed = 0; |
| 548 | 556 | ||
| 557 | if (rc) | ||
| 558 | quit (); | ||
| 559 | |||
| 549 | return unbind_to (idx, Qnil); | 560 | return unbind_to (idx, Qnil); |
| 550 | } | 561 | } |
| 551 | 562 | ||