Hi,

Two thigs: 
1. Original Events have also the "Handle" of the window who cuse the event.
2. you have two events of Focus in X itself:
        typedef XFocusChangeEvent XFocusInEvent;
        typedef XFocusChangeEvent XFocusOutEvent;

for the code that works for me more or less... :)

        case FocusOut:
        case FocusIn : 
                                                                                       
 if (Events_Status.xfocus.window == CurrentWindow) {
                                                                                       
                                 if (Events_Status.xfocus.mode == NotifyGrab)
                                                                                       
                                         printf ("The window reacived it's focus\n");
                                                                                       
                                 else
                                                                                       
                                 if (Events_Status.xfocus.mode == NotifyUngrab)
                                                                                       
                                         printf ("The window lost it's focus\n");
                                                                                       
                                 else printf ("For more info about focus see detail 
element.\n");
                                                                                       
 }
                                                                                       
 else printf ("Other window reacived/lost it's focus.\n");
                                                                                       
 break;


I'm trying to create a wiki in Lior Kaplan's site: 
http://guides.co.il/wiki/index.php/%D7%A9%D7%A8%D7%AA_X/%D7%AA%D7%9B%D7%A0%D7%95%D7%AA
about XLib programming... i put there some good resource i'm using... i hope they 
could help you as well, and that you also could
add your knowledge to the wiki :)

On Sunday 01 August 2004 03:27, Tzafrir Cohen wrote:
> Hi folks
> 
> I'm trying to write a small X11 client that will be notified whenever a
> window loses the input focus and whenever a window gains the input
> focus?
> 
> My best effort so far is:
> 
>   XSelectInput(display, root_win, FocusChangeMask );
>   ...
>   while (!done) {
>     XNextEvent(display, &an_event);
>     switch (an_event.type) {
>       case FocusIn:
>         ...
>         break;
>       case FocusOut:
>         ...
>         break;
>     }
>   }
> 
> This catches some of the cases: window switches using alt-tab, but not
> window switches using the mouse (my WM is IceWM).
> 
> As usual, any RTFM would be welcome. I already tried choo's guide,
> which was useful for getting started, BTW.
> 
> 

Cheers

Ido
-- 
As you grow older, you will still do foolish things, but you will do them
with much more enthusiasm.
                -- The Cowboy

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to