- fleshing out event system and window manager
- added tests back in for window management
This commit is contained in:
@@ -87,18 +87,20 @@ public:
|
||||
///
|
||||
/// \brief shared object release
|
||||
/// \param obj the shared object to release
|
||||
virtual void unload_object(shared_object* obj) = 0;
|
||||
virtual void unload_object(shared_object* obj) = 0;
|
||||
|
||||
///
|
||||
/// \brief shared object symbol locator
|
||||
/// \param obj the shared object to search
|
||||
/// \param name the name of the symbol to search for
|
||||
/// \returns a reference to the symbol
|
||||
virtual symbol find_symbol(shared_object* obj, const cstring& name) = 0;
|
||||
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; }
|
||||
|
||||
protected:
|
||||
unique_ptr<window_manager> wmanager; //!< the window manager
|
||||
|
||||
|
||||
@@ -336,9 +336,9 @@ public:
|
||||
protected:
|
||||
display_server* const server; //!< the display server the window belongs to
|
||||
window* const parent; //!< the parent window
|
||||
window* root; //!< the nearest top-level window in the hierarchy
|
||||
config cfg; //!< the current configuration
|
||||
state state; //!< the current state
|
||||
window* root; //!< the nearest top-level window in the hierarchy
|
||||
unique_ptr<gfxsurface> gfx_surface; //!< the corresponding graphics surface
|
||||
};
|
||||
|
||||
|
||||
@@ -38,28 +38,23 @@
|
||||
#include <fennec/containers/object_pool.h>
|
||||
#include <fennec/platform/interface/window.h>
|
||||
#include <fennec/threading/lock_guard.h>
|
||||
#include <fennec/threading/mpscq.h>
|
||||
#include <fennec/threading/mutex.h>
|
||||
#include <fennec/threading/thread.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
using window_id = size_t; //!< type representing an id for a window
|
||||
|
||||
///
|
||||
/// \brief class for handling display servers and windows
|
||||
class window_manager {
|
||||
// Definitions =========================================================================================================
|
||||
public:
|
||||
using window_id = size_t; //!< type representing an id for a window
|
||||
|
||||
static constexpr window_id nullid = -1; //!< constant representing a null window
|
||||
|
||||
private:
|
||||
using server_t = unique_ptr<display_server>;
|
||||
using window_t = unique_ptr<window>;
|
||||
using window_pool_t = object_pool<window_t>;
|
||||
|
||||
using config = window::config;
|
||||
|
||||
enum command_ : uint8_t {
|
||||
command_set_flag = 0,
|
||||
command_resize
|
||||
@@ -71,6 +66,14 @@ private:
|
||||
void* data;
|
||||
};
|
||||
|
||||
static constexpr size_t max_commands = 512;
|
||||
|
||||
using server_t = unique_ptr<display_server>;
|
||||
using window_t = unique_ptr<window>;
|
||||
using window_pool_t = object_pool<window_t>;
|
||||
using command_queue_t = mpscq<command>;
|
||||
using config = window::config;
|
||||
|
||||
|
||||
// Constructors & Destructor ===========================================================================================
|
||||
public:
|
||||
@@ -96,6 +99,7 @@ public:
|
||||
window_id create_window(const config& config, window_id parent = nullid);
|
||||
void begin(window_id window);
|
||||
void end(window_id window);
|
||||
void close(window_id window);
|
||||
|
||||
|
||||
// Thread-Safe Functions ===============================================================================================
|
||||
@@ -111,11 +115,11 @@ public:
|
||||
|
||||
ivec2 get_size(window_id window) const {
|
||||
lock_guard guard(_lock);
|
||||
return _size(window);
|
||||
return _get_size(window);
|
||||
}
|
||||
ivec2 get_position(window_id window) const {
|
||||
lock_guard guard(_lock);
|
||||
return _position(window);
|
||||
return _get_position(window);
|
||||
}
|
||||
|
||||
bool is_visible(window_id window) const { lock_guard guard(_lock); return _check_state(window, window::state_visible); }
|
||||
@@ -151,18 +155,20 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
mutable mutex _lock;
|
||||
thread::id _thread;
|
||||
platform* _platform;
|
||||
server_t _display;
|
||||
window_pool_t _windows;
|
||||
mutable mutex _lock;
|
||||
thread::id _thread;
|
||||
platform* _platform;
|
||||
server_t _display;
|
||||
window_pool_t _windows;
|
||||
command_queue_t _commands;
|
||||
|
||||
|
||||
|
||||
window_id _parent(window_id id) const;
|
||||
window_id _root(window_id id) const;
|
||||
|
||||
ivec2 _size(window_id id) const;
|
||||
ivec2 _position(window_id id) const;
|
||||
ivec2 _get_size(window_id id) const;
|
||||
ivec2 _get_position(window_id id) const;
|
||||
|
||||
bool _check_state(window_id id, uint8_t state) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user