emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: mouse-autoselect-window needs a de lay]


From: martin rudalics
Subject: Re: address@hidden: mouse-autoselect-window needs a de lay]
Date: Wed, 05 Jul 2006 14:19:30 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Please try the attached patch - it's based on Stefan's suggestion to
use `handle-select-window'.  martin.
*** dispextern.h        Sun Jul  2 09:50:00 2006
--- dispextern.h        Wed Jul  5 11:45:28 2006
***************
*** 2690,2696 ****
  extern int help_echo_pos;
  extern struct frame *last_mouse_frame;
  extern int last_tool_bar_item;
! extern int mouse_autoselect_window;
  extern int unibyte_display_via_language_environment;

  extern void reseat_at_previous_visible_line_start P_ ((struct it *));
--- 2690,2696 ----
  extern int help_echo_pos;
  extern struct frame *last_mouse_frame;
  extern int last_tool_bar_item;
! extern Lisp_Object mouse_autoselect_window;
  extern int unibyte_display_via_language_environment;

  extern void reseat_at_previous_visible_line_start P_ ((struct it *));

*** macterm.c   Sun Jul  2 09:50:00 2006
--- macterm.c   Wed Jul  5 12:02:28 2006
***************
*** 10562,10568 ****
                  else
                    {
                      /* Generate SELECT_WINDOW_EVENTs when needed.  */
!                     if (mouse_autoselect_window)
                        {
                          Lisp_Object window;

--- 10562,10568 ----
                  else
                    {
                      /* Generate SELECT_WINDOW_EVENTs when needed.  */
!                     if (!NILP (mouse_autoselect_window))
                        {
                          Lisp_Object window;


*** msdos.c     Sun Jul  2 12:09:26 2006
--- msdos.c     Wed Jul  5 12:02:46 2006
***************
*** 3381,3387 ****
            }

          /* Generate SELECT_WINDOW_EVENTs when needed.  */
!         if (mouse_autoselect_window)
            {
              mouse_window = window_from_coordinates (SELECTED_FRAME(),
                                                      mouse_last_x,
--- 3381,3387 ----
            }

          /* Generate SELECT_WINDOW_EVENTs when needed.  */
!         if (!NILP (mouse_autoselect_window))
            {
              mouse_window = window_from_coordinates (SELECTED_FRAME(),
                                                      mouse_last_x,

*** w32term.c   Sun Jul  2 09:50:02 2006
--- w32term.c   Wed Jul  5 12:02:08 2006
***************
*** 4286,4292 ****
          if (f)
            {
              /* Generate SELECT_WINDOW_EVENTs when needed.  */
!             if (mouse_autoselect_window)
                {
                  Lisp_Object window;
                  int x = LOWORD (msg.msg.lParam);
--- 4286,4292 ----
          if (f)
            {
              /* Generate SELECT_WINDOW_EVENTs when needed.  */
!             if (!NILP (mouse_autoselect_window))
                {
                  Lisp_Object window;
                  int x = LOWORD (msg.msg.lParam);

*** xdisp.c     Sun Jul  2 09:50:02 2006
--- xdisp.c     Wed Jul  5 13:57:26 2006
***************
*** 258,264 ****

  /* Non-zero means automatically select any window when the mouse
     cursor moves into it.  */
! int mouse_autoselect_window;

  /* Non-zero means draw tool bar buttons raised when the mouse moves
     over them.  */
--- 258,264 ----

  /* Non-zero means automatically select any window when the mouse
     cursor moves into it.  */
! Lisp_Object mouse_autoselect_window;

  /* Non-zero means draw tool bar buttons raised when the mouse moves
     over them.  */
***************
*** 23933,23941 ****
  See `set-window-redisplay-end-trigger'.  */);
    Vredisplay_end_trigger_functions = Qnil;

!   DEFVAR_BOOL ("mouse-autoselect-window", &mouse_autoselect_window,
!     doc: /* *Non-nil means autoselect window with mouse pointer.  */);
!   mouse_autoselect_window = 0;

    DEFVAR_BOOL ("auto-resize-tool-bars", &auto_resize_tool_bars_p,
      doc: /* *Non-nil means automatically resize tool-bars.
--- 23933,23946 ----
  See `set-window-redisplay-end-trigger'.  */);
    Vredisplay_end_trigger_functions = Qnil;

