- Setup EGL context for Wayland. Test window now opens as black rectangle.

This commit is contained in:
2025-12-15 13:20:08 -05:00
parent 5dcb58f53c
commit 1acf00138a
36 changed files with 992 additions and 80 deletions

View File

@@ -16,30 +16,19 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file wayland_server.h
/// \brief
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#include <fennec/core/logger.h>
#include <fennec/platform/linux/wayland/server.h>
#include <fennec/platform/linux/wayland/window.h>
#include <fennec/platform/linux/wayland/lib/loader.h>
#include <fennec/platform/linux/wayland/lib/wayland.h>
#include <fennec/platform/linux/wayland/lib/headers/xdg-shell-client-protocols.h>
#include <fennec/renderers/interface/gfxcontext.h>
namespace fennec
{
wayland_server::wayland_server(fennec::platform* p)
: display_server(p)
: display_server_base(p)
, display(nullptr), registry(nullptr), compositor(nullptr), seat(nullptr), fifo(false) {
// load shared lib
@@ -91,6 +80,22 @@ void wayland_server::connect() {
disconnect();
return;
}
auto contexts = ctx_registry::get_type_list();
while (not contexts.empty()) {
const auto& ctx = contexts.front();
gfx_context = ctx.ctor(this);
if (gfx_context->is_valid()) {
break;
} else {
delete gfx_context;
gfx_context = nullptr;
contexts.pop();
}
}
assertf(gfx_context != nullptr, "Failed to create graphics context.");
}
void wayland_server::disconnect() {
@@ -100,6 +105,10 @@ void wayland_server::disconnect() {
return;
}
// delete the gfx context
delete gfx_context;
// check compositor
if (compositor) {
wl_compositor_destroy(compositor);
@@ -115,7 +124,8 @@ void wayland_server::disconnect() {
wl_display_disconnect(display);
// clear vars
display = nullptr;
gfx_context = nullptr;
display = nullptr;
registry = nullptr;
compositor = nullptr;
seat = nullptr;
@@ -126,6 +136,10 @@ bool wayland_server::connected() const {
return display != nullptr;
}
void wayland_server::dispatch() {
wl_display_dispatch_pending(display);
}
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];