Function: ghostel-mouse-press-or-copy-mode

ghostel-mouse-press-or-copy-mode is an interactive and natively compiled function defined in ghostel.el.

Signature

(ghostel-mouse-press-or-copy-mode EVENT)

Documentation

Forward EVENT to the terminal, or hand off to mouse-drag-region.

When terminal input consumes the press, forwards it to the program. Otherwise, active focus-only clicks are consumed before Emacs can move point; interaction clicks hand off to mouse-drag-region. Records in ghostel--mouse-press-was-selected whether the window was already selected, in an already-focused frame, before focusing it, for ghostel-mouse-release-or-set-point.

Key Bindings

ghostel-mode-map <down-mouse-1>

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel-mouse-press-or-copy-mode (event)
  "Forward EVENT to the terminal, or hand off to `mouse-drag-region'.
When terminal input consumes the press, forwards it to the program.
Otherwise, active focus-only clicks are consumed before Emacs can move
point; interaction clicks hand off to `mouse-drag-region'.  Records in
`ghostel--mouse-press-was-selected' whether the window was already
selected, in an already-focused frame, before focusing it, for
`ghostel-mouse-release-or-set-point'."
  (interactive "e")
  (let* ((win (posn-window (event-start event)))
         (frame (window-frame win))
         ;; First press since the frame gained focus, or press dispatched
         ;; before the focus-in (nil, not `unknown'): a focus click.
         (refocused (or (frame-parameter frame 'ghostel--frame-refocused)
                        (null (frame-focus-state frame)))))
    (set-frame-parameter frame 'ghostel--frame-refocused nil)

    (setq ghostel--mouse-press-was-selected
          (and (eq win (selected-window)) (not refocused)))
    (select-window win)
    (let ((active (and ghostel-mouse-drag-input-mode
                       (eq ghostel--input-mode 'semi-char))))
      (unless (or (ghostel--mouse-press event)
                  (and active (not ghostel--mouse-press-was-selected)))
        ;; Do not call `mouse-drag-region' for focus-only clicks: it may
        ;; move point while preparing click/drag handling.
        ;; `mouse-drag-region' activates the mark mid-drag; the release
        ;; handler picks the input mode.  `ghostel--mark-activated' ignores
        ;; activations made under the mouse handlers, so the hook stays out of it.
        (mouse-drag-region event)))))