Skip to content

Commit

Permalink
subsurface: Remove width/height arguments to Subsurface::new
Browse files Browse the repository at this point in the history
In an earlier version, this took a `WlBuffer`, so the width/height
arguments were needed. But since using the same `wl_buffer` multiple
times conflicted with `release` handling we instead accept
`SubsurfaceBuffer`, which stores the same height/width.
  • Loading branch information
ids1024 committed Dec 3, 2024
1 parent 36c2a66 commit bd109b6
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions winit/src/platform_specific/wayland/subsurface_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ pub(crate) fn take_subsurfaces() -> Vec<SubsurfaceInfo> {

#[must_use]
pub struct Subsurface {
buffer_size: Size<f32>,
buffer: SubsurfaceBuffer,
width: Length,
height: Length,
Expand All @@ -603,10 +602,12 @@ where
_renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
let raw_size =
limits.resolve(self.width, self.height, self.buffer_size);
let buffer_size =
Size::new(self.buffer.width() as f32, self.buffer.height() as f32);

let full_size = self.content_fit.fit(self.buffer_size, raw_size);
let raw_size = limits.resolve(self.width, self.height, buffer_size);

let full_size = self.content_fit.fit(buffer_size, raw_size);

let final_size = Size {
width: match self.width {
Expand Down Expand Up @@ -645,13 +646,8 @@ where
}

impl Subsurface {
pub fn new(
buffer_width: u32,
buffer_height: u32,
buffer: SubsurfaceBuffer,
) -> Self {
pub fn new(buffer: SubsurfaceBuffer) -> Self {
Self {
buffer_size: Size::new(buffer_width as f32, buffer_height as f32),
buffer,
// Matches defaults of image widget
width: Length::Shrink,
Expand Down

0 comments on commit bd109b6

Please sign in to comment.