- More Documentation

This commit is contained in:
2026-01-12 00:36:39 -05:00
parent 450f725cab
commit ed381c4178
95 changed files with 5631 additions and 1718 deletions

View File

@@ -33,7 +33,7 @@
#include <fennec/containers/bitfield.h>
#include <fennec/platform/interface/fwd.h>
#include <fennec/platform/interface/forward.h>
#include <fennec/platform/interface/window.h>
#include <fennec/renderers/interface/gfxcontext.h>
@@ -55,9 +55,12 @@ class display_server;
/// must provide a constructor that accepts a `DisplayT*`. `DisplayT::ctx_registry::register_type` must then be
/// called for the \f$gfxcontext\f$ implementation.
class display_server : public type_registry<display_server, platform*> {
// Typedefs/Constants/Enums ============================================================================================
// Definitions & Constants =============================================================================================
public:
/// \name Definitions
/// @{
///
/// \brief enum representing features to test support for against the display server
enum feature_ : uint32_t {
@@ -96,10 +99,20 @@ public:
using featureset_t = bitfield<feature_count>; //!< a bitset holding the supported feature set
/// @}
// Public Members ======================================================================================================
// Public Member Variables =============================================================================================
public:
platform* const platform; //!< the parent platform
// Constructors ========================================================================================================
public:
/// \name Constructors & Destructor
/// @{
///
/// \brief display server constructor
/// \param p the parent platform
@@ -109,8 +122,16 @@ public:
///
/// \brief base destructor
virtual ~display_server() {
}
virtual ~display_server() = default;
/// @}
// Properties ==========================================================================================================
public:
/// \name Properties
/// @{
///
/// \brief feature support checking function
@@ -120,6 +141,19 @@ public:
return features.test(feature);
}
///
/// \returns \f$true\f$ if connected to the display server, \f$false\f$ otherwise
virtual bool connected() const = 0;
/// @}
// Operations ==========================================================================================================
public:
/// \name Operations
/// @{
///
/// \brief create a new window with the specified configuration and parent
/// \param cfg the configuration
@@ -135,10 +169,6 @@ public:
/// \brief disconnect from the display server
virtual void disconnect() = 0;
///
/// \returns \f$true\f$ if connected to the display server, \f$false\f$ otherwise
virtual bool connected() const = 0;
///
/// \brief dispatch the current context to the display server
virtual void dispatch() = 0;
@@ -153,10 +183,14 @@ public:
return gfx_context.get();
}
/// @}
// Protected Member Variables ==========================================================================================
protected:
featureset_t features; //!< the feature set of the display server
unique_ptr<gfxcontext> gfx_context; //!< the graphics context of the display server
private:
FENNEC_RTTI_CLASS_ENABLE() {
}
};

View File

@@ -16,8 +16,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_INTERFACE_FWD_H
#define FENNEC_PLATFORM_INTERFACE_FWD_H
#ifndef FENNEC_PLATFORM_INTERFACE_FORWARD_H
#define FENNEC_PLATFORM_INTERFACE_FORWARD_H
namespace fennec
{
@@ -31,4 +31,4 @@ class gfxsurface; // Handles the GFX surface of a window for a specific gfxc
}
#endif // FENNEC_PLATFORM_INTERFACE_FWD_H
#endif // FENNEC_PLATFORM_INTERFACE_FORWARD_H

View File

