aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2014-12-24 19:37:45 +0100
committerMartin Rudalics2014-12-24 19:37:45 +0100
commit350b30fa7ec0c374da6b015f4d8e31a62abe9fff (patch)
tree7fbccffbf9a82e00f919f9256afc5a55cc2728aa
parentf3be0025481f15717198befe557208614e513e92 (diff)
downloademacs-350b30fa7ec0c374da6b015f4d8e31a62abe9fff.tar.gz
emacs-350b30fa7ec0c374da6b015f4d8e31a62abe9fff.zip
Handle glitch in delayed autoselection of windows.
* window.el (mouse-autoselect-window-position-1): New variable. (mouse-autoselect-window-cancel) (mouse-autoselect-window-select, handle-select-window): With delayed autoselection select window only if mouse moves after selecting its frame.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/window.el41
2 files changed, 36 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0882a519f86..42b2fc474f9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12014-12-24 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (mouse-autoselect-window-position-1): New variable.
4 (mouse-autoselect-window-cancel)
5 (mouse-autoselect-window-select, handle-select-window): With
6 delayed autoselection select window only if mouse moves after
7 selecting its frame.
8
12014-12-24 Michael Albinus <michael.albinus@gmx.de> 92014-12-24 Michael Albinus <michael.albinus@gmx.de>
2 10
3 * eshell/esh-ext.el (eshell-find-interpreter): Expand relative 11 * eshell/esh-ext.el (eshell-find-interpreter): Expand relative
diff --git a/lisp/window.el b/lisp/window.el
index c95b0d6d418..cb9f1ed9b4c 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -7798,6 +7798,9 @@ With arg N, put point N/10 of the way from the true end."
7798(defvar mouse-autoselect-window-timer nil 7798(defvar mouse-autoselect-window-timer nil
7799 "Timer used by delayed window autoselection.") 7799 "Timer used by delayed window autoselection.")
7800 7800
7801(defvar mouse-autoselect-window-position-1 nil
7802 "First mouse position recorded by delayed window autoselection.")
7803
7801(defvar mouse-autoselect-window-position nil 7804(defvar mouse-autoselect-window-position nil
7802 "Last mouse position recorded by delayed window autoselection.") 7805 "Last mouse position recorded by delayed window autoselection.")
7803 7806
@@ -7822,6 +7825,7 @@ Optional argument FORCE means cancel unconditionally."
7822 (memq (nth 4 (event-end last-input-event)) 7825 (memq (nth 4 (event-end last-input-event))
7823 '(handle end-scroll))))) 7826 '(handle end-scroll)))))
7824 (setq mouse-autoselect-window-state nil) 7827 (setq mouse-autoselect-window-state nil)
7828 (setq mouse-autoselect-window-position-1 nil)
7825 (when (timerp mouse-autoselect-window-timer) 7829 (when (timerp mouse-autoselect-window-timer)
7826 (cancel-timer mouse-autoselect-window-timer)) 7830 (cancel-timer mouse-autoselect-window-timer))
7827 (remove-hook 'pre-command-hook 'mouse-autoselect-window-cancel))) 7831 (remove-hook 'pre-command-hook 'mouse-autoselect-window-cancel)))
@@ -7863,21 +7867,32 @@ is active. This function is run by `mouse-autoselect-window-timer'."
7863 ;; A menu / popup dialog is active or the mouse is not on the 7867 ;; A menu / popup dialog is active or the mouse is not on the
7864 ;; text region of WINDOW: Suspend autoselection temporarily. 7868 ;; text region of WINDOW: Suspend autoselection temporarily.
7865 (mouse-autoselect-window-start mouse-position nil t)) 7869 (mouse-autoselect-window-start mouse-position nil t))
7866 ((eq mouse-autoselect-window-state 'suspend) 7870 ((or (eq mouse-autoselect-window-state 'suspend)
7871 ;; When the mouse is at its first recorded position, restart
7872 ;; delayed autoselection. This works around a scenario with
7873 ;; two two-window frames with identic dimensions: Select the
7874 ;; first window of the first frame, switch to the second
7875 ;; frame, move the mouse to its second window, minimize the
7876 ;; second frame. Now the second window of the first frame
7877 ;; gets selected although the mouse never really "moved" into
7878 ;; that window.
7879 (and (numberp mouse-autoselect-window)
7880 (equal (mouse-position) mouse-autoselect-window-position-1)))
7867 ;; Delayed autoselection was temporarily suspended, reenable it. 7881 ;; Delayed autoselection was temporarily suspended, reenable it.
7868 (mouse-autoselect-window-start mouse-position)) 7882 (mouse-autoselect-window-start mouse-position))
7869 ((and window (not (eq window (selected-window))) 7883 ((and window (not (eq window (selected-window)))
7870 (or (not (numberp mouse-autoselect-window)) 7884 (or (not (numberp mouse-autoselect-window))
7871 (and (> mouse-autoselect-window 0) 7885 (and (>= mouse-autoselect-window 0)
7872 ;; If `mouse-autoselect-window' is positive, select 7886 ;; If `mouse-autoselect-window' is non-negative,
7873 ;; window if the window is the same as before. 7887 ;; select window if it's the same as before.
7874 (eq window mouse-autoselect-window-window)) 7888 (eq window mouse-autoselect-window-window))
7875 ;; Otherwise select window if the mouse is at the same 7889 ;; Otherwise select window iff the mouse is at the same
7876 ;; position as before. Observe that the first test after 7890 ;; position as before. Observe that the first test
7877 ;; starting autoselection usually fails since the value of 7891 ;; after starting autoselection usually fails since the
7878 ;; `mouse-autoselect-window-position' recorded there is the 7892 ;; value of `mouse-autoselect-window-position' recorded
7879 ;; position where the mouse has entered the new window and 7893 ;; there is the position where the mouse has entered the
7880 ;; not necessarily where the mouse has stopped moving. 7894 ;; new window and not necessarily where the mouse has
7895 ;; stopped moving.
7881 (equal mouse-position mouse-autoselect-window-position)) 7896 (equal mouse-position mouse-autoselect-window-position))
7882 ;; The minibuffer is a candidate window if it's active. 7897 ;; The minibuffer is a candidate window if it's active.
7883 (or (not (window-minibuffer-p window)) 7898 (or (not (window-minibuffer-p window))
@@ -7921,14 +7936,14 @@ is active. This function is run by `mouse-autoselect-window-timer'."
7921 (not (minibuffer-window-active-p window))) 7936 (not (minibuffer-window-active-p window)))
7922 ;; Don't switch when autoselection shall be delayed. 7937 ;; Don't switch when autoselection shall be delayed.
7923 (and (numberp mouse-autoselect-window) 7938 (and (numberp mouse-autoselect-window)
7924 (not (zerop mouse-autoselect-window))
7925 (not (eq mouse-autoselect-window-state 'select)) 7939 (not (eq mouse-autoselect-window-state 'select))
7926 (progn 7940 (let ((position (mouse-position)))
7927 ;; Cancel any delayed autoselection. 7941 ;; Cancel any delayed autoselection.
7928 (mouse-autoselect-window-cancel t) 7942 (mouse-autoselect-window-cancel t)
7929 ;; Start delayed autoselection from current mouse 7943 ;; Start delayed autoselection from current mouse
7930 ;; position and window. 7944 ;; position and window.
7931 (mouse-autoselect-window-start (mouse-position) window) 7945 (setq mouse-autoselect-window-position-1 position)
7946 (mouse-autoselect-window-start position window)
7932 ;; Executing a command cancels delayed autoselection. 7947 ;; Executing a command cancels delayed autoselection.
7933 (add-hook 7948 (add-hook
7934 'pre-command-hook 'mouse-autoselect-window-cancel)))) 7949 'pre-command-hook 'mouse-autoselect-window-cancel))))