CArcWindowManager
- Module
- Arc
- Header
#include "Arc/Framework/CArcWindowManager.h"- Namespace
Arcf
Type aliases
| Alias | Description |
|---|---|
using CContextMenuCallback = std::function<void(const char*, float, float, uint32_t)> | |
using CShortcutCallback = std::function<bool(int key, bool ctrl, bool shift, bool alt)> | |
using CDoubleShiftCallback = std::function<void()> | Shift tapped twice with no other key between, within kDoubleShiftWindowMs: the design's second way into the command palette. |
using COverlayCallback = std::function<void(CArcUIRenderer& renderer, float width, float height)> |
Properties
| Type | Name | Description |
|---|---|---|
static constexpr int32_t | kDoubleShiftWindowMs | Default 400. |
Public functions
| Returns | Name | Description |
|---|---|---|
CArcWindowManager& | Get | |
bool | Initialize | Initialize with an RHI device. |
void | Shutdown | |
IArcPlatformBackend* | GetPlatformBackend | |
void | SetModalLoopTickCallback | Replaces the default modal-loop repaint (all Arc-owned windows) with the host's own pump — see IArcPlatformBackend. |
bool | IsAnyWindowInModalSizeMove | |
void | SetShaderLoader | Shader loading (must be called before CreateWindow). |
void | SetShaderFallbackDirectory | |
CArcWindow* | CreateWindow | Create a new window from descriptor. |
CArcWindow* | CreateFromExisting | Create from an existing platform window. |
void | PaintMainWindow | Paint the main window's UI into an external command buffer (host owns swapchain + render pass). |
void | PaintMainWindowProduce | |
void | PaintMainWindowRecord | |
void | DestroyWindow | |
void | DestroyWindow | |
CArcWindow* | GetMainWindow | |
CArcWindow* | GetWindow | |
CArcWindow* | FindWindowByPlatformID | |
const std::vector<std::unique_ptr<CArcWindow>>& | GetAllWindows | |
size_t | GetLiveWindowCount | Windows a frame actually has to paint: parked popups (closed tooltips kept hidden for reuse) and windows already closing are still in GetAllWindows but cost nothing. |
bool | IsLiveWindowState | |
size_t | GetRetiringWindowCount | Closed popup windows hidden and waiting for the GPU to retire their last frames before their swapchain is freed (see RetirePopupWindow). |
uint64_t | GetRetiredPopupReleaseCount | Popup hosts torn down so far by each path: after the GPU retired them (no wait) or immediately with a device-wide idle wait. |
uint64_t | GetBlockingPopupReleaseCount | |
double | GetPopupReleaseMs | Milliseconds the game thread spent tearing popup hosts down, summed over every release — what a menu close costs the frame it lands on. |
void | SetDeferredPopupRelease | |
void | SetContextMenuCallback | |
void | SetShortcutCallback | |
void | SetDoubleShiftCallback | |
bool | TrackDoubleShift | Feeds one key press to the double-Shift detector; true when it completed a double tap (and the callback ran). |
void | SetOverlayCallback | |
void | ProcessEvents | |
void | RenderAll | |
void | RenderOwnedWindows | Renders and presents only the Arc-owned swapchain windows, skipping wrapped/external ones, all on the calling thread. |
std::vector<FArcOwnedWindowFrame> | ProduceOwnedWindows | RenderOwnedWindows in three parts for a host that records on its own rendering thread. |
void | RecordOwnedWindows | |
void | PresentOwnedWindows | |
void | SetRecordFence | Waits until no produced window frame is still being recorded. |
bool | HasOwnedWindowsToRender | True when RenderOwnedWindows would record at least one window. |
bool | ShouldQuit | |
void | ResetInputState | |
void | DismissTooltip | Hides the hover tooltip immediately and keeps it hidden until the pointer moves again. |
void | SetOSPopupsEnabled | Menus and tooltips as real OS windows (borderless, non-activating, topmost) so they can overhang the owning window like every native app. |
bool | AreOSPopupsEnabled | |
void | SetPopupsInWindowWhenTheyFit | A menu or tooltip that fits inside its owning window paints there, as Slate does, and only one that must overhang the window gets an OS window of its own. |
bool | ArePopupsInWindowWhenTheyFit | |
bool | PopupFitsInWindow | Whether a popup rect in the owner's logical space lies wholly inside the owner window, and so needs no OS window. |
uint64_t | GetPopupWindowsCreated | OS popup windows created since startup (a test reads how many an interaction cost). |
uint64_t | GetReentrantPaintsRefused | Window paints refused because another paint was still on the game thread's stack (a window message arriving mid-frame). |
uint64_t | GetSharedPipelineWindows | Windows that took an existing window's pipelines and white texture instead of building their own. |
bool | HasMenuPopup | True when the menu is currently hosted by a popup OS window (the owning window must then skip its in-window overlay paint). |
float | WindowScale | The window's effective UI scale: the global (main) scale for the main window, the per-window registration for everything else. |
bool | HandlePlatformEvent | Inject a platform event directly (for host engines that own the SDL event loop). |
bool | InjectEvent | Inject a raw native platform event (SDL_Event*, MSG*, etc.). |
bool | WantCaptureMouse | Capture-want flags across all windows (incl. |
bool | WantCaptureKeyboard | |
const FRouteCounters& | GetRouteCounters | |
void | SetSkipUnchangedWindows | Skips a window's layout, paint and batch snapshot — and the upload of a batch every frame slot already holds — on frames where nothing in it changed: 0 off (every window paints every frame), 1 skip the paint and the upload but still record and present, 2 also leave an owned window that samples nothing live without a record and a present. |
int32_t | GetSkipUnchangedWindows | |
const FPaintSkipStats& | GetPaintSkipStats | |
void | SetTextInputArea | Called by focused text widgets to dock the IME candidate window at their caret. |
Function details
Get
static CArcWindowManager& Get()Initialize
bool Initialize(IArcRHIDevice* device, IArcPlatformBackend* platformBackend = nullptr)Initialize with an RHI device. If platformBackend is null, creates a default one (SDL3).
Shutdown
void Shutdown()GetPlatformBackend
IArcPlatformBackend* GetPlatformBackend() constSetModalLoopTickCallback
void SetModalLoopTickCallback(std::function<void()> callback)Replaces the default modal-loop repaint (all Arc-owned windows) with the host's own pump — see IArcPlatformBackend.
IsAnyWindowInModalSizeMove
bool IsAnyWindowInModalSizeMove() constSetShaderLoader
void SetShaderLoader(CArcUIRenderer::CShaderReadFunc loader)Shader loading (must be called before CreateWindow).
SetShaderFallbackDirectory
void SetShaderFallbackDirectory(const std::string& spvDirectory)CreateWindow
CArcWindow* CreateWindow(const CArcWindowDesc& desc)Create a new window from descriptor. Arc creates and owns the OS window.
CreateFromExisting
CArcWindow* CreateFromExisting(std::unique_ptr<IArcPlatformWindow> platformWindow, bool createSwapchain = true, EArcPixelFormat externalColorFormat = EArcPixelFormat::BGRA8)Create from an existing platform window. Arc renders into it but doesn't own it. Set createSwapchain=false when the host engine owns the swapchain (UE5-style); externalColorFormat must then match the host's render-target format.
PaintMainWindow
void PaintMainWindow(IArcRHICommandBuffer* cmd, uint32_t width, uint32_t height, float deltaTime)Paint the main window's UI into an external command buffer (host owns swapchain + render pass). The caller must have already begun a render pass on cmd — HDR staging/encode is handled by the host's overlay pass.
PaintMainWindowProduce
void PaintMainWindowProduce(uint32_t width, uint32_t height, float deltaTime)PaintMainWindowRecord
void PaintMainWindowRecord(IArcRHICommandBuffer* cmd, uint64_t maxSerial = UINT64_MAX)DestroyWindow
void DestroyWindow(uint32_t windowId)DestroyWindow
void DestroyWindow(CArcWindow* window)GetMainWindow
CArcWindow* GetMainWindow() constGetWindow
CArcWindow* GetWindow(uint32_t id) constFindWindowByPlatformID
CArcWindow* FindWindowByPlatformID(uint32_t platformWindowId) constGetAllWindows
const std::vector<std::unique_ptr<CArcWindow>>& GetAllWindows() constGetLiveWindowCount
size_t GetLiveWindowCount() constWindows a frame actually has to paint: parked popups (closed tooltips kept hidden for reuse) and windows already closing are still in GetAllWindows but cost nothing. A host deciding whether the frame has more than one window must ask this, or the first tooltip of the session leaves a parked window that never goes away.
IsLiveWindowState
static bool IsLiveWindowState(bool hasPlatformWindow, bool shouldClose, bool parked)GetRetiringWindowCount
size_t GetRetiringWindowCount() constClosed popup windows hidden and waiting for the GPU to retire their last frames before their swapchain is freed (see RetirePopupWindow).
GetRetiredPopupReleaseCount
uint64_t GetRetiredPopupReleaseCount() constPopup hosts torn down so far by each path: after the GPU retired them (no wait) or immediately with a device-wide idle wait.
GetBlockingPopupReleaseCount
uint64_t GetBlockingPopupReleaseCount() constGetPopupReleaseMs
double GetPopupReleaseMs() constMilliseconds the game thread spent tearing popup hosts down, summed over every release — what a menu close costs the frame it lands on.
SetDeferredPopupRelease
void SetDeferredPopupRelease(bool deferred)SetContextMenuCallback
void SetContextMenuCallback(CContextMenuCallback cb)SetShortcutCallback
void SetShortcutCallback(CShortcutCallback cb)SetDoubleShiftCallback
void SetDoubleShiftCallback(CDoubleShiftCallback cb)TrackDoubleShift
bool TrackDoubleShift(EKey key)Feeds one key press to the double-Shift detector; true when it completed a double tap (and the callback ran).
SetOverlayCallback
void SetOverlayCallback(COverlayCallback cb)ProcessEvents
void ProcessEvents()RenderAll
void RenderAll(float deltaTime)RenderOwnedWindows
void RenderOwnedWindows(float deltaTime)Renders and presents only the Arc-owned swapchain windows, skipping wrapped/external ones, all on the calling thread. Host engines call it once per frame after PaintMainWindow. Does not tick the animation manager — PaintMainWindow already did.
ProduceOwnedWindows
std::vector<FArcOwnedWindowFrame> ProduceOwnedWindows(float deltaTime)RenderOwnedWindows in three parts for a host that records on its own rendering thread. Produce runs on the game thread (layout, paint, batch snapshot) and pins each window's batch; Record opens each window's frame, records the pinned batch and closes it; Present hands each recorded window to its swapchain's deferred present. Record and Present touch no widget and no platform window, so they may run on another thread while the game thread produces the next frame. The windows stay alive until the record fence (below) ran.
RecordOwnedWindows
void RecordOwnedWindows(std::vector<FArcOwnedWindowFrame>& frames)PresentOwnedWindows
void PresentOwnedWindows(const std::vector<FArcOwnedWindowFrame>& frames)SetRecordFence
void SetRecordFence(std::function<void()> fence)Waits until no produced window frame is still being recorded. Run before any window's GPU side is torn down; a host recording owned windows on another thread must install it.
HasOwnedWindowsToRender
bool HasOwnedWindowsToRender() constTrue when RenderOwnedWindows would record at least one window. A host that must fence its render thread before that recording asks first, so a frame with no floating panel or popup keeps its overlap.
ShouldQuit
bool ShouldQuit() constResetInputState
void ResetInputState()DismissTooltip
void DismissTooltip()Hides the hover tooltip immediately and keeps it hidden until the pointer moves again. Every mouse press routes through here, as does every popup that opens and every loss of window focus.
SetOSPopupsEnabled
void SetOSPopupsEnabled(bool enabled)Menus and tooltips as real OS windows (borderless, non-activating, topmost) so they can overhang the owning window like every native app. On by default; when off — or when popup creation fails — the legacy in-window overlay painting takes over.
AreOSPopupsEnabled
bool AreOSPopupsEnabled() constSetPopupsInWindowWhenTheyFit
void SetPopupsInWindowWhenTheyFit(bool enabled)A menu or tooltip that fits inside its owning window paints there, as Slate does, and only one that must overhang the window gets an OS window of its own. Each OS popup costs a swapchain, a command buffer and a renderer, and every one of those once drained the GPU on the game thread: the owner's 1-19 s stalls sat next to popup creation and resizes. On by default.
ArePopupsInWindowWhenTheyFit
bool ArePopupsInWindowWhenTheyFit() constPopupFitsInWindow
static bool PopupFitsInWindow(const CArcWindow* owner, const ArcRect& rect)Whether a popup rect in the owner's logical space lies wholly inside the owner window, and so needs no OS window.
GetPopupWindowsCreated
uint64_t GetPopupWindowsCreated() constOS popup windows created since startup (a test reads how many an interaction cost).
GetReentrantPaintsRefused
uint64_t GetReentrantPaintsRefused() constWindow paints refused because another paint was still on the game thread's stack (a window message arriving mid-frame).
GetSharedPipelineWindows
uint64_t GetSharedPipelineWindows() constWindows that took an existing window's pipelines and white texture instead of building their own. The first window to build a set leaves it held here, so every later popup shares it even after that window closed.
HasMenuPopup
bool HasMenuPopup(const AMenu* menu) constTrue when the menu is currently hosted by a popup OS window (the owning window must then skip its in-window overlay paint).
WindowScale
float WindowScale(const CArcWindow* win) constThe window's effective UI scale: the global (main) scale for the main window, the per-window registration for everything else.
HandlePlatformEvent
bool HandlePlatformEvent(const CArcPlatformEvent& event)Inject a platform event directly (for host engines that own the SDL event loop). Call this instead of ProcessEvents() when the host polls SDL events itself. Returns true when the UI consumed the event — a widget handled it, a modal or menu owned it, or the focused widget swallowed it. A widget that merely has focus or is merely hovered consumes nothing.
InjectEvent
bool InjectEvent(const void* nativeEvent, bool* outConsumed = nullptr)Inject a raw native platform event (SDL_Event*, MSG*, etc.). Delegates to the active platform backend's TranslateNativeEvent(), then dispatches. Returns true if the event was RECOGNIZED (translated); pass outConsumed to also learn whether the UI actually consumed it. The two answers differ for every event Arc routed and nobody took.
WantCaptureMouse
bool WantCaptureMouse() constCapture-want flags across all windows (incl. open menus/modals) — for host engines arbitrating input between coexisting UI stacks.
WantCaptureKeyboard
bool WantCaptureKeyboard() constGetRouteCounters
const FRouteCounters& GetRouteCounters() constSetSkipUnchangedWindows
void SetSkipUnchangedWindows(int32_t mode, uint32_t verifyFrames)Skips a window's layout, paint and batch snapshot — and the upload of a batch every frame slot already holds — on frames where nothing in it changed: 0 off (every window paints every frame), 1 skip the paint and the upload but still record and present, 2 also leave an owned window that samples nothing live without a record and a present. verifyFrames: a skipping window paints anyway after this many skipped frames and compares the result with what it was replaying.
GetSkipUnchangedWindows
int32_t GetSkipUnchangedWindows() constGetPaintSkipStats
const FPaintSkipStats& GetPaintSkipStats() constSetTextInputArea
void SetTextInputArea(const AWidget* focusedWidget, const ArcRect& logicalRect, float cursorOffsetX)Called by focused text widgets to dock the IME candidate window at their caret. rect in logical UI units; routed to the window whose input processor currently focuses the widget.