|
|
@ -387,18 +387,20 @@ int workspace_output_cmp_workspace(const void *a, const void *b) {
|
|
|
|
int sway_binding_cmp_keys(const void *a, const void *b) {
|
|
|
|
int sway_binding_cmp_keys(const void *a, const void *b) {
|
|
|
|
const struct sway_binding *binda = a, *bindb = b;
|
|
|
|
const struct sway_binding *binda = a, *bindb = b;
|
|
|
|
|
|
|
|
|
|
|
|
if (binda->modifiers > bindb->modifiers) {
|
|
|
|
// Count keys pressed for this binding. important so we check long before
|
|
|
|
return 1;
|
|
|
|
// short ones. for example mod+a+b before mod+a
|
|
|
|
} else if (binda->modifiers < bindb->modifiers) {
|
|
|
|
unsigned int moda = 0, modb = 0, i;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (binda->keys->length > bindb->keys->length) {
|
|
|
|
// Count how any modifiers are pressed
|
|
|
|
return 1;
|
|
|
|
for (i = 0; i < 8 * sizeof(binda->modifiers); ++i) {
|
|
|
|
} else if (binda->keys->length < bindb->keys->length) {
|
|
|
|
moda += (binda->modifiers & 1 << i) != 0;
|
|
|
|
return -1;
|
|
|
|
modb += (bindb->modifiers & 1 << i) != 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bindb->keys->length + modb != binda->keys->length + moda) {
|
|
|
|
|
|
|
|
return (bindb->keys->length + modb) - (binda->keys->length + moda);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise compare keys
|
|
|
|
for (int i = 0; i < binda->keys->length; i++) {
|
|
|
|
for (int i = 0; i < binda->keys->length; i++) {
|
|
|
|
xkb_keysym_t *ka = binda->keys->items[i],
|
|
|
|
xkb_keysym_t *ka = binda->keys->items[i],
|
|
|
|
*kb = bindb->keys->items[i];
|
|
|
|
*kb = bindb->keys->items[i];
|
|
|
|