Skip to content

Add Metal variant (macOS + iOS) - #47

Open
igagis-bot wants to merge 19 commits into
mainfrom
add-metal-variant
Open

igagis-bot wants to merge 19 commits into
mainfrom
add-metal-variant

Conversation

@igagis-bot

@igagis-bot igagis-bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add a Metal variant of the ruisapp glue layer for macOS and iOS:

  • macOS: CAMetalLayer-based window (MetalView/CocoaWindow), Cocoa glue, key-code mapping
  • iOS: UIKit/CAMetalLayer-based window
  • CMake: build the Metal variant library (shared sources + the platform Metal glue) with the RUISAPP_RENDER_METAL define, and the ruisapp-metal-test application
  • The glue passes the window's CAMetalLayer by reference to the Metal context (the one held by the native_window) — no native_window-specific method is needed (mirrors the Vulkan renderer's surface approach)

Depends on ruis PR #211 (register the renderer in the monorepo build) and on the Metal renderer PR (cppfw/ruis-render-metal PR #3).

Add a Metal variant of the ruisapp glue layer for macOS and iOS:
- macOS: MetalView/CAMetalLayer-based window, Cocoa glue, key-code mapping
- iOS: UIKit/CAMetalLayer-based window
- CMake: build the Metal variant library (with the corresponding glue sources)
  for the current platform, plus the ruisapp-metal-test application.

