From: Po Lu Date: Mon, 21 Mar 2022 09:00:38 +0000 (+0000) Subject: Minor fixes to Haiku DND support X-Git-Tag: emacs-29.0.90~1931^2~1016 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=efb76604c49c9277f8091da31aa75beb85e8c9fa;p=emacs.git 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. --- 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: struct haiku_drag_and_drop_event rq; if (msg->FindInt32 ("emacs:window_id", &windowid) == B_OK + && !msg->IsSourceRemote () && windowid == this->window_id) return; @@ -1449,7 +1450,7 @@ public: } void - MouseMoved (BPoint point, uint32 transit, const BMessage *msg) + MouseMoved (BPoint point, uint32 transit, const BMessage *drag_msg) { struct haiku_mouse_motion_event rq; @@ -1459,6 +1460,9 @@ public: rq.window = this->Window (); rq.time = system_time (); + if (drag_msg && transit != B_EXITED_VIEW) + return; + if (ToolTip ()) ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), -(point.y - tt_absl_pos.y))); @@ -3960,11 +3964,12 @@ be_drag_message_thread_entry (void *thread_data) return 0; } -void +bool be_drag_message (void *view, void *message, void (*block_input_function) (void), void (*unblock_input_function) (void), - void (*process_pending_signals_function) (void)) + void (*process_pending_signals_function) (void), + bool (*should_quit_function) (void)) { EmacsView *vw = (EmacsView *) view; EmacsWindow *window = (EmacsWindow *) vw->Window (); @@ -3995,7 +4000,7 @@ be_drag_message (void *view, void *message, unblock_input_function (); if (infos[1].object < B_OK) - return; + return false; block_input_function (); resume_thread (infos[1].object); @@ -4017,8 +4022,11 @@ be_drag_message (void *view, void *message, if (infos[0].events & B_EVENT_READ) process_pending_signals_function (); + if (should_quit_function ()) + return true; + if (infos[1].events & B_EVENT_INVALID) - return; + return false; infos[0].events = B_EVENT_READ; 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" extern void BMessage_delete (void *message); - extern void + extern bool be_drag_message (void *view, void *message, void (*block_input_function) (void), void (*unblock_input_function) (void), - void (*process_pending_signals_function) (void)); + void (*process_pending_signals_function) (void), + bool (*should_quit_function) (void)); #ifdef __cplusplus 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) CHECK_LIST_END (tem, obj); } +static bool +haiku_should_quit_drag (void) +{ + return !NILP (Vquit_flag); +} + DEFUN ("haiku-drag-message", Fhaiku_drag_message, Shaiku_drag_message, 2, 2, 0, doc: /* Begin dragging MESSAGE from FRAME. @@ -530,6 +536,7 @@ drag will originate. */) specpdl_ref idx; void *be_message; struct frame *f; + bool rc; idx = SPECPDL_INDEX (); f = decode_window_system_frame (frame); @@ -541,11 +548,15 @@ drag will originate. */) record_unwind_protect_ptr (BMessage_delete, be_message); haiku_lisp_to_message (message, be_message); - be_drag_message (FRAME_HAIKU_VIEW (f), be_message, - block_input, unblock_input, - process_pending_signals); + rc = be_drag_message (FRAME_HAIKU_VIEW (f), be_message, + block_input, unblock_input, + process_pending_signals, + haiku_should_quit_drag); FRAME_DISPLAY_INFO (f)->grabbed = 0; + if (rc) + quit (); + return unbind_to (idx, Qnil); }