class

Window

Module
MowoEngine
Header
#include "Core/Window.h"
Namespace
Mowo

Type aliases

AliasDescription
using ResizeCallback = std::function<void(int, int)>
using FileDropCallback = std::function<void(const std::vector<std::string>&, int, int)>Fires when files are dragged in from the OS file explorer.
using SDLEventCallback = std::function<void(const SDL_Event*)>SDL event callback — called for every SDL event before Window handles it. Used by UI backends that need raw events.
using CloseRequestCallback = std::function<bool()>Veto for the OS close request (Alt+F4 / titlebar X). Return true to allow the window to close, false to ignore the request. If unset, the request is always accepted. Used by the editor to refuse close while a modal (e.g. Exporter) is active.

Constructors

SignatureNameDescription
Window()Window
~Window()~Window

Public functions

ReturnsNameDescription
boolInitialize
voidShutdown
boolProcessMessages
voidSetTitle
voidSetMinimumSize
voidSetWindowIcon
boolSetWindowIconFromMemoryDecode an encoded image (PNG/...) from memory and set it as the window icon — the VFS path for packaged icons that only exist inside EngineContent.meaf.
boolHasWindowIconTrue once a SetWindowIcon/SetWindowIconFromMemory call stuck.
WindowHandleGetHandleNative handle for RHI (HWND on Windows, CAMetalLayer* on macOS)
void*GetMetalView
void*GetMetalLayer
intGetWidth
intGetHeight
intGetPixelWidthFramebuffer size — differs from GetWidth on
intGetPixelHeightRetina/high-DPI displays.
floatGetAspectRatio
floatGetPixelDensityBacking scale factor.
boolIsMinimized
boolIsShown
boolShouldClose
const char*GetCloseReasonWhy the window asked the loop to end.
boolIsInBackgroundMobile app lifecycle (M2.4): the OS moved the app out of / back to the foreground.
voidSetLowMemoryCallbackThe OS asked for memory (mobile).
boolIsFocusedTrue when the OS has keyboard/input focus on this window.
boolWaitForEventBlocks up to seconds or until the OS queues an event for this process, whichever is first; the event stays queued for the next ProcessMessages.
voidSetAuxFocusCheckExtra focus sources that count as "the app is focused" for the unfocused throttle — e.g.
boolIsHDROutputActiveTrue when this window's swapchain negotiated an HDR format/colorspace (r.HDROutput).
boolIsKeyDown
boolIsKeyPressed
voidGetMouseDelta
voidSetMouseCapture
boolIsMouseCaptured
voidSetCursorVisible
voidSetCursorConfinedConfine the cursor to the window WITHOUT taking it into relative mode, for a game that keeps a visible cursor.
boolIsCursorConfined
ECaptionHitClassifyCaptionHit
voidSetEditorRelativeMouseModeEditor-only SDL relative mouse mode, separate from the game/runtime SetMouseCapture.
boolIsEditorRelativeMouseMode
voidConsumeEditorMouseDeltaReads and clears the accumulated relative motion since the last call.
boolIsAnyRelativeMouseModeTrue when any relative-mouse path is engaged (runtime SetMouseCapture OR editor RMB).
voidSetResizeCallback
voidSetFileDropCallback
voidSetSDLEventCallback
voidAddSDLEventCallbackAdditional listener, for when more than one subsystem needs SDL events.
voidSetCloseRequestCallback
voidSetInputManager
voidSetTitleBarLeftInteractiveWidthLeft interactive (non-draggable) band of the custom titlebar.
intGetTitleBarLeftInteractiveWidth
voidSetTitleBarRightInteractiveLeftXEvery X >= this value, left of the close/max/min buttons, is a normal clickable region instead of an SDL drag handle.
intGetTitleBarRightInteractiveLeftX
boolHasCustomTitleBar
intGetTitleBarHeight
voidSetTitleBarHeightWindow pixels, not logical ones: the hit test runs in the OS coordinate space, so a host that draws its caption in logical units has to push the scaled height in whenever the display scale changes, or the bottom band of the drawn bar stops dragging the window.
voidSetTitleBarButtonsWidthWidth of the min/max/close cluster; the hit test treats the whole band as normal-clickable.
intGetTitleBarButtonsWidth
boolIsMaximizeButtonHotThe middle of the three caption buttons is the maximize button: over it Windows 11 offers its snap layouts, and the click there toggles the window.
voidMinimize
voidMaximize
voidShowreveal a startHidden window once init is done
voidHideinstant visual close while shutdown proceeds
voidRestore
voidToggleMaximize
boolIsMaximized
voidGetPositionScreen-space placement (editor editor persistence).
voidSetPosition
voidSetSize
SDL_Window*GetSDLWindow

