Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

exoticorn
Copy link
Contributor

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.

Can be triggered by a dedicated hardware switch, or by a toggle action.
Copy link
Owner

@YaLTeR YaLTeR left a 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);
Copy link
Owner

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 {
Copy link
Owner

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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub tablet_mode: bool,
// Tablet mode for convertibles: disable regular pointer and keyboard input.
pub tablet_mode: bool,

@exoticorn
Copy link
Contributor Author

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.

As far as I can tell, mutter just sets a property called touch-mode but doesn't change anything input-related in tablet/touch-mode. This now makes me question this whole PR. It could very well be that disabling keyboard & touch pad is supposed to happen at a level below the compositor.

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.

@YaLTeR
Copy link
Owner

YaLTeR commented Mar 3, 2024

Alright, thanks for checking. No rush, let's wait until we figure out better what's happening.

@Quackdoc
Copy link

Quackdoc commented Mar 4, 2024

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.

@YaLTeR
Copy link
Owner

YaLTeR commented Mar 5, 2024

As far as I can tell, mutter just sets a property called touch-mode but doesn't change anything input-related in tablet/touch-mode. This now makes me question this whole PR. It could very well be that disabling keyboard & touch pad is supposed to happen at a level below the compositor.

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).

@YaLTeR
Copy link
Owner

YaLTeR commented Nov 4, 2024

#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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants