Make sure we don’t set point just because there is a click in an inactive window
This commit is contained in:
parent
9f95dc62cc
commit
4737acaad0
27
lisp/gp-mouse.el
Normal file
27
lisp/gp-mouse.el
Normal file
@ -0,0 +1,27 @@
|
||||
;;; gp-mouse --- Extra mouse functionality
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(require 'mouse)
|
||||
|
||||
(defun gpolonkai/event-in-current-window-p (event)
|
||||
"Check if EVENT happened in the current window."
|
||||
(let ((current-window (selected-window))
|
||||
(event-window (posn-window (event-start event))))
|
||||
(eq current-window event-window)))
|
||||
|
||||
(defun gpolonkai/mouse-set-point (click &optional promote-to-region)
|
||||
"Set mouse position.
|
||||
|
||||
If CLICK happened in an inactive window, select that window without setting point"
|
||||
(interactive "e\np")
|
||||
(if (gpolonkai/event-in-current-window-p click)
|
||||
(call-interactively 'mouse-set-point)
|
||||
(call-interactively 'mouse-select-window)))
|
||||
|
||||
(global-set-key [mouse-1] 'mouse-select-window-or-set-point)
|
||||
(global-unset-key [down-mouse-1])
|
||||
|
||||
(provide 'gp-mouse)
|
||||
;;; gp-mouse.el ends here
|
Loading…
Reference in New Issue
Block a user