Function details

Window

C++
Window()

~Window

C++
~Window()

Initialize

C++
bool Initialize(const WindowDesc& desc)

Shutdown

C++
void Shutdown()

ProcessMessages

C++
bool ProcessMessages()

SetTitle

C++
void SetTitle(const std::wstring& title)

SetMinimumSize

C++
void SetMinimumSize(int width, int height)

SetWindowIcon

C++
void SetWindowIcon(const std::wstring& iconPath)

SetWindowIconFromMemory

C++
bool SetWindowIconFromMemory(const void* data, size_t size)

Decode an encoded image (PNG/...) from memory and set it as the window icon — the VFS path for packaged icons that only exist inside EngineContent.meaf. Returns false when decoding fails.

HasWindowIcon

C++
bool HasWindowIcon() const

True once a SetWindowIcon/SetWindowIconFromMemory call stuck.

GetHandle

C++
WindowHandle GetHandle() const

Native handle for RHI (HWND on Windows, CAMetalLayer* on macOS)

GetMetalView

C++
void* GetMetalView() const

GetMetalLayer

C++
void* GetMetalLayer() const

GetWidth

C++
int GetWidth() const

GetHeight

C++
int GetHeight() const

GetPixelWidth

C++
int GetPixelWidth() const

Framebuffer size — differs from GetWidth on

GetPixelHeight

C++
int GetPixelHeight() const

Retina/high-DPI displays.

GetAspectRatio

C++
float GetAspectRatio() const

GetPixelDensity

C++
float GetPixelDensity() const

Backing scale factor.

IsMinimized

C++
bool IsMinimized() const

IsShown

C++
bool IsShown() const

ShouldClose

C++
bool ShouldClose() const

GetCloseReason

C++
const char* GetCloseReason() const

Why the window asked the loop to end. A headless test that dies because its window was closed out from under it (a stray Cmd+Q while the suite cycles windows, a logout) otherwise reports exactly what a test that verified nothing reports — a bare exit code with no line in the log. Three GI rows failed that way on 2026-08-20 and cost a full diagnosis.

IsInBackground

C++
bool IsInBackground() const

Mobile app lifecycle (M2.4): the OS moved the app out of / back to the foreground. Engine::Run gates all GPU work on this the way it gates on minimize — iOS kills apps that touch the GPU in background. Desktop SDL never raises these events, so the flag stays false there.

SetLowMemoryCallback

C++
void SetLowMemoryCallback(std::function<void()> callback)

The OS asked for memory (mobile). Fired from the event pump; the callback should drop caches, not allocate.

IsFocused

C++
bool IsFocused() const

True when the OS has keyboard/input focus on this window. Drives the frame-rate throttle: a focused editor runs uncapped, an idle background window doesn't burn 170 FPS of CPU/GPU. Queries SDL flags every call.

WaitForEvent

C++
bool WaitForEvent(double seconds)

Blocks up to seconds or until the OS queues an event for this process, whichever is first; the event stays queued for the next ProcessMessages. The idle throttle waits here instead of sleeping, so a key or a mouse move ends the wait immediately instead of landing in the next 24 Hz frame. Returns true when an event ended the wait.

SetAuxFocusCheck

C++
void SetAuxFocusCheck(std::function<bool()> check)

Extra focus sources that count as "the app is focused" for the unfocused throttle — e.g. torn-off editor panels living in their own OS windows. IsFocused() ORs this in when set.

IsHDROutputActive

C++
bool IsHDROutputActive() const

True when this window's swapchain negotiated an HDR format/colorspace (r.HDROutput). Forwards Renderer::IsHDROutputActive for editor UI.

IsKeyDown

C++
bool IsKeyDown(int vkCode) const

IsKeyPressed

C++
bool IsKeyPressed(int vkCode) const

GetMouseDelta

C++
void GetMouseDelta(float& dx, float& dy) const

SetMouseCapture

C++
void SetMouseCapture(bool capture)

IsMouseCaptured

C++
bool IsMouseCaptured() const

SetCursorVisible

C++
void SetCursorVisible(bool visible)

SetCursorConfined

C++
void SetCursorConfined(bool confined)

Confine the cursor to the window WITHOUT taking it into relative mode, for a game that keeps a visible cursor. Relative mode confines as a side effect; this is the other half, and it was missing entirely.

IsCursorConfined

C++
bool IsCursorConfined() const

