Skip to content

Commit

Permalink
chore: fix persistent window size and save is_fullscreen (#1209)
Browse files Browse the repository at this point in the history
#1194
Description
---
* use `outer_position` and `inner_size` to match the window settings
identically
  • Loading branch information
mmrrnn authored Dec 9, 2024
1 parent dccf209 commit 6400cae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
29 changes: 13 additions & 16 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub async fn close_splashscreen(app: tauri::AppHandle) {

if let (Ok(window_position), Ok(window_size)) = (
splashscreen_window.outer_position(),
splashscreen_window.outer_size(),
splashscreen_window.inner_size(),
) {
splashscreen_window.close().expect("could not close");
main_window.show().expect("could not show");
Expand Down Expand Up @@ -369,17 +369,14 @@ pub async fn get_miner_metrics(
}
state.is_getting_miner_metrics.store(true, Ordering::SeqCst);

let (sha_hash_rate, randomx_hash_rate, block_reward, block_height, block_time, is_synced) =
state
.node_manager
.get_network_hash_rate_and_block_reward()
.await
.unwrap_or_else(|e| {
if !matches!(e, NodeManagerError::NodeNotStarted) {
warn!(target: LOG_TARGET, "Error getting network hash rate and block reward: {}", e);
}
(0, 0, MicroMinotari(0), 0, 0, false)
});
let (sha_hash_rate, randomx_hash_rate, block_reward, block_height, block_time, is_synced) = state.node_manager
.get_network_hash_rate_and_block_reward().await
.unwrap_or_else(|e| {
if !matches!(e, NodeManagerError::NodeNotStarted) {
warn!(target: LOG_TARGET, "Error getting network hash rate and block reward: {}", e);
}
(0, 0, MicroMinotari(0), 0, 0, false)
});

let cpu_miner = state.cpu_miner.read().await;
let cpu_mining_status = match cpu_miner
Expand Down Expand Up @@ -777,9 +774,9 @@ pub async fn import_seed_words(
}
Err(e) => {
error!(target: LOG_TARGET, "Error loading internal wallet: {:?}", e);
e.to_string()
e.to_string();
}
};
}

if timer.elapsed() > MAX_ACCEPTABLE_COMMAND_TIME {
warn!(target: LOG_TARGET, "import_seed_words took too long: {:?}", timer.elapsed());
Expand Down Expand Up @@ -1228,15 +1225,15 @@ pub async fn set_p2pool_enabled(
.await
.map_err(|error| error.to_string())?;
origin_config.set_to_use_base_node(base_node_grpc_port);
};
}
state
.mm_proxy_manager
.change_config(origin_config)
.await
.map_err(|error| error.to_string())?;
}
}
};
}

if timer.elapsed() > MAX_ACCEPTABLE_COMMAND_TIME {
warn!(target: LOG_TARGET, "set_p2pool_enabled took too long: {:?}", timer.elapsed());
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ fn main() {
if let Some(w_settings) = app_conf.window_settings() {
let window_position = PhysicalPosition::new(w_settings.x, w_settings.y);
let window_size = PhysicalSize::new(w_settings.width, w_settings.height);

if let Err(e) = splash_window.set_position(window_position).and_then(|_| splash_window.set_size(window_size)) {
error!(target: LOG_TARGET, "Could not set splashscreen window position or size: {:?}", e);
}
Expand Down Expand Up @@ -904,7 +905,7 @@ fn main() {
trace!(target: LOG_TARGET, "Window event: {:?} {:?}", label, event);
if let WindowEvent::CloseRequested { .. } = event {
if let Some(window) = app_handle.get_webview_window(&label) {
if let (Ok(window_position), Ok(window_size)) = (window.outer_position(), window.outer_size()) {
if let (Ok(window_position), Ok(window_size)) = (window.outer_position(), window.inner_size()) {
let window_settings = WindowSettings {
x: window_position.x,
y: window_position.y,
Expand Down

0 comments on commit 6400cae

Please sign in to comment.