[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mouse-autoselect-window
From: |
martin rudalics |
Subject: |
Re: mouse-autoselect-window |
Date: |
Fri, 28 Sep 2007 11:11:00 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> With this and with mouse-autoselect-window set to t, moving the mouse
> to another Emacs frame of the same session immediately raises and
> focusses it, just like with your other patch using select-frame and
> raise-frame. Again, that is the same as when I set the KDE focus
> policy to focus follows mouse -- but again, since I have the policy
> set to focus follows click, I would not expect Emacs to behave
> differently.
>
> With mouse-autoselect-window set to a number, I get both raising and
> focussing, but only with split windows and only in alternation. As
> before, with unsplit frame moving the mouse over another frame neither
> raises nor focusses.
I tried to fix a couple of bugs. Could you please try again with the
attached patches (against CVS EMACS_22_BASE) and all settings you can
reasonably test.
*** frame.c Wed Jul 25 07:15:52 2007
--- frame.c Fri Sep 28 10:39:16 2007
***************
*** 118,123 ****
--- 118,125 ----
Lisp_Object Vmouse_position_function;
Lisp_Object Vmouse_highlight;
Lisp_Object Vdelete_frame_functions;
+
+ int focus_follows_mouse;
static void
set_menu_bar_lines_1 (window, n)
***************
*** 4151,4156 ****
--- 4153,4173 ----
This variable is local to the current terminal and cannot be buffer-local.
*/);
+ DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse,
+ doc: /* Non-nil if window system changes focus when you move the
mouse.
+ You should set this variable to tell Emacs how your window manager
+ handles focus, since there is no way in general for Emacs to find out
+ automatically. */);
+ #ifdef HAVE_WINDOW_SYSTEM
+ #if defined(HAVE_NTGUI) || defined(MAC_OS)
+ focus_follows_mouse = 0;
+ #else
+ focus_follows_mouse = 1;
+ #endif
+ #else
+ focus_follows_mouse = 0;
+ #endif
+
staticpro (&Vframe_list);
defsubr (&Sactive_minibuffer_window);
*** frame.h Fri Sep 14 22:50:14 2007
--- frame.h Fri Sep 28 10:40:38 2007
***************
*** 39,44 ****
--- 39,49 ----
extern int message_buf_print;
+ /* Nonzero means window system changes focus when moving the
+ mouse. */
+
+ extern int focus_follows_mouse;
+
/* The structure representing a frame. */
*** keyboard.c Fri Sep 14 22:50:16 2007
--- keyboard.c Fri Sep 28 10:42:30 2007
***************
*** 3995,4000 ****
--- 3995,4003 ----
/* Wait until there is input available. */
for (;;)
{
+ if (CONSP (Vunread_command_events))
+ break;
+
if (kbd_fetch_ptr != kbd_store_ptr)
break;
#ifdef HAVE_MOUSE
*** macterm.c Tue Aug 28 08:27:32 2007
--- macterm.c Fri Sep 28 10:43:52 2007
***************
*** 11119,11125 ****
will be selected only when it is active. */
if (WINDOWP (window)
&& !EQ (window, last_window)
! && !EQ (window, selected_window))
{
inev.kind = SELECT_WINDOW_EVENT;
inev.frame_or_window = window;
--- 11119,11128 ----
will be selected only when it is active. */
if (WINDOWP (window)
&& !EQ (window, last_window)
! && !EQ (window, selected_window)
! && (focus_follows_mouse
! || (EQ (XWINDOW (window)->frame,
! XWINDOW (selected_window)->frame))))
{
inev.kind = SELECT_WINDOW_EVENT;
inev.frame_or_window = window;
*** msdos.c Wed Aug 8 23:12:16 2007
--- msdos.c Fri Sep 28 10:46:08 2007
***************
*** 3393,3399 ****
it is active. */
if (WINDOWP (mouse_window)
&& !EQ (mouse_window, last_mouse_window)
! && !EQ (mouse_window, selected_window))
{
event.kind = SELECT_WINDOW_EVENT;
event.frame_or_window = mouse_window;
--- 3393,3402 ----
it is active. */
if (WINDOWP (mouse_window)
&& !EQ (mouse_window, last_mouse_window)
! && !EQ (window, selected_window)
! && (focus_follows_mouse
! || (EQ (XWINDOW (window)->frame,
! XWINDOW (selected_window)->frame))))
{
event.kind = SELECT_WINDOW_EVENT;
event.frame_or_window = mouse_window;
*** w32term.c Sat Sep 22 10:39:36 2007
--- w32term.c Fri Sep 28 10:44:58 2007
***************
*** 4339,4345 ****
only when it is active. */
if (WINDOWP(window)
&& !EQ (window, last_window)
! && !EQ (window, selected_window))
{
inev.kind = SELECT_WINDOW_EVENT;
inev.frame_or_window = window;
--- 4339,4348 ----
only when it is active. */
if (WINDOWP(window)
&& !EQ (window, last_window)
! && !EQ (window, selected_window)
! && (focus_follows_mouse
! || (EQ (XWINDOW (window)->frame,
! XWINDOW (selected_window)->frame))))
{
inev.kind = SELECT_WINDOW_EVENT;
inev.frame_or_window = window;
*** xterm.c Fri Sep 14 22:50:16 2007
--- xterm.c Fri Sep 28 10:45:24 2007
***************
*** 6628,6634 ****
will be selected only when it is active. */
if (WINDOWP (window)
&& !EQ (window, last_window)
! && !EQ (window, selected_window))
{
inev.ie.kind = SELECT_WINDOW_EVENT;
inev.ie.frame_or_window = window;
--- 6628,6637 ----
will be selected only when it is active. */
if (WINDOWP (window)
&& !EQ (window, last_window)
! && !EQ (window, selected_window)
! && (focus_follows_mouse
! || (EQ (XWINDOW (window)->frame,
! XWINDOW (selected_window)->frame))))
{
inev.ie.kind = SELECT_WINDOW_EVENT;
inev.ie.frame_or_window = window;
*** cus-start.el Wed Jul 25 06:47:32 2007
--- cus-start.el Fri Sep 28 10:48:14 2007
***************
*** 167,172 ****
--- 167,173 ----
;; fns.c
(use-dialog-box menu boolean "21.1")
(use-file-dialog menu boolean "22.1")
+ (focus-follows-mouse frames boolean "20.3")
;; frame.c
(default-frame-alist frames
(repeat (cons :format "%v"
*** frame.el Fri Sep 28 10:33:36 2007
--- frame.el Fri Sep 28 10:49:38 2007
***************
*** 681,695 ****
(nreverse frame-initial-geometry-arguments))
(cdr param-list))
- (defcustom focus-follows-mouse (not (memq window-system '(mac w32)))
- "*Non-nil if window system changes focus when you move the mouse.
- You should set this variable to tell Emacs how your window manager
- handles focus, since there is no way in general for Emacs to find out
- automatically."
- :type 'boolean
- :group 'frames
- :version "20.3")
-
(defun select-frame-set-input-focus (frame)
"Select FRAME, raise it, and set input focus, if possible."
(select-frame frame)
--- 681,686 ----
*** window.el Wed Aug 8 23:12:06 2007
--- window.el Fri Sep 28 10:53:36 2007
***************
*** 805,814 ****
"Cancel delayed window autoselection.
Optional argument FORCE means cancel unconditionally."
(unless (and (not force)
! ;; Don't cancel while the user drags a scroll bar.
! (eq this-command 'scroll-bar-toolkit-scroll)
! (memq (nth 4 (event-end last-input-event))
! '(handle end-scroll)))
(setq mouse-autoselect-window-state nil)
(when (timerp mouse-autoselect-window-timer)
(cancel-timer mouse-autoselect-window-timer))
--- 805,817 ----
"Cancel delayed window autoselection.
Optional argument FORCE means cancel unconditionally."
(unless (and (not force)
! ;; Don't cancel for select-window or select-frame events
! ;; or when the user drags a scroll bar.
! (or (memq this-command
! '(handle-select-window handle-switch-frame))
! (and (eq this-command 'scroll-bar-toolkit-scroll)
! (memq (nth 4 (event-end last-input-event))
! '(handle end-scroll)))))
(setq mouse-autoselect-window-state nil)
(when (timerp mouse-autoselect-window-timer)
(cancel-timer mouse-autoselect-window-timer))
***************
*** 896,928 ****
"Handle select-window events."
(interactive "e")
(let ((window (posn-window (event-start event))))
! (when (and (window-live-p window)
! ;; Don't switch if we're currently in the minibuffer.
! ;; This tries to work around problems where the minibuffer gets
! ;; unselected unexpectedly, and where you then have to move
! ;; your mouse all the way down to the minibuffer to select it.
! (not (window-minibuffer-p (selected-window)))
! ;; Don't switch to a minibuffer window unless it's active.
! (or (not (window-minibuffer-p window))
! (minibuffer-window-active-p window)))
! (unless (and (numberp mouse-autoselect-window)
! (not (zerop mouse-autoselect-window))
! (not (eq mouse-autoselect-window-state 'select))
! (progn
! ;; Cancel any delayed autoselection.
! (mouse-autoselect-window-cancel t)
! ;; Start delayed autoselection from current mouse position
! ;; and window.
! (mouse-autoselect-window-start (mouse-position) window)
! ;; Executing a command cancels delayed autoselection.
! (add-hook
! 'pre-command-hook 'mouse-autoselect-window-cancel)))
;; Reset state of delayed autoselection.
(setq mouse-autoselect-window-state nil)
! (when mouse-autoselect-window
! ;; Run `mouse-leave-buffer-hook' when autoselecting window.
! (run-hooks 'mouse-leave-buffer-hook))
! (select-window window)))))
(define-key ctl-x-map "2" 'split-window-vertically)
(define-key ctl-x-map "3" 'split-window-horizontally)
--- 899,937 ----
"Handle select-window events."
(interactive "e")
(let ((window (posn-window (event-start event))))
! (unless (or (not (window-live-p window))
! ;; Don't switch if we're currently in the minibuffer.
! ;; This tries to work around problems where the
! ;; minibuffer gets unselected unexpectedly, and where
! ;; you then have to move your mouse all the way down to
! ;; the minibuffer to select it.
! (window-minibuffer-p (selected-window))
! ;; Don't switch to minibuffer window unless it's active.
! (and (window-minibuffer-p window)
! (not (minibuffer-window-active-p window)))
! ;; Don't switch when autoselection shall be delayed.
! (and (numberp mouse-autoselect-window)
! (not (zerop mouse-autoselect-window))
! (not (eq mouse-autoselect-window-state 'select))
! (progn
! ;; Cancel any delayed autoselection.
! (mouse-autoselect-window-cancel t)
! ;; Start delayed autoselection from current mouse
position
! ;; and window.
! (mouse-autoselect-window-start (mouse-position) window)
! ;; Executing a command cancels delayed autoselection.
! (add-hook
! 'pre-command-hook 'mouse-autoselect-window-cancel))))
! (when mouse-autoselect-window
;; Reset state of delayed autoselection.
(setq mouse-autoselect-window-state nil)
! ;; Set input focus to handle cross-frame movement. Bind
! ;; `focus-follows-mouse' to avoid moving the mouse cursor.
! (let (focus-follows-mouse)
! (select-frame-set-input-focus (window-frame window)))
! ;; Run `mouse-leave-buffer-hook' when autoselecting window.
! (run-hooks 'mouse-leave-buffer-hook))
! (select-window window))))
(define-key ctl-x-map "2" 'split-window-vertically)
(define-key ctl-x-map "3" 'split-window-horizontally)
- Re: mouse-autoselect-window, (continued)
- RE: mouse-autoselect-window, Drew Adams, 2007/09/18
- Re: mouse-autoselect-window, martin rudalics, 2007/09/18
- RE: mouse-autoselect-window, Drew Adams, 2007/09/18
- Re: mouse-autoselect-window, martin rudalics, 2007/09/18
- RE: mouse-autoselect-window, Drew Adams, 2007/09/18
- Re: mouse-autoselect-window, Stephen Berman, 2007/09/18
- Re: mouse-autoselect-window,
martin rudalics <=
- Re: mouse-autoselect-window, Glenn Morris, 2007/09/29
- Re: mouse-autoselect-window, martin rudalics, 2007/09/30
- Re: mouse-autoselect-window, Glenn Morris, 2007/09/30
- Re: mouse-autoselect-window, Jason Rumney, 2007/09/18
- RE: mouse-autoselect-window, Drew Adams, 2007/09/18
- Re: mouse-autoselect-window, Jason Rumney, 2007/09/18
- RE: mouse-autoselect-window, Drew Adams, 2007/09/18
- Re: mouse-autoselect-window, Eli Zaretskii, 2007/09/19
Re: mouse-autoselect-window, Eli Zaretskii, 2007/09/05