mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04:00
commit
d940815f6d
3 changed files with 65 additions and 32 deletions
|
|
@ -33,6 +33,8 @@
|
||||||
* **tweak.render-timer** option to `footrc`.
|
* **tweak.render-timer** option to `footrc`.
|
||||||
* Modifier support in mouse bindings
|
* Modifier support in mouse bindings
|
||||||
(https://codeberg.org/dnkl/foot/issues/77).
|
(https://codeberg.org/dnkl/foot/issues/77).
|
||||||
|
* Click count support in mouse bindings, i.e double- and triple-click
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/78).
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
80
config.c
80
config.c
|
|
@ -97,45 +97,43 @@ static const char *const search_binding_action_map[] = {
|
||||||
static_assert(ALEN(search_binding_action_map) == BIND_ACTION_SEARCH_COUNT,
|
static_assert(ALEN(search_binding_action_map) == BIND_ACTION_SEARCH_COUNT,
|
||||||
"search binding action map size mismatch");
|
"search binding action map size mismatch");
|
||||||
|
|
||||||
#define LOG_AND_NOTIFY_ERR(fmt, ...) \
|
#define LOG_AND_NOTIFY_ERR(fmt, ...) \
|
||||||
LOG_ERR(fmt, ## __VA_ARGS__); \
|
do { \
|
||||||
{ \
|
LOG_ERR(fmt, ## __VA_ARGS__); \
|
||||||
char *text = xasprintf(fmt, ## __VA_ARGS__); \
|
char *text = xasprintf(fmt, ## __VA_ARGS__); \
|
||||||
struct user_notification notif = { \
|
struct user_notification notif = { \
|
||||||
.kind = USER_NOTIFICATION_ERROR, \
|
.kind = USER_NOTIFICATION_ERROR, \
|
||||||
.text = text, \
|
.text = text, \
|
||||||
}; \
|
}; \
|
||||||
tll_push_back(conf->notifications, notif); \
|
tll_push_back(conf->notifications, notif); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
#define LOG_AND_NOTIFY_WARN(fmt, ...) \
|
#define LOG_AND_NOTIFY_WARN(fmt, ...) \
|
||||||
LOG_WARN(fmt, ## __VA_ARGS__); \
|
do { \
|
||||||
{ \
|
LOG_WARN(fmt, ## __VA_ARGS__); \
|
||||||
char *text = xasprintf(fmt, ## __VA_ARGS__); \
|
char *text = xasprintf(fmt, ## __VA_ARGS__); \
|
||||||
struct user_notification notif = { \
|
struct user_notification notif = { \
|
||||||
.kind = USER_NOTIFICATION_WARNING, \
|
.kind = USER_NOTIFICATION_WARNING, \
|
||||||
.text = text, \
|
.text = text, \
|
||||||
}; \
|
}; \
|
||||||
tll_push_back(conf->notifications, notif); \
|
tll_push_back(conf->notifications, notif); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
#define LOG_AND_NOTIFY_ERRNO(fmt, ...) \
|
#define LOG_AND_NOTIFY_ERRNO(fmt, ...) \
|
||||||
{ \
|
do { \
|
||||||
int _errno = errno; \
|
int _errno = errno; \
|
||||||
LOG_ERRNO(fmt, ## __VA_ARGS__); \
|
LOG_ERRNO(fmt, ## __VA_ARGS__); \
|
||||||
{ \
|
int len = snprintf(NULL, 0, fmt, ## __VA_ARGS__); \
|
||||||
int len = snprintf(NULL, 0, fmt, ## __VA_ARGS__); \
|
int errno_len = snprintf(NULL, 0, ": %s", strerror(_errno)); \
|
||||||
int errno_len = snprintf(NULL, 0, ": %s", strerror(_errno)); \
|
char *text = xmalloc(len + errno_len + 1); \
|
||||||
char *text = xmalloc(len + errno_len + 1); \
|
snprintf(text, len + errno_len + 1, fmt, ## __VA_ARGS__); \
|
||||||
snprintf(text, len + errno_len + 1, fmt, ## __VA_ARGS__); \
|
snprintf(&text[len], errno_len + 1, ": %s", strerror(_errno)); \
|
||||||
snprintf(&text[len], errno_len + 1, ": %s", strerror(_errno)); \
|
struct user_notification notif = { \
|
||||||
struct user_notification notif = { \
|
.kind = USER_NOTIFICATION_ERROR, \
|
||||||
.kind = USER_NOTIFICATION_ERROR, \
|
.text = text, \
|
||||||
.text = text, \
|
}; \
|
||||||
}; \
|
tll_push_back(conf->notifications, notif); \
|
||||||
tll_push_back(conf->notifications, notif); \
|
} while(0)
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_shell(void)
|
get_shell(void)
|
||||||
|
|
@ -1009,17 +1007,41 @@ parse_mouse_combos(struct config *conf, const char *combos, key_combo_list_t *ke
|
||||||
combo = strtok_r(NULL, " ", &tok_ctx))
|
combo = strtok_r(NULL, " ", &tok_ctx))
|
||||||
{
|
{
|
||||||
struct config_key_modifiers modifiers = {};
|
struct config_key_modifiers modifiers = {};
|
||||||
const char *key = strrchr(combo, '+');
|
char *key = strrchr(combo, '+');
|
||||||
|
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
/* No modifiers */
|
/* No modifiers */
|
||||||
key = combo;
|
key = combo;
|
||||||
} else {
|
} else {
|
||||||
|
*key = '\0';
|
||||||
if (!parse_modifiers(conf, combo, key - combo, &modifiers, path, lineno))
|
if (!parse_modifiers(conf, combo, key - combo, &modifiers, path, lineno))
|
||||||
goto err;
|
goto err;
|
||||||
key++; /* Skip past the '+' */
|
key++; /* Skip past the '+' */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
{
|
||||||
|
char *_count = strrchr(key, '-');
|
||||||
|
if (_count != NULL) {
|
||||||
|
*_count = '\0';
|
||||||
|
_count++;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
char *end;
|
||||||
|
unsigned long value = strtoul(_count, &end, 10);
|
||||||
|
if (_count[0] == '\0' || *end != '\0' || errno != 0) {
|
||||||
|
if (errno != 0)
|
||||||
|
LOG_AND_NOTIFY_ERRNO(
|
||||||
|
"%s:%d: %s: invalid click count", path, lineno, _count);
|
||||||
|
else
|
||||||
|
LOG_AND_NOTIFY_ERR(
|
||||||
|
"%s:%d: %s: invalid click count", path, lineno, _count);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
count = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
int code;
|
int code;
|
||||||
|
|
@ -1052,7 +1074,7 @@ parse_mouse_combos(struct config *conf, const char *combos, key_combo_list_t *ke
|
||||||
.modifiers = modifiers,
|
.modifiers = modifiers,
|
||||||
.m = {
|
.m = {
|
||||||
.button = button,
|
.button = button,
|
||||||
.count = 1,
|
.count = count,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
tll_push_back(*key_combos, new);
|
tll_push_back(*key_combos, new);
|
||||||
|
|
|
||||||
|
|
@ -364,9 +364,18 @@ This section lets you override the default mouse bindings.
|
||||||
|
|
||||||
The general format is _action=combo1...comboN_. That is, each action
|
The general format is _action=combo1...comboN_. That is, each action
|
||||||
may have one or more key combinations, space separated. Each
|
may have one or more key combinations, space separated. Each
|
||||||
combination is on the form _mod1+mod2+BTN\_<name>_. The names of the
|
combination is on the form _mod1+mod2+BTN\_<name>_[-COUNT]. The names
|
||||||
modifiers and the key *must* be valid XKB key names. You can find the
|
of the modifiers and the key *must* be valid XKB key names. You can
|
||||||
button names using *libinput debug-events*.
|
find the button names using *libinput debug-events*.
|
||||||
|
|
||||||
|
The trailing *COUNT* is optional and specifies the click count
|
||||||
|
required to trigger the binding. The default is *COUNT* is omitted is
|
||||||
|
_1_.
|
||||||
|
|
||||||
|
Example: *primary-paste=Control+BTN_LEFT-2*
|
||||||
|
|
||||||
|
Trigger _primary-paste_ when *ctrl* is pressed, and the left mouse
|
||||||
|
button is double clicked.
|
||||||
|
|
||||||
A button can only be mapped to *one* action. Lets say you want to bind
|
A button can only be mapped to *one* action. Lets say you want to bind
|
||||||
*BTN\_MIDDLE* to *fullscreen*. Since *BTN\_MIDDLE* is the default
|
*BTN\_MIDDLE* to *fullscreen*. Since *BTN\_MIDDLE* is the default
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue