Skip to content

Commit

Permalink
Handle resize if only one dimension is given.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Jul 17, 2024
1 parent 7b06526 commit 61c6753
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions window/src/os/wayland/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ impl WaylandWindow {
window: Some(window),
window_frame,
dimensions,
outer_size: (w, h),
resize_increments: None,
window_state: WindowState::default(),
last_mouse_coords: Point::new(0, 0),
Expand Down Expand Up @@ -493,6 +494,8 @@ pub struct WaylandWindowInner {
window: Option<XdgWindow>,
pub(super) window_frame: FallbackFrame<WaylandState>,
dimensions: Dimensions,
/// The size of the window, including decorations, according to the last configure event.
outer_size: (u32, u32),
resize_increments: Option<ResizeIncrement>,
window_state: WindowState,
last_mouse_coords: Point,
Expand Down Expand Up @@ -794,6 +797,7 @@ impl WaylandWindowInner {
pixel_height: pixel_height.try_into().unwrap(),
dpi,
};
self.outer_size = outer_size;

// Only trigger a resize if the new dimensions are different;
// this makes things more efficient and a little more smooth
Expand Down Expand Up @@ -1228,8 +1232,17 @@ impl WindowHandler for WaylandState {
.update_wm_capabilities(configure.capabilities);

// TODO: should we resize if only one of width or height is specified?
if let (Some(w), Some(h)) = configure.new_size {
window_inner.update_size(w.get(), h.get(), qh);
match configure.new_size {
(Some(w), Some(h)) => window_inner.update_size(w.get(), h.get(), qh),
(Some(w), None) => {
let h = window_inner.outer_size.1;
window_inner.update_size(w.get(), h, qh)
}
(None, Some(h)) => {
let w = window_inner.outer_size.0;
window_inner.update_size(w, h.get(), qh)
}
_ => {}
}

if let Some(notify) = window_inner.pending_first_configure.take() {
Expand Down

0 comments on commit 61c6753

Please sign in to comment.