refactor(displaycontrol): make physical_size an Option (#449)

This commit is contained in:
Isaiah Becker-Mayer
2024-05-01 23:07:53 +03:00
committed by GitHub
parent 35839459aa
commit ca9527f8be
2 changed files with 7 additions and 8 deletions
+5 -6
View File
@@ -64,16 +64,15 @@ impl GuiContext {
Event::WindowEvent { window_id, event } if window_id == window.id() => match event {
WindowEvent::Resized(size) => {
let scale_factor = (window.scale_factor() * 100.0) as u32;
// TODO: it should be possible to get the physical size here, however winit doesn't make it straightforward.
// FreeRDP does it based on DPI reading grabbed via [`SDL_GetDisplayDPI`](https://wiki.libsdl.org/SDL2/SDL_GetDisplayDPI):
// https://github.com/FreeRDP/FreeRDP/blob/ba8cf8cf2158018fb7abbedb51ab245f369be813/client/SDL/sdl_monitor.cpp#L250-L262
let (physical_width, physical_height) = (0, 0);
let _ = input_event_sender.send(RdpInputEvent::Resize {
width: u16::try_from(size.width).unwrap(),
height: u16::try_from(size.height).unwrap(),
scale_factor,
physical_width,
physical_height,
// TODO: it should be possible to get the physical size here, however winit doesn't make it straightforward.
// FreeRDP does it based on DPI reading grabbed via [`SDL_GetDisplayDPI`](https://wiki.libsdl.org/SDL2/SDL_GetDisplayDPI):
// https://github.com/FreeRDP/FreeRDP/blob/ba8cf8cf2158018fb7abbedb51ab245f369be813/client/SDL/sdl_monitor.cpp#L250-L262
physical_size: None,
});
}
WindowEvent::CloseRequested => {
+2 -2
View File
@@ -34,8 +34,8 @@ pub enum RdpInputEvent {
width: u16,
height: u16,
scale_factor: u32,
physical_width: u32,
physical_height: u32,
/// The physical size of the display in millimeters (width, height).
physical_size: Option<(u32, u32)>,
},
FastPath(SmallVec<[FastPathInputEvent; 2]>),
Close,