ClassifyCaptionHit

C++
static ECaptionHit ClassifyCaptionHit(const FCaptionHitInputs& in)

SetEditorRelativeMouseMode

C++
void SetEditorRelativeMouseMode(bool enabled)

Editor-only SDL relative mouse mode, separate from the game/runtime SetMouseCapture. Viewport panels use it for FPS-style RMB drag without manually warping the cursor, which is what caused the visible teleport when crossing the viewport edge. Engine ignores this path entirely, so toggling it never fights the InputManager. SDL3 restores the cursor to its pre-relative-mode position on disable.

IsEditorRelativeMouseMode

C++
bool IsEditorRelativeMouseMode() const

ConsumeEditorMouseDelta

C++
void ConsumeEditorMouseDelta(float& dx, float& dy)

Reads and clears the accumulated relative motion since the last call. dx/dy are zeroed before returning so each frame's caller gets a fresh slice — call once per frame from one site.

IsAnyRelativeMouseMode

C++
bool IsAnyRelativeMouseMode() const

True when any relative-mouse path is engaged (runtime SetMouseCapture OR editor RMB). Used by the editor to neutralise io.MousePos for the frame so panels under the invisible-but-still-moving virtual cursor don't fire hover/click events.

SetResizeCallback

C++
void SetResizeCallback(ResizeCallback callback)

SetFileDropCallback

C++
void SetFileDropCallback(FileDropCallback callback)

SetSDLEventCallback

C++
void SetSDLEventCallback(SDLEventCallback callback)

AddSDLEventCallback

C++
void AddSDLEventCallback(SDLEventCallback callback)

Additional listener, for when more than one subsystem needs SDL events. Listeners fire in the order they were added.

SetCloseRequestCallback

C++
void SetCloseRequestCallback(CloseRequestCallback callback)

SetInputManager

C++
void SetInputManager(InputManager* inputManager)

SetTitleBarLeftInteractiveWidth

C++
void SetTitleBarLeftInteractiveWidth(int width)

Left interactive (non-draggable) band of the custom titlebar.

GetTitleBarLeftInteractiveWidth

C++
int GetTitleBarLeftInteractiveWidth() const

SetTitleBarRightInteractiveLeftX

C++
void SetTitleBarRightInteractiveLeftX(int x)

Every X >= this value, left of the close/max/min buttons, is a normal clickable region instead of an SDL drag handle. Caller passes the leftmost X of the right cluster after laying it out. Default INT_MAX = no right band, so the whole right side stays draggable except the three window-control buttons.

GetTitleBarRightInteractiveLeftX

C++
int GetTitleBarRightInteractiveLeftX() const

HasCustomTitleBar

C++
bool HasCustomTitleBar() const

GetTitleBarHeight

C++
int GetTitleBarHeight() const

SetTitleBarHeight

C++
void SetTitleBarHeight(int height)

Window pixels, not logical ones: the hit test runs in the OS coordinate space, so a host that draws its caption in logical units has to push the scaled height in whenever the display scale changes, or the bottom band of the drawn bar stops dragging the window.

SetTitleBarButtonsWidth

C++
void SetTitleBarButtonsWidth(int width)

Width of the min/max/close cluster; the hit test treats the whole band as normal-clickable. Default 138 = 3 x 46, the legacy chrome's buttons; apps drawing their own set the exact width after layout.

GetTitleBarButtonsWidth

C++
int GetTitleBarButtonsWidth() const

IsMaximizeButtonHot

C++
bool IsMaximizeButtonHot() const

The middle of the three caption buttons is the maximize button: over it Windows 11 offers its snap layouts, and the click there toggles the window. The client gets no mouse moves while the system owns that button, so a caption that highlights it on hover asks here.

Minimize

C++
void Minimize()

Maximize

C++
void Maximize()

Show

C++
void Show()

reveal a startHidden window once init is done

Hide

C++
void Hide()

instant visual close while shutdown proceeds

Restore

C++
void Restore()

ToggleMaximize

C++
void ToggleMaximize()

IsMaximized

C++
bool IsMaximized() const

GetPosition

C++
void GetPosition(int& x, int& y) const

Screen-space placement (editor editor persistence). GetPosition reports the window's current top-left in global coordinates; the setters move/resize the OS window (no-ops while unset/minimized).

SetPosition

C++
void SetPosition(int x, int y)

SetSize

C++
void SetSize(int width, int height)

GetSDLWindow

C++
SDL_Window* GetSDLWindow() const
Generated from Core/Window.h via mowoengine.json · Oct 27, 2026Version 1.0.0