feat: subsurfaces

This commit is contained in:
Ashley Wulber 2025-03-14 11:16:25 -04:00 • committed by Ashley Wulber
parent 0f37c9922d
commit 93bc4bbd88
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
33 changed files with 1898 additions and 2651 deletions

View file

@ -1,6 +1,6 @@
use crate::platform_specific::wayland::Action;
use cctk::sctk::reexports::{
calloop::channel,
calloop::{LoopHandle, channel},
client::{
Proxy, QueueHandle,
protocol::{wl_display::WlDisplay, wl_surface::WlSurface},
@ -103,14 +103,14 @@ impl winit::window::Window for SctkWinitWindow {
) -> Option<winit::dpi::PhysicalSize<u32>> {
let mut guard = self.common.lock().unwrap();
self.request_redraw();
let size: LogicalSize<u32> =
let logical_size: LogicalSize<u32> =
size.to_logical(guard.fractional_scale.unwrap_or(1.));
match &self.surface {
CommonSurface::Popup(popup, positioner) => {
if size.width == 0 || size.height == 0 {
if logical_size.width == 0 || logical_size.height == 0 {
return None;
}
guard.size = size;
guard.size = logical_size;
guard.requested_size.0 = Some(guard.size.width);
guard.requested_size.1 = Some(guard.size.height);
positioner.set_size(
@ -138,16 +138,16 @@ impl winit::window::Window for SctkWinitWindow {
}
CommonSurface::Layer(layer_surface) => {
guard.requested_size = (
(size.width > 0).then_some(size.width),
(size.height > 0).then_some(size.height),
(logical_size.width > 0).then_some(logical_size.width),
(logical_size.height > 0).then_some(logical_size.height),
);
if size.width > 0 {
guard.size.width = size.width;
if logical_size.width > 0 {
guard.size.width = logical_size.width;
}
if size.height > 0 {
guard.size.height = size.height;
if logical_size.height > 0 {
guard.size.height = logical_size.height;
}
layer_surface.set_size(size.width, size.height);
layer_surface.set_size(logical_size.width, logical_size.height);
if let Some(viewport) = guard.wp_viewport.as_ref() {
// Set inner size without the borders.
viewport.set_destination(
@ -157,6 +157,23 @@ impl winit::window::Window for SctkWinitWindow {
}
}
CommonSurface::Lock(_) => {}
CommonSurface::Subsurface { .. } => {
guard.requested_size = (
(logical_size.width > 0).then_some(logical_size.width),
(logical_size.height > 0).then_some(logical_size.height),
);
guard.size = logical_size;
if let Some(viewport) = guard.wp_viewport.as_ref() {
// Set inner size without the borders.
viewport.set_destination(
guard.size.width as i32,
guard.size.height as i32,
);
}
_ = self
.tx
.send(Action::SubsurfaceResize(self.id.inner(), size));
}
}
None
}