winit/wayland: Subsurfaces for drag surfaces

Use `Icon::Surface` instead of `Icon::Buffer`, so we can then create
subsurfaces of the `wl_surface`.

Using `.screenshot()` then copying to an shm buffer is suboptimal, but
this does seem overall better than with the older Iced version when a
drag surface didn't appear until a Vulkan surface could be created for
it.

This re-uses `Connection` in the platform-specific code, instead of
creating from display handle on each call.
This commit is contained in:
Ian Douglas Scott 2024-12-17 15:13:24 -08:00 committed by Ashley Wulber
parent 545ecb8a8a
commit fde0689def
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
6 changed files with 190 additions and 26 deletions

View file

@ -24,6 +24,7 @@ pub use iced_program as program;
pub use program::core;
pub use program::graphics;
pub use program::runtime;
use raw_window_handle::HasWindowHandle;
pub use runtime::futures;
use window_clipboard::mime::ClipboardStoreData;
pub use winit;
@ -657,6 +658,10 @@ async fn run_instance<P>(
let mut clipboard = Clipboard::unconnected();
let mut cur_dnd_surface: Option<window::Id> = None;
let mut dnd_surface: Option<
Arc<Box<dyn HasWindowHandle + Send + Sync + 'static>>,
> = None;
#[cfg(feature = "a11y")]
let (mut adapters, mut a11y_enabled) = (Default::default(), false);
// let (mut adapters, mut a11y_enabled) = if let Some((main_id, title, raw)) =
@ -1133,7 +1138,8 @@ async fn run_instance<P>(
},
cursor,
);
platform_specific_handler.clear_subsurface_list();
platform_specific_handler
.update_subsurfaces(id, window.raw.rwh_06_window_handle());
draw_span.finish();
if let user_interface::State::Updated {
@ -1508,7 +1514,14 @@ async fn run_instance<P>(
dnd::DndEvent::Offer(..) => {
events.push((cur_dnd_surface, core::Event::Dnd(e)));
}
dnd::DndEvent::Source(_) => {
dnd::DndEvent::Source(evt) => {
match evt {
dnd::SourceEvent::Finished
| dnd::SourceEvent::Cancelled => {
dnd_surface = None;
}
_ => {}
}
for w in window_manager.ids() {
events.push((Some(w), core::Event::Dnd(e.clone())));
}