mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-19 14:33:16 -04:00
Merge d3de3d3f10 into 727b9fe77e
This commit is contained in:
commit
83ded0df18
2 changed files with 68 additions and 3 deletions
|
|
@ -45,6 +45,7 @@ typedef struct {
|
||||||
bool islockapply;
|
bool islockapply;
|
||||||
bool isreleaseapply;
|
bool isreleaseapply;
|
||||||
bool ispassapply;
|
bool ispassapply;
|
||||||
|
bool isexclusiveapply; // Requires isreleaseapply.
|
||||||
} KeyBinding;
|
} KeyBinding;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -516,6 +517,9 @@ void parse_bind_flags(const char *str, KeyBinding *kb) {
|
||||||
case 'p':
|
case 'p':
|
||||||
kb->ispassapply = true;
|
kb->ispassapply = true;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
kb->isexclusiveapply = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\033[1m\033[31m[ERROR]:\033[33m Unknown bind flag: %c\n",
|
"\033[1m\033[31m[ERROR]:\033[33m Unknown bind flag: %c\n",
|
||||||
|
|
@ -523,6 +527,13 @@ void parse_bind_flags(const char *str, KeyBinding *kb) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kb->isexclusiveapply && !kb->isreleaseapply) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"\033[1m\033[31m[ERROR]:\033[33m Exclusive bind flag "
|
||||||
|
"requires release flag ('r')\n");
|
||||||
|
kb->isexclusiveapply = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parse_circle_direction(const char *str) {
|
int32_t parse_circle_direction(const char *str) {
|
||||||
|
|
@ -2589,7 +2600,7 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
|
|
||||||
config->exec_once_count++;
|
config->exec_once_count++;
|
||||||
|
|
||||||
} else if (regex_match("^bind[s|l|r|p]*$", key)) {
|
} else if (regex_match("^bind[s|l|e|r|p]*$", key)) {
|
||||||
config->key_bindings =
|
config->key_bindings =
|
||||||
realloc(config->key_bindings,
|
realloc(config->key_bindings,
|
||||||
(config->key_bindings_count + 1) * sizeof(KeyBinding));
|
(config->key_bindings_count + 1) * sizeof(KeyBinding));
|
||||||
|
|
|
||||||
58
src/mango.c
58
src/mango.c
|
|
@ -1018,6 +1018,7 @@ static struct wl_event_source *hide_cursor_source;
|
||||||
static struct wl_event_source *keep_idle_inhibit_source;
|
static struct wl_event_source *keep_idle_inhibit_source;
|
||||||
static bool cursor_hidden = false;
|
static bool cursor_hidden = false;
|
||||||
static bool tag_combo = false;
|
static bool tag_combo = false;
|
||||||
|
static bool mod_key_used = false;
|
||||||
static const char *cli_config_path = NULL;
|
static const char *cli_config_path = NULL;
|
||||||
static bool cli_debug_log = false;
|
static bool cli_debug_log = false;
|
||||||
static KeyMode keymode = {
|
static KeyMode keymode = {
|
||||||
|
|
@ -2418,6 +2419,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
|
||||||
event->button == m->button && m->func &&
|
event->button == m->button && m->func &&
|
||||||
(CLEANMASK(m->mod) != 0 ||
|
(CLEANMASK(m->mod) != 0 ||
|
||||||
(event->button != BTN_LEFT && event->button != BTN_RIGHT))) {
|
(event->button != BTN_LEFT && event->button != BTN_RIGHT))) {
|
||||||
|
mod_key_used = true;
|
||||||
m->func(&m->arg);
|
m->func(&m->arg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -4130,6 +4132,10 @@ keybinding(uint32_t state, bool locked, uint32_t mods, xkb_keysym_t sym,
|
||||||
state != WL_KEYBOARD_KEY_STATE_RELEASED)
|
state != WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// exclusive binds are handled after this loop so that mod_key_used is set properly.
|
||||||
|
if (config.key_bindings[ji].isexclusiveapply)
|
||||||
|
continue;
|
||||||
|
|
||||||
k = &config.key_bindings[ji];
|
k = &config.key_bindings[ji];
|
||||||
if ((k->iscommonmode || (k->isdefaultmode && keymode.isdefault) ||
|
if ((k->iscommonmode || (k->isdefaultmode && keymode.isdefault) ||
|
||||||
(strcmp(keymode.mode, k->mode) == 0)) &&
|
(strcmp(keymode.mode, k->mode) == 0)) &&
|
||||||
|
|
@ -4143,10 +4149,12 @@ keybinding(uint32_t state, bool locked, uint32_t mods, xkb_keysym_t sym,
|
||||||
keycode == k->keysymcode.keycode.keycode3))) &&
|
keycode == k->keysymcode.keycode.keycode3))) &&
|
||||||
k->func) {
|
k->func) {
|
||||||
|
|
||||||
if (!k->ispassapply)
|
if (!k->ispassapply) {
|
||||||
handled = 1;
|
handled = 1;
|
||||||
else
|
mod_key_used = true;
|
||||||
|
} else {
|
||||||
handled = 0;
|
handled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
isbreak = k->func(&k->arg);
|
isbreak = k->func(&k->arg);
|
||||||
|
|
||||||
|
|
@ -4249,6 +4257,16 @@ void keypress(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
|
|
||||||
|
/* Track non-modifier key presses.
|
||||||
|
* Modifier keycodes: 133,134=Super 37,105=Ctrl 50,62=Shift 64,108=Alt */
|
||||||
|
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED &&
|
||||||
|
keycode != 133 && keycode != 134 &&
|
||||||
|
keycode != 37 && keycode != 105 &&
|
||||||
|
keycode != 50 && keycode != 62 &&
|
||||||
|
keycode != 64 && keycode != 108) {
|
||||||
|
mod_key_used = true;
|
||||||
|
}
|
||||||
|
|
||||||
// ov tab mode detect moe key release
|
// ov tab mode detect moe key release
|
||||||
if (config.ov_tab_mode && !locked && group == kb_group &&
|
if (config.ov_tab_mode && !locked && group == kb_group &&
|
||||||
event->state == WL_KEYBOARD_KEY_STATE_RELEASED &&
|
event->state == WL_KEYBOARD_KEY_STATE_RELEASED &&
|
||||||
|
|
@ -4271,6 +4289,38 @@ void keypress(struct wl_listener *listener, void *data) {
|
||||||
handled =
|
handled =
|
||||||
keybinding(event->state, locked, mods, syms[i], keycode) || handled;
|
keybinding(event->state, locked, mods, syms[i], keycode) || handled;
|
||||||
|
|
||||||
|
if (!mod_key_used &&
|
||||||
|
event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||||
|
for (int32_t ji = 0; ji < config.key_bindings_count; ji++) {
|
||||||
|
const KeyBinding *k = &config.key_bindings[ji];
|
||||||
|
if (!k->isexclusiveapply || !k->func)
|
||||||
|
continue;
|
||||||
|
if (locked && !k->islockapply)
|
||||||
|
continue;
|
||||||
|
if (!(k->iscommonmode ||
|
||||||
|
(k->isdefaultmode && keymode.isdefault) ||
|
||||||
|
(strcmp(keymode.mode, k->mode) == 0)))
|
||||||
|
continue;
|
||||||
|
if (CLEANMASK(mods) != CLEANMASK(k->mod))
|
||||||
|
continue;
|
||||||
|
bool key_match = false;
|
||||||
|
for (int32_t si = 0; si < nsyms && !key_match; si++) {
|
||||||
|
if ((k->keysymcode.type == KEY_TYPE_SYM &&
|
||||||
|
xkb_keysym_to_lower(syms[si]) ==
|
||||||
|
xkb_keysym_to_lower(k->keysymcode.keysym)) ||
|
||||||
|
(k->keysymcode.type == KEY_TYPE_CODE &&
|
||||||
|
(keycode == k->keysymcode.keycode.keycode1 ||
|
||||||
|
keycode == k->keysymcode.keycode.keycode2 ||
|
||||||
|
keycode == k->keysymcode.keycode.keycode3)))
|
||||||
|
key_match = true;
|
||||||
|
}
|
||||||
|
if (!key_match)
|
||||||
|
continue;
|
||||||
|
handled = !k->ispassapply;
|
||||||
|
k->func(&k->arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||||
tag_combo = false;
|
tag_combo = false;
|
||||||
}
|
}
|
||||||
|
|
@ -4342,6 +4392,10 @@ void keypressmod(struct wl_listener *listener, void *data) {
|
||||||
* pressed. We simply communicate this to the client. */
|
* pressed. We simply communicate this to the client. */
|
||||||
KeyboardGroup *group = wl_container_of(listener, group, modifiers);
|
KeyboardGroup *group = wl_container_of(listener, group, modifiers);
|
||||||
|
|
||||||
|
uint32_t cur_mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||||
|
if (cur_mods == 0)
|
||||||
|
mod_key_used = false;
|
||||||
|
|
||||||
if (!dwl_im_keyboard_grab_forward_modifiers(group)) {
|
if (!dwl_im_keyboard_grab_forward_modifiers(group)) {
|
||||||
|
|
||||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue