0

I'm writing a simple GTK3 application and I need to detect, that SHIFT key is pressed during while application is loading.

I want to quit as early as possible, if SHIFT is not pressed. So I have no application window at this point

How can I query global keyboard state from GTK/GDK?

I tried to use gdk_seat_get_keyboard + gdk_window_get_device_position, but I get gdk_window_get_device_position_double: assertion 'gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD' failed in console. It also requires to have an application window.

I'm ok with code sample in any language (C, Vala, Python preferred)

dmzkrsk
  • 2,011
  • 2
  • 20
  • 30
  • Make your mainwindiw grab focus (gtk_widget_grab_focus(GTK_WIDGET(mainwindow)) connect to keypress signal and filter values (https://stackoverflow.com/a/58996897/8627962) – Siva Guru Nov 23 '19 at 06:04
  • key press won't do the job as shift isn't a keypress. It only becomes a keypress event when you press another button say a in which case you can differentiate a from A. – Paul Childs Nov 26 '19 at 07:27
  • This is OS level functionality and not really a GTK question. You could delay your application start a reasonable amount of time and use OS level queries to check if the shift key is depressed. – Paul Childs Nov 26 '19 at 07:28

0 Answers0