-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keyboard: Don't hold lock in callback to
input
/input_intercept
Holding a mutex during the callback causes a deadlock if something invoked by the callback tries to call a `KeyboardHandle` method. Or if the callback locks another mutex, which in another thread may be held while the keyboard mutex is locked. This is bad, and the mutex here should generally be a hidden implementation detail. Or if absolutely necessarily this restriction should be documented. This requirements to make this work aren't ideal, but probably aren't a problem. We have to create a copy of `mods_state` on the stack. `Xkb` needs to be store in an `Arc<Mutex<_>>` for finer-grained locking. And `modified_syms()` and `raw_syms()` need to return `Vec`s instead of slices. The `Vec`s could be changed back to slices in the type signatures if we used `OnceCell` to cache the return value, but that probably doesn't matter that much in practice.
- Loading branch information
Showing
1 changed file
with
54 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters