Skip to content

Commit

Permalink
Improve Windows invalidation logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom committed Apr 28, 2020
1 parent 6d1ff52 commit abbc4a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions druid-shell/examples/invalidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ impl WinHandler for InvalidateTest {
}
}

fn destroy(&mut self) {
Application::global().quit()
}

fn as_any(&mut self) -> &mut dyn Any {
self
}
Expand Down
23 changes: 17 additions & 6 deletions druid-shell/src/platform/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl WndProc for MyWndProc {
WM_PAINT => unsafe {
if let Ok(mut s) = self.state.try_borrow_mut() {
let mut rect: RECT = mem::zeroed();
GetUpdateRect(hwnd, &mut rect, 0);
GetUpdateRect(hwnd, &mut rect, FALSE);
let s = s.as_mut().unwrap();
if s.render_target.is_none() {
let rt = paint::create_render_target(&self.d2d_factory, hwnd);
Expand Down Expand Up @@ -403,8 +403,11 @@ impl WndProc for MyWndProc {
let s = s.as_mut().unwrap();
if s.dcomp_state.is_some() {
let mut rect: RECT = mem::zeroed();
if GetClientRect(hwnd, &mut rect) == 0 {
warn!("GetClientRect failed.");
if GetClientRect(hwnd, &mut rect) == FALSE {
log::warn!(
"GetClientRect failed: {}",
Error::Hr(HRESULT_FROM_WIN32(GetLastError()))
);
return None;
}
let rt = paint::create_render_target(&self.d2d_factory, hwnd);
Expand Down Expand Up @@ -435,8 +438,11 @@ impl WndProc for MyWndProc {
let s = s.as_mut().unwrap();
if s.dcomp_state.is_some() {
let mut rect: RECT = mem::zeroed();
if GetClientRect(hwnd, &mut rect) == 0 {
warn!("GetClientRect failed.");
if GetClientRect(hwnd, &mut rect) == FALSE {
log::warn!(
"GetClientRect failed: {}",
Error::Hr(HRESULT_FROM_WIN32(GetLastError()))
);
return None;
}
let width = (rect.right - rect.left) as u32;
Expand Down Expand Up @@ -1214,7 +1220,12 @@ impl WindowHandle {
if let Some(w) = self.state.upgrade() {
let hwnd = w.hwnd.get();
unsafe {
InvalidateRect(hwnd, &r as *const _, FALSE);
if InvalidateRect(hwnd, &r as *const RECT, FALSE) == FALSE {
log::warn!(
"InvalidateRect failed: {}",
Error::Hr(HRESULT_FROM_WIN32(GetLastError()))
);
}
}
}
}
Expand Down

0 comments on commit abbc4a6

Please # to comment.