Forum: Ruby-Gnome 2 capture keyboard input without window focus

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1769b5ad3e8cfb8f3e78d7a5d2865277?d=identicon&s=25 Philipp Goetzinger (pgoetzin)
on 2009-02-26 20:09
Hello everyone,
i need a suggestion, i have a GTK app that start without a window when i
press shift+ctr+p a window should be shown.

My current try is like follow its not really nice but its nearly working
:-D

The code below is only working when the focus/cursor is on a window this
is not possible because its hidden, is there a opportunity to catch it
global from X ? or do i need a dummy window in the background ?


Gtk.key_snooper_install{|w, e|
   @key_input.push e.hardware_keycode
   #puts "code=#{e.hardware_keycode}"
   #puts "l =#{@key_input.length}"

   $SCHEDULER.in(1){@key_input.clear}
   @key_input.clear unless([33,37,64].include? e.hardware_keycode or
@key_input.length < 4)

   if @key_input.include?(33) and @key_input.include?(37) and
@key_input.include?(64)  then

       # show cusor that was hidden
       $login.root_window.set_cursor(
                        Gdk::Cursor.new(Gdk::DisplayManager.get.default_display,
                                        Gdk::Cursor::ARROW)
       )
       #do my action / unhide my window
       window.show_all...
   end


thanks ahead!


kind regards

Philipp
This topic is locked and can not be replied to.