emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e9d4f119da: Implement new DND options on Haiku


From: Po Lu
Subject: master e9d4f119da: Implement new DND options on Haiku
Date: Sat, 2 Apr 2022 21:29:48 -0400 (EDT)

branch: master
commit e9d4f119da48fe119d9d7a6d1b9a054c043bd517
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Implement new DND options on Haiku
    
    * lisp/term/haiku-win.el (haiku-drag-and-drop): Handle special
    drag and drop motion events.
    * src/haiku_support.cc (MouseMoved): Set `dnd_message' flag.
    * src/haiku_support.h (struct haiku_mouse_motion_event): New
    member `dnd_message'.
    * src/haikuterm.c (haiku_read_socket): Create special DND events
    when the mouse moves with a drop message.
---
 lisp/term/haiku-win.el | 37 ++++++++++++++++++++-----------------
 src/haiku_support.cc   |  1 +
 src/haiku_support.h    |  1 +
 src/haikuterm.c        | 21 ++++++++++++++++++---
 4 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el
index 810feced21..5b4ef0aaef 100644
--- a/lisp/term/haiku-win.el
+++ b/lisp/term/haiku-win.el
@@ -245,23 +245,26 @@ VALUE will be encoded as UTF-8 and stored under the type
   (interactive "e")
   (let* ((string (caddr event))
         (window (posn-window (event-start event))))
-    (cond
-     ((assoc "refs" string)
-      (with-selected-window window
-        (raise-frame)
-        (dolist (filename (cddr (assoc "refs" string)))
-          (dnd-handle-one-url window 'private
-                              (concat "file:" filename)))))
-     ((assoc "text/plain" string)
-      (with-selected-window window
-        (raise-frame)
-        (dolist (text (cddr (assoc "text/plain" string)))
-          (goto-char (posn-point (event-start event)))
-          (dnd-insert-text window 'private
-                           (if (multibyte-string-p text)
-                               text
-                             (decode-coding-string text 'undecided))))))
-     (t (message "Don't know how to drop any of: %s" (mapcar #'car string))))))
+    (if (eq string 'lambda) ; This means the mouse moved.
+        (dnd-handle-movement (event-start event))
+      (cond
+       ((assoc "refs" string)
+        (with-selected-window window
+          (raise-frame)
+          (dolist (filename (cddr (assoc "refs" string)))
+            (dnd-handle-one-url window 'private
+                                (concat "file:" filename)))))
+       ((assoc "text/plain" string)
+        (with-selected-window window
+          (raise-frame)
+          (dolist (text (cddr (assoc "text/plain" string)))
+            (goto-char (posn-point (event-start event)))
+            (dnd-insert-text window 'private
+                             (if (multibyte-string-p text)
+                                 text
+                               (decode-coding-string text 'undecided))))))
+       (t (message "Don't know how to drop any of: %s"
+                   (mapcar #'car string)))))))
 
 (define-key special-event-map [drag-n-drop]
             'haiku-drag-and-drop)
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index dd27d6317c..64556ba51b 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -1529,6 +1529,7 @@ public:
     rq.y = point.y;
     rq.window = this->Window ();
     rq.time = system_time ();
+    rq.dnd_message = drag_msg != NULL;
 
     if (ToolTip ())
       ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x),
diff --git a/src/haiku_support.h b/src/haiku_support.h
index ae3ad6a68a..ac3029fbf3 100644
--- a/src/haiku_support.h
+++ b/src/haiku_support.h
@@ -159,6 +159,7 @@ struct haiku_mouse_motion_event
   int x;
   int y;
   bigtime_t time;
+  bool dnd_message;
 };
 
 struct haiku_menu_bar_left_event
diff --git a/src/haikuterm.c b/src/haikuterm.c
index 304b7a3425..cdddf50d19 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -2970,6 +2970,7 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
            struct haiku_mouse_motion_event *b = buf;
            struct frame *f = haiku_mouse_or_wdesc_frame (b->window);
            Mouse_HLInfo *hlinfo = &x_display_list->mouse_highlight;
+           Lisp_Object frame;
 
            if (!f)
              continue;
@@ -2986,7 +2987,6 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
                break;
              }
 
-           Lisp_Object frame;
            XSETFRAME (frame, f);
 
            x_display_list->last_mouse_movement_time = b->time / 1000;
@@ -3102,8 +3102,8 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
                        && (!NILP (focus_follows_mouse)
                            || f == SELECTED_FRAME ()))
                      {
-                       inev.kind = SELECT_WINDOW_EVENT;
-                       inev.frame_or_window = window;
+                       inev2.kind = SELECT_WINDOW_EVENT;
+                       inev2.frame_or_window = window;
                      }
 
                    last_mouse_window = window;
@@ -3118,6 +3118,21 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
                if (!NILP (help_echo_string)
                    || !NILP (previous_help_echo_string))
                  do_help = 1;
+
+               if (b->dnd_message)
+                 {
+                   /* It doesn't make sense to show tooltips when
+                      another program is dragging stuff over us.  */
+
+                   do_help = -1;
+                   inev.kind = DRAG_N_DROP_EVENT;
+                   inev.arg = Qlambda;
+
+                   XSETINT (inev.x, b->x);
+                   XSETINT (inev.y, b->y);
+                   XSETFRAME (inev.frame_or_window, f);
+                   break;
+                 }
              }
 
            if (FRAME_DIRTY_P (f))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]