Add window::monitor_size task

This commit is contained in:
rhysd 2025-01-27 03:33:03 +09:00 committed by Héctor Ramón Jiménez
parent 5195a59e20
commit d7d8b67cdc
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 23 additions and 1 deletions

View file

@ -1631,7 +1631,7 @@ fn run_action<'a, P, C>(
let _ = channel.send(core::window::Screenshot::new(
bytes,
window.state.physical_size(),
window.state.viewport().scale_factor(),
window.state.scale_factor(),
));
}
}
@ -1645,6 +1645,18 @@ fn run_action<'a, P, C>(
let _ = window.raw.set_cursor_hittest(true);
}
}
window::Action::GetMonitorSize(id, channel) => {
if let Some(window) = window_manager.get(id) {
let size = window.raw.current_monitor().map(|monitor| {
let scale = window.state.scale_factor();
let size = monitor.size().to_logical(f64::from(scale));
Size::new(size.width, size.height)
});
let _ = channel.send(size);
}
}
window::Action::RedrawAll => {
for (_id, window) in window_manager.iter_mut() {
window.raw.request_redraw();