Capture ALT+F4 inside a GTK application
Is there any way to capture shortcuts as ALT+F4 and CTRL+ALT+DEL within a GTK Ubuntu app? I intend to make a kiosk aplication and I'd like to avoid these keys from my app not at OS level to avoid to be 开发者_运维问答closed by the user.
Ctrl+Alt+Del should be inhibited system-wide, not just in your app. This is IMHO best modified using GNOME's keybord shortcuts configuration program.
As about catching Alt+F4, you should instead catch the delete-event, as Jong Bor already told you. If you need to lock more functions, give a look at sabayon and pessulus. See also the lockdown section of the GNOME Administration documentation.
I agree with Jong Bor's comment, but if you want to capture keypresses, you can do so with Gtk::Widget::signal_key_press_event().
To catch modifiers such as CTRL, ALT or SHIFT, you'll have to create a mask as follows:
// Mask will match when CTRL and SHIFT are both pressed
// ALT is usually equal to Gdk::MOD1_MASK
const GdkModifierType maskToMatch = (GdkModifierType)(GDK_SHIFT_MASK | GDK_SHIFT_MASK);
精彩评论