7#include <condition_variable>
9#include <unordered_map>
10#include <unordered_set>
70 float m_refreshHz = 0.0f;
71 std::unordered_map<OSWindowHandle, Window> m_windows;
72 std::unordered_set<OSWindowHandle> m_pendingDestroy;
73 uintptr_t m_nextHandle = 0;
74 std::chrono::steady_clock::time_point m_start = std::chrono::steady_clock::now();
76 std::mutex m_wakeMutex;
77 std::condition_variable m_wakeSignal;
79 std::atomic<uint64_t> m_events = 0;
IWindowBackend()
Definition gui_window_backend.h:114
A window's rendering state: made by GraphicsContext::CreateWindowContext for each OS window,...
Definition gui_window_backend.h:72
void DetachWindowContext(OSWindowHandle window) override
Clears the context pointer stored in the OS window, so PollEvents' cleanup callback gets nullptr inst...
int2 GetScreenMousePos() override
The mouse position in screen pixels (SDL: as of the last PollEvents).
Definition gui_null_window_backend.h:44
uint64_t GetEventCount() const override
How many OS events (input, window changes, Wake) the backend has seen; it only goes up,...
Definition gui_null_window_backend.h:43
void PollEvents(std::function< void(OSWindowHandle, IWindowContext *)> cleanup) override
Handles the OS's pending events, delivering input to the attached handlers.
bool DestroyWindow(OSWindowHandle window) override
Queues the window for destruction: the next PollEvents passes its context to cleanup,...
std::vector< MonitorInfo > GetMonitors() const override
Every monitor, the primary first.
int2 GetWindowPos(OSWindowHandle window) override
The client area's top-left in screen pixels.
Definition gui_null_window_backend.h:52
OSWindowHandle CreateWindow(std::string_view title, int2 size, WindowFlags windowFlags, OSWindowHandle parentOSHandle) override
Creates a window whose client area is size pixels, placed by the OS.
int2 GetWindowSize(OSWindowHandle window) override
The client area's size in pixels; {0,0} while minimized.
Definition gui_null_window_backend.h:53
void SetWindowVisible(OSWindowHandle, bool) override
Shows or hides the window; hiding doesn't destroy it.
Definition gui_null_window_backend.h:56
void AttachContextToWindow(OSWindowHandle window, IWindowContext *context) override
Stores the window's context (not owned), for GetWindowContext, for the ID passed with the window's in...
void SwapBuffers(OSWindowHandle) override
Presents for a graphics API that swaps through the window (OpenGL).
Definition gui_null_window_backend.h:50
void AttachInputHandlerToWindow(OSWindowHandle, IPlatformInputHandler *) override
Where the window's input goes (see IPlatformInputHandler); not owned, nullptr for none.
Definition gui_null_window_backend.h:30
uint32_t GetTicks() const override
A millisecond clock (SDL: since SDL started).
void Wake() override
Ends a WaitForEvents early, or the next one when none runs; counts as an event.
MouseButtons GetMouseButtons() override
The mouse buttons held down, wherever the mouse is (SDL: as of the last PollEvents).
void WaitForEvents(float timeoutSecs) override
No OS events come: waits for Wake or the timeout.
bool IsWindow(OSWindowHandle window) override
True while the handle is a live window of this backend; false once it was destroyed (by code or the u...
Definition gui_null_window_backend.h:33
NullWindowBackend(IntRect monitor={ 0, 0, 1920, 1080 }, float refreshHz=0.0f)
monitor is the one monitor GetMonitors reports, in screen pixels, refreshing at refreshHz (0: unknown...
IntRect GetWindowRect(OSWindowHandle window) override
Client area in pixels; {0,0,0,0} while minimized.
OSWindowHandle CreateWindow(std::string_view title, IntRect rect, WindowFlags windowFlags, OSWindowHandle parentOSHandle) override
Creates a window whose client area is rect (screen pixels); otherwise as the size overload.
OSWindowHandle GetActiveWindow() override
The window with the keyboard focus, or nullptr when none of the backend's windows has it.
Definition gui_null_window_backend.h:37
void * GetNativeHandle(OSWindowHandle) override
The OS's own window handle, passed to GraphicsContext::CreateWindowContext (HWND on Windows,...
Definition gui_null_window_backend.h:54
void BringToFront(OSWindowHandle) override
Raises the window above the others and asks the OS for the input focus.
Definition gui_null_window_backend.h:35
void SetTextInputArea(OSWindowHandle, IntRect) override
Where text is being typed in the window (window coordinates), so the IME places its candidate list ne...
Definition gui_null_window_backend.h:47
bool SetWindowRect(OSWindowHandle window, const IntRect &clientRect) override
Moves and resizes the window so its client area is clientRect (screen pixels); the backend accounts f...
float GetWindowDisplayScale(OSWindowHandle) override
The UI scale the OS asks for in this window: pixel density times the monitor's content scale (1....
Definition gui_null_window_backend.h:48
IntRect GetWindowPixelRect(OSWindowHandle window) override
The window's render target: OS position (for OS compositing) and size in physical pixels.
Definition gui_null_window_backend.h:49
uint32_t GetFocusChangeCount() const override
Goes up whenever keyboard focus moves between windows, or to or from another application; open popups...
Definition gui_null_window_backend.h:38
void SetCursor(MouseCursor) override
Shows the system cursor for that shape; MouseCursor::None hides the cursor.
Definition gui_null_window_backend.h:46
int GetMonitorAt(int2) const override
Index into GetMonitors of the monitor holding the screen point pos; 0 (the primary) when no monitor h...
Definition gui_null_window_backend.h:58
IWindowContext * GetWindowContext(OSWindowHandle window) override
The context attached with AttachContextToWindow, or nullptr.
int GetMonitorFromWindow(OSWindowHandle) const override
Index into GetMonitors of the window's monitor; -1 for an unknown window.
Definition gui_null_window_backend.h:59
OSWindowHandle GetWindowUnderMouse() override
The backend's window under the mouse, or nullptr.
Definition gui_null_window_backend.h:36
MouseCursor
Mouse cursor shown over an element (CSS: cursor).
Definition gui_style.h:481
WindowFlags
How an OS window is made and behaves (IWindowBackend::CreateWindow); flags combine with |.
Definition gui_window_flags.h:14
void * OSWindowHandle
An OS window, opaque; what it points to is up to the window backend.
Definition gui_window_backend.h:37
Definition gui_logging.h:24
Definition gui_base_types.h:406
Integer 2D vector.
Definition gui_base_types.h:18