diff --git a/lisp/gp-mouse.el b/lisp/gp-mouse.el new file mode 100644 index 0000000..a943071 --- /dev/null +++ b/lisp/gp-mouse.el @@ -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