]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement new DND options on Haiku
authorPo Lu <luangruo@yahoo.com>
Sun, 3 Apr 2022 01:26:32 +0000 (01:26 +0000)
committerPo Lu <luangruo@yahoo.com>
Sun, 3 Apr 2022 01:26:32 +0000 (01:26 +0000)
* 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
src/haiku_support.cc
src/haiku_support.h
src/haikuterm.c

index 810feced21279cb9bd15b74af89badbfc31eab19..5b4ef0aaef836ff27d04b0778cc8bedd95bf737a 100644 (file)
@@ -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)
index dd27d6317c506f687f11485f1686290687a5cae6..64556ba51b6ccacf129ba6cee9ddff2c7ea343a4 100644 (file)
@@ -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),
index ae3ad6a68a8ec6fe3083f17c024d84164038df7b..ac3029fbf3f45f9169b3f1e0c9ec7c820be0333a 100644 (file)
@@ -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
index 304b7a3425586ebd97859db853af12cf7c1af562..cdddf50d19d1b1a3dbc2b1018d0be2a7be41d202 100644 (file)
@@ -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))