From f736bfa4e4c934affd3218c59541a1ed4ad061f7 Mon Sep 17 00:00:00 2001 From: David Botton Date: Thu, 22 Aug 2024 07:21:54 -0400 Subject: [PATCH] fix drag issue on multiple windows with selected text at same time --- source/clog-gui.lisp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/source/clog-gui.lisp b/source/clog-gui.lisp index 2aa57ee..bda8289 100644 --- a/source/clog-gui.lisp +++ b/source/clog-gui.lisp @@ -989,7 +989,6 @@ The on-window-change clog-obj received is the new window")) (defun on-gui-drag-down (obj data) "Handle mouse down on drag items" (let ((app (connection-data-item obj "clog-gui"))) - (setf (in-drag app) (attribute obj "data-drag-type")) (handler-case (let* ((target (gethash (attribute obj "data-drag-obj") (windows app))) (pointer-x (getf data ':screen-x)) @@ -999,6 +998,9 @@ The on-window-change clog-obj received is the new window")) (perform-drag nil)) (when target (setf (drag-obj app) target) + (unless (keep-on-top (drag-obj app)) + (setf (z-index (drag-obj app)) (incf (last-z app)))) + (setf (in-drag app) (attribute obj "data-drag-type")) (cond ((equalp (in-drag app) "m") (setf obj-top (js-to-integer (top (drag-obj app)))) @@ -1011,18 +1013,22 @@ The on-window-change clog-obj received is the new window")) (setf perform-drag (fire-on-window-can-size (drag-obj app)))) (t (format t "Warning - invalid data-drag-type attribute"))) - (unless (keep-on-top (drag-obj app)) - (setf (z-index (drag-obj app)) (incf (last-z app)))) (fire-on-window-change (drag-obj app) app) (setf (drag-y app) (- pointer-y obj-top)) - (setf (drag-x app) (- pointer-x obj-left))) - (cond (perform-drag - (set-on-pointer-move obj 'on-gui-drag-move) - (set-on-pointer-cancel obj 'on-gui-drag-stop) - (set-on-pointer-up obj 'on-gui-drag-stop)) - (t - (setf (in-drag app) nil)))) - (error () nil)))) + (setf (drag-x app) (- pointer-x obj-left)) + (cond (perform-drag + (set-on-pointer-move obj 'on-gui-drag-move) + (set-on-pointer-cancel obj + (lambda (obj data) + (setf (getf data ':screen-x) pointer-x) + (setf (getf data ':screen-y) pointer-y) + (on-gui-drag-stop obj data))) + (set-on-pointer-up obj 'on-gui-drag-stop)) + (t + (setf (in-drag app) nil))))) + (error () + (setf (in-drag app) nil))))) + ;;;;;;;;;;;;;;;;;;;;;; ;; on-gui-drag-move ;; ;;;;;;;;;;;;;;;;;;;;;;