mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 10:51:11 +01:00
Keep palette popups within the Windows desktop work area
This commit is contained in:
1 parent
97f2e7fc1d
commit
a36cafd02b
2 files changed
+15
-3
No files matched your search
@@ -11,7 +11,7 @@ workspace = true
|
||||
|
||||
[features]
|
||||
default = ["wgpu", "accessibility"]
|
||||
wgpu = ["eframe/wgpu", "dep:winsafe"]
|
||||
wgpu = ["eframe/wgpu"]
|
||||
accessibility = ["eframe/accesskit"]
|
||||
|
||||
[dependencies]
|
||||
@@ -45,7 +45,7 @@ winreg = "0.55"
|
||||
# GPU that shows it: drawing on a GPU without a monitor reset the display driver. Safe wrappers over
|
||||
# Win32 (MIT); the `user` feature is User32.dll only. Only the wgpu renderer chooses an adapter.
|
||||
|
||||
winsafe = { version = "0.0.29", default-features = false, features = ["user", "shell"], optional = true }
|
||||
winsafe = { version = "0.0.29", default-features = false, features = ["user", "shell"] }
|
||||
# Waits for Direct3D 12's adapter list before the window starts (src/gpu.rs, #4150). MIT OR
|
||||
# Apache-2.0, already in the build through eframe.
|
||||
pollster = "1"
|
||||
|
||||
@@ -17,12 +17,24 @@ pub(super) fn monitor_layout(window: &Window) -> (Vec<Monitor>, Option<usize>) {
|
||||
let size = handle.size();
|
||||
let size = [size.width, size.height];
|
||||
let pos = handle.position();
|
||||
Monitor::new(MonitorKey::new(handle.name().unwrap_or_default(), size), [pos.x, pos.y], size, handle.scale_factor() as f32)
|
||||
let monitor = Monitor::new(MonitorKey::new(handle.name().unwrap_or_default(), size), [pos.x, pos.y], size, handle.scale_factor() as f32);
|
||||
#[cfg(windows)]
|
||||
let monitor = windows_work_area(monitor, pos.x, pos.y);
|
||||
monitor
|
||||
})
|
||||
.collect();
|
||||
(monitors, home)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn windows_work_area(monitor: Monitor, x: i32, y: i32) -> Monitor {
|
||||
use winsafe::{HMONITOR, POINT, co};
|
||||
let Ok(info) = HMONITOR::MonitorFromPoint(POINT { x, y }, co::MONITOR::DEFAULTTONULL).GetMonitorInfo() else { return monitor };
|
||||
let work = info.rcWork;
|
||||
let (Ok(width), Ok(height)) = (u32::try_from(work.right - work.left), u32::try_from(work.bottom - work.top)) else { return monitor };
|
||||
monitor.with_work_px([work.left, work.top], [width, height])
|
||||
}
|
||||
|
||||
pub(super) struct DesktopWindows {
|
||||
window: Weak<Window>,
|
||||
monitors: Mutex<Option<(Instant, Vec<Monitor>)>>,
|
||||
|
||||
Reference in new issue
Block a user