From 62427684630377f1b4b01c893184691717825feb Mon Sep 17 00:00:00 2001 From: Ivan Gagis Date: Wed, 2 Dec 2026 21:31:35 +0200 Subject: [PATCH] Fix missing native_window::get_dims() override on macOS The base native_window::get_dims() returns {0, 0}. The macOS native_window never overrode it, so the OpenGL renderer computed the viewport y-offset as (0 - 0 - height), placing the viewport entirely off-screen. As a result, all drawing was clipped away and the window rendered black. Implement get_dims() to return the current window dimensions in physical pixels (points scaled by the backing scale factor), matching the behavior of the other platforms. --- src/ruisapp/glue/macos/window.cxx | 10 ++++++++++ src/ruisapp/glue/macos/window.hxx | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/ruisapp/glue/macos/window.cxx b/src/ruisapp/glue/macos/window.cxx index b62337a6..0605cdf0 100644 --- a/src/ruisapp/glue/macos/window.cxx +++ b/src/ruisapp/glue/macos/window.cxx @@ -686,6 +686,16 @@ void native_window::set_fullscreen_internal(bool enable) [this->cocoa_window.window init_stuff]; } +r4::vector2 native_window::get_dims() const noexcept +{ + auto scale = this->get_scale(); + using std::round; + return { + uint(round(this->cur_win_dims.x() * scale)), // + uint(round(this->cur_win_dims.y() * scale)) + }; +} + ruis::real native_window::get_scale() const noexcept { NSScreen* screen = [this->cocoa_window.window screen]; diff --git a/src/ruisapp/glue/macos/window.hxx b/src/ruisapp/glue/macos/window.hxx index 4d4e3422..39943317 100644 --- a/src/ruisapp/glue/macos/window.hxx +++ b/src/ruisapp/glue/macos/window.hxx @@ -257,6 +257,8 @@ public: return this->cur_win_dims; } + r4::vector2 get_dims() const noexcept override; + ruis::real get_scale() const noexcept; ruis::real get_dpi() const noexcept;