emacs-devel
[Top][All Lists]
Advanced

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

Re: x_autoselect_window_p


From: Gerd Moellmann
Subject: Re: x_autoselect_window_p
Date: 01 Apr 2002 11:25:16 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

address@hidden (Pavel Janík) writes:

> BTW - do you think that this patch is correct? I do not have
> overview as you have...

I'll add some notes below.  The principle seems correct to me.


> --- termhooks.h.~1.57.~       Sun Mar 10 19:22:28 2002
> +++ termhooks.h       Sun Mar 31 20:55:30 2002
> @@ -325,6 +325,9 @@
>       `switch-frame' events in kbd_buffer_get_event, if necessary.  */
>    FOCUS_IN_EVENT,
>  
> +  /* Generated when mouse moves over window not currently selected.  */
> +  WINDOW_IN_EVENT,

People might be more happy with a more telling name
(SELECT_WINDOW_EVENT, SWITCH_WINDOW_EVENT, ...?)

> +
>    /* Queued from XTread_socket when session manager sends
>       save yourself before shutdown. */
>    save_session_event
> 
> 
> xterm.c now generates this event when it should:
> 
> --- xterm.c.~1.716.~  Sun Mar 31 18:32:34 2002
> +++ xterm.c   Sun Mar 31 20:58:44 2002
> @@ -10894,8 +10894,39 @@
>                   clear_mouse_face (dpyinfo);
>                 }
>  
> -             if (f)
> +             if (f) {

(signal 'coding-convention-error "{") :-)

> +
> +               /* Generate WINDOW_IN_EVENTs when needed.  */
> +               if (x_autoselect_window_p)
> +                 {
> +                   Lisp_Object window;
> +                   int area;
> +                   static Lisp_Object last_window;

On some systems, `static' gets defined away, so if you need such a
variable in Emacs, you must move it to global scope.

> +
> +                   window = window_from_coordinates (f,
> +                                                     XINT (event.xmotion.x), 
> XINT (event.xmotion.y),
> +                                                     &area, 0);
> +
> +                   /* Window will be selected only when it is not selected 
> now and
> +                      last mouse movement event was not in it.  Minibuffer 
> window
> +                      will be selected iff it is active.  */
> +                   if (!EQ (window, last_window)
> +                       && !EQ (window, selected_window)
> +                       && (!MINI_WINDOW_P (XWINDOW (window))
> +                           || (EQ (window, minibuf_window) && minibuf_level 
> > 0)))

Maybe it's better to leave this condition testing to the Lisp function
that is called at the end for handling the event?  It would have the
advantage of being more flexible.

> +                     {
> +                       fprintf(stderr, "WINDOW_IN_EVENT generated!\n");
> +
> +                       bufp->kind = WINDOW_IN_EVENT;
> +                       XSETFRAME (bufp->frame_or_window, window);
> +                       bufp->arg = Qnil;

Strictly speaking, it might be a good idea to check for numchars > 0
before filling in the event.

> +                       ++bufp, ++count, --numchars;
> +                     }
> +
> +                   last_window=window;
> +                 }
>                 note_mouse_movement (f, &event.xmotion);
> +             }
>               else
>                 {
>  #ifndef USE_TOOLKIT_SCROLL_BARS
> 
> 
> So far, it is without problems, WINDOW_IN_EVENT is generated and seen in
> keyboard.c without problems. Now, we should process it:
> 
> --- keyboard.h.~1.57.~        Wed Mar  6 17:03:10 2002
> +++ keyboard.h        Sun Mar 31 20:59:52 2002
> @@ -181,6 +181,9 @@
>  /* Total number of times read_char has returned.  */
>  extern int num_input_events;
>  
> +/* Defined in xterm.c  */
> +extern int x_autoselect_window_p;
> +

If this isn't an X-only feature, the `x_' prefix might be a bit
confusing.



reply via email to

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