diff options
Diffstat (limited to 'src/osx')
-rw-r--r-- | src/osx/graphics/quartz/TextLayout.cpp | 2 | ||||
-rw-r--r-- | src/osx/gui/Window.mm | 17 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/osx/graphics/quartz/TextLayout.cpp b/src/osx/graphics/quartz/TextLayout.cpp index a5607854..c3a138f2 100644 --- a/src/osx/graphics/quartz/TextLayout.cpp +++ b/src/osx/graphics/quartz/TextLayout.cpp @@ -115,6 +115,8 @@ void OsxCTTextLayout::SetEditMode(bool enable) { } Rect OsxCTTextLayout::GetTextBounds(bool includingTrailingSpace) { + if (text_.empty() && edit_mode_) return Rect(0, 0, 0, font_->GetFontSize()); + auto result = DoGetTextBoundsIncludingEmptyLines(includingTrailingSpace); return Rect(0, 0, result.size.width, result.size.height); } 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(); |