-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
implement tablet mode (disabling keyboard and mouse/touch pad) #238
base: main
Are you sure you want to change the base?
Conversation
Can be triggered by a dedicated hardware switch, or by a toggle action.
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.
Open question: Can we reliably distinguish internal from external devices? If yes, we might only want to disable internal devices.
Could you check what mutter does? Its tablet support isn't perfect by any means, but there's one maintainer constantly using it with a tablet.
@@ -1572,6 +1598,13 @@ fn should_intercept_key( | |||
disable_power_key_handling, | |||
); | |||
|
|||
if tablet_mode { | |||
if final_action != Some(Action::ToggleTabletMode) { | |||
suppressed_keys.insert(key_code); |
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.
Doesn't this need to remove on key release?
@@ -697,6 +703,10 @@ impl State { | |||
} | |||
|
|||
fn on_pointer_motion<I: InputBackend>(&mut self, event: I::PointerMotionEvent) { | |||
if self.niri.tablet_mode { |
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'm thinking, maybe handle all of these one level above? I.e. before dispatching in process_input_event()
, do:
if self.niri.tablet_mode && matches!(event, ...) {
return;
}
@@ -195,6 +195,7 @@ pub struct Niri { | |||
pub gesture_swipe_3f_cumulative: Option<(f64, f64)>, | |||
|
|||
pub lock_state: LockState, | |||
pub tablet_mode: bool, |
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.
pub tablet_mode: bool, | |
// Tablet mode for convertibles: disable regular pointer and keyboard input. | |
pub tablet_mode: bool, |
As far as I can tell, mutter just sets a property called Unfortunately, the tablet switch in my convertible is not supported on linux, so I cannot verify this behavior myself. I'm inclined to shelve this PR until testing can be done on more devices. |
Alright, thanks for checking. No rush, let's wait until we figure out better what's happening. |
I think it's a useful feature to have regardless. I have an old convertible laptop.... somewhere I can use for testing if it would help, but it never had consistently working "tablet mode" in any DE. so I think having niri capable of doing it at the compositor level is at least useful. |
So apparently that's exactly what happens on ThinkPad convertibles at least, the keyboard is disabled at a hardware level. In Mutter / Shell it just makes the on-screen keyboard pop up, and enables auto-rotation (although I've heard feedback that the auto-rotation toggle should not really be tied to the tablet mode, as it can be useful outside also). |
#747 added the ability to bind commands to switch events, so you can bind a command that toggles the on-screen keyboard when going to tablet mode. I guess that's all that's needed more or less? |
Can be triggered by a dedicated hardware switch, or by a toggle action.
Open question: Can we reliably distinguish internal from external devices? If yes, we might only want to disable internal devices.