egui
egui copied to clipboard
File drag and drop not working under wayland
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.
Do you get a WindowEvent::DroppedFile
in egui-winit/src/lib.rs
?
How do I best test for this? I basically use the code provided here (under ui_file_drag_and_drop
)
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
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.
Thanks for the clarification that it's the responsibility of winit. There is an open issue in for exactly that: https://github.com/rust-windowing/winit/issues/1881 Currently, it's just not implemented yet. If it is resolved, we can mark this issue as resolved as well.
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,
}