Implement modes. Modes allow you to use different keybindings and switch between them.

For example, you can create a mode which will let you resize windows
with some easy to use keys. So, instead of binding a combination
of your homerow and modifiers to resize, like this:

	bind Mod4+44 resize right +10
	bind Mod4+45 resize right -10
	...

You can instead define a new mode:

	mode "resize" {
		bind 44 resize right +10
		bind 45 resize right -10
		...
		bind 36 mode default
	}

	bindsym Mod4+r mode resize

So, if you press Mod4+r now, your keybindings will be set to the ones
defined in your resize mode above. You can then use your homerow
(without any other modifier) to resize the current column/row and
press enter to go back to the default mode when you are done.

Note that using this option requires you to enable the new lexer/parser
by passing the -l flag to i3 when starting.
This commit is contained in:
Michael Stapelberg
2009-09-27 18:45:39 +02:00
parent 97d949d16c
commit 8f67eba044
7 changed files with 96 additions and 13 deletions

View File

@ -21,6 +21,7 @@
typedef struct Config Config;
extern Config config;
extern bool config_use_lexer;
extern SLIST_HEAD(modes_head, Mode) modes;
/**
* Part of the struct Config. It makes sense to group colors for background,
@ -46,6 +47,19 @@ struct Variable {
SLIST_ENTRY(Variable) variables;
};
/**
* The configuration file can contain multiple sets of bindings. Apart from the
* default set (name == "default"), you can specify other sets and change the
* currently active set of bindings by using the "mode <name>" command.
*
*/
struct Mode {
char *name;
struct bindings_head *bindings;
SLIST_ENTRY(Mode) modes;
};
/**
* Holds part of the configuration (the part which is not already in dedicated
* structures in include/data.h).
@ -97,4 +111,10 @@ void ungrab_all_keys(xcb_connection_t *conn);
*/
void grab_all_keys(xcb_connection_t *conn);
/**
* Switches the key bindings to the given mode, if the mode exists
*
*/
void switch_mode(xcb_connection_t *conn, const char *new_mode);
#endif