pnmixer
Volume mixer for the system tray
Functions | Variables
hotkey.c File Reference

Hotkey subsystem. More...

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/XKBlib.h>
#include "support-log.h"
#include "hotkey.h"
Include dependency graph for hotkey.c:

Go to the source code of this file.

Functions

static int grab_error_handler (G_GNUC_UNUSED Display *disp, G_GNUC_UNUSED XErrorEvent *ev)
 
void hotkey_ungrab (Hotkey *hotkey)
 
gboolean hotkey_grab (Hotkey *hotkey)
 
gboolean hotkey_matches (Hotkey *hotkey, guint code, GdkModifierType mods)
 
void hotkey_free (Hotkey *hotkey)
 
Hotkeyhotkey_new (guint code, GdkModifierType mods)
 
gchar * hotkey_code_to_accel (guint code, GdkModifierType mods)
 
void hotkey_accel_to_code (const gchar *accel, gint *code, GdkModifierType *mods)
 

Variables

static guint keymasks []
 
static char grab_error
 

Detailed Description

Hotkey subsystem.

This file define what's a hotkey. Deals with the low-level XKBlib and Gtk/Gdk.

Definition in file hotkey.c.

Function Documentation

◆ grab_error_handler()

static int grab_error_handler ( G_GNUC_UNUSED Display *  disp,
G_GNUC_UNUSED XErrorEvent *  ev 
)
static

Definition at line 52 of file hotkey.c.

◆ hotkey_accel_to_code()

void hotkey_accel_to_code ( const gchar *  accel,
gint *  code,
GdkModifierType *  mods 
)

Translate a Gtk Accelerator string to a key code and mods.

Parameters
accelthe accelerator string to parse.
codethe key code returned after parsing.
modsthe key modifiers after parsing.

Definition at line 230 of file hotkey.c.

◆ hotkey_code_to_accel()

gchar* hotkey_code_to_accel ( guint  code,
GdkModifierType  mods 
)

Translate a key into a Gtk Accelerator string.

Parameters
codethe key code to process.
modsthe key modifiers to process.
Returns
the accelerator string, must be freed.

Definition at line 208 of file hotkey.c.

◆ hotkey_free()

void hotkey_free ( Hotkey hotkey)

Ungrab a key and free any resources.

Parameters
hotkeya Hotkey instance.

Definition at line 160 of file hotkey.c.

◆ hotkey_grab()

gboolean hotkey_grab ( Hotkey hotkey)

Grab a key manually. Should be paired with a hotkey_ungrab() call.

Parameters
hotkeya Hotkey instance.
Returns
TRUE on success, FALSE on error.

Definition at line 92 of file hotkey.c.

◆ hotkey_matches()

gboolean hotkey_matches ( Hotkey hotkey,
guint  code,
GdkModifierType  mods 
)

Checks if the keycode we got (minus modifiers like numlock/capslock) matches the hotkey. Thus numlock + o will match o.

Parameters
hotkeya Hotkey instance.
codethe key code to compare against.
modsthe key modifiers to compare against.
Returns
TRUE if there is a match, FALSE otherwise.

Definition at line 138 of file hotkey.c.

◆ hotkey_new()

Hotkey* hotkey_new ( guint  code,
GdkModifierType  mods 
)

Creates a new hotkey and grab it.

Parameters
codethe key's code.
modsthe key's modifiers.
Returns
the newly created Hotkey instance.

Definition at line 179 of file hotkey.c.

◆ hotkey_ungrab()

void hotkey_ungrab ( Hotkey hotkey)

Ungrab a key manually. Should be paired with a hotkey_grab() call.

Parameters
hotkeya Hotkey instance.
Returns
TRUE on success, FALSE on error.

Definition at line 68 of file hotkey.c.

Variable Documentation

◆ grab_error

char grab_error
static

Definition at line 41 of file hotkey.c.

◆ keymasks

guint keymasks[]
static
Initial value:
= {
0,
GDK_MOD2_MASK,
GDK_LOCK_MASK,
GDK_MOD2_MASK | GDK_LOCK_MASK
}

Definition at line 33 of file hotkey.c.