Re: Getting keyboard input into an unfocused window



Thanks for the excellent tip, it got me started in the right direction.
I eventually settled for :

gdk_keyboard_grab(window, GDK_KEY_PRESS_MASK, GDK_CURRENT_TIME);

Mostly because I didn't want to hog the focus, but just the keyboard.
It is just what the doctor ordered.  Well actually, ideally my application
wouldn't hog the entire keyboard either.  It could be out of focus, yet
watching out for certain keysrokes that make my application do some work.

Kinda like how most window managers sit in the background and listen
for Alt-Tab to switch applications for you.  Any idea on how they do
that?

P.S.  I saw your book at the local Barnes and Noble last night.  I am going
to have to buy it now.  :)

Mubashir Cheema

--- Havoc Pennington <hp redhat com> wrote:

Mubashir <mcheema yahoo com> writes:
I have been able to get keyboard input for my application without a
problem (when it is in focus).  Using the following:

gtk_signal_connect( (GTK_OBJECT(window), "key_press_event",
                      GTK_SIGNAL_FUNC(eventPressKey), NULL);

However I need to get keyboard input even when my application window
does
not have the focus.  I have played around with XGrabKeyboard, which
does
a good job of grabbing the keyboard, however it does not send the
events
to my application window when my app goes out of focus.  I am very new
at GTK programming and would appreciate any pointers.


If you also gdk_pointer_grab(), it should keep the focus in your app.

Havoc
  

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/




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