mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-13 04:27:47 -05:00
config: avoid tll() code expansion when generating default bindings
tll_push_back() is a macro that results in quite a lot of instructions. Expanding this macro explicitly in many places thus causes code explosion. This is what happened in when we generate the default key/mouse bindings. Fix by calling tll_push_back() in a no-inline function. Reduces code size with ~4-5K
This commit is contained in:
parent
449ac7c361
commit
ba2c3606bf
2 changed files with 34 additions and 29 deletions
60
config.c
60
config.c
|
|
@ -2132,15 +2132,20 @@ get_server_socket_path(void)
|
|||
return xasprintf("%s/foot-%s.sock", xdg_runtime, wayland_display);
|
||||
}
|
||||
|
||||
static void NOINLINE
|
||||
add_key_binding(config_key_binding_list_t *list, int action,
|
||||
const struct config_key_modifiers *mods, xkb_keysym_t sym)
|
||||
{
|
||||
tll_push_back(
|
||||
*list,
|
||||
((struct config_key_binding){action, *mods, sym}));
|
||||
}
|
||||
|
||||
static void
|
||||
add_default_key_bindings(struct config *conf)
|
||||
{
|
||||
#define add_binding(action, mods, sym) \
|
||||
do { \
|
||||
tll_push_back( \
|
||||
conf->bindings.key, \
|
||||
((struct config_key_binding){action, mods, sym})); \
|
||||
} while (0)
|
||||
#define add_binding(action, mods, sym) \
|
||||
add_key_binding(&conf->bindings.key, action, &mods, sym)
|
||||
|
||||
const struct config_key_modifiers shift = {.shift = true};
|
||||
const struct config_key_modifiers ctrl = {.ctrl = true};
|
||||
|
|
@ -2162,18 +2167,15 @@ add_default_key_bindings(struct config *conf)
|
|||
add_binding(BIND_ACTION_SPAWN_TERMINAL, ctrl_shift, XKB_KEY_n);
|
||||
add_binding(BIND_ACTION_SHOW_URLS_LAUNCH, ctrl_shift, XKB_KEY_u);
|
||||
|
||||
#undef add_binding
|
||||
#undef add_binding
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_default_search_bindings(struct config *conf)
|
||||
{
|
||||
#define add_binding(action, mods, sym) \
|
||||
do { \
|
||||
tll_push_back( \
|
||||
conf->bindings.search, \
|
||||
((struct config_key_binding){action, mods, sym})); \
|
||||
} while (0)
|
||||
#define add_binding(action, mods, sym) \
|
||||
add_key_binding(&conf->bindings.search, action, &mods, sym)
|
||||
|
||||
const struct config_key_modifiers none = {0};
|
||||
const struct config_key_modifiers alt = {.alt = true};
|
||||
|
|
@ -2210,18 +2212,14 @@ add_default_search_bindings(struct config *conf)
|
|||
add_binding(BIND_ACTION_SEARCH_CLIPBOARD_PASTE, ctrl, XKB_KEY_y);
|
||||
add_binding(BIND_ACTION_SEARCH_PRIMARY_PASTE, shift, XKB_KEY_Insert);
|
||||
|
||||
#undef add_binding
|
||||
#undef add_binding
|
||||
}
|
||||
|
||||
static void
|
||||
add_default_url_bindings(struct config *conf)
|
||||
{
|
||||
#define add_binding(action, mods, sym) \
|
||||
do { \
|
||||
tll_push_back( \
|
||||
conf->bindings.url, \
|
||||
((struct config_key_binding){action, mods, sym})); \
|
||||
} while (0)
|
||||
#define add_binding(action, mods, sym) \
|
||||
add_key_binding(&conf->bindings.url, action, &mods, sym)
|
||||
|
||||
const struct config_key_modifiers none = {0};
|
||||
const struct config_key_modifiers ctrl = {.ctrl = true};
|
||||
|
|
@ -2231,18 +2229,24 @@ add_default_url_bindings(struct config *conf)
|
|||
add_binding(BIND_ACTION_URL_CANCEL, none, XKB_KEY_Escape);
|
||||
add_binding(BIND_ACTION_URL_TOGGLE_URL_ON_JUMP_LABEL, none, XKB_KEY_t);
|
||||
|
||||
#undef add_binding
|
||||
#undef add_binding
|
||||
}
|
||||
|
||||
static void NOINLINE
|
||||
add_mouse_binding(config_mouse_binding_list_t *list, int action,
|
||||
const struct config_key_modifiers *mods,
|
||||
int button, int count)
|
||||
{
|
||||
tll_push_back(
|
||||
*list,
|
||||
((struct config_mouse_binding){action, *mods, button, count, {0}}));
|
||||
}
|
||||
|
||||
static void
|
||||
add_default_mouse_bindings(struct config *conf)
|
||||
{
|
||||
#define add_binding(action, mods, btn, count) \
|
||||
do { \
|
||||
tll_push_back( \
|
||||
conf->bindings.mouse, \
|
||||
((struct config_mouse_binding){action, mods, btn, count, {0}})); \
|
||||
} while (0)
|
||||
#define add_binding(action, mods, btn, count) \
|
||||
add_mouse_binding(&conf->bindings.mouse, action, &mods, btn, count)
|
||||
|
||||
const struct config_key_modifiers none = {0};
|
||||
const struct config_key_modifiers ctrl = {.ctrl = true};
|
||||
|
|
@ -2256,7 +2260,7 @@ add_default_mouse_bindings(struct config *conf)
|
|||
add_binding(BIND_ACTION_SELECT_WORD_WS, ctrl, BTN_LEFT, 2);
|
||||
add_binding(BIND_ACTION_SELECT_ROW, none, BTN_LEFT, 3);
|
||||
|
||||
#undef add_binding
|
||||
#undef add_binding
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
3
config.h
3
config.h
|
|
@ -52,6 +52,7 @@ struct config_mouse_binding {
|
|||
int count;
|
||||
struct config_binding_pipe pipe;
|
||||
};
|
||||
typedef tll(struct config_mouse_binding) config_mouse_binding_list_t;
|
||||
|
||||
struct config_spawn_template {
|
||||
char *raw_cmd;
|
||||
|
|
@ -166,7 +167,7 @@ struct config {
|
|||
struct {
|
||||
/* Bindings for "normal" mode */
|
||||
config_key_binding_list_t key;
|
||||
tll(struct config_mouse_binding) mouse;
|
||||
config_mouse_binding_list_t mouse;
|
||||
|
||||
/*
|
||||
* Special modes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue