mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
fix: rogcc not starting in rog ally
This commit is contained in:
@@ -14,6 +14,7 @@ mocking = []
|
|||||||
x11 = ["slint/backend-winit-x11"]
|
x11 = ["slint/backend-winit-x11"]
|
||||||
# Optional tokio debug feature does not require nightly; remove RUSTFLAGS note.
|
# Optional tokio debug feature does not require nightly; remove RUSTFLAGS note.
|
||||||
tokio-debug = ["console-subscriber"]
|
tokio-debug = ["console-subscriber"]
|
||||||
|
rog_ally = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
console-subscriber = { version = "^0.4", optional = true }
|
console-subscriber = { version = "^0.4", optional = true }
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ async fn main() -> Result<()> {
|
|||||||
let board_name = dmi.board_name;
|
let board_name = dmi.board_name;
|
||||||
let prod_family = dmi.product_family;
|
let prod_family = dmi.product_family;
|
||||||
info!("Running on {board_name}, product: {prod_family}");
|
info!("Running on {board_name}, product: {prod_family}");
|
||||||
let is_rog_ally = board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally";
|
|
||||||
|
|
||||||
let args: Vec<String> = args().skip(1).collect();
|
let args: Vec<String> = args().skip(1).collect();
|
||||||
|
|
||||||
@@ -138,6 +137,18 @@ async fn main() -> Result<()> {
|
|||||||
config.start_fullscreen = false;
|
config.start_fullscreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let is_rog_ally = {
|
||||||
|
#[cfg(feature = "rog_ally")]
|
||||||
|
{
|
||||||
|
board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally"
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "rog_ally"))]
|
||||||
|
{
|
||||||
|
false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "rog_ally")]
|
||||||
if is_rog_ally {
|
if is_rog_ally {
|
||||||
config.notifications.enabled = false;
|
config.notifications.enabled = false;
|
||||||
config.enable_tray_icon = false;
|
config.enable_tray_icon = false;
|
||||||
@@ -145,6 +156,7 @@ async fn main() -> Result<()> {
|
|||||||
config.startup_in_background = false;
|
config.startup_in_background = false;
|
||||||
config.start_fullscreen = true;
|
config.start_fullscreen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.write();
|
config.write();
|
||||||
|
|
||||||
let enable_tray_icon = config.enable_tray_icon;
|
let enable_tray_icon = config.enable_tray_icon;
|
||||||
@@ -203,76 +215,77 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
} else {
|
|
||||||
// save as a var, don't hold the lock the entire time or deadlocks happen
|
continue;
|
||||||
if let Ok(app_state) = app_state.lock() {
|
}
|
||||||
state = *app_state;
|
|
||||||
|
// save as a var, don't hold the lock the entire time or deadlocks happen
|
||||||
|
if let Ok(app_state) = app_state.lock() {
|
||||||
|
state = *app_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This sleep is required to give the event loop time to react
|
||||||
|
sleep(Duration::from_millis(300));
|
||||||
|
if state == AppState::MainWindowShouldOpen {
|
||||||
|
if let Ok(mut app_state) = app_state.lock() {
|
||||||
|
*app_state = AppState::MainWindowOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This sleep is required to give the event loop time to react
|
let config_copy = config.clone();
|
||||||
sleep(Duration::from_millis(300));
|
let app_state_copy = app_state.clone();
|
||||||
if state == AppState::MainWindowShouldOpen {
|
slint::invoke_from_event_loop(move || {
|
||||||
if let Ok(mut app_state) = app_state.lock() {
|
UI.with(|ui| {
|
||||||
*app_state = AppState::MainWindowOpen;
|
let app_state_copy = app_state_copy.clone();
|
||||||
}
|
let mut ui = ui.borrow_mut();
|
||||||
|
if let Some(ui) = ui.as_mut() {
|
||||||
|
ui.window().show().unwrap();
|
||||||
|
ui.window().on_close_requested(move || {
|
||||||
|
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||||
|
*app_state = AppState::MainWindowClosed;
|
||||||
|
}
|
||||||
|
slint::CloseRequestResponse::HideWindow
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let config_copy_2 = config_copy.clone();
|
||||||
|
let newui = setup_window(config_copy);
|
||||||
|
newui.window().on_close_requested(move || {
|
||||||
|
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||||
|
*app_state = AppState::MainWindowClosed;
|
||||||
|
}
|
||||||
|
slint::CloseRequestResponse::HideWindow
|
||||||
|
});
|
||||||
|
|
||||||
let config_copy = config.clone();
|
let ui_copy = newui.as_weak();
|
||||||
let app_state_copy = app_state.clone();
|
newui
|
||||||
slint::invoke_from_event_loop(move || {
|
.window()
|
||||||
UI.with(|ui| {
|
.set_rendering_notifier(move |s, _| {
|
||||||
let app_state_copy = app_state_copy.clone();
|
if let slint::RenderingState::RenderingSetup = s {
|
||||||
let mut ui = ui.borrow_mut();
|
let config = config_copy_2.clone();
|
||||||
if let Some(ui) = ui.as_mut() {
|
ui_copy
|
||||||
ui.window().show().unwrap();
|
.upgrade_in_event_loop(move |w| {
|
||||||
ui.window().on_close_requested(move || {
|
let fullscreen =
|
||||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
config.lock().is_ok_and(|c| c.start_fullscreen);
|
||||||
*app_state = AppState::MainWindowClosed;
|
if fullscreen && !w.window().is_fullscreen() {
|
||||||
|
w.window().set_fullscreen(fullscreen);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
slint::CloseRequestResponse::HideWindow
|
})
|
||||||
});
|
.ok();
|
||||||
} else {
|
ui.replace(newui);
|
||||||
let config_copy_2 = config_copy.clone();
|
|
||||||
let newui = setup_window(config_copy);
|
|
||||||
newui.window().on_close_requested(move || {
|
|
||||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
|
||||||
*app_state = AppState::MainWindowClosed;
|
|
||||||
}
|
|
||||||
slint::CloseRequestResponse::HideWindow
|
|
||||||
});
|
|
||||||
|
|
||||||
let ui_copy = newui.as_weak();
|
|
||||||
newui
|
|
||||||
.window()
|
|
||||||
.set_rendering_notifier(move |s, _| {
|
|
||||||
if let slint::RenderingState::RenderingSetup = s {
|
|
||||||
let config = config_copy_2.clone();
|
|
||||||
ui_copy
|
|
||||||
.upgrade_in_event_loop(move |w| {
|
|
||||||
let fullscreen = config
|
|
||||||
.lock()
|
|
||||||
.is_ok_and(|c| c.start_fullscreen);
|
|
||||||
if fullscreen && !w.window().is_fullscreen() {
|
|
||||||
w.window().set_fullscreen(fullscreen);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
ui.replace(newui);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
} else if state == AppState::QuitApp {
|
|
||||||
slint::quit_event_loop().unwrap();
|
|
||||||
exit(0);
|
|
||||||
} else if state != AppState::MainWindowOpen {
|
|
||||||
if let Ok(config) = config.lock() {
|
|
||||||
if !config.run_in_background {
|
|
||||||
slint::quit_event_loop().unwrap();
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
} else if state == AppState::QuitApp {
|
||||||
|
slint::quit_event_loop().unwrap();
|
||||||
|
exit(0);
|
||||||
|
} else if state != AppState::MainWindowOpen {
|
||||||
|
if let Ok(config) = config.lock() {
|
||||||
|
if !config.run_in_background {
|
||||||
|
slint::quit_event_loop().unwrap();
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user