24 #include <X11/XKBlib.h> 37 GDK_MOD2_MASK | GDK_LOCK_MASK
54 WARN(
"Error while grabbing hotkey");
73 g_return_if_fail(hotkey != NULL);
75 DEBUG(
"Ungrabbing hotkey '%s'", hotkey->
str);
77 disp = gdk_x11_get_default_xdisplay();
80 for (i = 0; i < G_N_ELEMENTS(
keymasks); i++)
95 XErrorHandler old_hdlr;
98 g_return_val_if_fail(hotkey != NULL, FALSE);
100 DEBUG(
"Grabbing hotkey '%s'", hotkey->
str);
102 disp = gdk_x11_get_default_xdisplay();
109 for (i = 0; i < G_N_ELEMENTS(
keymasks); i++)
111 GDK_ROOT_WINDOW(), 1, GrabModeAsync, GrabModeAsync);
118 (void) XSetErrorHandler(old_hdlr);
142 g_return_val_if_fail(hotkey != NULL, FALSE);
144 if (code != hotkey->
code)
147 for (i = 0; i < G_N_ELEMENTS(
keymasks); i++)
184 hotkey = g_new0(
Hotkey, 1);
185 disp = gdk_x11_get_default_xdisplay();
189 hotkey->
sym = XkbKeycodeToKeysym(disp, hotkey->
code, 0, 0);
190 hotkey->
str = gtk_accelerator_name(hotkey->
sym, hotkey->
mods);
214 disp = gdk_x11_get_default_xdisplay();
216 sym = XkbKeycodeToKeysym(disp, code, 0, 0);
217 accel = gtk_accelerator_name(sym, mods);
235 disp = gdk_x11_get_default_xdisplay();
237 gtk_accelerator_parse(accel, &sym, mods);
239 *code = XKeysymToKeycode(disp, sym);
void hotkey_ungrab(Hotkey *hotkey)
gchar * hotkey_code_to_accel(guint code, GdkModifierType mods)
void hotkey_accel_to_code(const gchar *accel, gint *code, GdkModifierType *mods)
gboolean hotkey_matches(Hotkey *hotkey, guint code, GdkModifierType mods)
gboolean hotkey_grab(Hotkey *hotkey)
Hotkey * hotkey_new(guint code, GdkModifierType mods)
void hotkey_free(Hotkey *hotkey)
static int grab_error_handler(G_GNUC_UNUSED Display *disp, G_GNUC_UNUSED XErrorEvent *ev)