GNU bug report logs -
#19988
25.0.50; Drag events ending in different frame
Previous Next
Full log
View this message in rfc822 format
> Is there a reason why drag events cannot work across different frames of
> the very same Emacs instance?
They could but it's a bit tricky when frames overlap. And probably some
routines would have to be rewritten because they expect events to happen
on the selected frame.
> Background: I've written a command that uses drag events to swap buffers
> of two Emacs windows:
I'd rewrite it (sloppily) as follows:
(defun th/swap-window-buffers-by-dnd (drag-event)
"Swaps the buffers displayed in the DRAG-EVENT's start and end
window."
(interactive "e")
(let ((start-win (cl-caadr drag-event))
(end-win (cl-caaddr drag-event)))
(unless (window-live-p end-win)
(let* ((selected-frame (selected-frame))
(frames (delq selected-frame (frame-list)))
position frame window)
(unwind-protect
(catch 'found
(while frames
(select-frame (car frames))
(setq position (mouse-position))
(setq window (window-at (cadr position) (cddr position)))
(when (window-live-p window)
(setq end-win window)
(throw 'found t))
(setq frames (cdr frames))))
(select-frame selected-frame))))
(when (and (windowp start-win)
(windowp end-win)
(not (eq start-win end-win)))
(let ((bs (window-buffer start-win))
(be (window-buffer end-win)))
(set-window-buffer start-win be)
(set-window-buffer end-win bs)))))
(global-set-key (kbd "<C-S-drag-mouse-1>")
#'th/swap-window-buffers-by-dnd)
martin
This bug report was last modified 10 years and 156 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.