Skip to content

Engine → Platform → window.h

window

Syntax

class CONJURE_API window

Derived Classes

Classes that use this as a base

Constructors

AccessSignatureDescription
publicwindow();

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
publicvirtual ~window();

Functions

Public

as_null

[[nodiscard]] virtual null_backend *as_null() noexcept;

This window as the null backend, or nullptr for a real window.

backend

[[nodiscard]] virtual backend_kind backend() const noexcept = 0;

The backend behind this window.

cancel_close

virtual void cancel_close() noexcept = 0;

Withdraws a close request, the user's or request_close()'s: should_close() is false afterwards and the window stays open (an application that asks the user first keeps it open this way). A close_event already queued is still delivered.

clipboard_text

[[nodiscard]] virtual core::result<std::string> clipboard_text() const = 0;

The clipboard's text (UTF-8). CLIPBOARD_UNAVAILABLE when it holds no text or the platform refused.

content_scale

[[nodiscard]] virtual math::vec2 content_scale() const noexcept = 0;

framebuffer_size() / window_size() per axis: 1 on Windows and X11, where the framebuffer is as large as the window, and, with window_flags::SCALE_FRAMEBUFFER (part of DEFAULT), the backing scale on a macOS Retina display or a scaled Wayland output; 1 there too without that flag. While either size has a zero axis (minimised) the last ratio the window had is kept, 1 if it never had a size. It is not the OS UI scale a monitor is set to; monitors()[i].contentScale reports that. The null backend reports window_desc::nullContentScale, then what simulate_content_scale set.

create_vulkan_surface

[[nodiscard]] virtual core::result<void> create_vulkan_surface(
    void *instance,
    void **surface) const = 0;

Creates a VkSurfaceKHR for VkInstance instance and stores it in *surface (both are 64-bit handles passed as opaque pointers; no Vulkan header is involved). VULKAN_UNSUPPORTED on the null backend or without a Vulkan loader; SURFACE_CREATE_FAILED with the VkResult in the message otherwise.

current_cursor_mode

[[nodiscard]] virtual cursor_mode current_cursor_mode() const noexcept = 0;

framebuffer_size

[[nodiscard]] virtual math::uvec2 framebuffer_size() const noexcept = 0;

Drawable size in pixels; 0 x 0 while minimised.

gamepad_name

[[nodiscard]] virtual std::string_view gamepad_name(
    u32 index) const noexcept = 0;

Human-readable name of a connected gamepad slot (glfwGetGamepadName); empty when the slot is not connected or the index is out of range.

hide

virtual void hide() = 0;

