Skip to content

chore: use maximized instead of fullscreen on windows #902

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

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Maximized is not saved on windows `#902`

### Security

Expand Down
2 changes: 2 additions & 0 deletions vrc-get-gui/notes-beta.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# This is notes text for the updater json, which will be shown in the updater dialog.
# Lines starting with '#' will be ignored (as comments).
This release includes the following fixes!:
- maximized state is not saved
30 changes: 27 additions & 3 deletions vrc-get-gui/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,32 @@ use crate::commands::prelude::*;

use log::{error, info};
use std::io;
use tauri::{App, AppHandle, LogicalSize, Manager, State, WindowEvent};
use tauri::{App, AppHandle, LogicalSize, Manager, State, Window, WindowEvent};
use tokio::sync::Mutex;
use vrc_get_vpm::unity_hub;

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 fn startup(app: &mut App) {
let handle = app.handle();
tauri::async_runtime::spawn(async move {
Expand Down Expand Up @@ -82,7 +104,9 @@ pub fn startup(app: &mut App) {
})?;
}

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

let cloned = window.clone();

Expand All @@ -101,7 +125,7 @@ pub 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
Loading