mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-20 20:11:11 +02:00
wip dependency injection
This commit is contained in:
Generated
+1
-1
@@ -6080,7 +6080,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "win32-display-data"
|
name = "win32-display-data"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/LGUG2Z/win32-display-data?rev=93949750b1f123fb79827ba4d66ffcab68055654#93949750b1f123fb79827ba4d66ffcab68055654"
|
source = "git+https://github.com/LGUG2Z/win32-display-data?rev=a28c6559a9de2f92c142a714947a9b081776caca#a28c6559a9de2f92c142a714947a9b081776caca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|||||||
paste = "1"
|
paste = "1"
|
||||||
sysinfo = "0.33"
|
sysinfo = "0.33"
|
||||||
uds_windows = "1"
|
uds_windows = "1"
|
||||||
win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "93949750b1f123fb79827ba4d66ffcab68055654" }
|
win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "a28c6559a9de2f92c142a714947a9b081776caca" }
|
||||||
windows-numerics = { version = "0.2" }
|
windows-numerics = { version = "0.2" }
|
||||||
windows-implement = { version = "0.60" }
|
windows-implement = { version = "0.60" }
|
||||||
windows-interface = { version = "0.59" }
|
windows-interface = { version = "0.59" }
|
||||||
|
|||||||
@@ -84,10 +84,12 @@ pub fn insert_in_monitor_cache(serial_or_device_id: &str, monitor: Monitor) {
|
|||||||
monitor_cache.insert(preferred_id, monitor);
|
monitor_cache.insert(preferred_id, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attached_display_devices() -> color_eyre::Result<Vec<Monitor>> {
|
pub fn attached_display_devices<F, I>(display_provider: F) -> color_eyre::Result<Vec<Monitor>>
|
||||||
let all_displays = win32_display_data::connected_displays_all()
|
where
|
||||||
.flatten()
|
F: Fn() -> I + Copy,
|
||||||
.collect::<Vec<_>>();
|
I: Iterator<Item = Result<win32_display_data::Device, win32_display_data::Error>>,
|
||||||
|
{
|
||||||
|
let all_displays = display_provider().flatten().collect::<Vec<_>>();
|
||||||
|
|
||||||
let mut serial_id_map = HashMap::new();
|
let mut serial_id_map = HashMap::new();
|
||||||
|
|
||||||
@@ -154,7 +156,7 @@ pub fn listen_for_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Re
|
|||||||
tracing::info!("created hidden window to listen for monitor-related events");
|
tracing::info!("created hidden window to listen for monitor-related events");
|
||||||
|
|
||||||
std::thread::spawn(move || loop {
|
std::thread::spawn(move || loop {
|
||||||
match handle_notifications(wm.clone()) {
|
match handle_notifications(wm.clone(), win32_display_data::connected_displays_all) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
tracing::warn!("restarting finished thread");
|
tracing::warn!("restarting finished thread");
|
||||||
}
|
}
|
||||||
@@ -171,7 +173,14 @@ pub fn listen_for_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Re
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result<()> {
|
pub fn handle_notifications<F, I>(
|
||||||
|
wm: Arc<Mutex<WindowManager>>,
|
||||||
|
display_provider: F,
|
||||||
|
) -> color_eyre::Result<()>
|
||||||
|
where
|
||||||
|
F: Fn() -> I + Copy,
|
||||||
|
I: Iterator<Item = Result<win32_display_data::Device, win32_display_data::Error>>,
|
||||||
|
{
|
||||||
tracing::info!("listening");
|
tracing::info!("listening");
|
||||||
|
|
||||||
let receiver = event_rx();
|
let receiver = event_rx();
|
||||||
@@ -296,7 +305,7 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
let initial_monitor_count = wm.monitors().len();
|
let initial_monitor_count = wm.monitors().len();
|
||||||
|
|
||||||
// Get the currently attached display devices
|
// Get the currently attached display devices
|
||||||
let attached_devices = attached_display_devices()?;
|
let attached_devices = attached_display_devices(display_provider)?;
|
||||||
|
|
||||||
// Make sure that in our state any attached displays have the latest Win32 data
|
// Make sure that in our state any attached displays have the latest Win32 data
|
||||||
for monitor in wm.monitors_mut() {
|
for monitor in wm.monitors_mut() {
|
||||||
|
|||||||
Reference in New Issue
Block a user