Skip to content

Commit

Permalink
Move HWND render target creation to WM_CREATE.
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom committed May 11, 2020
1 parent 3878d31 commit 9434a13
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 @@ -75,6 +75,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
- X11: Support individual window closing. ([#900] by [@xStrom])
- X11: Support `Application::quit`. ([#900] by [@xStrom])
- GTK: Support file filters in open/save dialogs. ([#903] by [@jneem])
- Windows: Reduced chance of white flash when opening a new window. ([#916] by [@xStrom])

### Visual

Expand Down Expand Up @@ -157,6 +158,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
[#900]: https://github.com/xi-editor/druid/pull/900
[#903]: https://github.com/xi-editor/druid/pull/903
[#909]: https://github.com/xi-editor/druid/pull/909
[#916]: https://github.com/xi-editor/druid/pull/916

## [0.5.0] - 2020-04-01

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 @@ -378,22 +378,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 9434a13

Please sign in to comment.