From bb860f438fa394d02bfb85d6124cdf123607945e Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 23 Sep 2024 09:21:46 -0400 Subject: [PATCH] fix: insert user interfaces for popup and lock surfaces on creation --- .../wayland/event_loop/state.rs | 2 - .../platform_specific/wayland/sctk_event.rs | 42 +++++++++++++++++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/winit/src/platform_specific/wayland/event_loop/state.rs b/winit/src/platform_specific/wayland/event_loop/state.rs index f3c985e185..d614bb18d1 100644 --- a/winit/src/platform_specific/wayland/event_loop/state.rs +++ b/winit/src/platform_specific/wayland/event_loop/state.rs @@ -793,7 +793,6 @@ impl SctkState { } => { let title = builder.namespace.clone(); if let Ok((id, wl_surface, common)) = self.get_layer_surface(builder) { - let object_id = wl_surface.id(); // TODO Ashley: all surfaces should probably have an optional title for a11y if nothing else send_event(&self.events_sender, SctkEvent::LayerSurfaceEvent { @@ -810,7 +809,6 @@ impl SctkState { } => { if let Some(layer_surface) = self.layer_surfaces.iter_mut().find(|l| l.id == id) { layer_surface.set_size(width, height); - // pending_redraws.push(layer_surface.surface.wl_surface().id()); let wl_surface = layer_surface.surface.wl_surface(); if let Some(mut prev_configure) = layer_surface.last_configure.clone() { diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 4b0fca8335..8bd6bf4be5 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -674,7 +674,7 @@ impl SctkEvent { iced_runtime::core::Event::Keyboard( keyboard::Event::KeyReleased { key: k, - location: location, + location, modifiers: modifiers_to_native(*modifiers), }, ), @@ -955,11 +955,27 @@ impl SctkEvent { ); } - _ = window_manager.insert( + let window = window_manager.insert( surface_id, sctk_winit, program, compositor, false, // TODO do we want to get this value here? 0, ); + let logical_size = window.size(); + + let _ = user_interfaces.insert( + surface_id, + crate::program::build_user_interface( + program, + user_interface::Cache::default(), + &mut window.renderer, + logical_size, + debug, + surface_id, + window.raw.clone(), + window.prev_dnd_destination_rectangles_count, + clipboard, + ), + ); } PopupEventVariant::Configure(_, _, _) => {} // TODO PopupEventVariant::RepositionionedPopup { token: _ } => {} @@ -1021,8 +1037,9 @@ impl SctkEvent { common, display, } => { + let object_id = surface.id().clone(); let wrapper = SurfaceIdWrapper::SessionLock(surface_id.clone()); - _ = surface_ids.insert(surface.id().clone(), wrapper.clone()); + _ = surface_ids.insert(object_id.clone(), wrapper.clone()); let sctk_winit = SctkWinitWindow::new( sctk_tx.clone(), common, @@ -1077,11 +1094,28 @@ impl SctkEvent { ); } - _ = window_manager.insert( + let window = window_manager.insert( surface_id, sctk_winit, program, compositor, false, // TODO do we want to get this value here? 0, ); + _ = surface_ids.insert(object_id, wrapper.clone()); + let logical_size = window.size(); + + let _ = user_interfaces.insert( + surface_id, + crate::program::build_user_interface( + program, + user_interface::Cache::default(), + &mut window.renderer, + logical_size, + debug, + surface_id, + window.raw.clone(), + window.prev_dnd_destination_rectangles_count, + clipboard, + ), + ); } SctkEvent::SessionLockSurfaceConfigure { .. } => {} SctkEvent::SessionLockSurfaceDone { surface } => {