Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Sep 21, 2024
1 parent c8e2a8d commit 3427044
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions src-tauri/src/functionality/streamer_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn start_streamer_mode_watcher(win: tauri::WebviewWindow) {
return;
}

// TODO integrate this into rsRPC somehow
// Check processes every couple seconds to see if OBS is open
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_secs(2));
Expand Down
11 changes: 4 additions & 7 deletions src-tauri/src/functionality/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tauri::{
AppHandle, Manager,
};

use crate::log;
use crate::{log, util::window_helpers::ultrashow};

flate!(static DEFAULT: [u8] from "./icons/32x32.png");
flate!(static CONNECTED: [u8] from "./icons/tray/connected.png");
Expand Down Expand Up @@ -64,9 +64,7 @@ pub fn create_tray(app: &AppHandle) -> Result<(), tauri::Error> {
}
"open" => {
if let Some(win) = app.get_webview_window("main") {
win.show().unwrap_or_default();
win.set_focus().unwrap_or_default();
win.unminimize().unwrap_or_default();
ultrashow(&win);
}
}
"restart" => {
Expand All @@ -89,9 +87,8 @@ pub fn create_tray(app: &AppHandle) -> Result<(), tauri::Error> {
} = event
{
let app = tray.app_handle();
if let Some(webview_window) = app.get_webview_window("main") {
let _ = webview_window.show();
let _ = webview_window.set_focus();
if let Some(win) = app.get_webview_window("main") {
ultrashow(&win);
}
}
})
Expand Down
6 changes: 2 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use util::{
logger::log,
notifications,
paths::get_webdata_dir,
window_helpers::{self, clear_cache_check, set_user_agent},
window_helpers::{self, clear_cache_check, set_user_agent, ultrashow},
};

use crate::{
Expand Down Expand Up @@ -248,9 +248,7 @@ fn main() {
}
};

win.set_focus().unwrap_or_default();
win.unminimize().unwrap_or_default();
win.show().unwrap_or_default();
ultrashow(&win);
},
))
.unwrap_or_else(|_| log!("Failed to register single instance plugin"));
Expand Down
7 changes: 7 additions & 0 deletions src-tauri/src/util/window_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,10 @@ pub fn set_user_agent(win: &tauri::WebviewWindow) {
})
.expect("Failed to set user agent!");
}

/// Stupid name but this just ensures the window is visible regardless of being unfocused/minimized/hidden
pub fn ultrashow(win: &tauri::WebviewWindow) {
win.unminimize().unwrap_or_default();
win.show().unwrap_or_default();
win.set_focus().unwrap_or_default();
}

0 comments on commit 3427044

Please sign in to comment.