Update Monado IPC, display brightness slider
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -2884,8 +2884,7 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libmonado"
|
name = "libmonado"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/technobaboo/libmonado-rs.git?rev=26292e5b14663ee2f089f66f0851438a0c00ee67#26292e5b14663ee2f089f66f0851438a0c00ee67"
|
||||||
checksum = "f56d8582a273a05076c57d5478faa51c39958744760938f2da770e890b43c62d"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cmake",
|
"cmake",
|
||||||
|
|||||||
@@ -28,8 +28,13 @@
|
|||||||
|
|
||||||
<elements>
|
<elements>
|
||||||
<TabTitle translation="MONADO_RUNTIME" icon="dashboard/monado.svg" />
|
<TabTitle translation="MONADO_RUNTIME" icon="dashboard/monado.svg" />
|
||||||
|
<label translation="DISPLAY_BRIGHTNESS" />
|
||||||
|
<Slider id="slider_brightness" width="300" height="24" min_value="0" max_value="140" />
|
||||||
|
|
||||||
|
<label translation="LIST_OF_PROCESSES" />
|
||||||
<div id="list_parent" flex_direction="column" gap="8">
|
<div id="list_parent" flex_direction="column" gap="8">
|
||||||
<!-- filled at runtime -->
|
<!-- filled at runtime -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</elements>
|
</elements>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -144,5 +144,6 @@
|
|||||||
},
|
},
|
||||||
"AUTOSTART": "Automatisch beim Start ausführen",
|
"AUTOSTART": "Automatisch beim Start ausführen",
|
||||||
"LAUNCH": "Starten"
|
"LAUNCH": "Starten"
|
||||||
}
|
},
|
||||||
|
"DISPLAY_BRIGHTNESS": "Bildschirmhelligkeit"
|
||||||
}
|
}
|
||||||
@@ -113,6 +113,7 @@
|
|||||||
"VOLUME": "Volume"
|
"VOLUME": "Volume"
|
||||||
},
|
},
|
||||||
"CLOSE_WINDOW": "Close window",
|
"CLOSE_WINDOW": "Close window",
|
||||||
|
"DISPLAY_BRIGHTNESS": "Display brightness",
|
||||||
"FAILED_TO_LAUNCH_APPLICATION": "Failed to launch a application:",
|
"FAILED_TO_LAUNCH_APPLICATION": "Failed to launch a application:",
|
||||||
"GAME_LAUNCHED": "Game launched",
|
"GAME_LAUNCHED": "Game launched",
|
||||||
"GAME_LIST": {
|
"GAME_LIST": {
|
||||||
|
|||||||
@@ -144,5 +144,6 @@
|
|||||||
},
|
},
|
||||||
"AUTOSTART": "Ejecutar automáticamente al inicio",
|
"AUTOSTART": "Ejecutar automáticamente al inicio",
|
||||||
"LAUNCH": "Iniciar"
|
"LAUNCH": "Iniciar"
|
||||||
}
|
},
|
||||||
|
"DISPLAY_BRIGHTNESS": "Brillo de la pantalla"
|
||||||
}
|
}
|
||||||
@@ -144,5 +144,6 @@
|
|||||||
},
|
},
|
||||||
"AUTOSTART": "起動時に自動実行",
|
"AUTOSTART": "起動時に自動実行",
|
||||||
"LAUNCH": "起動"
|
"LAUNCH": "起動"
|
||||||
}
|
},
|
||||||
|
"DISPLAY_BRIGHTNESS": "ディスプレイの明るさ"
|
||||||
}
|
}
|
||||||
@@ -144,5 +144,6 @@
|
|||||||
},
|
},
|
||||||
"AUTOSTART": "Uruchom automatycznie przy starcie",
|
"AUTOSTART": "Uruchom automatycznie przy starcie",
|
||||||
"LAUNCH": "Uruchom"
|
"LAUNCH": "Uruchom"
|
||||||
}
|
},
|
||||||
|
"DISPLAY_BRIGHTNESS": "Jasność wyświetlacza"
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ use std::{collections::HashMap, marker::PhantomData, rc::Rc};
|
|||||||
|
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::checkbox::ComponentCheckbox,
|
components::{checkbox::ComponentCheckbox, slider::ComponentSlider},
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
layout::WidgetID,
|
layout::WidgetID,
|
||||||
parser::{self, Fetchable, ParseDocumentParams, ParserState},
|
parser::{self, Fetchable, ParseDocumentParams, ParserState},
|
||||||
@@ -19,6 +19,7 @@ use crate::{
|
|||||||
enum Task {
|
enum Task {
|
||||||
Refresh,
|
Refresh,
|
||||||
FocusClient(String),
|
FocusClient(String),
|
||||||
|
SetBrightness(f32),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TabMonado<T> {
|
pub struct TabMonado<T> {
|
||||||
@@ -46,6 +47,7 @@ impl<T> Tab<T> for TabMonado<T> {
|
|||||||
match task {
|
match task {
|
||||||
Task::Refresh => self.refresh(frontend, data)?,
|
Task::Refresh => self.refresh(frontend, data)?,
|
||||||
Task::FocusClient(name) => self.focus_client(frontend, data, name)?,
|
Task::FocusClient(name) => self.focus_client(frontend, data, name)?,
|
||||||
|
Task::SetBrightness(brightness) => self.set_brightness(frontend, data, brightness),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +154,22 @@ impl<T> TabMonado<T> {
|
|||||||
self.mount_client(frontend, &client)?;
|
self.mount_client(frontend, &client)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get brightness
|
||||||
|
let slider_brightness = self.state.fetch_component_as::<ComponentSlider>("slider_brightness")?;
|
||||||
|
if let Some(brightness) = frontend.interface.monado_brightness_get(data) {
|
||||||
|
let mut c = frontend.layout.start_common();
|
||||||
|
slider_brightness.set_value(&mut c.common(), brightness * 100.0);
|
||||||
|
c.finish()?;
|
||||||
|
|
||||||
|
slider_brightness.on_value_changed({
|
||||||
|
let tasks = self.tasks.clone();
|
||||||
|
Box::new(move |_common, e| {
|
||||||
|
tasks.push(Task::SetBrightness(e.value / 100.0));
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,4 +178,8 @@ impl<T> TabMonado<T> {
|
|||||||
self.tasks.push(Task::Refresh);
|
self.tasks.push(Task::Refresh);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_brightness(&mut self, frontend: &mut Frontend<T>, data: &mut T, brightness: f32) {
|
||||||
|
frontend.interface.monado_brightness_set(data, brightness);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ pub trait DashInterface<T> {
|
|||||||
fn process_terminate(&mut self, data: &mut T, handle: WvrProcessHandle) -> anyhow::Result<()>;
|
fn process_terminate(&mut self, data: &mut T, handle: WvrProcessHandle) -> anyhow::Result<()>;
|
||||||
fn monado_client_list(&mut self, data: &mut T) -> anyhow::Result<Vec<MonadoClient>>;
|
fn monado_client_list(&mut self, data: &mut T) -> anyhow::Result<Vec<MonadoClient>>;
|
||||||
fn monado_client_focus(&mut self, data: &mut T, name: &str) -> anyhow::Result<()>;
|
fn monado_client_focus(&mut self, data: &mut T, name: &str) -> anyhow::Result<()>;
|
||||||
|
fn monado_brightness_get(&mut self, data: &mut T) -> Option<f32>;
|
||||||
|
fn monado_brightness_set(&mut self, data: &mut T, brightness: f32) -> Option<()>;
|
||||||
fn recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()>;
|
fn recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()>;
|
||||||
fn desktop_finder<'a>(&'a mut self, data: &'a mut T) -> &'a mut DesktopFinder;
|
fn desktop_finder<'a>(&'a mut self, data: &'a mut T) -> &'a mut DesktopFinder;
|
||||||
fn general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig;
|
fn general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ pub struct DashInterfaceEmulated {
|
|||||||
desktop_finder: DesktopFinder,
|
desktop_finder: DesktopFinder,
|
||||||
general_config: GeneralConfig,
|
general_config: GeneralConfig,
|
||||||
monado_clients: Vec<dash_interface::MonadoClient>,
|
monado_clients: Vec<dash_interface::MonadoClient>,
|
||||||
|
brightness: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DashInterfaceEmulated {
|
impl DashInterfaceEmulated {
|
||||||
@@ -119,6 +120,7 @@ impl DashInterfaceEmulated {
|
|||||||
desktop_finder,
|
desktop_finder,
|
||||||
general_config,
|
general_config,
|
||||||
monado_clients,
|
monado_clients,
|
||||||
|
brightness: 1.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,4 +245,13 @@ impl DashInterface<()> for DashInterfaceEmulated {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn monado_brightness_get(&mut self, _: &mut ()) -> Option<f32> {
|
||||||
|
Some(self.brightness)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn monado_brightness_set(&mut self, _: &mut (), brightness: f32) -> Option<()> {
|
||||||
|
self.brightness = brightness;
|
||||||
|
Some(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ interprocess = { version = "2.2.3" }
|
|||||||
json = { version = "0.12.4", optional = true }
|
json = { version = "0.12.4", optional = true }
|
||||||
json5 = "1.3.0"
|
json5 = "1.3.0"
|
||||||
libc = "0.2.178"
|
libc = "0.2.178"
|
||||||
libmonado = { version = "1.3.2", optional = true }
|
libmonado = { git = "https://github.com/technobaboo/libmonado-rs.git", rev = "26292e5b14663ee2f089f66f0851438a0c00ee67", optional = true }
|
||||||
log-panics = { version = "2.1.0", features = ["with-backtrace"] }
|
log-panics = { version = "2.1.0", features = ["with-backtrace"] }
|
||||||
mint = "0.5.9"
|
mint = "0.5.9"
|
||||||
openxr = { git = "https://github.com/Ralith/openxrs", rev = "d0afdd3365bc1e14de28f6a3a21f457e788a702e", features = [
|
openxr = { git = "https://github.com/Ralith/openxrs", rev = "d0afdd3365bc1e14de28f6a3a21f457e788a702e", features = [
|
||||||
|
|||||||
@@ -487,10 +487,37 @@ impl DashInterface<AppState> for DashInterfaceLive {
|
|||||||
app.monado_init();
|
app.monado_init();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn monado_brightness_get(&mut self, app: &mut AppState) -> Option<f32> {
|
||||||
|
let Some(monado) = &mut app.monado else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
monado_get_brightness(monado)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn monado_brightness_set(&mut self, app: &mut AppState, brightness: f32) -> Option<()> {
|
||||||
|
let Some(monado) = &mut app.monado else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
monado_set_brightness(monado, brightness).ok()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLIENT_NAME_BLACKLIST: [&str; 2] = ["wlx-overlay-s", "libmonado"];
|
const CLIENT_NAME_BLACKLIST: [&str; 2] = ["wlx-overlay-s", "libmonado"];
|
||||||
|
|
||||||
|
fn monado_get_brightness(monado: &mut libmonado::Monado) -> Option<f32> {
|
||||||
|
let device = monado.device_from_role(libmonado::DeviceRole::Head).ok()?;
|
||||||
|
device.brightness().ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn monado_set_brightness(monado: &mut libmonado::Monado, brightness: f32) -> anyhow::Result<()> {
|
||||||
|
let device = monado.device_from_role(libmonado::DeviceRole::Head)?;
|
||||||
|
device.set_brightness(brightness, false)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn monado_list_clients_filtered(
|
fn monado_list_clients_filtered(
|
||||||
monado: &mut libmonado::Monado,
|
monado: &mut libmonado::Monado,
|
||||||
) -> anyhow::Result<Vec<libmonado::Client<'_>>> {
|
) -> anyhow::Result<Vec<libmonado::Client<'_>>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user