aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2025-02-12 15:49:12 +0800
committerPo Lu2025-02-12 15:51:39 +0800
commitfa4260594fd2aae1c7d3e829b3cb15e344bc25ff (patch)
tree34f13502c6a5272f1e15dfb0dfe4a21356d8506b
parentaade1b707c6b4932ed023f387d49324c6a7123eb (diff)
downloademacs-fa4260594fd2aae1c7d3e829b3cb15e344bc25ff.tar.gz
emacs-fa4260594fd2aae1c7d3e829b3cb15e344bc25ff.zip
X11 drag-and-drop corrections
* lisp/x-dnd.el (x-dnd-handle-drag-n-drop-event): Take cdddr of client-message, skipping the selection information. (x-dnd-do-direct-save): Do not erase the local copy of a remote file if it was not in fact copied on behalf of the recipient. (x-dnd-handle-xds-drop): Return proper action. * src/xterm.c (x_term_init): Remove unused variable on non-GTK builds.
-rw-r--r--lisp/x-dnd.el79
-rw-r--r--src/xterm.c2
2 files changed, 44 insertions, 37 deletions
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index fc48a8290f3..760dd0a42bf 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -469,13 +469,15 @@ Currently XDND, Motif and old KDE 1.x protocols are recognized."
469 (progn 469 (progn
470 (let ((action (cdr (assoc (symbol-name (cadr client-message)) 470 (let ((action (cdr (assoc (symbol-name (cadr client-message))
471 x-dnd-xdnd-to-action))) 471 x-dnd-xdnd-to-action)))
472 (targets (cddr client-message)) 472 (targets (cdddr client-message))
473 (local-value (nth 2 client-message))) 473 (local-value (nth 2 client-message)))
474 (when (windowp window) 474 (when (windowp window)
475 (select-window window)) 475 (select-window window))
476 (x-dnd-save-state window nil nil 476 ;; Remove XdndDirectSave0 from this list--Emacs does not
477 (apply #'vector targets)) 477 ;; support this protocol for internal drops.
478 (x-dnd-maybe-call-test-function window action) 478 (setq targets (delete 'XdndDirectSave0 targets))
479 (x-dnd-save-state window nil nil (apply #'vector targets))
480 (x-dnd-maybe-call-test-function window action nil)
479 (unwind-protect 481 (unwind-protect
480 (x-dnd-drop-data event (if (framep window) window 482 (x-dnd-drop-data event (if (framep window) window
481 (window-frame window)) 483 (window-frame window))
@@ -1542,43 +1544,46 @@ was taken, or the direct save failed."
1542 (x-dnd-use-offix-drop nil) 1544 (x-dnd-use-offix-drop nil)
1543 (x-dnd-use-unsupported-drop nil) 1545 (x-dnd-use-unsupported-drop nil)
1544 (prop-deleted nil) 1546 (prop-deleted nil)
1547 (action nil)
1545 encoded-name) 1548 encoded-name)
1546 (unwind-protect 1549 (unwind-protect
1547 (progn 1550 (setq action
1548 (when (file-remote-p file) 1551 (progn
1549 (setq file-name (file-local-copy file)) 1552 (when (file-remote-p file)
1550 (setq dnd-last-dragged-remote-file file-name) 1553 (setq file-name (file-local-copy file))
1551 (add-hook 'kill-emacs-hook 1554 (setq dnd-last-dragged-remote-file file-name)
1552 #'dnd-remove-last-dragged-remote-file)) 1555 (add-hook 'kill-emacs-hook
1553 (setq encoded-name 1556 #'dnd-remove-last-dragged-remote-file))
1554 (encode-coding-string name 1557 (setq encoded-name
1555 (or file-name-coding-system 1558 (encode-coding-string name
1556 default-file-name-coding-system))) 1559 (or file-name-coding-system
1557 (setq x-dnd-xds-current-file file-name) 1560 default-file-name-coding-system)))
1558 (x-change-window-property "XdndDirectSave0" encoded-name 1561 (setq x-dnd-xds-current-file file-name)
1559 frame "text/plain" 8 nil) 1562 (x-change-window-property "XdndDirectSave0" encoded-name
1560 (gui-set-selection 'XdndSelection (concat "file://" file-name)) 1563 frame "text/plain" 8 nil)
1561 ;; FIXME: this does not work with GTK file managers, since 1564 (gui-set-selection 'XdndSelection (concat "file://" file-name))
1562 ;; they always reach for `text/uri-list' first, contrary to 1565 ;; FIXME: this does not work with GTK file managers,
1563 ;; the spec. 1566 ;; since they always reach for `text/uri-list' first,
1564 (let ((action (x-begin-drag '("XdndDirectSave0" "text/uri-list" 1567 ;; contrary to the spec.
1565 "application/octet-stream") 1568 (let ((action (x-begin-drag '("XdndDirectSave0" "text/uri-list"
1566 'XdndActionDirectSave 1569 "application/octet-stream")
1567 frame nil allow-same-frame))) 1570 'XdndActionDirectSave
1568 (if (not x-dnd-xds-performed) 1571 frame nil allow-same-frame)))
1569 action 1572 (if (not x-dnd-xds-performed)
1570 (let ((property (x-window-property "XdndDirectSave0" frame 1573 action
1571 "AnyPropertyType" nil t))) 1574 (let ((property (x-window-property "XdndDirectSave0" frame
1572 (setq prop-deleted t) 1575 "AnyPropertyType" nil t)))
1573 ;; "System-G" deletes the property upon success. 1576 (setq prop-deleted t)
1574 (and (or (null property) 1577 ;; "System-G" deletes the property upon success.
1575 (and (stringp property) 1578 (and (or (null property)
1576 (not (equal property "")))) 1579 (and (stringp property)
1577 action))))) 1580 (not (equal property ""))))
1581 action))))))
1578 (unless prop-deleted 1582 (unless prop-deleted
1579 (x-delete-window-property "XdndDirectSave0" frame)) 1583 (x-delete-window-property "XdndDirectSave0" frame))
1580 ;; Delete any remote copy that was made. 1584 ;; Delete any remote copy that was made.
1581 (when (not (equal file-name original-file-name)) 1585 (when (and (not (equal file-name original-file-name))
1586 x-dnd-xds-performed)
1582 (delete-file file-name))))) 1587 (delete-file file-name)))))
1583 1588
1584(defun x-dnd-save-direct (need-name filename) 1589(defun x-dnd-save-direct (need-name filename)
@@ -1717,7 +1722,7 @@ VERSION is the version of the XDND protocol understood by SOURCE."
1717 (if (or (not success) 1722 (if (or (not success)
1718 (< version 5)) 1723 (< version 5))
1719 0 1724 0
1720 "XdndDirectSave0"))))))) 1725 "XdndActionDirectSave")))))))
1721 1726
1722;; Internal wheel movement. 1727;; Internal wheel movement.
1723 1728
diff --git a/src/xterm.c b/src/xterm.c
index 0a877e9edf9..c3047c4098b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -30591,7 +30591,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
30591 30591
30592 block_input (); 30592 block_input ();
30593 30593
30594#ifdef USE_GTK
30594 bool was_initialized = x_initialized; 30595 bool was_initialized = x_initialized;
30596#endif /* USE_GTK */
30595 if (!x_initialized) 30597 if (!x_initialized)
30596 { 30598 {
30597 x_initialize (); 30599 x_initialize ();