Hides the window, and the OS moves focus elsewhere (the null backend's focus changes only through simulate_focus). A fullscreen window too, except on Wayland (see show()).

is_focused

[[nodiscard]] virtual bool is_focused() const noexcept = 0;

is_fullscreen

[[nodiscard]] virtual bool is_fullscreen() const noexcept = 0;

is_minimised

[[nodiscard]] virtual bool is_minimised() const noexcept = 0;

is_visible

[[nodiscard]] virtual bool is_visible() const noexcept = 0;

monitors

[[nodiscard]] virtual std::span<const monitor_info> monitors() const noexcept = 0;

The connected monitors, primary first; refreshed by pump_events(). A real window rebuilds the list after a monitor connects or disconnects or the OS reports a new UI scale for the window; a scale change on a monitor the window is not on raises no such report, so that monitor's contentScale stays stale until the next rebuild.

native_handle

[[nodiscard]] virtual native_window_handle native_handle() const noexcept = 0;

Opaque per-OS handles for rhi (D3D12 swapchain, MoltenVK). kind == NONE on the null backend.

position

[[nodiscard]] virtual math::ivec2 position() const noexcept = 0;

Position of the client area on the virtual desktop in logical coordinates.

pump_events

[[nodiscard]] virtual std::span<const event> pump_events() = 0;

Processes OS events and returns this frame's batch; the span is valid until the next call. Several framebuffer size changes in one pump are coalesced into one framebuffer_resized_event at the end of the batch. A content_scale_changed_event comes before it when a real window's framebuffer to window ratio changed since the scale last announced (before any, the ratio the window was created with, or 1 when it had no size then): a framebuffer that a fractional scale only rounds differently is no change. The null backend queues one per simulate_content_scale call.

request_close

virtual void request_close() noexcept = 0;

Marks the window as asked to close; should_close() is true afterwards.

required_vulkan_instance_extensions

[[nodiscard]] virtual std::span<const char *const> required_vulkan_instance_extensions() const noexcept = 0;

Instance extensions Vulkan needs to present to this window; empty on the null backend and when Vulkan is unavailable.

set_clipboard_text

[[nodiscard]] virtual core::result<void> set_clipboard_text(
    std::string_view text) = 0;

Replaces the clipboard's text (UTF-8).

set_cursor_mode

[[nodiscard]] virtual core::result<void> set_cursor_mode(
    cursor_mode mode) = 0;

Changes how the cursor behaves over the window. FEATURE_UNAVAILABLE (state unchanged) where the mode is not supported, e.g. CAPTURED on Wayland.

set_cursor_position

virtual void set_cursor_position(
    math::vec2 logicalPosition) = 0;

Warps the cursor to a position in logical window coordinates.

set_fullscreen

[[nodiscard]] virtual core::result<void> set_fullscreen(
    bool fullscreen,
    u32 monitorIndex = 0) = 0;

Borderless fullscreen on monitors()[monitorIndex] with its current video mode: the window loses its decoration and covers the monitor without owning it, so losing focus neither minimises it nor keeps it above other applications (an X11 window manager decides itself whether its panels stay above). Called while fullscreen, the window moves to that monitor. false returns to the previous windowed size, position and decoration; a window created fullscreen without window_desc::position is centred on its monitor's work area. Wayland, where a window cannot be placed, uses the compositor's fullscreen instead, which also stays on focus loss. While a fullscreen window is shown and not minimised, the display stays awake on Windows and macOS hides the menu bar and the Dock whenever the application is active; on Wayland the display stays awake while fullscreen when the compositor supports the idle-inhibit protocol, and an X11 screen saver may still start. A window created fullscreen is shown only with window_flags::VISIBLE, except on Wayland, and window_flags::MAXIMISED maximises it only when it first leaves fullscreen (the null backend has no maximised state). MONITOR_NOT_FOUND leaves the window unchanged.

set_icon

[[nodiscard]] virtual core::result<void> set_icon(
    std::span<const core::image> images) = 0;

Sets the icon the OS shows for this window (title bar, task switcher, taskbar) from RGBA8 images; the OS picks the size closest to each use, so pass several (16, 32 and 48 px at least). The pixels are copied. An empty span restores the default icon. INVALID_ARGUMENT, icon unchanged, when validate_window_icon rejects the images; FEATURE_UNAVAILABLE where windows have no icon of their own (macOS shows the application bundle's, Wayland the desktop file's).

set_position

[[nodiscard]] virtual core::result<void> set_position(
    math::ivec2 position) = 0;

Moves the window on the virtual desktop. FEATURE_UNAVAILABLE where the display server does not allow it (Wayland). Ignored while fullscreen (success, nothing moves): leaving fullscreen restores the windowed position from before.

set_raw_mouse_motion

[[nodiscard]] virtual core::result<void> set_raw_mouse_motion(
    bool enabled) = 0;

Raw (unaccelerated) mouse motion while the cursor is DISABLED. FEATURE_UNAVAILABLE when the system does not provide it.

set_size

virtual void set_size(
    math::uvec2 logicalSize) = 0;

Resizes the window in logical coordinates; the framebuffer change arrives as an event. Ignored while fullscreen: the window keeps covering its monitor, and leaving fullscreen restores the windowed size from before.

set_title

virtual void set_title(
    std::string_view title) = 0;

Changes the title shown by the OS (UTF-8).

should_close

[[nodiscard]] virtual bool should_close() const noexcept = 0;

True once the user or request_close() asked the window to close.

show

virtual void show() = 0;

Shows the window; it takes focus when the OS allows it. A fullscreen window too, except the compositor fullscreen of Wayland, which GLFW never shows or hides.

title

[[nodiscard]] virtual std::string_view title() const noexcept = 0;

The current title.

video_modes

[[nodiscard]] virtual std::span<const video_mode> video_modes(
    u32 monitorIndex) const noexcept = 0;

The video modes a monitor supports; empty for an unknown index.

window_size

[[nodiscard]] virtual math::uvec2 window_size() const noexcept = 0;

Size in logical screen coordinates.