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

Make cross-platform window size adjustments #112

Merged
merged 4 commits into from
Aug 6, 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
31 changes: 18 additions & 13 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use tauri_specta::ts;
use tokio::sync::Mutex;

use cli::{Cli, Commands};
#[cfg(target_os = "macos")]
use commands::preferences::get_preferences_file_contents;
use commands::{
chat, export_db, get_api_call, get_api_calls, get_api_keys, get_preferences,
Expand Down Expand Up @@ -79,19 +78,25 @@ fn main() {
});
});

let prefs = get_preferences_file_contents(&config_dir)?;
#[cfg(target_os = "macos")]
{
let prefs = get_preferences_file_contents(&config_dir)?;
if prefs.high_dpi_adjust.is_none()
|| prefs.high_dpi_adjust.unwrap()
{
app.get_window("main")
.ok_or(anyhow::anyhow!("No main window"))?
.set_size(tauri::Size::Logical(tauri::LogicalSize {
width: 666.6, // 800 * 0.8333...
height: 500.0, // 600 * 0.8333...
}))?;
}
let high_dpi_adjust_on = prefs.high_dpi_adjust.unwrap_or(true);
#[cfg(not(target_os = "macos"))]
let high_dpi_adjust_on = prefs.high_dpi_adjust.unwrap_or(false);
if high_dpi_adjust_on {
app.get_window("main")
.ok_or(anyhow::anyhow!("No main window"))?
.set_size(tauri::Size::Logical(tauri::LogicalSize {
width: 708.0, // 850 * 0.8333...
height: 541.0, // 650 * 0.8333...
}))?;
} else {
app.get_window("main")
.ok_or(anyhow::anyhow!("No main window"))?
.set_size(tauri::Size::Logical(tauri::LogicalSize {
width: 850.0,
height: 650.0,
}))?;
}

Ok(())
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions webdriver/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"types": ["node", "@wdio/globals/types"]
}
}
10 changes: 9 additions & 1 deletion webdriver/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ exports.config = {
stdio: [null, process.stdout, process.stderr],
})),

before: (
_capabilities: Record<string, unknown>[],
_specs: string[],
browser: WebdriverIO.Browser,
) => {
browser.setWindowSize(850, 650);
},

// clean up the `tauri-driver` process we spawned at the start of the session
afterSession: () => tauriDriver.kill(),

Expand All @@ -44,7 +52,7 @@ exports.config = {
"image-comparison",
{
baselineFolder: join(process.cwd(), "./screenshots/baseline/"),
formatImageName: "{tag}-{width}x{height}",
formatImageName: "{tag}",
screenshotPath: join(process.cwd(), "./screenshots/testing/"),
savePerInstance: true,
autoSaveBaseline: true,
Expand Down
Loading