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

touchscreen click events are not detected properly (on Linux) #4895

Closed
girtsf opened this issue Jul 31, 2024 · 2 comments · Fixed by #4939
Closed

touchscreen click events are not detected properly (on Linux) #4895

girtsf opened this issue Jul 31, 2024 · 2 comments · Fixed by #4939
Labels
bug Something is broken

Comments

@girtsf
Copy link
Contributor

girtsf commented Jul 31, 2024

Describe the bug

With any widget, such as a Button or Label, .clicked() events are not recognized when the screen is tapped once. Instead, a single tap triggers long_touched() after a delay. Tapping twice in a quick succession generates a clicked() followed by a long_touched().

To Reproduce

Cargo.toml:

[package]
name = "repro"
version = "0.1.0"
edition = "2021"

[dependencies]
egui = { git = "https://github.com/emilk/egui", branch = "master" }
eframe = { git = "https://github.com/emilk/egui", branch = "master" }

src/main.rs:

#[derive(Default)]
struct App {
    log: String,
}

impl eframe::App for App {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            let button = ui.button("click me");
            if button.clicked() {
                self.log.push_str("clicked()\n");
            }
            if button.long_touched() {
                self.log.push_str("long_touched()\n");
            }
            ui.label(&self.log);
        });
    }
}

fn main() {
    eframe::run_native(
        "test",
        eframe::NativeOptions::default(),
        Box::new(|_cc| Ok(Box::new(App::default()))),
    )
    .unwrap();
}

Steps to reproduce the behavior:

  1. cargo run the above code
  2. tap on "click me" button

Expected behavior
clicked() gets shown on the screen.

Screenshots
Screenshot from 2024-07-31 14-48-42

This can also be reproduced by egui_demo_app, built from latest master (d856f7b), by opening "Input Test" and tapping on "Sense::click" label:

Screenshot from 2024-07-31 14-53-00

Desktop:

  • OS: Ubuntu 24.04
  • Device: Lenovo Yoga 7 2-in-1 14IML9
  • Wayland

(I tested on Windows, on a slightly different touchscreen-equipped Lenovo laptop, and it works correctly there.)

Additional context

This might be related to the observations found in #4668 ?

I bisected the behavior using egui_demo_app: last working commit is 8503a85, and it breaks at 8e5959d.

@girtsf girtsf added the bug Something is broken label Jul 31, 2024
@Zoxc
Copy link
Contributor

Zoxc commented Aug 4, 2024

I see similar behavior on Android with 0.28.1.

@gfolkmanis-nhgh
Copy link

I did some further digging and found that we were not getting WindowEvent::Touch events from winit with TouchPhase::Ended when finger was lifted from the screen. Instead, the event would get sent together with the next TouchPhase::Started.

I confirmed the behavior happens with winit example code (no egui involved) on v0.30.2. Tested later versions and found that the issue was fixed in winit v0.30.4.

For funsies, I kept digging into winit changes, and it's likely that bumping to a newer smithay-client-toolkit fixed it (which brought in Smithay/client-toolkit@8708dd5). I didn't retest to confirm the exact root cause, but that's likely it.

So once egui switches to winit v0.30.4 or later, this issue should resolve itself. Looks like it is currently pinned to v0.30.2 as per #4849. Looks like the fix for that might be ready to go as of today, and #4939 might bring it in!

@emilk emilk linked a pull request Aug 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants