- Started setting up a thread safe window manager
- Created thread & atomic structures
This commit is contained in:
@@ -29,25 +29,22 @@ platform::platform() {
|
||||
}
|
||||
|
||||
void platform::initialize() {
|
||||
if (wmanager) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger::log(format("Initializing platform {}", get_type().name()));
|
||||
|
||||
display_server::entrylist_t display_servers = display_server::get_type_list();
|
||||
while (not display_servers.empty()) {
|
||||
display_server::entry it = display_servers.front();
|
||||
display_servers.pop();
|
||||
|
||||
unique_ptr<display_server> server = unique_ptr(it.ctor(this));
|
||||
server->connect();
|
||||
if (server->connected()) {
|
||||
logger::log(format("Selected {} for the display server.", server->get_type().name()));
|
||||
display = move(server);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Setup Window Manager
|
||||
wmanager = make_unique<window_manager>(this);
|
||||
wmanager->initialize();
|
||||
}
|
||||
|
||||
void platform::shutdown() {
|
||||
display.reset();
|
||||
|
||||
// Cleanup Window Manager
|
||||
wmanager->shutdown();
|
||||
wmanager.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,14 +29,20 @@
|
||||
///
|
||||
|
||||
#include <fennec/platform/interface/window.h>
|
||||
#include <fennec/platform/interface/display_server.h>
|
||||
#include <fennec/renderers/interface/gfxsurface.h>
|
||||
#include <fennec/platform/interface/display_server.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
window* window::get_parent() const {
|
||||
return server->get_window(cfg.parent);
|
||||
window::window(display_server* server, const config& conf, window* parent)
|
||||
: server(server), parent(parent)
|
||||
, cfg(conf), state(), root(nullptr) {
|
||||
state.mode = conf.mode;
|
||||
}
|
||||
|
||||
window::~window() {
|
||||
|
||||
}
|
||||
|
||||
void window::begin_frame() {
|
||||
|
||||
@@ -177,9 +177,8 @@ void wayland_server::dispatch() {
|
||||
}
|
||||
}
|
||||
|
||||
window* wayland_server::create_window(const window::config& conf) {
|
||||
size_t id = windows.insert(new wayland_window(this, windows.next_id(), conf));
|
||||
return windows[id];
|
||||
window* wayland_server::create_window(const window::config& conf, window* parent) {
|
||||
return new wayland_window(this, conf, parent);
|
||||
}
|
||||
|
||||
void wayland_server::_wl_registry_listen_global(void* data, wl_registry* reg, uint32_t id, const char* name, uint32_t version) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <fennec/math/relational.h>
|
||||
#include <fennec/platform/interface/display_server.h>
|
||||
|
||||
#include <fennec/renderers/interface/gfxsurface.h>
|
||||
#include <fennec/renderers/interface/gfxcontext.h>
|
||||
|
||||
#include <fennec/platform/linux/wayland/server.h>
|
||||
@@ -27,7 +28,6 @@
|
||||
#include <fennec/platform/linux/wayland/lib/wayland.h>
|
||||
#include <fennec/platform/linux/wayland/lib/headers/xdg-shell-client-protocols.h>
|
||||
#include <fennec/platform/linux/wayland/libdecor/libdecor.h>
|
||||
#include <fennec/renderers/interface/gfxsurface.h>
|
||||
|
||||
#if FENNEC_HAS_LIBDECOR
|
||||
#include <fennec/platform/linux/wayland/libdecor/libdecor.h>
|
||||
@@ -35,11 +35,10 @@
|
||||
|
||||
using namespace fennec;
|
||||
|
||||
wayland_window::wayland_window(display_server* server, uint32_t id, const config& cfg)
|
||||
: window_base(server, id, cfg)
|
||||
wayland_window::wayland_window(display_server* server, const config& cfg, window* parent)
|
||||
: window_base(server, cfg, parent)
|
||||
, surface(nullptr)
|
||||
, xdgsurface(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
wayland_window::~wayland_window() {
|
||||
@@ -79,7 +78,7 @@ void wayland_window::initialize() {
|
||||
}
|
||||
|
||||
|
||||
wayland_window* root = this;
|
||||
root = parent;
|
||||
while (root != nullptr and root->is_popup()) {
|
||||
root = static_cast<wayland_window*>(root->get_parent());
|
||||
}
|
||||
@@ -110,7 +109,7 @@ void wayland_window::initialize() {
|
||||
.reserved9 = nullptr,
|
||||
};
|
||||
|
||||
gfx_surface = wl_server->get_gfx_context()->create_surface(this);
|
||||
gfx_surface = unique_ptr(wl_server->get_gfx_context()->create_surface(this));
|
||||
|
||||
if (wl_server->has_libdecor) {
|
||||
|
||||
@@ -151,11 +150,6 @@ void wayland_window::shutdown() {
|
||||
|
||||
wayland_server* wl_server = static_cast<wayland_server*>(server);
|
||||
|
||||
if (frame_callback) {
|
||||
wl_callback_destroy(frame_callback);
|
||||
frame_callback = nullptr;
|
||||
}
|
||||
|
||||
#if FENNEC_HAS_LIBDECOR
|
||||
if (libdecorframe) {
|
||||
libdecor_frame_unref(libdecorframe);
|
||||
@@ -164,6 +158,15 @@ void wayland_window::shutdown() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gfx_surface) {
|
||||
gfx_surface.reset();
|
||||
}
|
||||
|
||||
if (frame_callback) {
|
||||
wl_callback_destroy(frame_callback);
|
||||
frame_callback = nullptr;
|
||||
}
|
||||
|
||||
if (xdgtoplevel) {
|
||||
xdg_toplevel_destroy(xdgtoplevel);
|
||||
xdgtoplevel = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user