Depends on ruis with the native_window::get_native_metal_layer() method and
on ruis-render-metal (Metal renderer).
Replace the native_window::get_native_metal_layer() virtual with the surface
approach (mirroring the Vulkan renderer): the glue creates a
ruis::render::metal::surface holding the window's CAMetalLayer and the shared
device, and passes it to the Metal context, which keeps it alive for its own
lifetime.
The surface now holds a shared_ref to the window (ruis-render-metal PR #3),
so the glue passes its window reference to the surface constructor.
The context now takes the CAMetalLayer by reference, so the glue passes it
directly instead of creating a surface provider.
The content view is layer-backed, so AppKit keeps the CAMetalLayer's
geometry in sync with the view's bounds. resize() set layer.frame to a
screen-coordinate rect, which fought that sync and mispositioned the
rendered content (it appeared shifted up by the title-bar height, easing
into place at launch). Let AppKit own the layer geometry; only set
contentsScale, which AppKit does not derive for the drawable.
@igagis

igagis commented Dec 4, 2026

Copy link
Copy Markdown
Member

why separate glue and application created for metal, is it too different from opengl one? can't it be done using #ifdef interlieved in same glue and application?

@igagis-bot

Copy link
Copy Markdown
Contributor Author

The split is per-variant because each variant owns a different rendering surface, which is inherent to the backend:

  • GL (macos/): the native window owns an NSOpenGLContext (created via NSOpenGLPixelFormat), plus a hidden shared-context window.
  • Metal (macos/metal/): the native window owns a CAMetalLayer (installed as the view's backing layer).

The native_window and the Cocoa view are coupled to that surface, so they're backend-specific. Concretely, the GL window.hxx carries an opengl_context_wrapper (~60 lines of NSOpenGLPixelFormat/NSOpenGLContext setup) that has no Metal counterpart, and window.cxx is 719 lines for GL vs 557 for Metal. Interleaving those with #ifdef would put two large, unrelated blocks in one file, which I think is harder to maintain than the current split.

The application main loop is the shared part (~83% identical); the only differences are in the constructor, which wires up the backend-specific factory/context (GL passes the shared-context window; Metal extracts the CAMetalLayer).

So: yes, it can be done with #ifdef, but my recommendation is to keep the per-variant native_window separate. If reducing duplication is the goal, the cleaner move is to extract the shared main loop into a common base and keep only the surface/context creation per-variant — no #ifdef needed.

Let me know which direction you'd like and I'll do it.

@igagis

igagis commented Dec 4, 2026

Copy link
Copy Markdown
Member

make two window implementations opengl_window and metal_window, everything else merge into same files

… separate

Per review feedback, instead of a fully separate glue tree for the metal
variant, the shared glue files (application, glue, cocoa) are now a single
copy that selects the rendering backend via #ifdef RUISAPP_RENDER_METAL.
Only the window implementations are kept as separate per-backend files:

  opengl_window.{hxx,cxx}  - the opengl / opengles window (and its GL context
                             wrapper on macos)
  metal_window.{hxx,cxx}   - the metal window (owns the CAMetalLayer)

This removes the duplicated application/glue/cocoa/key_code code that
differed between the two backends by only a handful of lines.

macos:
  - macos/window.{hxx,cxx}        -> macos/opengl_window.{hxx,cxx}
  - macos/metal/window.{hxx,cxx}  -> macos/metal_window.{hxx,cxx}
  - macos/metal/{application,glue,cocoa,key_code.map}.* removed (merged)

ios:
  - ios/window.{hxx,cxx}          -> ios/opengl_window.{hxx,cxx}
  - ios/metal/window.{hxx,cxx}    -> ios/metal_window.{hxx,cxx}
  - ios/metal/{application,glue}.* removed (merged)

build/cmake: the metal variant now reuses the shared glue directory instead
of a per-variant /metal subdirectory.
@igagis-bot

Copy link
Copy Markdown
Contributor Author

Done — pushed as 75ef761.

There are now two window implementations (opengl_window.{hxx,cxx} and metal_window.{hxx,cxx}) and everything else is merged into the shared glue files. The shared application.{hxx,cxx}, glue.mm, cocoa.hxx (and key_code.map.hxx on macos) are a single copy that selects the backend via #ifdef RUISAPP_RENDER_METAL:

  • constructor: metal creates a metal::factory; opengl keeps the shared-GL-context window.
  • make_window(): metal extracts the CAMetalLayer and builds a metal::context; opengl passes the shared GL context and builds an opengl::context.
  • the window files are the only per-backend sources (the rest of the window code — event handling, resize, fullscreen, vsync — is identical and stays in the respective window impl).

The redundant per-variant metal/{application,glue,cocoa,key_code.map}.* files are removed. Net change: 107 insertions / 1297 deletions. Both the opengl and metal macos variants still build, and the metal test app renders identically to before.

LICENSE file and all other sources (the license check compares each file's
header against the LICENSE file).
@igagis-bot

Copy link
Copy Markdown
Contributor Author

Note on CI: the vcpkg - macos and vcpkg - ios jobs fail with assertion failure: target ruis-render-metal::ruis-render-metal does not exist. That's expected — the ruis-render-metal vcpkg port isn't in the cppfw vcpkg-repo yet (it's PR cppfw/ruis-render-metal#3, still open). Those jobs should go green once that port is merged.

The other failures (lint, msys2, sanitizer, macosx) were a license-header year mismatch in the renamed metal_window.{cxx,hxx} (had 2016-2026 while the LICENSE file has 2016-2025); fixed in 50a39a6.

Comment thread src/ruisapp/glue/macos/application.cxx Resolved
Comment thread src/ruisapp/glue/macos/application.cxx Resolved
Comment thread src/ruisapp/glue/ios/glue.mm Resolved
Comment thread src/ruisapp/glue/ios/glue.mm Resolved
Comment thread src/ruisapp/glue/macos/application.hxx Resolved
Comment thread src/ruisapp/glue/macos/application.hxx Resolved
Comment thread src/ruisapp/glue/macos/glue.mm Resolved
Comment thread src/ruisapp/glue/macos/glue.mm Resolved
Comment thread src/ruisapp/glue/macos/metal_window.hxx Outdated
@end

namespace {
class native_window : public ruis::render::native_window

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't opengl_window and metal_window share something? would it make sense to make base cocoa_window : public ruis::native_window and derive metal and opengl windows from the cocoa window?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right — after the split into opengl_window / metal_window, almost everything left is shared. I measured the duplication:

  • Obj-C CocoaWindow delegate methods (init_stuff, windowDidResize:, windowDidChangeScreen:, windowWillResize:, windowShouldClose:, canBecomeKeyWindow, canBecomeMainWindow, acceptsFirstResponder): identical except for one line (the view class instantiated in initWithContentRect:).
  • Obj-C view event handlers (all of mouseDown:/mouseUp:/rightMouse*/otherMouse*/scrollWheel:/mouseMoved:/*MouseDragged:/mouseEntered:/mouseExited:/keyDown:/keyUp:, ~16 methods): functionally identical. The only real difference is that MetalView's initWithFrame: creates the CAMetalLayer; the GL file also carries some log_debug calls and a different call formatting, both of which would be normalized in a shared base.
  • C++ cocoa_window_wrapper (NSWindow alloc/init/title/show/release lifecycle): near-identical.
  • C++ native_window common surface: the same members (before_fullscreen_window_rect, mouse_cursor_currently_visible, cur_win_dims) and the same methods (set_app_window, cursor visibility, dims/get_dims/get_scale/get_dpi, set_fullscreen_internal).

What is genuinely backend-specific is small:

  • Metal: the CAMetalLayer backing layer, current_metal_layer(), no-op bind_rendering_context()/swap_frame_buffers(), displaySyncEnabled vsync, contentsScale on resize.
  • GL: opengl_context_wrapper (NSOpenGLPixelFormat/NSOpenGLContext), makeCurrentContext/flushBuffer, NSOpenGLCPSwapInterval vsync, [context update] on resize, and the extra shared_gl_context_native_window ctor arg.

So a base class makes sense. The shape I'd take:

  • C++: cocoa_window : public ruis::render::native_window owns cocoa_window_wrapper + the common members/methods, and exposes the backend hooks as virtuals (bind_rendering_context, swap_frame_buffers, set_vsync_enabled_internal, resize). metal_window and opengl_window derive from it and override only those hooks; GL keeps opengl_context_wrapper and the shared-context ctor arg.
  • Obj-C: one base view (e.g. ruis_view : NSView) owning the window pointer and all event forwarding; MetalView derives from it and just adds the CAMetalLayer in initWithFrame:/dealloc. CocoaWindow becomes a single shared class (its delegate methods are backend-agnostic), typed against the base view.

Two things to flag before I start:

  1. Build model fits: glue.mm #includes exactly one of metal_window.cxx / opengl_window.cxx under #ifdef RUISAPP_RENDER_* (the .cxx files are HEADER_FILE_ONLY, never compiled standalone). The base would live in an always-included header/TU, and the #ifdef selects only the derived window — no change to the selection mechanism.

  2. iOS parity + manual retain/release: glue/ios/ mirrors this (metal_window.cxx + opengl_window.cxx under #ifdef RUISAPP_RENDER_METAL / OPENGLES), so the refactor should apply to both platforms to keep them consistent — that's where most of the work is. The Obj-C side is manual retain/release (no ARC), so the new class hierarchy needs care around init/dealloc chaining and the view pointer lifecycle.

Net: this removes on the order of ~400 lines of duplicated code and prevents the two files from drifting (they've already drifted slightly in formatting/logging). I'm happy to do it — just confirming the shape above is what you had in mind, and whether you'd like it in this PR or as a focused follow-up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for macOS — pushed as 16f169c.

The two window implementations now share a cocoa_window base (cocoa_window.{hxx,cxx}), mirroring the shape we discussed:

  • C++: cocoa_window : public ruis::render::native_window owns the cocoa_window_wrapper (NSWindow lifecycle) plus the common members (before_fullscreen_window_rect, mouse_cursor_currently_visible, cur_win_dims) and the common methods (set_app_window, cursor visibility, dims/get_dims/get_scale/get_dpi, set_fullscreen_internal, resize). metal_window/opengl_window derive from it and override only the backend hooks (bind_rendering_context, swap_frame_buffers, set_vsync_enabled_internal, and the CAMetalLayer contentsScale/drawableSize handling on resize). GL keeps its opengl_context_wrapper and the shared-context ctor arg.
  • Obj-C: one shared ruis_view : NSView base carries the window pointer and all ~16 event-forwarding handlers; MetalView derives from it and only adds the CAMetalLayer in initWithFrame:/layoutSubviews. CocoaWindow is a single shared delegate class. The only per-backend difference in initWithContentRect: is the view class, now passed in.

glue.mm includes the shared cocoa_window.cxx once, then #ifdef-selects the one derived window — same selection mechanism as before. Both macOS variants build, full rebuild is clean, 353/353 tests pass, and the Metal and OpenGL test apps render identically to before. Net removal of the duplicated delegate/view/event code.

Also fixed the iOS counterpart of the resize bug in dd8e07c: the iOS CAMetalLayer never had its drawableSize updated, so on a view-size change (fullscreen toggle / rotation) the content got stretched. MetalView.layoutSubviews now sets drawableSize = bounds * contentsScale, matching get_dims().

On the iOS half of the shared-base refactor — flagging before I sink time into it: the two iOS view controllers cannot share a base class (Metal's is UIViewController + CADisplayLink, GL's is GLKViewController + EAGLContext), so unlike macOS only the C++ window/method layer could be shared, not the view layer. That C++ base also runs into a construction-order wrinkle (the window wrapper needs the view controller, but the base is constructed before the derived's VC member) on top of manual retain/release. I can't runtime-verify iOS in this environment (code-signing), so I'd rather not ship an unverifiable memory-management change for a ~150-line dedup — happy to attempt it anyway if you want, but wanted to surface the tradeoff first.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do iOS refactoring then, seems like it makes no sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood — skipping the iOS shared-base refactor then.

To be clear on what stays: the iOS drawableSize change (dd8e07c) is a genuine bug fix (the CAMetalLayer drawable never resized, so content got stretched on fullscreen toggle/rotation), not part of the refactor — I'll keep that. The macOS shared-base refactor is in 16f169c.

iOS touch coordinate offset:
- Convert touch locations (view coords, points) to GUI coordinates by
  scaling to pixels and subtracting the viewport origin (content_rect.p).
  Previously the status-bar height was not subtracted, so taps landed
  below the actual touch position; most noticeable with Metal, whose
  viewport is offset by the status-bar height (the GLES viewport starts
  at the top of the screen).

iOS fullscreen:
- Add a custom Info.plist template (ios_info.plist.in) declaring an empty
  UILaunchScreen dict. Without a launch screen iOS runs the app in a
  scaled compatibility mode (320x480pt) instead of natively filling the
  whole screen, like the Android backend does.
- The template uses Xcode build-setting vars ($(EXECUTABLE_NAME),
  $(PRODUCT_BUNDLE_IDENTIFIER), $(PRODUCT_NAME)) because custom
  MACOSX_BUNDLE_INFO_PLIST templates do not get ${APPLE_GUI_*} subst.

iOS deprecations / Metal layer:
- Replace deprecated UI_USER_INTERFACE_IDIOM() with
  [[UIDevice currentDevice] userInterfaceIdiom]; silence statusBarFrame
  and mainScreen deprecations with pragmas.
- Use the CAMetalLayer created via the +layerClass override instead of
  assigning a new layer to the readonly UIView.layer.

Review feedback - rendering API conditionals:
- Restructure "#ifdef RUISAPP_RENDER_METAL / #else" into
  "#ifdef METAL / #elif defined(OPENGL|OPENGLES) / #else #error
  "Unknown graphics API"", matching the other glue backends.
- Convert the "#ifndef RUISAPP_RENDER_METAL" shared-GL-context member to
  the positive condition "#ifdef RUISAPP_RENDER_OPENGL".
src/makefile: the glue.mm Objective-C++ compile rule was defined before
prorab-build-lib runs and referenced this_cxxflags, which
prorab-clear-this-vars empties at the end of the makefile. The renderer
define (-D RUISAPP_RENDER_<api>) therefore never reached glue.mm,
tripping its #error "Unknown graphics API" in the macosx CI job. Move
the rule to after prorab-build-lib and use prorab_cxxflags (the snapshot
that survives the clear), matching how the regular .cpp objects compile.

macos glue: drop the manual NSWindowDidChangeScreenNotification
addObserver/removeObserver pair from both the metal and opengl windows.
windowDidResize:/windowDidChangeScreen: are NSWindowDelegate methods
already invoked through setDelegate:, and init_stuff runs on every
fullscreen toggle, so the manual registration accumulated duplicate
observers.

ios/metal_window.cxx: fix comment indentation flagged by clang-format.
The vcpkg ios/macos CI legs failed with 'No "Findruis-render-metal.cmake"
found in CMAKE_MODULE_PATH' because ruis-render-metal was not declared as
a dependency of the ruisapp vcpkg port, so vcpkg never installed it.

The port already exists in cppfw/vcpkg-repo at the pinned baseline
(versions/r-/ruis-render-metal.json -> 1.0.2), so this only adds the
missing wiring:

- build/vcpkg/vcpkg.json.in: depend on ruis-render-metal for osx|ios,
  matching the Metal renderer's platform support.
- build/vcpkg/test/vcpkg-configuration.json: add ruis-render-metal to the
  cppfw registry package list so vcpkg resolves it from cppfw/vcpkg-repo.

The linux/windows vcpkg legs are unaffected (the dependency is
platform-filtered to osx|ios).
Comment thread build/cmake/ios_info.plist.in Resolved
The drawable surface size was never updated when the window resized, so the rendered content kept the initial surface size and got stretched/squeezed to fit the new window size. Update layer.drawableSize to the content size (in points) times contentsScale in native_window::resize(), matching get_dims().

The render/projection matrix was already correct (scaled to the viewport dims in the shared ruis::gui::render path); only the Metal surface size was stale.
@igagis-bot

Copy link
Copy Markdown
Contributor Author

Added a fix for the macOS Metal window-resize bug (commit 438af74).

Bug: resizing the window did not update CAMetalLayer.drawableSize, so the rendered content kept the initial surface size (e.g. 1024x800) and was stretched/squeezed to fit the new window size (e.g. 1920x1080 fullscreen).

Root cause: unlike the OpenGL default framebuffer, CAMetalLayer does not resize its drawable automatically when the layer bounds change. The layer bounds and the framework viewport were updated correctly on resize; only the drawable surface size was stale. The render/projection matrix was never the problem — it is already scaled to the viewport dims in the shared ruis::gui::render() / make_viewport_matrix() path used by both backends.

Fix: in native_window::resize() (macOS glue), set layer.drawableSize = content_size (points) * contentsScale, matching get_dims(). One block, macOS-only.

Verification: instrumented the resize path — before the fix a resize to 1920x1080 left drawableSize stuck at 1024x800 while layerBounds/dims were 1920x1080; after the fix drawableSize tracks the window (1920x1080). Full rebuild + 353/353 tests pass; clang-format clean.

Note: iOS has the same latent issue (it never sets drawableSize either), but the iOS glue has no resize infrastructure and it can't be exercised in this environment, so I left it untouched here — happy to address it separately if desired.

Extract the Cocoa window/view code that was duplicated between the
Metal and OpenGL backends into a shared base, per review:

- cocoa_window.hxx/.cxx (new): shared Obj-C ruis_view (NSView) with all
  event handlers, shared CocoaWindow (NSWindow) delegate, and the C++
  cocoa_window base class (window wrapper, fullscreen/mouse-cursor/
  resize-and-dims tracking).
- metal_window: MetalView now derives from ruis_view and adds only the
  CAMetalLayer; native_window derives from cocoa_window.
- opengl_window: reuses ruis_view (the duplicated CocoaView is removed);
  native_window derives from cocoa_window.

Pure refactor, behavior-preserving: all event handler bodies, the window
delegate logic, and the Metal CAMetalLayer.drawableSize resize fix are
unchanged.
The iOS CAMetalLayer never had its drawableSize updated, so on a view
size change (fullscreen toggle via the test app's fullscreen button, or
rotation) the drawable kept the old size and the rendered content got
stretched/squeezed. This is the iOS counterpart of the macOS fix: update
drawableSize (bounds x contentsScale) in MetalView's layoutSubviews.
iOS has no concept of application exit: the lifecycle is managed by the OS and
the main run loop (UIApplicationMain) does not return until the system
terminates the app, so there is no loop iteration a quit request could end.

A bare exit(0) is deliberately not used: it would skip the
applicationWillTerminate: lifecycle callback and would not destroy the
application object owned by the AppDelegate, so Metal/GL contexts and windows
would not be released cleanly.
The non-fullscreen branch of set_fullscreen_internal() offset the
root view's frame down by the status-bar height and shrank it, while
get_content_rect() already returns a viewport that is inset by the same
status-bar height (and touch_to_gui_pos() accounts for it too). The
inset was therefore applied twice, so every fullscreen -> normal toggle
pushed the content further down (roughly doubling the offset each time).

Keep the view filling the whole window in both states and let the
viewport be the single source of the status-bar inset, so toggling
returns to the same position the app launched at.
@igagis-bot

Copy link
Copy Markdown
Contributor Author

Fix: iOS Metal content slid further down on every fullscreen toggle

Symptom. On iOS the Metal app launched correctly below the status bar, but pressing the fullscreen button and then pressing it again left the content starting roughly twice as far down as at launch (and each extra toggle pushed it further).

Root cause. The status-bar inset was applied twice in the non-fullscreen state:

  • native_window::set_fullscreen_internal(false) shifted the root view's frame down by statusBarFrame.size.height (and shrank it), and
  • native_window::get_content_rect() already returned a viewport inset by the same status-bar height (p = (0, round(statusBarHeight * scale))), which touch_to_gui_pos() also accounts for.

At launch the view is still full-screen (so only the viewport inset applied → correct 1×), but after a fullscreen→normal toggle the view-frame shift was added on top of the viewport inset → 2×, drifting further with each toggle.

Fix. Keep the view filling the whole window in both states and let the viewport be the single source of the status-bar inset (commit 75b4a1e). The OpenGL ES iOS variant is unaffected — its get_content_rect() returns p = (0,0) and relies on the view-frame shift only.

Verification (iPhone 16 simulator, iOS 18.6, Metal variant; toggled via the probe by clicking fullscreen_button):

step GUI top edge (px from screen top)
launch 162
fullscreen ON 0
fullscreen OFF 162
fullscreen ON 0
fullscreen OFF 162

The window now returns to its exact launch position on every toggle — no cumulative offset.

The OpenGL ES iOS backend still used the pre-fix approach for the
non-fullscreen state: get_content_rect() returned a zero origin while
set_fullscreen_internal() shifted the view frame down by the status-bar
height. The viewport and the view frame disagreed, so toggling
fullscreen back produced a red band at the top and clipped content.

- get_content_rect() now returns the status-bar offset as the content
  rect origin in the non-fullscreen state, and the view always fills
  the whole window (mirrors the Metal backend fix).
- drawInRect: now pushes the viewport to the renderer on every frame:
  GLKView resets glViewport before every call, while gui::set_viewport()
  only pushes it when the rect changes, so only the first frame used to
  get the correct viewport.
- window_parameters::fullscreen is now applied when creating the window
  on iOS (previously ignored; the app always started non-fullscreen).
@igagis-bot

Copy link
Copy Markdown
Contributor Author

OpenGL ES iOS backend: same fullscreen fix + honoring the fullscreen flag (7ee9bfd)

While verifying the Metal fix I found the OpenGL ES iOS app had both problems:

  1. it launched "fullscreen" although window_parameters.fullscreen == false (the flag was simply ignored on iOS), and
  2. after toggling fullscreen back, the top band turned red (the test app's cube_bg_color rectangle showing through), window captions/texts disappeared and the camera image was truncated at the bottom.

Root cause (GLES)

The GLES backend still used the pre-75b4a1e approach:

  • get_content_rect() returned origin (0,0) in the non-fullscreen state, while set_fullscreen_internal(false) shifted the root view's frame down by the status-bar height and shrank it — but get_dims()/the viewport are derived from the UIWindow frame. The view-frame shift and the window-frame-based viewport disagreed → uncovered status-bar band + offset/clipped content, sliding further down on every toggle.
  • Additionally, gui::set_viewport() only pushes the viewport to the renderer when the rect changes, but GLKView resets glViewport to the whole drawable before every drawInRect: call — so only the first frame ever got the correct viewport; every subsequent frame rendered with the full-screen viewport (content stretched over it).

Fix (mirrors the Metal backend)

  • get_content_rect() now returns p = (0, round(statusBarSize.height * scale)) in the non-fullscreen state (same as metal_window.cxx), wrapped in a #pragma clang diagnostic for the deprecated statusBarFrame.
  • set_fullscreen_internal(false) no longer shifts the view frame — the view always fills the window; the viewport is the single source of the status-bar inset (also removed the dead commented-out update_window_rect TODO blocks).
  • drawInRect: now pushes the viewport to the renderer every frame via ren_ctx.set_viewport(content_rect.to<uint32_t>()), because GLKView resets it each frame.
  • application_glue::make_window() now honors window_parameters::fullscreen (copies the flag before moving the params, calls set_fullscreen(fullscreen) after window creation — same pattern as the Android backend). Updated the window_parameters::fullscreen TODO: done: wayland, android, ios.

Verification (iPhone 16 simulator, 1179×2556)

GLES variant, probe clicks on fullscreen_button, top edge of GUI content measured with PIL:

state top edge red band
launch (fullscreen == false) 162 none
toggle → fullscreen ON 0 none
toggle → back to non-fullscreen 162 none
second full cycle 0 → 162 → 0 → 162 none

No drift, no red band (the broken state had ~9400 red samples in the top band). The Metal variant was re-checked after the shared application.cxx change: launch top=162, toggle 0↔162, no regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants