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

[Left/RightShift + <key>] not picked up by get_keys on wayland #349

Open
bhavyakukkar opened this issue Mar 28, 2024 · 1 comment
Open
Labels

Comments

@bhavyakukkar
Copy link

When pressing the Left/Right-Shift key first, followed by any other key, the set of keys down returned by get_keys only contains the Left/Right-Shift key on the wayland build.

This is a program to demonstrate the issue:

use minifb::{Key, Window, WindowOptions, KeyRepeat};

fn main() {
    let mut buffer: Vec<u32> = vec![0; 200*200];
    let mut window = Window::new("", 200, 200, WindowOptions::default()).unwrap();

    window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));

    loop {
        if window.is_open() {
            let keys = window.get_keys();
            if keys.len() == 2 {
                panic!("Received these two keys: {:?}", keys);
            }

            window
                .update_with_buffer(&buffer, 200, 200)
                .unwrap();
        }
    }
}

This program,

  • when run with only the 'x11' cargo feature:

does panic when LeftShift+L (LeftShift then L) is typed (desired behavior)

thread 'main' panicked at src/main.rs:13:17:
Received these two keys: [L, LeftShift]
  • when run with only the 'wayland' cargo feature:

does not panic when LeftShift+L (LeftShift then L) is typed (undesired behavior)

I have tested:

  • both builds on two wayland-compositors: sway & dwl (letting the compositor infer & start an xwayland server for the X11 builds)
    The problem only occurs in the wayland builds, i.e. the program does not panic on the wayland builds.
  • the X11 build on two xorg window-managers: dwm & bspwm
    The problem does not occur, i.e. the program does panic.

Additionally,

  • I tried both the latest crates.io version (v0.25.0) and git version (latest commit 29af982) of minifb

$ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04) (Void Linux)

bhavyakukkar added a commit to bhavyakukkar/pixylene that referenced this issue Mar 30, 2024
- Force minifb to build x11 window since wayland window currently has an
  inconsistency with pressing shift keys, as reported in [this
  issue](emoon/rust_minifb#349)
@emoon emoon added the wayland label Apr 1, 2024
@emoon
Copy link
Owner

emoon commented Apr 1, 2024

Thanks for the report

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

No branches or pull requests

2 participants