Capture keyboard input without window focus


#1

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
:smiley:

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