winit/wayland: Allow Vec for input_zone

This commit is contained in:
Ian Douglas Scott 2025-09-18 13:05:18 -07:00 committed by Ashley Wulber
parent 621713fe15
commit 20e60ffde6
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
3 changed files with 20 additions and 16 deletions

View file

@ -27,7 +27,7 @@ pub struct SctkPopupSettings {
pub close_with_children: bool,
/// input zone
/// None results in accepting all input
pub input_zone: Option<Rectangle>,
pub input_zone: Option<Vec<Rectangle>>,
}
impl Hash for SctkPopupSettings {

View file

@ -35,7 +35,7 @@ pub struct SctkSubsurfaceSettings {
/// input zone
/// None results in accepting all input
pub input_zone: Option<Rectangle>,
pub input_zone: Option<Vec<Rectangle>>,
}
impl Hash for SctkSubsurfaceSettings {

View file

@ -729,17 +729,19 @@ impl SctkState {
let wl_surface =
self.compositor_state.create_surface(&self.queue_handle);
_ = self.id_map.insert(wl_surface.id(), settings.id.clone());
if let Some(z) = settings.input_zone {
if let Some(zone) = &settings.input_zone {
let region = self
.compositor_state
.wl_compositor()
.create_region(&self.queue_handle, ());
region.add(
z.x.round() as i32,
z.y.round() as i32,
z.width.round() as i32,
z.height.round() as i32,
);
for rect in zone {
region.add(
rect.x.round() as i32,
rect.y.round() as i32,
rect.width.round() as i32,
rect.height.round() as i32,
);
}
wl_surface.set_input_region(Some(&region));
}
let (toplevel, popup) = match &parent {
@ -1684,17 +1686,19 @@ impl SctkState {
);
wl_subsurface.set_position(bounds.x as i32, bounds.y as i32);
_ = wl_surface.frame(&self.queue_handle, wl_surface.clone());
if let Some(zone) = settings.input_zone {
if let Some(zone) = &settings.input_zone {
let region = self
.compositor_state
.wl_compositor()
.create_region(&self.queue_handle, ());
region.add(
zone.x.round() as i32,
zone.y.round() as i32,
zone.width.round() as i32,
zone.height.round() as i32,
);
for rect in zone {
region.add(
rect.x.round() as i32,
rect.y.round() as i32,
rect.width.round() as i32,
rect.height.round() as i32,
);
}
wl_surface.set_input_region(Some(&region));
region.destroy();
}