Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move HWND render target creation to WM_CREATE. #916

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,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 @@ -201,6 +202,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