Skip to content

Commit

Permalink
Win32: implement Window::size
Browse files Browse the repository at this point in the history
  • Loading branch information
micahrj committed Sep 27, 2023
1 parent fc15f40 commit e84ab6b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/backend/win32/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use windows_sys::Win32::Foundation::{
use windows_sys::Win32::Graphics::Gdi::{self as gdi};
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ReleaseCapture, SetCapture};
use windows_sys::Win32::UI::WindowsAndMessaging::{
self as msg, AdjustWindowRectEx, CreateWindowExW, DefWindowProcW, DestroyWindow,
self as msg, AdjustWindowRectEx, CreateWindowExW, DefWindowProcW, DestroyWindow, GetClientRect,
GetWindowLongPtrW, LoadCursorW, SetCursor, SetCursorPos, SetWindowLongPtrW, ShowWindow,
};

Expand Down Expand Up @@ -207,7 +207,20 @@ impl WindowInner {
}

pub fn size(&self) -> Size {
unimplemented!()
let mut rect = RECT {
left: 0,
top: 0,
right: 0,
bottom: 0,
};
unsafe {
GetClientRect(self.hwnd, &mut rect);
}

Size::new(
(rect.right - rect.left) as f64,
(rect.bottom - rect.top) as f64,
)
}

pub fn scale(&self) -> f64 {
Expand Down

0 comments on commit e84ab6b

Please sign in to comment.