@@ -64,10 +64,25 @@ namespace fennec
///
/// \brief Main platform class
class platform : public singleton<platform*> {
// Definitions =========================================================================================================
public:
/// \name Definitions
/// @{
using shared_object = struct shared_object; //!< handle for shared object code
using symbol = void*; //!< handle for a symbol loaded from a shared object
/// @}
// Constructors & Destructors ==========================================================================================
public:
/// \name Constructors & Destructors
/// @{
///
/// \brief constructor
platform();
@@ -76,8 +91,31 @@ public:
/// \brief destructor
virtual ~platform() = default;
private:
platform(const platform&) = delete;
/// @}
// Initialization ======================================================================================================
public:
/// \name Initialization
/// @{
virtual void initialize(); //!< Initialize Drivers and Contexts
virtual void shutdown(); //!< Close Drivers and Contexts
/// @}
// Shared Objects ======================================================================================================
public:
/// \name Shared Objects
/// @{
///
/// \brief shared object linker
/// \param file the name of the shared object to link
@@ -96,10 +134,23 @@ public:
/// \returns a reference to the symbol
virtual symbol find_symbol(shared_object* obj, const cstring& name) = 0;
virtual void initialize(); //!< Initialize Drivers and Contexts
virtual void shutdown(); //!< Close Drivers and Contexts
/// @}
virtual window_manager& get_window_manager() const { return *wmanager; }
// Window Management ===================================================================================================
public:
/// \name Window Management
/// @{
///
/// \brief Returns the window manager for the platform
/// \returns Reference to the window manager.
virtual window_manager& get_window_manager() const {
return *wmanager;
}
/// @}
protected:
unique_ptr<window_manager> wmanager; //!< the window manager

View File

@@ -31,7 +31,7 @@
#ifndef FENNEC_PLATFORM_INTERFACE_WINDOW_H
#define FENNEC_PLATFORM_INTERFACE_WINDOW_H
#include <fennec/platform/interface/fwd.h>
#include <fennec/platform/interface/forward.h>
#include <fennec/math/ext/rect.h>
@@ -49,6 +49,10 @@ namespace fennec
class window {
// Definitions =========================================================================================================
public:
/// \name Definitions
/// @{
///
/// \brief window mode
enum mode_ : uint8_t {
@@ -127,9 +131,15 @@ public:
double_t fractional_scaling; //!< current fractional scaling factor
};
/// @}
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
///
/// \brief window constructor
@@ -142,9 +152,15 @@ public:
/// \brief base destructor
virtual ~window();
/// @}
// Properties ==========================================================================================================
public:
/// \name Properties
/// @{
///
/// \returns the current configuration of the window
@@ -162,18 +178,33 @@ public:
/// \returns the underlying handle of the window
virtual void* get_native_handle() = 0;
/// @}
// Positional Info =====================================================================================================
public:
/// \name Screen Bounds
/// @{
///
/// \returns the size of the window
const ivec2& get_size() const { return state.rect.size; }
const ivec2& get_size() const {
return state.rect.size;
}
///
/// \returns the position of the window
const ivec2& get_position() const { return state.rect.position; }
const ivec2& get_position() const {
return state.rect.position;
}
///
/// \returns the bounds of the window
const irect& get_bounds() const {
return state.rect;
}
///
/// \returns the width of the window
@@ -191,9 +222,15 @@ public:
/// \returns the y position of the window
int get_pos_y() const { return state.rect.position.y; }
/// @}
// Status ==============================================================================================================
public:
/// \name Status
/// @{
///
/// \brief tests if the window is visible
@@ -215,9 +252,15 @@ public:
/// \returns \f$true\f$ if the window is suspended, \f$false\f$ otherwise
bool is_suspended() const { return state.flags.test(state_suspended); }
/// @}
// Behaviour ===========================================================================================================
public:
/// \name Behaviour Flags
/// @{
///
/// \brief tests a specific flag
@@ -234,12 +277,12 @@ public:
///
/// \brief check if the window is flagged to have no window decorations
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_borderless() const { return get_flag(flag_borderless); }
bool is_borderless() const { return get_flag(flag_borderless); }
///
/// \brief check if the window is flagged to be modal
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_modal() const { return get_flag(flag_modal); }
bool is_modal() const { return get_flag(flag_modal); }
///
/// \brief check if the window is flagged to pass mouse input to windows underneath from the same application
@@ -249,22 +292,22 @@ public:
///
/// \brief check if the window is flagged as a popup
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_popup() const { return get_flag(flag_popup); }
bool is_popup() const { return get_flag(flag_popup); }
///
/// \brief check if the window is flagged to be resizable
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_resizable() const { return get_flag(flag_resizable); }
bool is_resizable() const { return get_flag(flag_resizable); }
///
/// \brief check if the window is flagged to be transparent
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_transparent() const { return get_flag(flag_transparent); }
bool is_transparent() const { return get_flag(flag_transparent); }
///
/// \brief check if the window is flagged to be unfocusable
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_no_focus() const { return get_flag(flag_no_focus); }
bool is_no_focus() const { return get_flag(flag_no_focus); }
///
@@ -284,48 +327,53 @@ public:
/// \brief sets whether to have no window decorations
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_borderless(bool val) { return set_flag(flag_borderless, val); }
bool set_borderless(bool val) { return set_flag(flag_borderless, val); }
///
/// \brief sets whether to be modal
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_modal(bool val) { return set_flag(flag_modal, val); }
bool set_modal(bool val) { return set_flag(flag_modal, val); }
///
/// \brief sets whether to pass mouse input to windows underneath from the same application
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_passing_mouse(bool val) { return set_flag(flag_pass_mouse, val); }
bool set_passing_mouse(bool val) { return set_flag(flag_pass_mouse, val); }
///
/// \brief sets whether the window is a popup
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_popup(bool val) { return set_flag(flag_popup, val); }
bool set_popup(bool val) { return set_flag(flag_popup, val); }
///
/// \brief sets whether to be resizable
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_resizable(bool val) { return set_flag(flag_resizable, val); }
bool set_resizable(bool val) { return set_flag(flag_resizable, val); }
///
/// \brief sets whetherto be transparent
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_transparent(bool val) { return set_flag(flag_transparent, val); }
bool set_transparent(bool val) { return set_flag(flag_transparent, val); }
///
/// \brief sets whether to be unfocusable
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_no_focus(bool val) { return set_flag(flag_no_focus, val); }
bool set_no_focus(bool val) { return set_flag(flag_no_focus, val); }
/// @}
// Window Management Functions =========================================================================================
// Initialization & Update =============================================================================================
public:
/// \name Initialization & Update
/// @{
virtual void initialize() = 0; //!< initialization function
virtual void shutdown() = 0; //!< shutdown function
@@ -333,6 +381,10 @@ public:
virtual void begin_frame(); //!< start a frame for the window, setting the correct graphics context
virtual void end_frame(); //!< end a frame for the window, swapping the underlying buffers
/// @}
// Protected Member Variables ==========================================================================================
protected:
display_server* const server; //!< the display server the window belongs to
window* const parent; //!< the parent window

View File

@@ -24,12 +24,23 @@ namespace fennec
{
class linux_platform : public unix_platform {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor ================================================================================
/// @{
/// \brief constructor
linux_platform()
: unix_platform() {
}
/// @}
//
void initialize() override; //!< platform initialization
void shutdown() override; //!< platform shutdown

View File

@@ -40,7 +40,12 @@ namespace fennec
///
/// \brief wayland egl context
class wayland_eglcontext : public eglcontext {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
/// \brief constructor
/// \param display the display server
explicit wayland_eglcontext(display_server* display);
@@ -48,11 +53,23 @@ public:
/// \brief destructor
~wayland_eglcontext();
/// @}
// Operations ==========================================================================================================
public:
/// \name Operations
/// @{
/// \brief create a surface for a window
/// \param window the window
/// \returns a new surface for the window
gfxsurface* create_surface(window* window) override;
/// @}
// Private Member Variables ============================================================================================
private:
FENNEC_RTTI_CLASS_ENABLE(eglcontext) {
wayland_server::ctx_registry::register_type<wayland_eglcontext>();

View File

@@ -33,7 +33,7 @@
#define LATFORM_LINUX_WAYLAND_EGL_SURFACE_H
#include <fennec/platform/opengl/egl/surface.h>
#include <fennec/platform/linux/wayland/fwd.h>
#include <fennec/platform/linux/wayland/forward.h>
namespace fennec
{
@@ -41,7 +41,13 @@ namespace fennec
///
/// \brief wayland egl surface
class wayland_eglsurface : public eglsurface {
// Constructors ========================================================================================================
public:
/// \name Constructors & Destructor
/// @{
/// \brief constructor
/// \param win the wayland window
/// \param ctx the egl context
@@ -50,10 +56,22 @@ public:
/// \brief destructor
~wayland_eglsurface();
/// @}
// Operations ==========================================================================================================
public:
/// \name Operations
/// @{
///
/// \brief resize the surface
/// \param size the new size
void resize(const ivec2& size) override;
/// @}
private:
};

View File

@@ -17,7 +17,7 @@
// =====================================================================================================================
///
/// \file fennec/platform/linux/wayland/fwd.h
/// \file fennec/platform/linux/wayland/forward.h
/// \brief
///
///
@@ -29,8 +29,8 @@
///
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FORWARD_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_FORWARD_H
namespace fennec
{
@@ -40,4 +40,4 @@ class wayland_window;
}
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FORWARD_H

View File

@@ -31,7 +31,7 @@
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
#include <fennec/platform/linux/wayland/fwd.h>
#include <fennec/platform/linux/wayland/forward.h>
#include <fennec/platform/interface/display_server.h>
#if FENNEC_HAS_LIBDECOR
@@ -56,7 +56,13 @@ namespace fennec
///
/// \brief Class for handling the Wayland Display Server
class wayland_server : public display_server_base<wayland_server, wayland_window> {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
/// \brief constructor
/// \param p the platform
explicit wayland_server(fennec::platform* p);
@@ -64,6 +70,15 @@ public:
/// \brief destructor
~wayland_server() override;
/// @}
// Operations ==========================================================================================================
public:
/// \name Operations
/// @{
void connect() override; //!< connect to wayland
void disconnect() override; //!< disconnect from wayland
bool connected() const override; //!< check if connected to wayland \returns \f$true\f$ if connected, \f$false\f$ otherwise
@@ -79,8 +94,9 @@ public:
/// \returns the native wl_display handle
void* get_native_handle() override { return display; }
/// @}
// Fields ==============================================================================================================
// Private Member Variables ============================================================================================
private:
wl_display* display;
wl_registry* registry;
@@ -96,6 +112,7 @@ private:
// Listeners ===========================================================================================================
private:
static void _wl_registry_listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t);
static void _wl_registry_on_global_remove(void*, wl_registry*, uint32_t);

View File

@@ -31,7 +31,7 @@
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
#include <fennec/platform/linux/wayland/fwd.h>
#include <fennec/platform/linux/wayland/forward.h>
#include <fennec/platform/interface/window.h>
#ifndef FENNEC_DOXYGEN
@@ -55,21 +55,32 @@ namespace fennec
///
/// \brief Class for handling a Wayland window
class wayland_window : public window_base<wayland_server> {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
///
/// \brief constructor
/// \param server the display server
/// \param cfg the configuration
/// \param parent the parent window
wayland_window(display_server* server, const config& cfg, window* parent);
///
/// \brief destructor
~wayland_window();
void initialize() override; //!< initialize the window
void shutdown() override; //!< shutdown the window
/// @}
/// \returns the native wl_surface handle
void* get_native_handle() override;
// Behaviour Flags =====================================================================================================
public:
/// \name Behaviour Flags
/// @{
///
/// \brief sets a specific flag
@@ -78,8 +89,25 @@ public:
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
bool set_flag(uint8_t flag, bool val) override;
/// @}
// Fields ==============================================================================================================
// Initialization & Update =============================================================================================
public:
/// \name Initialization & Update
/// @{
void initialize() override; //!< initialize the window
void shutdown() override; //!< shutdown the window
/// \returns the native wl_surface handle
void* get_native_handle() override;
/// @}
// Private Member Variables ============================================================================================
private:
wl_surface* surface;
xdg_surface* xdgsurface;
@@ -92,12 +120,13 @@ private:
#endif
// Helpers =============================================================================================================
// Private Helpers =====================================================================================================
private:
void _update_size(const ivec2& size);
// Listeners ===========================================================================================================
private:
static void _wl_surface_listen_enter(void*, wl_surface*, wl_output*);
static void _wl_surface_listen_leave(void*, wl_surface*, wl_output*);

View File

@@ -41,16 +41,31 @@
namespace fennec
{
///
/// \brief base egl context with platform-independent behaviour
class eglcontext : public glcontext {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
///
/// \brief constructor
/// \param display the corresponding display server
eglcontext(display_server* display);
///
/// \brief destructor
~eglcontext();
/// @}
//
///
/// \returns \f$true\f$ if the context is valid, \f$false\f$ otherwise
bool is_valid() override;

View File

@@ -17,7 +17,7 @@
// =====================================================================================================================
///
/// \file fennec/platform/opengl/egl/fwd.h
/// \file fennec/platform/opengl/egl/forward.h
/// \brief
///
///
@@ -29,8 +29,8 @@
///
#ifndef FENNEC_PLATFORM_OPENGL_EGL_FWD_H
#define FENNEC_PLATFORM_OPENGL_EGL_FWD_H
#ifndef FENNEC_PLATFORM_OPENGL_EGL_FORWARD_H
#define FENNEC_PLATFORM_OPENGL_EGL_FORWARD_H
namespace fennec
{
@@ -40,4 +40,4 @@ class eglsurface;
}
#endif // FENNEC_PLATFORM_OPENGL_EGL_FWD_H
#endif // FENNEC_PLATFORM_OPENGL_EGL_FORWARD_H

View File

@@ -33,7 +33,7 @@
#define FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
#include <fennec/platform/opengl/glad/egl.h>
#include <fennec/platform/opengl/egl/fwd.h>
#include <fennec/platform/opengl/egl/forward.h>
#include <fennec/renderers/interface/gfxsurface.h>
@@ -42,17 +42,37 @@ namespace fennec
{
/// \brief base egl surface with platform-independent behaviour
class eglsurface : public gfxsurface {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
/// \brief constructor
/// \param win the associated window
/// \param ctx the associated context
/// \param eglwindow the create egl window
eglsurface(fennec::window* win, eglcontext* ctx, void* eglwindow);
///
/// \brief Destructor
~eglsurface();
// Operations ==========================================================================================================
public:
/// \name Operations
/// @{
void make_current() override; //!< makes this surface the current target of the context
void swap() override; //!< swaps the front and back buffers
/// @}
// Protected Member Variables ==========================================================================================
protected:
void* _eglwindow; //!< the underlying handle to the window
EGLSurface _eglsurface; //!< the handle for the surface

View File

@@ -25,13 +25,27 @@ namespace fennec
{
/// \brief base unix platform for generic unix functionality
class unix_platform : public platform {
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
///
/// \brief constructor
explicit unix_platform()
: platform() {
}
/// @}
// Shared Objects ======================================================================================================
public:
/// \name Shared Objects
/// @{
///
/// \brief shared object linker
/// \param file the name of the shared object to link
@@ -50,7 +64,13 @@ public:
/// \returns a reference to the symbol
symbol find_symbol(shared_object* obj, const cstring& name) override;
/// @}
// Private Member Variables ============================================================================================
private:
FENNEC_RTTI_CLASS_ENABLE(platform) {
}
};

View File

@@ -32,10 +32,11 @@
#ifndef FENNEC_PLATFORM_WINDOWMANAGER_H
#define FENNEC_PLATFORM_WINDOWMANAGER_H
#include <fennec/platform/interface/fwd.h>
#include <fennec/platform/interface/forward.h>
#include <fennec/memory/pointers.h>
#include <fennec/containers/object_pool.h>
#include <fennec/containers/variant.h>
#include <fennec/platform/interface/window.h>
#include <fennec/threading/lock_guard.h>
#include <fennec/threading/mpscq.h>
@@ -50,20 +51,33 @@ using window_id = size_t; //!< type representing an id for a window
///
/// \brief class for handling display servers and windows
class window_manager {
// Definitions =========================================================================================================
// Definitions & Constants =============================================================================================
public:
/// \name Constants
/// @{
static constexpr window_id nullid = -1; //!< constant representing a null window
/// @}
private:
enum command_ : uint8_t {
command_set_flag = 0,
command_resize
};
struct flag_val {
uint8_t index;
bool val;
};
using cmd_data_t = variant<flag_val, ivec2>;
struct command {
uint8_t cmd;
window_id win;
void* data;
uint8_t cmd;
window_id win;
cmd_data_t data;
};
static constexpr size_t max_commands = 512;
@@ -78,6 +92,9 @@ private:
// Constructors & Destructor ===========================================================================================
public:
/// \name Constructors & Destructor
/// @{
///
/// \brief constructor
/// \param platform the platform
@@ -87,73 +104,379 @@ public:
/// \brief destructor
~window_manager();
/// @}
private:
window_manager(const window_manager&) = delete;
// Thread-Specific Functions ===========================================================================================
// Initialization & Update =============================================================================================
public:
void initialize(); //!< initialize the window system
void shutdown(); //!< shutdown the window system
void dispatch(); //!< dispatch the commands to the system
/// \name Initialization & Update
/// @{
///
/// \brief Initialization
///
/// \details Initializes the windowing system on the current thread.
void initialize();
///
/// \brief Shutdown
///
/// \details Shuts down the windowing system, must be called on the same thread as `window_manager::initialize`.
void shutdown();
///
/// \brief Command Dispatch
///
/// \details Dispatches commands to the server, must be called on the same thread as `window_manager::initialize`.
void dispatch();
/// @}
// Operations ==========================================================================================================
public:
/// \name Operations
/// @{
///
/// \brief Create a new window.
///
/// \details Must be called on the same thread as `window_manager::initialize`.
/// \param config The configuration for the new window.
/// \param parent The parent window.
window_id create_window(const config& config, window_id parent = nullid);
void begin(window_id window);
void end(window_id window);
///
/// \brief Start a frame for a window.
/// \param window The window.
///
/// \details Begins a new frame for the specified window. This will make the context and surface associated with
/// this window the new current context. Must be called on the same thread as `window_manager::initialize`.
void begin_frame(window_id window);
///
/// \brief Ends a frame for the window.
/// \param window The window.
///
/// \details Ends the current frame for the specified window. This will swap the front and back buffers for the
/// window. Must be called on the same thread as `window_manager::initialize`.
void end_frame(window_id window);
///
/// \brief Closes a window.
/// \param window The window.
///
/// \details Closes the window, cleaning up the surface associated with the window.
void close(window_id window);
/// @}
// Thread-Safe Functions ===============================================================================================
// Window Properties ===================================================================================================
public:
/// \name Window Properties
/// @{
///
/// \param window The window.
/// \returns the parent window
window_id get_parent(window_id window) const {
lock_guard guard(_lock);
return _parent(window);
}
///
/// \param window The window.
/// \returns the nearest top-level window in the hierarchy
window_id get_root(window_id window) const {
lock_guard guard(_lock);
return _root(window);
}
/// @}
// Window Bounds =======================================================================================================
public:
/// \name Window Bounds
/// @{
///
/// \param window The window.
/// \returns the size of the window
ivec2 get_size(window_id window) const {
lock_guard guard(_lock);
return _get_size(window);
}
///
/// \param window The window.
/// \returns the position of the window
ivec2 get_position(window_id window) const {
lock_guard guard(_lock);
return _get_position(window);
}
bool is_visible(window_id window) const { lock_guard guard(_lock); return _check_state(window, window::state_visible); }
bool is_child(window_id window) const { lock_guard guard(_lock); return _check_state(window, window::state_child); }
bool is_running(window_id window) const { lock_guard guard(_lock); return _check_state(window, window::state_running); }
bool is_suspended(window_id window) const { lock_guard guard(_lock); return _check_state(window, window::state_suspended); }
///
/// \param window The window.
/// \returns the bounds of the window
irect get_bounds(window_id window) const {
lock_guard guard(_lock);
return _get_bounds(window);
}
/// @}
// Window Status =======================================================================================================
public:
/// \name Window Status
/// @{
///
/// \brief tests if the window is visible
///
/// \param window The window.
/// \returns \f$true\f$ if the window is visible, \f$false\f$ otherwise
bool is_visible(window_id window) const {
lock_guard guard(_lock);
return _check_state(window, window::state_visible);
}
///
/// \brief tests if the window is a child
///
/// \param window The window.
/// \returns \f$true\f$ if the window is a child, \f$false\f$ otherwise
bool is_child(window_id window) const {
lock_guard guard(_lock);
return _check_state(window, window::state_child);
}
///
/// \brief tests if the window is running
///
/// \param window The window.
/// \returns \f$true\f$ if the window is running, \f$false\f$ otherwise
bool is_running(window_id window) const {
lock_guard guard(_lock);
return _check_state(window, window::state_running);
}
///
/// \brief tests if the window is suspended
///
/// \param window The window.
/// \returns \f$true\f$ if the window is suspended, \f$false\f$ otherwise
bool is_suspended(window_id window) const {
lock_guard guard(_lock);
return _check_state(window, window::state_suspended);
}
/// @}
// Window Behaviour Flags ==============================================================================================
public:
/// \name Window Behaviour Flags
/// @{
///
/// \brief tests a specific flag
///
/// \param window The window.
/// \param flag the flag from `window::flag_`
/// \returns \f$true\f$ if the flag is set, \f$false\f$ otherwise
bool get_flag(window_id window, uint8_t flag) {
lock_guard guard(_lock);
return _get_flag(window, flag);
}
bool is_always_on_top(window_id window) { return get_flag(window, window::flag_always_on_top); }
bool is_borderless(window_id window) { return get_flag(window, window::flag_borderless); }
bool is_modal(window_id window) { return get_flag(window, window::flag_modal); }
bool is_passing_mouse(window_id window) { return get_flag(window, window::flag_pass_mouse); }
bool is_popup(window_id window) { return get_flag(window, window::flag_popup); }
bool is_resizable(window_id window) { return get_flag(window, window::flag_resizable); }
bool is_transparent(window_id window) { return get_flag(window, window::flag_transparent); }
bool is_no_focus(window_id window) { return get_flag(window, window::flag_no_focus); }
///
/// \brief check if the window is flagged to always be on top of other windows
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_always_on_top(window_id window) {
return get_flag(window, window::flag_always_on_top);
}
///
/// \brief check if the window is flagged to have no window decorations
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_borderless(window_id window) {
return get_flag(window, window::flag_borderless);
}
///
/// \brief check if the window is flagged to be modal
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_modal(window_id window) {
return get_flag(window, window::flag_modal);
}
///
/// \brief check if the window is flagged to pass mouse input to windows underneath from the same application
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_passing_mouse(window_id window) {
return get_flag(window, window::flag_pass_mouse);
}
///
/// \brief check if the window is flagged as a popup
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_popup(window_id window) {
return get_flag(window, window::flag_popup);
}
///
/// \brief check if the window is flagged to be resizable
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_resizable(window_id window) {
return get_flag(window, window::flag_resizable);
}
///
/// \brief check if the window is flagged to be transparent
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_transparent(window_id window) {
return get_flag(window, window::flag_transparent);
}
///
/// \brief check if the window is flagged to be unfocusable
///
/// \param window The window.
/// \returns \f$true\f$ if set, \f$false\f$ otherwise
bool is_no_focus(window_id window) {
return get_flag(window, window::flag_no_focus);
}
bool set_flag(window_id window, uint8_t flag, bool val);
///
/// \brief sets a specific flag
///
/// \param window The window.
/// \param flag the flag from `window::flag_`
/// \param val the value to set the flag to
void set_flag(window_id window, uint8_t flag, bool val) {
lock_guard guard(_lock);
bool set_always_on_top(window_id window, bool val) { return set_flag(window, window::flag_always_on_top, val); }
bool set_borderless(window_id window, bool val) { return set_flag(window, window::flag_borderless, val); }
bool set_modal(window_id window, bool val) { return set_flag(window, window::flag_modal, val); }
bool set_passing_mouse(window_id window, bool val) { return set_flag(window, window::flag_pass_mouse, val); }
bool set_popup(window_id window, bool val) { return set_flag(window, window::flag_popup, val); }
bool set_resizable(window_id window, bool val) { return set_flag(window, window::flag_resizable, val); }
bool set_transparent(window_id window, bool val) { return set_flag(window, window::flag_transparent, val); }
bool set_no_focus(window_id window, bool val) { return set_flag(window, window::flag_no_focus, val); }
_commands.push(command {
.cmd = command_set_flag,
.win = window,
.data = flag_val{ .index = flag, .val = val }
});
}
///
/// \brief sets whether to always be on top of other windows
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_always_on_top(window_id window, bool val) {
return set_flag(window, window::flag_always_on_top, val);
}
///
/// \brief sets whether to have no window decorations
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_borderless(window_id window, bool val) {
return set_flag(window, window::flag_borderless, val);
}
///
/// \brief sets whether to be modal
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_modal(window_id window, bool val) {
return set_flag(window, window::flag_modal, val);
}
///
/// \brief sets whether to pass mouse input to windows underneath from the same application
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_passing_mouse(window_id window, bool val) {
return set_flag(window, window::flag_pass_mouse, val);
}
///
/// \brief sets whether the window is a popup
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_popup(window_id window, bool val) {
return set_flag(window, window::flag_popup, val);
}
///
/// \brief sets whether to be resizable
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_resizable(window_id window, bool val) {
return set_flag(window, window::flag_resizable, val);
}
///
/// \brief sets whetherto be transparent
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_transparent(window_id window, bool val) {
return set_flag(window, window::flag_transparent, val);
}
///
/// \brief sets whether to be unfocusable
///
/// \param window The window.
/// \param val the value to set the flag to
/// \returns \f$true\f$ on success, \f$false\f$ otherwise
void set_no_focus(window_id window, bool val) {
return set_flag(window, window::flag_no_focus, val);
}
/// @}
// Private Member Variables ============================================================================================
private:
mutable mutex _lock;
thread::id _thread;
@@ -163,12 +486,14 @@ private:
command_queue_t _commands;
// Private Helpers =====================================================================================================
private:
window_id _parent(window_id id) const;
window_id _root(window_id id) const;
ivec2 _get_size(window_id id) const;
ivec2 _get_position(window_id id) const;
irect _get_bounds(window_id id) const;
bool _check_state(window_id id, uint8_t state) const;