-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make key repeat and delay configurable #3730
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1ba82fe
Make `make_keyboard_helper` the only way to make `KeyboardHelper`s
tarek-y-ismail 61c9e2c
Swap `KeyboardHelper` instances to `shared_ptr`
tarek-y-ismail b21446e
Add `mir::shell::KeyboardHelper`
tarek-y-ismail 771f19c
Add `mir::shell::AccessibilityManager`
tarek-y-ismail 5393235
Expose `the_accessibility_manager` in `mir::Server`
tarek-y-ismail 2ee2f64
Pass the accessibility manager down to `WlSeat`
tarek-y-ismail ca56673
Hook up input config (re)loading to the accessibility manager
tarek-y-ismail 384afb6
Make `AccessibilityManager` aware of "enable-key-repeat"
tarek-y-ismail 0cc08c3
Pass keyboard helper by `const&` instead of copying
tarek-y-ismail 4f16caf
Revert newline deletion
tarek-y-ismail d484803
Make `repeat_rate` optional in `{frontend,shell}::KeyboardHelper`
tarek-y-ismail d64852c
Apply input config changes on server start
tarek-y-ismail 4e9cdaa
Consolidate config application logic into a lambda
tarek-y-ismail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright © Canonical Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 or 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef MIR_SHELL_KEYBOARD_HELPER_ | ||
#define MIR_SHELL_KEYBOARD_HELPER_ | ||
|
||
#include <optional> | ||
namespace mir | ||
{ | ||
namespace shell | ||
{ | ||
class KeyboardHelper | ||
{ | ||
public: | ||
virtual ~KeyboardHelper() = default; | ||
virtual void repeat_info_changed(std::optional<int> rate, int delay) const = 0; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright © Canonical Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 or 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef MIR_SHELL_ACCESSIBILITY_MANAGER_H | ||
#define MIR_SHELL_ACCESSIBILITY_MANAGER_H | ||
|
||
#include <memory> | ||
#include <optional> | ||
#include <vector> | ||
|
||
namespace mir | ||
{ | ||
namespace shell | ||
{ | ||
class KeyboardHelper; | ||
class AccessibilityManager | ||
{ | ||
public: | ||
void register_keyboard_helper(std::shared_ptr<shell::KeyboardHelper> const&); | ||
|
||
std::optional<int> repeat_rate() const; | ||
int repeat_delay() const; | ||
|
||
void repeat_rate(int new_rate); | ||
void repeat_delay(int new_rate); | ||
void override_key_repeat_settings(bool enable); | ||
|
||
void notify_helpers() const; | ||
|
||
private: | ||
std::vector<std::shared_ptr<shell::KeyboardHelper>> keyboard_helpers; | ||
|
||
// 25 rate and 600 delay are the default in Weston and Sway | ||
int repeat_rate_{25}; | ||
int repeat_delay_{600}; | ||
bool enable_key_repeat{true}; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could grow a utility class that combines these and the repeated "apply" logic?
Also, we need to be careful: we're now accessing
mouse
,touchpad
andkeyboard
on multiple threads.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having said that, I like the revised approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, do you have anything particular in mind? The simplest solution I can think of is keeping the initialization logic as is and wrapping the application logic in a lambda with a mutex.
Something like:
But I don't really think this needs its own utility class, just having something like this as an example should be enough.
Edit: Moved the lock to be external to
config_applier
since we also need to protectmouse
,keyboard
, andtouchpad
from being modified as we apply the config or vice-versaThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is always possible to have data and related functions separately, but it is clearer to the reader when they are grouped as a class. In particular, it is easier to check invariants when it is clear which code can access the data.
In this case, I think the logic around
config_mutex
,mouse
,touchpad
andkeyboard
is complex enough to make isolating this data desirable:It is quick to see that the data is only touched by this code, and that it is appropriately locked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a version without the undefined behaviour and compilation errors:
One small annoyance is that this isn't Copyable, and that means the
run_with()
parameter needs passing withstd::ref()
. Hoisting the state into a shared Self would work, but seems overkill.