forked from external/yambar
module/sway-xkb: handle device being added again
If a device is removed while the computer is hibernating, and then reconnected after waking it up, Sway sends an “added” event without first sending a “removed” event. Yambar used to assert that an “added” event didn’t refer to an already tracked device. This patch changes this, and simply ignores duplicate “added” events. Closes #177
This commit is contained in:
parent
ca077447c2
commit
f4ceaaad52
1 changed files with 19 additions and 13 deletions
|
@ -207,21 +207,27 @@ handle_input_event(int type, const struct json_object *json, void *_mod)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_removed || is_added) {
|
if (is_removed) {
|
||||||
mtx_lock(&mod->lock);
|
if (input->exists) {
|
||||||
assert((is_removed && input->exists) ||
|
mtx_lock(&mod->lock);
|
||||||
(is_added && !input->exists));
|
input->exists = false;
|
||||||
|
m->num_existing_inputs--;
|
||||||
|
m->dirty = true;
|
||||||
|
mtx_unlock(&mod->lock);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
input->exists = !input->exists;
|
if (is_added) {
|
||||||
m->num_existing_inputs += is_added ? 1 : -1;
|
if (!input->exists) {
|
||||||
m->dirty = true;
|
mtx_lock(&mod->lock);
|
||||||
|
input->exists = true;
|
||||||
|
m->num_existing_inputs++;
|
||||||
|
m->dirty = true;
|
||||||
|
mtx_unlock(&mod->lock);
|
||||||
|
}
|
||||||
|
|
||||||
mtx_unlock(&mod->lock);
|
/* “fallthrough”, to query current/active layout */
|
||||||
|
|
||||||
if (is_removed)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
/* let is_added fall through, to update layout */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get current/active layout */
|
/* Get current/active layout */
|
||||||
|
|
Loading…
Add table
Reference in a new issue