From 62309496676072b5bc633476f63c340ae10e5dc2 Mon Sep 17 00:00:00 2001 From: MagicRB Date: Wed, 4 Oct 2023 15:14:56 +0200 Subject: [PATCH] Disable window switching by mouse Signed-off-by: MagicRB --- emacs-lisp/windows_and_frames.org | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/emacs-lisp/windows_and_frames.org b/emacs-lisp/windows_and_frames.org index 0a6fe7c..478f720 100644 --- a/emacs-lisp/windows_and_frames.org +++ b/emacs-lisp/windows_and_frames.org @@ -9,3 +9,24 @@ (add-to-list 'default-frame-alist '(alpha-background . 80)) #+end_src +Disable window changing using the mouse, it saves me from accidental switches. + +#+begin_src emacs-lisp + (defun cv/mouse-set-point (fun event &optional promote) + (let ((window (car (car (cdr event))))) + (when (equal window (selected-window)) + (funcall fun event promote)))) + (advice-add 'mouse-set-point :around 'cv/mouse-set-point) + + (defun cv/mouse-drag-region (fun event) + (let ((window (car (car (cdr event))))) + (when (equal window (selected-window)) + (funcall fun event)))) + (advice-add 'mouse-drag-region :around 'cv/mouse-drag-region) + + (defun cv/mouse-set-region (fun event) + (let ((window (car (car (cdr event))))) + (when (equal window (selected-window)) + (funcall fun event)))) + (advice-add 'mouse-set-region :around 'cv/mouse-set-region) +#+end_src