[Top][All Lists]

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

bug#19988: 25.0.50; Drag events ending in different frame

From: martin rudalics
Subject: bug#19988: 25.0.50; Drag events ending in different frame
Date: Wed, 04 Mar 2015 16:10:58 +0100

> 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
  (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)
            (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>")


reply via email to

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