Window
- Module
- MowoEngine
- Header
#include "Core/Window.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
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
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Initialize | |
void | Shutdown | |
bool | ProcessMessages | |
void | SetTitle | |
void | SetMinimumSize | |
void | SetWindowIcon | |
bool | SetWindowIconFromMemory | 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. |
bool | HasWindowIcon | True once a SetWindowIcon/SetWindowIconFromMemory call stuck. |
WindowHandle | GetHandle | Native handle for RHI (HWND on Windows, CAMetalLayer* on macOS) |
void* | GetMetalView | |
void* | GetMetalLayer | |
int | GetWidth | |
int | GetHeight | |
int | GetPixelWidth | Framebuffer size — differs from GetWidth on |
int | GetPixelHeight | Retina/high-DPI displays. |
float | GetAspectRatio | |
float | GetPixelDensity | Backing scale factor. |
bool | IsMinimized | |
bool | IsShown | |
bool | ShouldClose | |
const char* | GetCloseReason | Why the window asked the loop to end. |
bool | IsInBackground | Mobile app lifecycle (M2.4): the OS moved the app out of / back to the foreground. |
void | SetLowMemoryCallback | The OS asked for memory (mobile). |
bool | IsFocused | True when the OS has keyboard/input focus on this window. |
bool | WaitForEvent | 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. |
void | SetAuxFocusCheck | Extra focus sources that count as "the app is focused" for the unfocused throttle — e.g. |
bool | IsHDROutputActive | True when this window's swapchain negotiated an HDR format/colorspace (r.HDROutput). |
bool | IsKeyDown | |
bool | IsKeyPressed | |
void | GetMouseDelta | |
void | SetMouseCapture | |
bool | IsMouseCaptured | |
void | SetCursorVisible | |
void | SetCursorConfined | Confine the cursor to the window WITHOUT taking it into relative mode, for a game that keeps a visible cursor. |
bool | IsCursorConfined | |
ECaptionHit | ClassifyCaptionHit | |
void | SetEditorRelativeMouseMode | Editor-only SDL relative mouse mode, separate from the game/runtime SetMouseCapture. |
bool | IsEditorRelativeMouseMode | |
void | ConsumeEditorMouseDelta | Reads and clears the accumulated relative motion since the last call. |
bool | IsAnyRelativeMouseMode | True when any relative-mouse path is engaged (runtime SetMouseCapture OR editor RMB). |
void | SetResizeCallback | |
void | SetFileDropCallback | |
void | SetSDLEventCallback | |
void | AddSDLEventCallback | Additional listener, for when more than one subsystem needs SDL events. |
void | SetCloseRequestCallback | |
void | SetInputManager | |
void | SetTitleBarLeftInteractiveWidth | Left interactive (non-draggable) band of the custom titlebar. |
int | GetTitleBarLeftInteractiveWidth | |
void | SetTitleBarRightInteractiveLeftX | Every X >= this value, left of the close/max/min buttons, is a normal clickable region instead of an SDL drag handle. |
int | GetTitleBarRightInteractiveLeftX | |
bool | HasCustomTitleBar | |
int | GetTitleBarHeight | |
void | SetTitleBarHeight | 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. |
void | SetTitleBarButtonsWidth | Width of the min/max/close cluster; the hit test treats the whole band as normal-clickable. |
int | GetTitleBarButtonsWidth | |
bool | IsMaximizeButtonHot | 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. |
void | Minimize | |
void | Maximize | |
void | Show | reveal a startHidden window once init is done |
void | Hide | instant visual close while shutdown proceeds |
void | Restore | |
void | ToggleMaximize | |
bool | IsMaximized | |
void | GetPosition | Screen-space placement (editor editor persistence). |
void | SetPosition | |
void | SetSize | |
SDL_Window* | GetSDLWindow |
Function details
Window
Window()~Window
~Window()Initialize
bool Initialize(const WindowDesc& desc)Shutdown
void Shutdown()ProcessMessages
bool ProcessMessages()SetTitle
void SetTitle(const std::wstring& title)SetMinimumSize
void SetMinimumSize(int width, int height)SetWindowIcon
void SetWindowIcon(const std::wstring& iconPath)SetWindowIconFromMemory
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
bool HasWindowIcon() constTrue once a SetWindowIcon/SetWindowIconFromMemory call stuck.
GetHandle
WindowHandle GetHandle() constNative handle for RHI (HWND on Windows, CAMetalLayer* on macOS)
GetMetalView
void* GetMetalView() constGetMetalLayer
void* GetMetalLayer() constGetWidth
int GetWidth() constGetHeight
int GetHeight() constGetPixelWidth
int GetPixelWidth() constFramebuffer size — differs from GetWidth on
GetPixelHeight
int GetPixelHeight() constRetina/high-DPI displays.
GetAspectRatio
float GetAspectRatio() constGetPixelDensity
float GetPixelDensity() constBacking scale factor.
IsMinimized
bool IsMinimized() constIsShown
bool IsShown() constShouldClose
bool ShouldClose() constGetCloseReason
const char* GetCloseReason() constWhy 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
bool IsInBackground() constMobile 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
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
bool IsFocused() constTrue 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
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
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
bool IsHDROutputActive() constTrue when this window's swapchain negotiated an HDR format/colorspace (r.HDROutput). Forwards Renderer::IsHDROutputActive for editor UI.
IsKeyDown
bool IsKeyDown(int vkCode) constIsKeyPressed
bool IsKeyPressed(int vkCode) constGetMouseDelta
void GetMouseDelta(float& dx, float& dy) constSetMouseCapture
void SetMouseCapture(bool capture)IsMouseCaptured
bool IsMouseCaptured() constSetCursorVisible
void SetCursorVisible(bool visible)SetCursorConfined
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
bool IsCursorConfined() constClassifyCaptionHit
static ECaptionHit ClassifyCaptionHit(const FCaptionHitInputs& in)SetEditorRelativeMouseMode
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
bool IsEditorRelativeMouseMode() constConsumeEditorMouseDelta
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
bool IsAnyRelativeMouseMode() constTrue 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
void SetResizeCallback(ResizeCallback callback)SetFileDropCallback
void SetFileDropCallback(FileDropCallback callback)SetSDLEventCallback
void SetSDLEventCallback(SDLEventCallback callback)AddSDLEventCallback
void AddSDLEventCallback(SDLEventCallback callback)Additional listener, for when more than one subsystem needs SDL events. Listeners fire in the order they were added.
SetCloseRequestCallback
void SetCloseRequestCallback(CloseRequestCallback callback)SetInputManager
void SetInputManager(InputManager* inputManager)SetTitleBarLeftInteractiveWidth
void SetTitleBarLeftInteractiveWidth(int width)Left interactive (non-draggable) band of the custom titlebar.
GetTitleBarLeftInteractiveWidth
int GetTitleBarLeftInteractiveWidth() constSetTitleBarRightInteractiveLeftX
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
int GetTitleBarRightInteractiveLeftX() constHasCustomTitleBar
bool HasCustomTitleBar() constGetTitleBarHeight
int GetTitleBarHeight() constSetTitleBarHeight
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
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
int GetTitleBarButtonsWidth() constIsMaximizeButtonHot
bool IsMaximizeButtonHot() constThe 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
void Minimize()Maximize
void Maximize()Show
void Show()reveal a startHidden window once init is done
Hide
void Hide()instant visual close while shutdown proceeds
Restore
void Restore()ToggleMaximize
void ToggleMaximize()IsMaximized
bool IsMaximized() constGetPosition
void GetPosition(int& x, int& y) constScreen-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
void SetPosition(int x, int y)SetSize
void SetSize(int width, int height)GetSDLWindow
SDL_Window* GetSDLWindow() const