floating_modifier uses mod_keys instead of anykey

This commit is contained in:
taiyu 2015-08-19 09:09:35 -07:00
parent 2d3bd3c747
commit 8205a6fd3b
2 changed files with 22 additions and 7 deletions

View file

@ -240,7 +240,24 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv)
if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) { if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) {
return false; return false;
} }
config->floating_mod = xkb_keysym_from_name(argv[0], XKB_KEYSYM_CASE_INSENSITIVE); int i, j;
list_t *split = split_string(argv[0], "+");
fprintf(stderr,"%s, %d,%d\n",argv[0], split->length,split->items);
config->floating_mod = 0;
//set modifer keys
for (i = 0; i < split->length; ++i) {
for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) {
if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
config->floating_mod |= modifiers[j].mod;
}
}
}
list_free(split);
if (!config->floating_mod) {
sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]);
return false;
}
return true; return true;
} }

View file

@ -15,8 +15,10 @@
#include "focus.h" #include "focus.h"
uint32_t keys_pressed[32]; uint32_t keys_pressed[32];
uint32_t key_modifiers;
int keys_pressed_length = 0; int keys_pressed_length = 0;
static struct wlc_origin mouse_origin; static struct wlc_origin mouse_origin;
static bool m1_held = false; static bool m1_held = false;
@ -25,12 +27,7 @@ static bool m2_held = false;
static bool resizing = false; static bool resizing = false;
static bool floating_mod_pressed(void) { static bool floating_mod_pressed(void) {
int i = 0; return key_modifiers & config->floating_mod;
while (i < keys_pressed_length) {
if (keys_pressed[i++] == config->floating_mod)
return true;
}
return false;
} }
static bool pointer_test(swayc_t *view, void *_origin) { static bool pointer_test(swayc_t *view, void *_origin) {
@ -297,6 +294,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
return false; return false;
} }
bool cmd_success = false; bool cmd_success = false;
key_modifiers = modifiers->mods;
struct sway_mode *mode = config->current_mode; struct sway_mode *mode = config->current_mode;
// Lowercase if necessary // Lowercase if necessary