Skip to content

Commit 9434a13

Browse files
committed
Move HWND render target creation to WM_CREATE.
1 parent 3878d31 commit 9434a13

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
@@ -75,6 +75,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
7575
- X11: Support individual window closing. ([#900] by [@xStrom])
7676
- X11: Support `Application::quit`. ([#900] by [@xStrom])
7777
- GTK: Support file filters in open/save dialogs. ([#903] by [@jneem])
78+
- Windows: Reduced chance of white flash when opening a new window. ([#916] by [@xStrom])
7879

7980
### Visual
8081

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

161163
## [0.5.0] - 2020-04-01
162164

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

+15-10
Original file line numberDiff line numberDiff line change
@@ -378,22 +378,27 @@ impl WndProc for MyWndProc {
378378
//println!("wndproc msg: {}", msg);
379379
match msg {
380380
WM_CREATE => {
381-
let dcomp_state = unsafe {
382-
create_dcomp_state(self.present_strategy, hwnd).unwrap_or_else(|e| {
383-
warn!("Creating swapchain failed, falling back to hwnd: {:?}", e);
384-
None
385-
})
386-
};
387-
388-
self.state.borrow_mut().as_mut().unwrap().dcomp_state = dcomp_state;
389381
if let Some(state) = self.handle.borrow().state.upgrade() {
390382
state.hwnd.set(hwnd);
391383
}
392-
let handle = self.handle.borrow().to_owned();
393384
if let Some(state) = self.state.borrow_mut().as_mut() {
385+
let dcomp_state = unsafe {
386+
create_dcomp_state(self.present_strategy, hwnd).unwrap_or_else(|e| {
387+
warn!("Creating swapchain failed, falling back to hwnd: {:?}", e);
388+
None
389+
})
390+
};
391+
if dcomp_state.is_none() {
392+
unsafe {
393+
let rt = paint::create_render_target(&self.d2d_factory, hwnd);
394+
state.render_target = rt.ok();
395+
}
396+
}
397+
state.dcomp_state = dcomp_state;
398+
399+
let handle = self.handle.borrow().to_owned();
394400
state.handler.connect(&handle.into());
395401
}
396-
397402
Some(0)
398403
}
399404
WM_ERASEBKGND => Some(0),

0 commit comments

Comments
 (0)