Skip to content

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

@girtsf

Description

@girtsf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions