diff options
| author | Po Lu | 2022-04-05 00:54:03 +0000 |
|---|---|---|
| committer | Po Lu | 2022-04-05 00:54:03 +0000 |
| commit | 1e1a66831bf1d8ca33b3ad37d23211fa98d92e63 (patch) | |
| tree | bf2e05c9bac5b72f1bab68ab15738649b3e75467 | |
| parent | 74100997b3853a6c00c60e1998ed5a86a9a01bc3 (diff) | |
| download | emacs-1e1a66831bf1d8ca33b3ad37d23211fa98d92e63.tar.gz emacs-1e1a66831bf1d8ca33b3ad37d23211fa98d92e63.zip | |
Respect new DND options when dragging to ourselves on Haiku
* lisp/mouse.el (mouse-drag-and-drop-region): Allow dragging to
the current frame if we know `return-frame' doesn't work.
* lisp/term/haiku-win.el (haiku-dnd-drag-handler): New function.
* src/haiku_support.cc (MouseMoved): Don't send drag motion
events for the drag frame.
* src/haikuselect.c (haiku_note_drag_motion_1)
(haiku_note_drag_motion_2, haiku_note_drag_motion): New
functions.
(syms_of_haikuselect): New variable `haiku-drag-track-function'.
* src/haikuterm.c (haiku_read_socket): Note mouse motion in that
case.q
* src/haikuterm.h: Update prototypes.
| -rw-r--r-- | lisp/mouse.el | 7 | ||||
| -rw-r--r-- | lisp/term/haiku-win.el | 15 | ||||
| -rw-r--r-- | src/haiku_support.cc | 14 | ||||
| -rw-r--r-- | src/haikuselect.c | 28 | ||||
| -rw-r--r-- | src/haikuterm.c | 3 | ||||
| -rw-r--r-- | src/haikuterm.h | 1 |
6 files changed, 65 insertions, 3 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 26a17365da2..b66cfad4878 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -3190,7 +3190,12 @@ is copied instead of being cut." | |||
| 3190 | (if mouse-drag-and-drop-region-cut-when-buffers-differ | 3190 | (if mouse-drag-and-drop-region-cut-when-buffers-differ |
| 3191 | 'XdndActionMove | 3191 | 'XdndActionMove |
| 3192 | 'XdndActionCopy) | 3192 | 'XdndActionCopy) |
| 3193 | (posn-window (event-end event)) 'now) | 3193 | (posn-window (event-end event)) 'now |
| 3194 | ;; On platforms where we know | ||
| 3195 | ;; `return-frame' doesn't | ||
| 3196 | ;; work, allow dropping on | ||
| 3197 | ;; the drop frame. | ||
| 3198 | (eq window-system 'haiku)) | ||
| 3194 | (quit nil)))) | 3199 | (quit nil)))) |
| 3195 | (when (framep drag-action-or-frame) | 3200 | (when (framep drag-action-or-frame) |
| 3196 | ;; With some window managers `x-begin-drag' | 3201 | ;; With some window managers `x-begin-drag' |
diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el index 5b4ef0aaef8..fd0b68b5fcb 100644 --- a/lisp/term/haiku-win.el +++ b/lisp/term/haiku-win.el | |||
| @@ -277,6 +277,21 @@ This is necessary because on Haiku `use-system-tooltip' doesn't | |||
| 277 | take effect on menu items until the menu bar is updated again." | 277 | take effect on menu items until the menu bar is updated again." |
| 278 | (force-mode-line-update t)) | 278 | (force-mode-line-update t)) |
| 279 | 279 | ||
| 280 | ;; Note that `mouse-position' can't return the actual frame the mouse | ||
| 281 | ;; pointer is under, so this only works for the frame where the drop | ||
| 282 | ;; started. | ||
| 283 | (defun haiku-dnd-drag-handler () | ||
| 284 | "Handle mouse movement during drag-and-drop." | ||
| 285 | (let ((track-mouse 'drag-source) | ||
| 286 | (mouse-position (mouse-pixel-position))) | ||
| 287 | (when (car mouse-position) | ||
| 288 | (dnd-handle-movement (posn-at-x-y (cadr mouse-position) | ||
| 289 | (cddr mouse-position) | ||
| 290 | (car mouse-position))) | ||
| 291 | (redisplay)))) | ||
| 292 | |||
| 293 | (setq haiku-drag-track-function #'haiku-dnd-drag-handler) | ||
| 294 | |||
| 280 | (defun x-begin-drag (targets &optional action frame _return-frame allow-current-frame) | 295 | (defun x-begin-drag (targets &optional action frame _return-frame allow-current-frame) |
| 281 | "SKIP: real doc in xfns.c." | 296 | "SKIP: real doc in xfns.c." |
| 282 | (unless haiku-dnd-selection-value | 297 | (unless haiku-dnd-selection-value |
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 40112e2b717..830255d3f07 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc | |||
| @@ -1524,13 +1524,23 @@ public: | |||
| 1524 | MouseMoved (BPoint point, uint32 transit, const BMessage *drag_msg) | 1524 | MouseMoved (BPoint point, uint32 transit, const BMessage *drag_msg) |
| 1525 | { | 1525 | { |
| 1526 | struct haiku_mouse_motion_event rq; | 1526 | struct haiku_mouse_motion_event rq; |
| 1527 | int32 windowid; | ||
| 1528 | EmacsWindow *window; | ||
| 1527 | 1529 | ||
| 1530 | window = (EmacsWindow *) Window (); | ||
| 1528 | rq.just_exited_p = transit == B_EXITED_VIEW; | 1531 | rq.just_exited_p = transit == B_EXITED_VIEW; |
| 1529 | rq.x = point.x; | 1532 | rq.x = point.x; |
| 1530 | rq.y = point.y; | 1533 | rq.y = point.y; |
| 1531 | rq.window = this->Window (); | 1534 | rq.window = window; |
| 1532 | rq.time = system_time (); | 1535 | rq.time = system_time (); |
| 1533 | rq.dnd_message = drag_msg != NULL; | 1536 | |
| 1537 | if (drag_msg && (drag_msg->IsSourceRemote () | ||
| 1538 | || drag_msg->FindInt32 ("emacs:window_id", | ||
| 1539 | &windowid) != B_OK | ||
| 1540 | || windowid != window->window_id)) | ||
| 1541 | rq.dnd_message = true; | ||
| 1542 | else | ||
| 1543 | rq.dnd_message = false; | ||
| 1534 | 1544 | ||
| 1535 | if (ToolTip ()) | 1545 | if (ToolTip ()) |
| 1536 | ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), | 1546 | ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), |
diff --git a/src/haikuselect.c b/src/haikuselect.c index f6199ccc1e7..c3053688f5a 100644 --- a/src/haikuselect.c +++ b/src/haikuselect.c | |||
| @@ -791,6 +791,28 @@ ignored if it is dropped on top of FRAME. */) | |||
| 791 | return unbind_to (idx, Qnil); | 791 | return unbind_to (idx, Qnil); |
| 792 | } | 792 | } |
| 793 | 793 | ||
| 794 | static Lisp_Object | ||
| 795 | haiku_note_drag_motion_1 (void *data) | ||
| 796 | { | ||
| 797 | if (!NILP (Vhaiku_drag_track_function)) | ||
| 798 | return call0 (Vhaiku_drag_track_function); | ||
| 799 | |||
| 800 | return Qnil; | ||
| 801 | } | ||
| 802 | |||
| 803 | static Lisp_Object | ||
| 804 | haiku_note_drag_motion_2 (enum nonlocal_exit exit, Lisp_Object error) | ||
| 805 | { | ||
| 806 | return Qnil; | ||
| 807 | } | ||
| 808 | |||
| 809 | void | ||
| 810 | haiku_note_drag_motion (void) | ||
| 811 | { | ||
| 812 | internal_catch_all (haiku_note_drag_motion_1, NULL, | ||
| 813 | haiku_note_drag_motion_2); | ||
| 814 | } | ||
| 815 | |||
| 794 | void | 816 | void |
| 795 | syms_of_haikuselect (void) | 817 | syms_of_haikuselect (void) |
| 796 | { | 818 | { |
| @@ -800,6 +822,12 @@ Otherwise, an error will be signalled if adding a file reference to a | |||
| 800 | system message failed. */); | 822 | system message failed. */); |
| 801 | haiku_signal_invalid_refs = true; | 823 | haiku_signal_invalid_refs = true; |
| 802 | 824 | ||
| 825 | DEFVAR_LISP ("haiku-drag-track-function", Vhaiku_drag_track_function, | ||
| 826 | doc: /* If non-nil, a function to call upon mouse movement while dragging a message. | ||
| 827 | The function is called without any arguments. `mouse-position' can be | ||
| 828 | used to retrieve the current position of the mouse. */); | ||
| 829 | Vhaiku_drag_track_function = Qnil; | ||
| 830 | |||
| 803 | DEFSYM (QSECONDARY, "SECONDARY"); | 831 | DEFSYM (QSECONDARY, "SECONDARY"); |
| 804 | DEFSYM (QCLIPBOARD, "CLIPBOARD"); | 832 | DEFSYM (QCLIPBOARD, "CLIPBOARD"); |
| 805 | DEFSYM (QSTRING, "STRING"); | 833 | DEFSYM (QSTRING, "STRING"); |
diff --git a/src/haikuterm.c b/src/haikuterm.c index e2d6a9a4670..1270fba4101 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c | |||
| @@ -3155,6 +3155,9 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) | |||
| 3155 | XSETINT (inev.y, b->y); | 3155 | XSETINT (inev.y, b->y); |
| 3156 | XSETFRAME (inev.frame_or_window, f); | 3156 | XSETFRAME (inev.frame_or_window, f); |
| 3157 | } | 3157 | } |
| 3158 | else | ||
| 3159 | haiku_note_drag_motion (); | ||
| 3160 | |||
| 3158 | break; | 3161 | break; |
| 3159 | } | 3162 | } |
| 3160 | } | 3163 | } |
diff --git a/src/haikuterm.h b/src/haikuterm.h index 5f8052f0f99..8f311b2ab12 100644 --- a/src/haikuterm.h +++ b/src/haikuterm.h | |||
| @@ -293,6 +293,7 @@ extern void haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel); | |||
| 293 | extern Lisp_Object haiku_menu_show (struct frame *f, int x, int y, int menu_flags, | 293 | extern Lisp_Object haiku_menu_show (struct frame *f, int x, int y, int menu_flags, |
| 294 | Lisp_Object title, const char **error_name); | 294 | Lisp_Object title, const char **error_name); |
| 295 | extern Lisp_Object haiku_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents); | 295 | extern Lisp_Object haiku_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents); |
| 296 | extern void haiku_note_drag_motion (void); | ||
| 296 | 297 | ||
| 297 | extern void initialize_frame_menubar (struct frame *f); | 298 | extern void initialize_frame_menubar (struct frame *f); |
| 298 | 299 | ||