Skip to content

Commit

Permalink
subsurface_widget: Remove subsurface_ids
Browse files Browse the repository at this point in the history
This was previously needed, but should be redundant now that an empty
input region is set for the subsurface. With that, the subsurface should
never get input events, so mapping them isn't needed.
  • Loading branch information
ids1024 committed Nov 21, 2024
1 parent 5e20091 commit 4fe9e3d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 43 deletions.
8 changes: 4 additions & 4 deletions winit/src/platform_specific/wayland/handlers/seat/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ impl KeyboardHandler for SctkState {
winit::event::WindowEvent::Focused(true),
));
self.sctk_events.push(SctkEvent::KeyboardEvent {
variant: KeyboardEventVariant::Enter(surface.clone()),
kbd_id: keyboard.clone(),
seat_id: seat,
surface: surface.clone(),
variant: KeyboardEventVariant::Enter(surface.clone()),
kbd_id: keyboard.clone(),
seat_id: seat,
surface: surface.clone(),
});
}
}
Expand Down
5 changes: 0 additions & 5 deletions winit/src/platform_specific/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub(crate) struct WaylandSpecific {
modifiers: Modifiers,
surface_ids: HashMap<ObjectId, SurfaceIdWrapper>,
destroyed_surface_ids: HashMap<ObjectId, SurfaceIdWrapper>,
subsurface_ids: HashMap<ObjectId, (i32, i32, window::Id)>,
subsurface_state: Option<SubsurfaceState>,
surface_subsurfaces: HashMap<window::Id, Vec<SubsurfaceInstance>>,
}
Expand Down Expand Up @@ -138,7 +137,6 @@ impl WaylandSpecific {
display_handle,
surface_ids,
destroyed_surface_ids,
subsurface_ids,
modifiers,
subsurface_state,
surface_subsurfaces,
Expand All @@ -165,7 +163,6 @@ impl WaylandSpecific {
compositor,
window_manager,
surface_ids,
subsurface_ids,
sender,
event_sender,
proxy,
Expand Down Expand Up @@ -198,8 +195,6 @@ impl WaylandSpecific {
};

subsurface_state.update_subsurfaces(
id,
&mut self.subsurface_ids,
wl_surface,
surface_subsurfaces,
&subsurfaces,
Expand Down
18 changes: 3 additions & 15 deletions winit/src/platform_specific/wayland/sctk_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ impl SctkEvent {
compositor: &mut C,
window_manager: &mut crate::program::WindowManager<P, C>,
surface_ids: &mut HashMap<ObjectId, SurfaceIdWrapper>,
subsurface_ids: &mut HashMap<ObjectId, (i32, i32, window::Id)>,
sctk_tx: &channel::Sender<super::Action>,
control_sender: &mpsc::UnboundedSender<Control>,
proxy: &EventLoopProxy,
Expand Down Expand Up @@ -326,34 +325,23 @@ impl SctkEvent {
iced_runtime::core::Event::Mouse(mouse::Event::CursorLeft),
)),
PointerEventKind::Motion { .. } => {
let offset = if let Some((x_offset, y_offset, _)) =
subsurface_ids.get(&variant.surface.id())
{
(*x_offset, *y_offset)
} else {
(0, 0)
};
let id = surface_ids
.get(&variant.surface.id())
.map(|id| id.inner());
if let Some(w) =
id.clone().and_then(|id| window_manager.get_mut(id))
{
w.state.set_logical_cursor_pos(
(
variant.position.0 + offset.0 as f64,
variant.position.1 + offset.1 as f64,
)
.into(),
(variant.position.0, variant.position.1).into(),
)
}
events.push((
id,
iced_runtime::core::Event::Mouse(
mouse::Event::CursorMoved {
position: Point::new(
variant.position.0 as f32 + offset.0 as f32,
variant.position.1 as f32 + offset.1 as f32,
variant.position.0 as f32,
variant.position.1 as f32,
),
},
),
Expand Down
20 changes: 1 addition & 19 deletions winit/src/platform_specific/wayland/subsurface_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ impl SubsurfaceState {
// Update `subsurfaces` from `view_subsurfaces`
pub(crate) fn update_subsurfaces(
&mut self,
parent_id: window::Id,
subsurface_ids: &mut HashMap<ObjectId, (i32, i32, window::Id)>,
parent: &WlSurface,
subsurfaces: &mut Vec<SubsurfaceInstance>,
view_subsurfaces: &[SubsurfaceInfo],
Expand Down Expand Up @@ -405,16 +403,7 @@ impl SubsurfaceState {
for (subsurface_data, subsurface) in
view_subsurfaces.iter().zip(subsurfaces.iter_mut())
{
subsurface.attach_and_commit(
parent_id,
subsurface_ids,
subsurface_data,
self,
);
}

if let Some(backend) = parent.backend().upgrade() {
subsurface_ids.retain(|k, _| backend.info(k.clone()).is_ok());
subsurface.attach_and_commit(subsurface_data, self);
}
}

Expand Down Expand Up @@ -478,8 +467,6 @@ impl SubsurfaceInstance {
// TODO correct damage? no damage/commit if unchanged?
fn attach_and_commit(
&mut self,
parent_id: window::Id,
subsurface_ids: &mut HashMap<ObjectId, (i32, i32, window::Id)>,
info: &SubsurfaceInfo,
state: &mut SubsurfaceState,
) {
Expand Down Expand Up @@ -542,11 +529,6 @@ impl SubsurfaceInstance {
wp_alpha_modifier_surface.set_multiplier(alpha);
}

_ = subsurface_ids.insert(
self.wl_surface.id(),
(info.bounds.x as i32, info.bounds.y as i32, parent_id),
);

self.wl_buffer = Some(buffer);
self.bounds = Some(info.bounds);
}
Expand Down

0 comments on commit 4fe9e3d

Please sign in to comment.