emacs-diffs
[Top][All Lists]
Advanced

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

master f229710d41: Implement new DND features on GNUstep


From: Po Lu
Subject: master f229710d41: Implement new DND features on GNUstep
Date: Sat, 2 Apr 2022 21:59:36 -0400 (EDT)

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

    Implement new DND features on GNUstep
    
    * lisp/term/ns-win.el (ns-drag-n-drop): Handle special `lambda'
    drag-n-drop events.
    * src/nsterm.m: ([EmacsView wantsPeriodicDraggingUpdates]):
    ([EmacsView draggingUpdated:]): New functions.
---
 lisp/term/ns-win.el | 41 ++++++++++++++++++++++-------------------
 src/nsterm.m        | 31 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index da6c5adee2..065ca235b4 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -508,25 +508,28 @@ unless the current buffer is a scratch buffer."
 Switch to a buffer editing the last file dropped, or insert the
 string dropped into the current buffer."
   (interactive "e")
-  (let* ((window (posn-window (event-start event)))
-         (arg (car (cdr (cdr event))))
-         (type (car arg))
-         (operations (car (cdr arg)))
-         (objects (cdr (cdr arg)))
-         (string (mapconcat 'identity objects "\n")))
-    (set-frame-selected-window nil window)
-    (raise-frame)
-    (setq window (selected-window))
-    (cond ((or (memq 'ns-drag-operation-generic operations)
-               (memq 'ns-drag-operation-copy operations))
-           ;; Perform the default/copy action.
-           (dolist (data objects)
-             (dnd-handle-one-url window 'private (if (eq type 'file)
-                                                     (concat "file:" data)
-                                                   data))))
-          (t
-           ;; Insert the text as is.
-           (dnd-insert-text window 'private string)))))
+  (if (eq (car-safe (cdr-safe (cdr-safe event))) 'lambda)
+      (dnd-handle-movement (event-start event))
+    (let* ((window (posn-window (event-start event)))
+           (arg (car (cdr (cdr event))))
+           (type (car arg))
+           (operations (car (cdr arg)))
+           (objects (cdr (cdr arg)))
+           (string (mapconcat 'identity objects "\n")))
+      (set-frame-selected-window nil window)
+      (raise-frame)
+      (setq window (selected-window))
+      (goto-char (posn-point (event-start event)))
+      (cond ((or (memq 'ns-drag-operation-generic operations)
+                 (memq 'ns-drag-operation-copy operations))
+             ;; Perform the default/copy action.
+             (dolist (data objects)
+               (dnd-handle-one-url window 'private (if (eq type 'file)
+                                                       (concat "file:" data)
+                                                     data))))
+            (t
+             ;; Insert the text as is.
+             (dnd-insert-text window 'private string))))))
 
 (global-set-key [drag-n-drop] 'ns-drag-n-drop)
 
diff --git a/src/nsterm.m b/src/nsterm.m
index fd56094c28..f4c1e08925 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8056,6 +8056,37 @@ not_in_argv (NSString *arg)
   return YES;
 }
 
+- (BOOL) wantsPeriodicDraggingUpdates
+{
+  return YES;
+}
+
+- (NSDragOperation) draggingUpdated: (id <NSDraggingInfo>) sender
+{
+  struct input_event ie;
+  NSPoint position;
+  int x, y;
+
+  EVENT_INIT (ie);
+  ie.kind = DRAG_N_DROP_EVENT;
+
+  /* Get rid of mouse face.  */
+  [self mouseExited: [[self window] currentEvent]];
+
+  position = [self convertPoint: [sender draggingLocation]
+                      fromView: nil];
+  x = lrint (position.x);
+  y = lrint (position.y);
+
+  XSETINT (ie.x, x);
+  XSETINT (ie.y, y);
+  XSETFRAME (ie.frame_or_window, emacsframe);
+  ie.arg = Qlambda;
+  ie.modifiers = 0;
+
+  kbd_buffer_store_event (&ie);
+  return NSDragOperationGeneric;
+}
 
 -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
 {



reply via email to

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