!   DEFVAR_LISP ("mouse-autoselect-window", &mouse_autoselect_window,
!      doc: /* *Non-nil means autoselect windows with mouse pointer.
! If nil, do not autoselect windows.  If t, autoselection occurs 
instantaneously.
! A number means delay autoselection by that many seconds: A window is selected 
iff
! Emacs can establish that the mouse has remained in that window quiescent for 
the
! time indicated by the delay.  A delay of less than 0.1 seconds is 
automatically
! translated into a delay of 0.1 seconds.  */);
!   mouse_autoselect_window = Qnil;

    DEFVAR_BOOL ("auto-resize-tool-bars", &auto_resize_tool_bars_p,
      doc: /* *Non-nil means automatically resize tool-bars.

*** xterm.c     Sun Jul  2 12:10:00 2006
--- xterm.c     Wed Jul  5 12:03:04 2006
***************
*** 6575,6581 ****
            {

              /* Generate SELECT_WINDOW_EVENTs when needed.  */
!             if (mouse_autoselect_window)
                {
                  Lisp_Object window;

--- 6575,6581 ----
            {

              /* Generate SELECT_WINDOW_EVENTs when needed.  */
!             if (!NILP (mouse_autoselect_window))
                {
                  Lisp_Object window;


*** cus-start.el        Sun Jul  2 09:49:56 2006
--- cus-start.el        Sun Jul  2 11:40:24 2006
***************
*** 360,365 ****
--- 360,370 ----
                                            (other :tag "Unlimited" t)))
             (unibyte-display-via-language-environment mule boolean)
             (blink-cursor-alist cursor alist "22.1")
+              (mouse-autoselect-window display
+                                     (choice (const :tag "Off" nil)
+                                             (number :tag "Delay" 0.5)
+                                             (const :tag "Immediate" t))
+                                     "21.3")
             ;; xfaces.c
             (scalable-fonts-allowed display boolean)
             ;; xfns.c
***************
*** 369,375 ****
             (x-gtk-show-hidden-files menu boolean "22.1")
             (x-gtk-whole-detached-tool-bar x boolean "22.1")
             ;; xterm.c
-              (mouse-autoselect-window display boolean "21.3")
             (x-use-underline-position-properties display boolean "21.3")
             (x-stretch-cursor display boolean "21.1")))
        this symbol group type standard version native-p
--- 374,379 ----

*** window.el   Mon Jul  3 17:35:12 2006
--- window.el   Wed Jul  5 13:57:36 2006
***************
*** 777,792 ****
    "Handle select-window events."
    (interactive "e")
    (let ((window (posn-window (event-start event))))
!     (if (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)))
!       (select-window window))))

  (define-key ctl-x-map "2" 'split-window-vertically)
  (define-key ctl-x-map "3" 'split-window-horizontally)
--- 777,853 ----
    "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)))
!       (if (numberp mouse-autoselect-window)
!         (autoselect-window-start)
!       (when mouse-autoselect-window
!         (run-hooks 'mouse-leave-buffer-hook))
!       (select-window window)))))
! 
! (defvar autoselect-window-timer nil
!   "Timer used by timer-driven window autoselection.")
! 
! (defvar autoselect-window-position nil
!   "Last mouse position calculated during timer-driven window autoselection.")
! 
! (defun autoselect-window-cancel ()
!   "Terminate timer-driven window autoselection."
!   (when (timerp autoselect-window-timer)
!     (cancel-timer autoselect-window-timer))
!   (remove-hook 'pre-command-hook 'autoselect-window-cancel))
! 
! (defun autoselect-window-start ()
!   "Initiate timer-driven window autoselection.
! This function is called when the mouse was moved and the variable
! `mouse-autoselect-window' has a numeric value."
!   (autoselect-window-cancel)
!   ;; Avoid a zero delay here, use 0.1 secs as minimum.
!   (let ((delay (max mouse-autoselect-window 0.1)))
!     (setq autoselect-window-position (mouse-position))
!     (setq autoselect-window-timer
!         (run-at-time t delay 'autoselect-window-select))
!     (add-hook 'pre-command-hook 'autoselect-window-cancel)))
! 
! (defun autoselect-window-select ()
!   "Select window with timer-driven autoselection of windows.
! Select window where the mouse appears provided the mouse has not moved
! for at least `mouse-autoselect-window' seconds and the window is not yet
! selected.  The minibuffer window is selected iff the minibuffer is
! active."
!   (condition-case nil
!       (let ((mouse-position (mouse-position)))
!       (if (equal mouse-position autoselect-window-position)
!           ;; mouse-position has stabilized, try to select a new window.
!           (let* ((mouse-x-pos (cadr mouse-position))
!                  (mouse-y-pos (cddr mouse-position))
!                  (frame (car mouse-position))
!                  (window (window-at mouse-x-pos mouse-y-pos frame)))
!             (cond
!              ((and window (not (eq window (selected-window)))
!                    (or (not (window-minibuffer-p window))
!                        (eq window (active-minibuffer-window)))
!                    (let ((edges (window-inside-edges window)))
!                      (and (<= (nth 0 edges) mouse-x-pos)
!                           (<= mouse-x-pos (nth 2 edges))
!                           (<= (nth 1 edges) mouse-y-pos)
!                           (<= mouse-y-pos (nth 3 edges)))))
!               (autoselect-window-cancel)
!               (run-hooks 'mouse-leave-buffer-hook)
!               (unless (window-minibuffer-p (selected-window))
!                 (select-window window)))
!              ((and window (eq window (selected-window)))
!               (autoselect-window-cancel))))
!         ;; mouse-position has not stabilized yet, record new position.
!         (setq autoselect-window-position mouse-position)))
!     (error nil)))

  (define-key ctl-x-map "2" 'split-window-vertically)
  (define-key ctl-x-map "3" 'split-window-horizontally)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]