Implement support for using key symbols in configuration file
Use "bindsym" instead of "bind". You have to use the names of keys as in xmodmap. To get a list of currently bounud symbols, use xmodmap -pke Technical quirk: Xlib generated MappingNotify events upon XkbMapNotify events (from XKB, as the name says). XCB does not yet have support for XKB, thus we need to select and handle the event by ourself. Hopefully, this will change in the future.
This commit is contained in:
@ -79,6 +79,18 @@ struct Config {
|
||||
*
|
||||
*/
|
||||
void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
|
||||
|
||||
/**
|
||||
* Ungrabs all keys, to be called before re-grabbing the keys because of a
|
||||
* mapping_notify event or a configuration file reload
|
||||
*
|
||||
*/
|
||||
void ungrab_all_keys(xcb_connection_t *conn);
|
||||
|
||||
/**
|
||||
* Grab the bound keys (tell X to send us keypress events for those keycodes)
|
||||
*
|
||||
*/
|
||||
void grab_all_keys(xcb_connection_t *conn);
|
||||
|
||||
#endif
|
||||
|
@ -230,12 +230,29 @@ struct Workspace {
|
||||
*
|
||||
*/
|
||||
struct Binding {
|
||||
/** Symbol the user specified in configfile, if any. This needs to be
|
||||
* stored with the binding to be able to re-convert it into a keycode
|
||||
* if the keyboard mapping changes (using Xmodmap for example) */
|
||||
char *symbol;
|
||||
|
||||
/** Only in use if symbol != NULL. Gets set to the value to which the
|
||||
* symbol got translated when binding. Useful for unbinding and
|
||||
* checking which binding was used when a key press event comes in.
|
||||
*
|
||||
* This is an array of number_keycodes size. */
|
||||
xcb_keycode_t *translated_to;
|
||||
|
||||
uint32_t number_keycodes;
|
||||
|
||||
/** Keycode to bind */
|
||||
uint32_t keycode;
|
||||
|
||||
/** Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
|
||||
uint32_t mods;
|
||||
|
||||
/** Command, like in command mode */
|
||||
char *command;
|
||||
|
||||
TAILQ_ENTRY(Binding) bindings;
|
||||
};
|
||||
|
||||
|
@ -44,6 +44,14 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn,
|
||||
int handle_motion_notify(void *ignored, xcb_connection_t *conn,
|
||||
xcb_motion_notify_event_t *event);
|
||||
|
||||
/**
|
||||
* Called when the keyboard mapping changes (for example by using Xmodmap),
|
||||
* we need to update our key bindings then (re-translate symbols).
|
||||
*
|
||||
*/
|
||||
int handle_mapping_notify(void *ignored, xcb_connection_t *conn,
|
||||
xcb_mapping_notify_event_t *event);
|
||||
|
||||
/**
|
||||
* Checks if the button press was on a stack window, handles focus setting and
|
||||
* returns true if so, or false otherwise.
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_property.h>
|
||||
#include <xcb/xcb_event.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
@ -23,6 +24,7 @@
|
||||
#define NUM_ATOMS 18
|
||||
|
||||
extern xcb_connection_t *global_conn;
|
||||
extern xcb_key_symbols_t *keysyms;
|
||||
extern char **start_argv;
|
||||
extern Display *xkbdpy;
|
||||
extern TAILQ_HEAD(bindings_head, Binding) bindings;
|
||||
|
Reference in New Issue
Block a user