diff options
author | crupest <crupest@outlook.com> | 2021-11-20 21:25:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-20 21:25:29 +0800 |
commit | 1a53ed0791d9793ed8030d3a44e833e5e7c4542b (patch) | |
tree | 28aedaabee675b192e414489122349ad4985a31b /src/osx/gui/Window.mm | |
parent | a9da4c10459e3c45115c8a42e771b00cb1caeab7 (diff) | |
download | cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.tar.gz cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.tar.bz2 cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.zip |
...
Diffstat (limited to 'src/osx/gui/Window.mm')
-rw-r--r-- | src/osx/gui/Window.mm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm index 0112fd43..9f0d9742 100644 --- a/src/osx/gui/Window.mm +++ b/src/osx/gui/Window.mm @@ -71,7 +71,13 @@ void OsxWindowPrivate::OnWindowDidResize() { [view addTrackingArea:tracking_area]; CGLayerRelease(draw_layer_); - draw_layer_ = CGLayerCreateWithContext(nullptr, rect.size, nullptr); + + // If size is 0 then create layer will fail. + auto s = rect.size; + if (s.width == 0) s.width = 1; + if (s.height == 0) s.height = 1; + + draw_layer_ = CGLayerCreateWithContext(nullptr, s, nullptr); Ensures(draw_layer_); resize_event_.Raise(osx_window_->GetClientSize()); @@ -252,8 +258,13 @@ void OsxWindow::CreateWindow() { [p_->window_ setContentView:content_view]; - p_->draw_layer_ = CGLayerCreateWithContext( - nullptr, cru::platform::graphics::osx::quartz::Convert(p_->content_rect_.GetSize()), nullptr); + // If size is 0 then create layer will fail. + auto s = p_->content_rect_.GetSize(); + if (s.width == 0) s.width = 1; + if (s.height == 0) s.height = 1; + + p_->draw_layer_ = + CGLayerCreateWithContext(nullptr, cru::platform::graphics::osx::quartz::Convert(s), nullptr); Ensures(p_->draw_layer_); RequestRepaint(); |