Skip to content

Commit

Permalink
Delaying resize until after render
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Sep 22, 2024
1 parent 1aa7563 commit 8561b6c
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,27 @@ where
let render_size = actual_size.min(window_size);
layout_context.invalidate_when_changed(&self.inner_size);
layout_context.invalidate_when_changed(&self.resize_to_fit);

self.root.set_layout(Rect::from(render_size.into_signed()));

if self.initial_frame {
self.initial_frame = false;
self.root
.lock()
.as_widget()
.mounted(&mut layout_context.as_event_context());
layout_context.focus();
layout_context.as_event_context().apply_pending_state();
}

if render_size.width < window_size.width || render_size.height < window_size.height {
layout_context
.clipped_to(Rect::from(render_size.into_signed()))
.redraw();
} else {
layout_context.redraw();
}

let new_size = if let Some(new_size) = self.inner_size.updated() {
layout_context.request_inner_size(*new_size)
} else if actual_size != window_size && !resizable {
Expand All @@ -1934,25 +1955,6 @@ where
self.outer_size.set(layout_context.window().outer_size());
self.root.invalidate();
}
self.root.set_layout(Rect::from(render_size.into_signed()));

if self.initial_frame {
self.initial_frame = false;
self.root
.lock()
.as_widget()
.mounted(&mut layout_context.as_event_context());
layout_context.focus();
layout_context.as_event_context().apply_pending_state();
}

if render_size.width < window_size.width || render_size.height < window_size.height {
layout_context
.clipped_to(Rect::from(render_size.into_signed()))
.redraw();
} else {
layout_context.redraw();
}
}

fn close_requested<W>(&mut self, window: W, kludgine: &mut Kludgine) -> bool
Expand Down

0 comments on commit 8561b6c

Please sign in to comment.