Move switch_mode to bindings.[ch]
This commit is contained in:
parent
05f0585817
commit
702906d0cf
|
@ -42,3 +42,9 @@ Binding *get_keyboard_binding(uint16_t modifiers, bool key_release, xcb_keycode_
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void translate_keysyms(void);
|
void translate_keysyms(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switches the key bindings to the given mode, if the mode exists
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void switch_mode(const char *new_mode);
|
||||||
|
|
|
@ -315,12 +315,6 @@ void load_configuration(xcb_connection_t *conn, const char *override_configfile,
|
||||||
*/
|
*/
|
||||||
void ungrab_all_keys(xcb_connection_t *conn);
|
void ungrab_all_keys(xcb_connection_t *conn);
|
||||||
|
|
||||||
/**
|
|
||||||
* Switches the key bindings to the given mode, if the mode exists
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void switch_mode(const char *new_mode);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the current bar configuration as an event to all barconfig_update listeners.
|
* Sends the current bar configuration as an event to all barconfig_update listeners.
|
||||||
* This update mechnism currently only includes the hidden_state and the mode in the config.
|
* This update mechnism currently only includes the hidden_state and the mode in the config.
|
||||||
|
|
|
@ -229,3 +229,33 @@ void translate_keysyms(void) {
|
||||||
bind->number_keycodes);
|
bind->number_keycodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switches the key bindings to the given mode, if the mode exists
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void switch_mode(const char *new_mode) {
|
||||||
|
struct Mode *mode;
|
||||||
|
|
||||||
|
DLOG("Switching to mode %s\n", new_mode);
|
||||||
|
|
||||||
|
SLIST_FOREACH(mode, &modes, modes) {
|
||||||
|
if (strcasecmp(mode->name, new_mode) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ungrab_all_keys(conn);
|
||||||
|
bindings = mode->bindings;
|
||||||
|
translate_keysyms();
|
||||||
|
grab_all_keys(conn, false);
|
||||||
|
|
||||||
|
char *event_msg;
|
||||||
|
sasprintf(&event_msg, "{\"change\":\"%s\"}", mode->name);
|
||||||
|
|
||||||
|
ipc_send_event("mode", I3_IPC_EVENT_MODE, event_msg);
|
||||||
|
FREE(event_msg);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ELOG("ERROR: Mode not found\n");
|
||||||
|
}
|
||||||
|
|
30
src/config.c
30
src/config.c
|
@ -30,36 +30,6 @@ void ungrab_all_keys(xcb_connection_t *conn) {
|
||||||
xcb_ungrab_key(conn, XCB_GRAB_ANY, root, XCB_BUTTON_MASK_ANY);
|
xcb_ungrab_key(conn, XCB_GRAB_ANY, root, XCB_BUTTON_MASK_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Switches the key bindings to the given mode, if the mode exists
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void switch_mode(const char *new_mode) {
|
|
||||||
struct Mode *mode;
|
|
||||||
|
|
||||||
LOG("Switching to mode %s\n", new_mode);
|
|
||||||
|
|
||||||
SLIST_FOREACH(mode, &modes, modes) {
|
|
||||||
if (strcasecmp(mode->name, new_mode) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ungrab_all_keys(conn);
|
|
||||||
bindings = mode->bindings;
|
|
||||||
translate_keysyms();
|
|
||||||
grab_all_keys(conn, false);
|
|
||||||
|
|
||||||
char *event_msg;
|
|
||||||
sasprintf(&event_msg, "{\"change\":\"%s\"}", mode->name);
|
|
||||||
|
|
||||||
ipc_send_event("mode", I3_IPC_EVENT_MODE, event_msg);
|
|
||||||
FREE(event_msg);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ELOG("ERROR: Mode not found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sends the current bar configuration as an event to all barconfig_update listeners.
|
* Sends the current bar configuration as an event to all barconfig_update listeners.
|
||||||
* This update mechnism currently only includes the hidden_state and the mode in the config.
|
* This update mechnism currently only includes the hidden_state and the mode in the config.
|
||||||
|
|
Loading…
Reference in New Issue