subsurface_widget: Sort parent WlSurface, not ObjectId

This commit is contained in:
Ian Douglas Scott 2025-03-27 12:10:32 -07:00 committed by Ashley Wulber
parent 9f07d15617
commit 02bd5d17ef
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
5 changed files with 18 additions and 19 deletions

View file

@ -132,7 +132,7 @@ impl SctkEventLoop {
.enumerate() .enumerate()
.filter_map(|(i, s)| { .filter_map(|(i, s)| {
(winit::window::WindowId::from_raw( (winit::window::WindowId::from_raw(
s.instance.parent.as_ptr() s.instance.parent.id().as_ptr()
as usize, as usize,
) == w.window.id()) ) == w.window.id())
.then_some(i) .then_some(i)

View file

@ -1016,7 +1016,7 @@ impl SctkState {
.subsurfaces .subsurfaces
.drain(..) .drain(..)
.partition(|s| { .partition(|s| {
s.instance.parent == l.surface.wl_surface().id() s.instance.parent == *l.surface.wl_surface()
}); });
self.subsurfaces = remaining; self.subsurfaces = remaining;
@ -1244,7 +1244,7 @@ impl SctkState {
.subsurfaces .subsurfaces
.drain(..) .drain(..)
.partition(|s| { .partition(|s| {
s.instance.parent == popup.popup.wl_surface().id() s.instance.parent == *popup.popup.wl_surface()
}); });
self.subsurfaces = remaining; self.subsurfaces = remaining;
@ -1365,7 +1365,7 @@ impl SctkState {
.subsurfaces .subsurfaces
.drain(..) .drain(..)
.partition(|s| { .partition(|s| {
s.instance.parent == surface.session_lock_surface.wl_surface().id() s.instance.parent == *surface.session_lock_surface.wl_surface()
}); });
self.subsurfaces = remaining; self.subsurfaces = remaining;
@ -1443,7 +1443,7 @@ impl SctkState {
for (destroyed, parent) in destroyed { for (destroyed, parent) in destroyed {
if let Some((wl_surface, f)) = self.seats.iter_mut().find(|f| { if let Some((wl_surface, f)) = self.seats.iter_mut().find(|f| {
f.kbd_focus.as_ref().is_some_and(|f| *f == destroyed) f.kbd_focus.as_ref().is_some_and(|f| *f == destroyed)
}).and_then(|f| WlSurface::from_id(&self.connection, parent).ok().map(|wl| (wl, &mut f.kbd_focus))) { }).and_then(|f| Some((parent, &mut f.kbd_focus))) {
*f = Some(wl_surface); *f = Some(wl_surface);
} }
} }
@ -1610,7 +1610,7 @@ impl SctkState {
transform: transform:
cctk::wayland_client::protocol::wl_output::Transform::Normal, cctk::wayland_client::protocol::wl_output::Transform::Normal,
z: settings.z, z: settings.z,
parent: parent_wl_surface.id(), parent: parent_wl_surface.clone(),
}; };
common.wp_viewport = Some(wp_viewport); common.wp_viewport = Some(wp_viewport);
let common = Arc::new(Mutex::new(common)); let common = Arc::new(Mutex::new(common));

View file

@ -34,7 +34,7 @@ impl KeyboardHandler for SctkState {
let surface = if let Some(subsurface) = let surface = if let Some(subsurface) =
self.subsurfaces.iter().find(|s| { self.subsurfaces.iter().find(|s| {
s.steals_keyboard_focus && s.instance.parent == surface.id() s.steals_keyboard_focus && s.instance.parent == *surface
}) { }) {
&subsurface.instance.wl_surface &subsurface.instance.wl_surface
} else { } else {
@ -53,7 +53,7 @@ impl KeyboardHandler for SctkState {
self.request_redraw(&surface); self.request_redraw(&surface);
let surfaces = self.subsurfaces.iter().filter_map(|s| { let surfaces = self.subsurfaces.iter().filter_map(|s| {
(s.instance.parent == surface.id()).then(|| &s.instance.wl_surface) (s.instance.parent == *surface).then(|| &s.instance.wl_surface)
}); });
for surface in surfaces.chain(std::iter::once(surface)) { for surface in surfaces.chain(std::iter::once(surface)) {
if is_active { if is_active {
@ -104,7 +104,7 @@ impl KeyboardHandler for SctkState {
(is_active, seat, kbd) (is_active, seat, kbd)
}; };
let surfaces = self.subsurfaces.iter().filter_map(|s| { let surfaces = self.subsurfaces.iter().filter_map(|s| {
(s.instance.parent == surface.id()).then(|| &s.instance.wl_surface) (s.instance.parent == *surface).then(|| &s.instance.wl_surface)
}); });
for surface in surfaces.chain(std::iter::once(surface)) { for surface in surfaces.chain(std::iter::once(surface)) {
if is_active { if is_active {
@ -169,7 +169,7 @@ impl KeyboardHandler for SctkState {
if let Some(surface) = my_seat.kbd_focus.clone() { if let Some(surface) = my_seat.kbd_focus.clone() {
self.request_redraw(&surface); self.request_redraw(&surface);
let surfaces = self.subsurfaces.iter().filter_map(|s| { let surfaces = self.subsurfaces.iter().filter_map(|s| {
(s.instance.parent == surface.id()) (s.instance.parent == surface)
.then(|| &s.instance.wl_surface) .then(|| &s.instance.wl_surface)
}); });
for surface in surfaces.chain(std::iter::once(&surface)) { for surface in surfaces.chain(std::iter::once(&surface)) {
@ -210,7 +210,7 @@ impl KeyboardHandler for SctkState {
if let Some(surface) = my_seat.kbd_focus.clone() { if let Some(surface) = my_seat.kbd_focus.clone() {
self.request_redraw(&surface); self.request_redraw(&surface);
let surfaces = self.subsurfaces.iter().filter_map(|s| { let surfaces = self.subsurfaces.iter().filter_map(|s| {
(s.instance.parent == surface.id()) (s.instance.parent == surface)
.then(|| &s.instance.wl_surface) .then(|| &s.instance.wl_surface)
}); });
for surface in surfaces.chain(std::iter::once(&surface)) { for surface in surfaces.chain(std::iter::once(&surface)) {
@ -252,7 +252,7 @@ impl KeyboardHandler for SctkState {
if let Some(surface) = my_seat.kbd_focus.clone() { if let Some(surface) = my_seat.kbd_focus.clone() {
self.request_redraw(&surface); self.request_redraw(&surface);
let surfaces = self.subsurfaces.iter().filter_map(|s| { let surfaces = self.subsurfaces.iter().filter_map(|s| {
(s.instance.parent == surface.id()) (s.instance.parent == surface)
.then(|| &s.instance.wl_surface) .then(|| &s.instance.wl_surface)
}); });
for surface in surfaces.chain(std::iter::once(&surface)) { for surface in surfaces.chain(std::iter::once(&surface)) {

View file

@ -1462,7 +1462,7 @@ impl SctkEvent {
if let Some(subsurface_state) = subsurface_state.as_mut() { if let Some(subsurface_state) = subsurface_state.as_mut() {
subsurface_state.new_iced_subsurfaces.push(( subsurface_state.new_iced_subsurfaces.push((
parent_id, parent_id,
parent.id(), parent,
surface_id, surface_id,
wl_subsurface.clone(), wl_subsurface.clone(),
wl_surface.clone(), wl_surface.clone(),

View file

@ -42,7 +42,6 @@ use cctk::sctk::{
shm::slot::SlotPool, shm::slot::SlotPool,
}; };
use iced_futures::core::window; use iced_futures::core::window;
use wayland_backend::client::ObjectId;
use wayland_protocols::wp::{ use wayland_protocols::wp::{
alpha_modifier::v1::client::{ alpha_modifier::v1::client::{
wp_alpha_modifier_surface_v1::WpAlphaModifierSurfaceV1, wp_alpha_modifier_surface_v1::WpAlphaModifierSurfaceV1,
@ -370,7 +369,7 @@ pub struct SubsurfaceState {
pub(crate) unmapped_subsurfaces: Vec<SubsurfaceInstance>, pub(crate) unmapped_subsurfaces: Vec<SubsurfaceInstance>,
pub new_iced_subsurfaces: Vec<( pub new_iced_subsurfaces: Vec<(
window::Id, window::Id,
ObjectId, WlSurface,
window::Id, window::Id,
WlSubsurface, WlSubsurface,
WlSurface, WlSurface,
@ -459,7 +458,7 @@ impl SubsurfaceState {
wp_fractional_scale: None, wp_fractional_scale: None,
transform: wl_output::Transform::Normal, transform: wl_output::Transform::Normal,
z: 0, z: 0,
parent: parent.id(), parent: parent.clone(),
} }
} }
@ -622,7 +621,7 @@ pub(crate) struct SubsurfaceInstance {
pub(crate) bounds: Option<Rectangle<f32>>, pub(crate) bounds: Option<Rectangle<f32>>,
pub(crate) transform: wl_output::Transform, pub(crate) transform: wl_output::Transform,
pub(crate) z: u32, pub(crate) z: u32,
pub parent: ObjectId, pub parent: WlSurface,
} }
impl SubsurfaceInstance { impl SubsurfaceInstance {
@ -729,7 +728,7 @@ pub(crate) struct SubsurfaceInfo {
thread_local! { thread_local! {
static SUBSURFACES: RefCell<Vec<SubsurfaceInfo>> = RefCell::new(Vec::new()); static SUBSURFACES: RefCell<Vec<SubsurfaceInfo>> = RefCell::new(Vec::new());
static ICED_SUBSURFACES: RefCell<Vec<(window::Id, ObjectId, window::Id, WlSubsurface, WlSurface, u32)>> = RefCell::new(Vec::new()); static ICED_SUBSURFACES: RefCell<Vec<(window::Id, WlSurface, window::Id, WlSubsurface, WlSurface, u32)>> = RefCell::new(Vec::new());
} }
pub(crate) fn take_subsurfaces() -> Vec<SubsurfaceInfo> { pub(crate) fn take_subsurfaces() -> Vec<SubsurfaceInfo> {
@ -742,7 +741,7 @@ pub(crate) fn subsurface_ids(parent: WindowId) -> Vec<WindowId> {
.borrow_mut() .borrow_mut()
.iter() .iter()
.filter_map(|s| { .filter_map(|s| {
if winit::window::WindowId::from_raw(s.1.as_ptr() as usize) if winit::window::WindowId::from_raw(s.1.id().as_ptr() as usize)
== parent == parent
{ {
Some(winit::window::WindowId::from_raw( Some(winit::window::WindowId::from_raw(