Skip to content

Commit

Permalink
Move HWND render target creation to WM_CREATE. (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom authored May 22, 2020
1 parent 7c2fa9c commit 1cacd85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
- GTK: Support file filters in open/save dialogs. ([#903] by [@jneem])
- GTK: Support DPI values other than 96. ([#904] by [@xStrom])
- Windows: Removed flashes of white background at the edge of the window when resizing. ([#915] by [@xStrom])
- Windows: Reduced chance of white flash when opening a new window. ([#916] by [@xStrom])
- X11: Support key and mouse button state. ([#920] by [@jneem])
- Routing `LifeCycle::FocusChanged` to descendant widgets. ([#925] by [@yrns])
- Built-in open and save menu items now show the correct label and submit the right commands. ([#930] by [@finnerale])
Expand Down Expand Up @@ -202,6 +203,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
[#905]: https://github.com/xi-editor/druid/pull/905
[#909]: https://github.com/xi-editor/druid/pull/909
[#915]: https://github.com/xi-editor/druid/pull/915
[#916]: https://github.com/xi-editor/druid/pull/916
[#917]: https://github.com/xi-editor/druid/pull/917
[#920]: https://github.com/xi-editor/druid/pull/920
[#924]: https://github.com/xi-editor/druid/pull/924
Expand Down
25 changes: 15 additions & 10 deletions druid-shell/src/platform/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,22 +422,27 @@ impl WndProc for MyWndProc {
//println!("wndproc msg: {}", msg);
match msg {
WM_CREATE => {
let dcomp_state = unsafe {
create_dcomp_state(self.present_strategy, hwnd).unwrap_or_else(|e| {
warn!("Creating swapchain failed, falling back to hwnd: {:?}", e);
None
})
};

self.state.borrow_mut().as_mut().unwrap().dcomp_state = dcomp_state;
if let Some(state) = self.handle.borrow().state.upgrade() {
state.hwnd.set(hwnd);
}
let handle = self.handle.borrow().to_owned();
if let Some(state) = self.state.borrow_mut().as_mut() {
let dcomp_state = unsafe {
create_dcomp_state(self.present_strategy, hwnd).unwrap_or_else(|e| {
warn!("Creating swapchain failed, falling back to hwnd: {:?}", e);
None
})
};
if dcomp_state.is_none() {
unsafe {
let rt = paint::create_render_target(&self.d2d_factory, hwnd);
state.render_target = rt.ok();
}
}
state.dcomp_state = dcomp_state;

let handle = self.handle.borrow().to_owned();
state.handler.connect(&handle.into());
}

Some(0)
}
WM_ERASEBKGND => Some(0),
Expand Down

0 comments on commit 1cacd85

Please sign in to comment.