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

File drag and drop not working under wayland #1563

Open
tfachmann opened this issue May 3, 2022 · 6 comments
Open

File drag and drop not working under wayland #1563

tfachmann opened this issue May 3, 2022 · 6 comments
Labels
bug Something is broken egui-winit porblems related to winit native-linux Problem specific to Linux

Comments

@tfachmann
Copy link

Describe the bug
Under wayland, File drag and drop is unrecognized. In particular, the following two interfaces are always empty:

&ctx.input().raw.hovered_files
&ctx.input().raw.dropped_files

To Reproduce
Use the egui::DroppedFile interface under wayland.

Expected behavior
Under wayland, raw.hovered_files and raw.dropped_files should be recognized and processed.
Under the web, the events are recognized.
Under Xwayland (via env -u WAYLAND_DISPLAY cargo run) the events are also recognized

Desktop (please complete the following information):

  • OS: 5.17.5-arch1-1
  • WM: sway version 1.7
  • Version: egui = "0.18.0" && eframe = "0.18.0"

Additional context

I tried forcing

let mut native_options = eframe::NativeOptions::default();
native_options.drag_and_drop_support = true;

with no luck.

@tfachmann tfachmann added the bug Something is broken label May 3, 2022
@emilk
Copy link
Owner

emilk commented May 3, 2022

Do you get a WindowEvent::DroppedFile in egui-winit/src/lib.rs?

@tfachmann
Copy link
Author

tfachmann commented May 3, 2022

How do I best test for this? I basically use the code provided here (under ui_file_drag_and_drop)

@tfachmann
Copy link
Author

Ok, I built it manually. This are prints of the Event under wayland:

Received Event: CursorMoved { device_id: DeviceId(Wayland(DeviceId)), position: PhysicalPosition { x: 75.5234375, y: 225.234375 }, modifiers: (empty) }
Received Event: CursorMoved { device_id: DeviceId(Wayland(DeviceId)), position: PhysicalPosition { x: 34.3203125, y: 235.41796875 }, modifiers: (empty) }
Received Event: CursorLeft { device_id: DeviceId(Wayland(DeviceId)) }
Received Event: Focused(false)
Received Event: Focused(true)
Received Event: ModifiersChanged((empty))
Received Event: CursorEntered { device_id: DeviceId(Wayland(DeviceId)) }
Received Event: CursorMoved { device_id: DeviceId(Wayland(DeviceId)), position: PhysicalPosition { x: 408.11328125, y: 212.62890625 }, modifiers: (empty) }

and this under Xwayland:

Received Event: AxisMotion { device_id: DeviceId(X(DeviceId(2))), axis: 0, value: 968.0 }
Received Event: AxisMotion { device_id: DeviceId(X(DeviceId(2))), axis: 1, value: 781.0 }
Received Event: ModifiersChanged((empty))
Received Event: Focused(false)
Received Event: Focused(true)
Received Event: CursorMoved { device_id: DeviceId(X(DeviceId(2))), position: PhysicalPosition { x: 3.0, y: 221.0 }, modifiers: (empty) }
Received Event: HoveredFile("/home/timo/bitmap.png")
Received Event: DroppedFile("/home/timo/bitmap.png")
Received Event: HoveredFileCancelled
Received Event: ModifiersChanged((empty))
Received Event: Focused(false)
Received Event: Focused(true)
Received Event: CursorMoved { device_id: DeviceId(X(DeviceId(2))), position: PhysicalPosition { x: 3.0, y: 221.0 }, modifiers: (empty) }
Received Event: CursorMoved { device_id: DeviceId(X(DeviceId(2))), position: PhysicalPosition { x: 427.0, y: 173.0 }, modifiers: (empty) }
Received Event: AxisMotion { device_id: DeviceId(X(DeviceId(2))), axis: 0, value: 1392.0 }

So indeed, no WindowEvent::DroppedFile is emitted

@emilk
Copy link
Owner

emilk commented May 4, 2022

Then that sounds like a bug in winit. I suggest making a simple drag-and-drop demo for winit (you can find some templates at https://github.com/rust-windowing/winit/tree/master/examples) and open an winit issue.

@emilk emilk added the egui-winit porblems related to winit label May 4, 2022
@tfachmann
Copy link
Author

Thanks for the clarification that it's the responsibility of winit. There is an open issue in for exactly that: rust-windowing/winit#1881
Currently, it's just not implemented yet. If it is resolved, we can mark this issue as resolved as well.

@emilk emilk added the native-linux Problem specific to Linux label May 4, 2022
@thomas992
Copy link
Contributor

thomas992 commented May 31, 2022

I think this is relevant
docs
drag and drop wayland

line 68 winit>src>lib.rs

    pub fn new_with_wayland_display(wayland_display: Option<*mut c_void>) -> Self {
        Self {
            start_time: instant::Instant::now(),
            egui_input: Default::default(),
            pointer_pos_in_points: None,
            any_pointer_button_down: false,
            current_cursor_icon: egui::CursorIcon::Default,
            current_pixels_per_point: 1.0,

            clipboard: clipboard::Clipboard::new(wayland_display),
            screen_reader: screen_reader::ScreenReader::default(),

            simulate_touch_screen: false,
            pointer_touch_id: None,
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui-winit porblems related to winit native-linux Problem specific to Linux
Projects
None yet
Development

No branches or pull requests

3 participants