Skip to content

Commit

Permalink
restore previous maximized window state when restore config is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jan 16, 2024
1 parent a1b2154 commit f92d963
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions v2/src/persistent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub struct WindowState {
pub fullscreen: bool,
pub zoom_level: ZoomLevel,
pub always_on_top: bool,
pub maximized: bool,
}

impl PersistentData for WindowState {
Expand Down
16 changes: 14 additions & 2 deletions v2/src/wry/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,25 @@ impl WebViewRenderer {

let window_state = if config.window().restore { config.data_dir().load() } else { None };
let (zoom_level, always_on_top) = if let Some(state) = window_state {
let WindowState { height, width, x, y, fullscreen, zoom_level, always_on_top } = state;
let WindowState {
height,
width,
x,
y,
fullscreen,
zoom_level,
always_on_top,
maximized,
} = state;
log::debug!("Restoring window state {state:?}");
let size = PhysicalSize { width, height };
builder = builder.with_inner_size(size);
let position = PhysicalPosition { x, y };
builder = builder.with_position(position);
if fullscreen {
builder = builder.with_fullscreen(Some(Fullscreen::Borderless(None)));
} else if maximized {
builder = builder.with_maximized(true);
}
(zoom_level, always_on_top)
} else {
Expand Down Expand Up @@ -279,7 +290,8 @@ impl Renderer for WebViewRenderer {
let fullscreen = self.window.fullscreen().is_some();
let zoom_level = self.zoom_level;
let always_on_top = self.always_on_top;
Some(WindowState { width, height, x, y, fullscreen, zoom_level, always_on_top })
let maximized = self.window.is_maximized();
Some(WindowState { width, height, x, y, fullscreen, zoom_level, always_on_top, maximized })
}

fn theme(&self) -> RendererTheme {
Expand Down

0 comments on commit f92d963

Please sign in to comment.