Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use maximized instead of fullscreen on windows #902

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog].
- Added dedicated messages for bulk actions in manage packages page `#819`
- Panics are ignored `#846`
- From this version, panics will be logged to error logs instead of stderr.
- Maximized is not saved on windows `#902`

### Security

Expand Down
29 changes: 27 additions & 2 deletions vrc-get-gui/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ macro_rules! with_config {
}};
}

trait WindowExt {
fn make_fullscreen_ish(&self) -> tauri::Result<()>;
fn is_fullscreen_ish(&self) -> tauri::Result<bool>;
}

impl WindowExt for Window {
fn make_fullscreen_ish(&self) -> tauri::Result<()> {
if cfg!(windows) {
self.maximize()
} else {
self.set_fullscreen(true)
}
}

fn is_fullscreen_ish(&self) -> tauri::Result<bool> {
if cfg!(windows) {
self.is_maximized()
} else {
self.is_fullscreen()
}
}
}

pub(crate) fn startup(app: &mut App) {
let handle = app.handle();
tauri::async_runtime::spawn(async move {
Expand Down Expand Up @@ -247,7 +270,9 @@ pub(crate) fn startup(app: &mut App) {
})?;
}

window.set_fullscreen(fullscreen)?;
if fullscreen {
window.make_fullscreen_ish()?;
}

let cloned = window.clone();

Expand All @@ -266,7 +291,7 @@ pub(crate) fn startup(app: &mut App) {
return;
}

let fullscreen = cloned.is_fullscreen().unwrap();
let fullscreen = cloned.is_fullscreen_ish().unwrap();

let mut resize_debounce = resize_debounce.lock().unwrap();

Expand Down