Re: [gtk-list] gtk apps without focus




robert@muth.org writes:

> Hi:
> 
> I am using a window manager that leaves
> the focus with a window as long as 
> mouse does not move over another window that uses
> keyboard input. (sloppy focus in fvwm2)
>  
> For example, if I move the mouse from my emacs 
> window over the xclock window, my keyboard events
> still go to the emacs window.
> I noticed that with gtk applications I always lose
> the focus, even if the application does not need 
> any keyboard input. 
> 
> I tried the very radical
> 
>    window.unset_flags(gtk.CAN_FOCUS)    
>    window.set_events(0)
> 
> on the top level window of a gtk application but
> it still graps the focus.
> 
> How can I turn focus grabbing off?
> 
> To motivate this: imagine a little gtk app 
> emulating a keyboard, showing a button
> for each keyboard key.
> If you click a button the application would 
> generate a keyboard event which would be 
> consumed by the application currently holding the
> focus. This  does not work very well, if the
> keyboard emulator itself owns the focus.

This functionality is not currently exposed in GTK+ ...
if you don't mind dropping down directly into 
Xlib, then it would look a bit like:

 #include <gdk/gdkx.h>

 XWMHints *wmhints;

 gtk_widget_realize (window_widget);
 whmhints = XGetWMHints (GDK_WINDOW_XDISPLAY (window_widget->window),
                         GDK_WINDOW_XWINDOW (window_widget->window));

 wmhints->flags |= InputHint;
 wmhints->input = False;

 XSetWMHints (GDK_WINDOW_XDISPLAY (window_widget->window),
              GDK_WINDOW_XWINDOW (window_widget->window), wmhints);    
 XFree (wmhints);

[ I'm not sure what language you are working in; your
  code fragment above looks a bit like Python. In
  which case you wouldn't have much luck with the
  above... but it might just be pseudocode. ]

This seems generally useful enough that it might be worth
adding to the GDK API. So, you might want to submit a
wishlist bug report to the bug tracker. (See the README
file in the distribution.) It will probably get acted on
faster if you include a patch :-)

Regards,
                                        Owen
 



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