GWindow Developer Guide
September 30, 2025 ยท View on GitHub
This guide is for developers extending GWindow, such as adding platform support or modifying internals.
For user-facing API usage, see API-Reference.md.
Overview
GWindow uses a class hierarchy:
WindowBase(WindowBase.h): Abstract base class with core logic.- Platform Classes:
Window_xcb,Window_win32,Window_androidimplement platform-specific functionality. GWindow(Window.h): Alias for the platform-specific class.
Internal Components
Protected Members (WindowBase)
Mouse mouse: Mouse position/buttons.bool keystate[256]: Keyboard state.Gamepad gamepad[MAX_GAMEPADS]: Up to 4 gamepads.EventFIFO eventFIFO: Event queue (64 slots).float display_scale: HiDPI scaling.bool running,has_focus,is_resized,fullscreen: Window state.struct shape_t { int16_t x, y; uint16_t width, height; } shape: Window geometry.std::string clipboard: Clipboard storage.
Helper Classes
EventFIFO: Manages event queue (push,pop,isEmpty).CMTouch: Handles multi-touch (up to 10 pointers;Clear,Event,Event_by_ID).
Protected Event Methods
Generate EventType objects:
mouseEvent,keyEvent,textEvent,moveEvent,resizeEvent,focusEvent,gpadConnect,gpadButton,gpadAxis,closeEvent.
Adding Platform Support
-
Create Class:
- Define
Window_newplatforminwindow_newplatform.h, inheriting fromWindowBase. - Implement
getEvent(),getNativeHandle(), and other virtual methods.
- Define
-
Update
Window.h:#elif defined(VK_USE_PLATFORM_NEWPLATFORM_KHR) typedef Window_newplatform GWindow; #include "window_newplatform.h" -
Implement Logic:
- Use platform APIs to manage windows and inputs.
- Update
shape,mouse, etc., and push events toeventFIFO.
-
Test:
- Add tests in
tests/. - Update CMake/Gradle scripts.
- Add tests in
Amalgamation
Run amalgamate.py to combine Window/ sources into GWindow.h:
python3 amalgamate.py
- Update script for new platform headers.
Guidelines
- Minimize Dependencies: Avoid external libraries.
- Style: Match
WindowBase.hconventions. - Tests: Update
tests/for new features. - Documentation: Update
docs/todo.txtandAPI-Reference.mdif user-facing APIs change.
Resources
- Source:
Window/. - Tests:
tests/test_header/,tests/test_lib/. - Gamepad Mappings:
gamepads/gamecontrollerdb.txt. - Documentation:
docs/(seedocs/todo.txt).