Skip to content

Commit 88ef8ba

Browse files
committed
Move HWND render target creation to WM_CREATE.
1 parent 1d1b97b commit 88ef8ba

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
102102
- GTK: Support file filters in open/save dialogs. ([#903] by [@jneem])
103103
- GTK: Support DPI values other than 96. ([#904] by [@xStrom])
104104
- Windows: Removed flashes of white background at the edge of the window when resizing. ([#915] by [@xStrom])
105+
- Windows: Reduced chance of white flash when opening a new window. ([#916] by [@xStrom])
105106
- X11: Support key and mouse button state. ([#920] by [@jneem])
106107
- Routing `LifeCycle::FocusChanged` to descendant widgets. ([#925] by [@yrns])
107108
- Built-in open and save menu items now show the correct label and submit the right commands. ([#930] by [@finnerale])
@@ -201,6 +202,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
201202
[#905]: https://github.com/xi-editor/druid/pull/905
202203
[#909]: https://github.com/xi-editor/druid/pull/909
203204
[#915]: https://github.com/xi-editor/druid/pull/915
205+
[#916]: https://github.com/xi-editor/druid/pull/916
204206
[#917]: https://github.com/xi-editor/druid/pull/917
205207
[#920]: https://github.com/xi-editor/druid/pull/920
206208
[#924]: https://github.com/xi-editor/druid/pull/924

druid-shell/src/platform/windows/window.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -422,22 +422,27 @@ impl WndProc for MyWndProc {
422422
//println!("wndproc msg: {}", msg);
423423
match msg {
424424
WM_CREATE => {
425-
let dcomp_state = unsafe {
426-
create_dcomp_state(self.present_strategy, hwnd).unwrap_or_else(|e| {
427-
warn!("Creating swapchain failed, falling back to hwnd: {:?}", e);
428-
None
429-
})
430-
};
431-
432-
self.state.borrow_mut().as_mut().unwrap().dcomp_state = dcomp_state;
433425
if let Some(state) = self.handle.borrow().state.upgrade() {
434426
state.hwnd.set(hwnd);
435427
}
436-
let handle = self.handle.borrow().to_owned();
437428
if let Some(state) = self.state.borrow_mut().as_mut() {
429+
let dcomp_state = unsafe {
430+
create_dcomp_state(self.present_strategy, hwnd).unwrap_or_else(|e| {
431+
warn!("Creating swapchain failed, falling back to hwnd: {:?}", e);
432+
None
433+
})
434+
};
435+
if dcomp_state.is_none() {
436+
unsafe {
437+
let rt = paint::create_render_target(&self.d2d_factory, hwnd);
438+
state.render_target = rt.ok();
439+
}
440+
}
441+
state.dcomp_state = dcomp_state;
442+
443+
let handle = self.handle.borrow().to_owned();
438444
state.handler.connect(&handle.into());
439445
}
440-
441446
Some(0)
442447
}
443448
WM_ERASEBKGND => Some(0),

0 commit comments

Comments
 (0)