Skip to content

Commit

Permalink
fix(wayland): match inner window and window frame sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaksandr-trush authored and wez committed Sep 22, 2024
1 parent 1c4fdd3 commit 16a8bcd
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions window/src/os/wayland/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,10 @@ impl WaylandWindow {
}

window.set_min_size(Some((32, 32)));
let (w, h) = window_frame.add_borders(
dimensions.pixel_width as u32,
dimensions.pixel_height as u32,
);
let (x, y) = window_frame.location();
window
.xdg_surface()
.set_window_geometry(x, y, w as i32, h as i32);
.set_window_geometry(x, y, dimensions.pixel_width as i32, dimensions.pixel_height as i32);
window.commit();

let copy_and_paste = CopyAndPaste::create();
Expand Down Expand Up @@ -826,23 +822,20 @@ impl WaylandWindowInner {
}

log::trace!("Resizing frame");
let (width, height) = self.window_frame.subtract_borders(
NonZeroU32::new(pixel_width as u32).unwrap(),
NonZeroU32::new(pixel_height as u32).unwrap(),
);
// Clamp the size to at least one pixel.
let width = width.unwrap_or(NonZeroU32::new(1).unwrap());
let height = height.unwrap_or(NonZeroU32::new(1).unwrap());
if !self.window_frame.is_hidden() {
// Clamp the size to at least one pixel.
let width =
NonZeroU32::new(pixel_width as u32).unwrap_or(NonZeroU32::new(1).unwrap());
let height =
NonZeroU32::new(pixel_height as u32).unwrap_or(NonZeroU32::new(1).unwrap());
self.window_frame.resize(width, height);
}
let (x, y) = self.window_frame.location();
let outer_size = self.window_frame.add_borders(width.get(), height.get());
self.window
.as_mut()
.unwrap()
.xdg_surface()
.set_window_geometry(x, y, outer_size.0 as i32, outer_size.1 as i32);
.set_window_geometry(x, y, pixel_width, pixel_height);
// Compute the new pixel dimensions
let new_dimensions = Dimensions {
pixel_width: pixel_width.try_into().unwrap(),
Expand Down

0 comments on commit 16a8bcd

Please sign in to comment.