- More implementations and dependencies for Linux Wayland support
This commit is contained in:
71
include/fennec/platform/interface/displaydev.h
Normal file
71
include/fennec/platform/interface/displaydev.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H
|
||||
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \brief Interface for display management
|
||||
class displaydev
|
||||
{
|
||||
public:
|
||||
struct pixel_format {
|
||||
uint8_t depth;
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
struct config {
|
||||
pixel_format format;
|
||||
};
|
||||
|
||||
virtual bool connected() const = 0;
|
||||
virtual ~displaydev() = default;
|
||||
|
||||
virtual window* create_window() = 0;
|
||||
|
||||
const pixel_format& get_color_format() const {
|
||||
return _config.format;
|
||||
}
|
||||
|
||||
template<typename ContextT>
|
||||
ContextT* get_context() {
|
||||
return static_cast<ContextT*>(_context);
|
||||
}
|
||||
|
||||
template<typename PlatformT>
|
||||
PlatformT* get_platform() {
|
||||
return static_cast<PlatformT*>(_platform);
|
||||
}
|
||||
|
||||
protected:
|
||||
platform* _platform;
|
||||
gfxcontext* _context;
|
||||
config _config;
|
||||
|
||||
displaydev(platform* platform);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H
|
||||
@@ -22,8 +22,11 @@
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class platform;
|
||||
class window;
|
||||
class display;
|
||||
class displaydev;
|
||||
class gfxcontext;
|
||||
class gfxsurface;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,30 +16,28 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \brief Interface for display management
|
||||
class display
|
||||
{
|
||||
class gfxcontext {
|
||||
public:
|
||||
struct config {
|
||||
template<typename TypeT>
|
||||
TypeT* get_device() {
|
||||
return static_cast<TypeT*>(_device);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
virtual bool connected() const = 0;
|
||||
virtual ~display() = default;
|
||||
protected:
|
||||
gfxcontext(displaydev* device);
|
||||
|
||||
private:
|
||||
config _config;
|
||||
displaydev* _device;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
@@ -16,31 +16,33 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
|
||||
|
||||
#include <fennec/fproc/strings/cstring.h>
|
||||
#include <fennec/platform/interface/display.h>
|
||||
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_display : public display {
|
||||
public:
|
||||
wayland_display(linux_platform* platform);
|
||||
wayland_display(linux_platform* platform, const cstring& drv);
|
||||
~wayland_display() override;
|
||||
class gfxsurface {
|
||||
template<typename ContextT>
|
||||
ContextT* get_context() {
|
||||
return static_cast<ContextT*>(_context);
|
||||
}
|
||||
|
||||
bool connected() const override;
|
||||
template<typename WindowT>
|
||||
WindowT* get_window() {
|
||||
return static_cast<WindowT*>(_window);
|
||||
}
|
||||
|
||||
protected:
|
||||
gfxsurface(window* window, gfxcontext* context);
|
||||
|
||||
private:
|
||||
struct wl_display* _handle;
|
||||
linux_platform* _platform;
|
||||
window* _window;
|
||||
gfxcontext* _context;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
|
||||
@@ -16,12 +16,21 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H
|
||||
|
||||
#define FENNEC_LIB(name) inline bool FENNEC_HAS_LIB_##name = false;
|
||||
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
|
||||
inline sym_##fn fn = nullptr;
|
||||
#include <fennec/platform/linux/wayland/lib/sym.h>
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
class inputdevice {
|
||||
public:
|
||||
virtual bool has_keyboard() = 0;
|
||||
virtual bool has_mouse() = 0;
|
||||
virtual bool has_touch() = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H
|
||||
@@ -29,19 +29,14 @@ class platform {
|
||||
public:
|
||||
using shared_object = struct shared_object;
|
||||
using function_pointer = void (*)(void);
|
||||
using global = void*;
|
||||
|
||||
struct shared_lib {
|
||||
shared_object* _lib;
|
||||
const cstring _name;
|
||||
};
|
||||
|
||||
enum class user {
|
||||
client,
|
||||
server
|
||||
};
|
||||
|
||||
struct config {
|
||||
user type;
|
||||
};
|
||||
|
||||
// Functions with default implementations
|
||||
@@ -52,17 +47,18 @@ public:
|
||||
|
||||
// Pure Virtual Functions
|
||||
|
||||
virtual display* get_display() = 0;
|
||||
virtual displaydev* get_display() = 0;
|
||||
|
||||
virtual shared_object* load_object(const cstring& file) = 0;
|
||||
virtual void unload_object(shared_object* obj) = 0;
|
||||
|
||||
virtual function_pointer find_symbol(shared_object* hndl, const cstring& name) = 0;
|
||||
virtual global find_global(shared_object* hndl, const cstring& name) = 0;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
platform(user t);
|
||||
platform();
|
||||
virtual ~platform() = default;
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/fproc/strings/string.h>
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
#include <fennec/platform/interface/gfxsurface.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -45,19 +47,18 @@ public:
|
||||
flags_block_screensaver = 0x1 << 4,
|
||||
};
|
||||
|
||||
union bits {
|
||||
uint32_t depth;
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
|
||||
struct config {
|
||||
string title;
|
||||
uint32_t flags;
|
||||
size_t width, height;
|
||||
fullscreen_mode fullscreen;
|
||||
bits bit_depth;
|
||||
};
|
||||
|
||||
virtual bool running() = 0;
|
||||
virtual void configure(const config& config) = 0;
|
||||
virtual bool initialize(bool modal) = 0;
|
||||
virtual bool shutdown() = 0;
|
||||
|
||||
virtual bool set_title(const cstring& title) = 0;
|
||||
virtual bool set_title(const string& title) = 0;
|
||||
|
||||
@@ -74,60 +75,76 @@ public:
|
||||
virtual bool block_screensaver(bool e) = 0;
|
||||
|
||||
bool is_child() const {
|
||||
return _config.flags & flags_child;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_child;
|
||||
}
|
||||
|
||||
bool is_modal() const {
|
||||
return _config.flags & flags_modal;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_modal;
|
||||
}
|
||||
|
||||
display* get_display() {
|
||||
displaydev* get_display() {
|
||||
return _display;
|
||||
}
|
||||
|
||||
const display* get_display() const {
|
||||
const displaydev* get_display() const {
|
||||
return _display;
|
||||
}
|
||||
|
||||
|
||||
const string& get_title() const {
|
||||
return _config.title;
|
||||
static const string _null = { "null" };
|
||||
if (not _config) return _null;
|
||||
return _config->title;
|
||||
}
|
||||
|
||||
|
||||
size_t get_width() const {
|
||||
return _config.width;
|
||||
if (not _config) return false;
|
||||
return _config->width;
|
||||
}
|
||||
|
||||
size_t get_height() const {
|
||||
return _config.height;
|
||||
if (not _config) return false;
|
||||
return _config->height;
|
||||
}
|
||||
|
||||
|
||||
fullscreen_mode get_fullscreen_mode() const {
|
||||
return _config.fullscreen;
|
||||
if (not _config) return fullscreen_mode::windowed;
|
||||
return _config->fullscreen;
|
||||
}
|
||||
|
||||
|
||||
bool is_keyboard_grabbed() const {
|
||||
return _config.flags & flags_grab_keyboard;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_grab_keyboard;
|
||||
}
|
||||
|
||||
bool is_mouse_grabbed() const {
|
||||
return _config.flags & flags_grab_mouse;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_grab_mouse;
|
||||
}
|
||||
|
||||
bool is_screensaver_blocked() const {
|
||||
return _config.flags & flags_block_screensaver;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_block_screensaver;
|
||||
}
|
||||
|
||||
template<class DisplayT>
|
||||
DisplayT* get_display() {
|
||||
return static_cast<DisplayT*>(_display);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~window() = default;
|
||||
window(display* display, window* parent, bool modal);
|
||||
window(displaydev* display, window* parent);
|
||||
|
||||
display* _display;
|
||||
window* _parent;
|
||||
config _config;
|
||||
displaydev* _display;
|
||||
window* _parent;
|
||||
optional<config> _config;
|
||||
gfxsurface* _context;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define FENNEC_PLATFORM_LINUX_PLATFORM_H
|
||||
|
||||
#include <fennec/containers/set.h>
|
||||
#include <fennec/platform/interface/display.h>
|
||||
#include <fennec/platform/interface/displaydev.h>
|
||||
#include <fennec/platform/interface/platform.h>
|
||||
|
||||
namespace fennec
|
||||
@@ -34,18 +34,20 @@ public:
|
||||
display_wayland,
|
||||
};
|
||||
|
||||
linux_platform(user type);
|
||||
linux_platform();
|
||||
~linux_platform() override;
|
||||
|
||||
shared_object* load_object(const cstring& file) override;
|
||||
void unload_object(shared_object* obj) override;
|
||||
function_pointer find_symbol(shared_object* hndl, const cstring& name) override;
|
||||
void unload_object(shared_object* obj) override;
|
||||
|
||||
display* get_display() override;
|
||||
function_pointer find_symbol(shared_object* hndl, const cstring& name) override;
|
||||
global find_global(shared_object* hndl, const cstring& name) override;
|
||||
|
||||
displaydev* get_display() override;
|
||||
|
||||
|
||||
private:
|
||||
display* _display;
|
||||
displaydev* _display;
|
||||
int_t _display_driver;
|
||||
|
||||
void _runtime_client_checks();
|
||||
|
||||
71
include/fennec/platform/linux/wayland/displaydev.h
Normal file
71
include/fennec/platform/linux/wayland/displaydev.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/fproc/strings/cstring.h>
|
||||
|
||||
#include <fennec/platform/interface/displaydev.h>
|
||||
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#include <fennec/platform/linux/wayland/lib/wayland-client.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_display : public displaydev {
|
||||
public:
|
||||
wayland_display(linux_platform* platform);
|
||||
wayland_display(linux_platform* platform, const cstring& drv);
|
||||
~wayland_display() override;
|
||||
|
||||
bool connected() const override;
|
||||
|
||||
window* create_window() override;
|
||||
|
||||
inline wl_display* get_handle() { return _handle; }
|
||||
inline wl_registry* get_registry() { return _registry; }
|
||||
inline wl_compositor* get_compositor() { return _compositor; }
|
||||
inline wl_shell* get_shell() { return _shell; }
|
||||
inline wl_seat* get_seat() { return _seat; }
|
||||
inline wl_pointer* get_pointer() { return _pointer; }
|
||||
inline wl_keyboard* get_keyboard() { return _keyboard; }
|
||||
inline wl_shm* get_shm() { return _shm; }
|
||||
|
||||
private:
|
||||
wl_display* _handle;
|
||||
wl_registry* _registry;
|
||||
wl_compositor* _compositor;
|
||||
wl_shell* _shell;
|
||||
wl_seat* _seat;
|
||||
wl_pointer* _pointer;
|
||||
wl_keyboard* _keyboard;
|
||||
wl_shm* _shm;
|
||||
list<wayland_window*> _windows;
|
||||
|
||||
static void listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t);
|
||||
static void listen_global_remove(void*, wl_registry*, uint32_t);
|
||||
static void listen_seat(void*, wl_seat*, uint32_t);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
30
include/fennec/platform/linux/wayland/fwd.h
Normal file
30
include/fennec/platform/linux/wayland/fwd.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_display;
|
||||
class wayland_window;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
@@ -16,9 +16,46 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
struct wl_object;
|
||||
struct wl_proxy;
|
||||
struct wl_display;
|
||||
struct wl_event_queue;
|
||||
struct wl_buffer;
|
||||
struct wl_callback;
|
||||
struct wl_compositor;
|
||||
struct wl_data_device;
|
||||
struct wl_data_device_manager;
|
||||
struct wl_data_offer;
|
||||
struct wl_data_source;
|
||||
struct wl_keyboard;
|
||||
struct wl_output;
|
||||
struct wl_pointer;
|
||||
struct wl_region;
|
||||
struct wl_registry;
|
||||
struct wl_seat;
|
||||
struct wl_shell;
|
||||
struct wl_shell_surface;
|
||||
struct wl_shm;
|
||||
struct wl_shm_pool;
|
||||
struct wl_subcompositor;
|
||||
struct wl_subsurface;
|
||||
struct wl_surface;
|
||||
struct wl_touch;
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
struct wl_egl_window;
|
||||
struct wl_surface;
|
||||
|
||||
typedef int32_t wl_fixed_t;
|
||||
|
||||
#define WL_PRINTF(x, y) __attribute__((__format__(__printf__, x, y)))
|
||||
typedef void (*wl_log_func_t)(const char *fmt, va_list args) WL_PRINTF(1, 0);
|
||||
|
||||
#define WL_MARSHAL_FLAG_DESTROY (1 << 0)
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
|
||||
#ifndef FENNEC_LIB
|
||||
@@ -26,12 +27,87 @@
|
||||
#define FENNEC_SYMBOL(...)
|
||||
#endif
|
||||
|
||||
#ifndef FENNEC_GLOBAL
|
||||
#define FENNEC_GLOBAL(...)
|
||||
#endif
|
||||
|
||||
|
||||
FENNEC_LIB(WAYLAND);
|
||||
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect, const char* name);
|
||||
FENNEC_SYMBOL(void, wl_display_disconnect, wl_display* name);
|
||||
FENNEC_SYMBOL(void, wl_proxy_marshal, struct wl_proxy*, uint32_t, ...);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_marshal_flags, struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, ...);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_create, struct wl_proxy*, const struct wl_interface*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_destroy, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(int, wl_proxy_add_listener, struct wl_proxy*, void (**)(void), void*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_set_user_data, struct wl_proxy*, void*);
|
||||
FENNEC_SYMBOL(void*, wl_proxy_get_user_data, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(uint32_t, wl_proxy_get_version, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(uint32_t, wl_proxy_get_id, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(const char*, wl_proxy_get_class, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_set_queue, struct wl_proxy*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(void*, wl_proxy_create_wrapper, void*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_wrapper_destroy, void*);
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect, const char*);
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect_to_fd, int);
|
||||
FENNEC_SYMBOL(void, wl_display_disconnect, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_get_fd, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch_queue, struct wl_display*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch_queue_pending, struct wl_display*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch_pending, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_prepare_read, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_prepare_read_queue, struct wl_display*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(int, wl_display_read_events, struct wl_display*);
|
||||
FENNEC_SYMBOL(void, wl_display_cancel_read, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_get_error, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_flush, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_roundtrip, struct wl_display*);
|
||||
FENNEC_SYMBOL(struct wl_event_queue*, wl_display_create_queue, struct wl_display*);
|
||||
FENNEC_SYMBOL(void, wl_event_queue_destroy, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(void, wl_log_set_handler_client, wl_log_func_t);
|
||||
FENNEC_SYMBOL(void, wl_list_init, struct wl_list*);
|
||||
FENNEC_SYMBOL(void, wl_list_insert, struct wl_list*, struct wl_list*) ;
|
||||
FENNEC_SYMBOL(void, wl_list_remove, struct wl_list*);
|
||||
FENNEC_SYMBOL(int, wl_list_length, const struct wl_list*);
|
||||
FENNEC_SYMBOL(int, wl_list_empty, const struct wl_list*);
|
||||
FENNEC_SYMBOL(void, wl_list_insert_list, struct wl_list*, struct wl_list*);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_marshal_constructor, struct wl_proxy*, uint32_t opcode, const struct wl_interface*interface, ...);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_marshal_constructor_versioned, struct wl_proxy*proxy, uint32_t opcode, const struct wl_interface*interface, uint32_t version, ...);
|
||||
FENNEC_SYMBOL(void, wl_proxy_set_tag, struct wl_proxy*, const char* const*);
|
||||
FENNEC_SYMBOL(const char* const*, wl_proxy_get_tag, struct wl_proxy*);
|
||||
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_display_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_registry_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_callback_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_compositor_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shm_pool_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shm_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_buffer_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_offer_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_source_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_device_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_device_manager_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shell_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shell_surface_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_surface_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_seat_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_pointer_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_keyboard_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_touch_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_output_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_region_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_subcompositor_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_subsurface_interface);
|
||||
|
||||
FENNEC_LIB(WAYLAND_EGL);
|
||||
|
||||
FENNEC_SYMBOL(struct wl_egl_window*, wl_egl_window_create, struct wl_surface *surface, int width, int height);
|
||||
FENNEC_SYMBOL(void, wl_egl_window_destroy, struct wl_egl_window *egl_window);
|
||||
FENNEC_SYMBOL(void, wl_egl_window_resize, struct wl_egl_window *egl_window, int width, int height, int dx, int dy);
|
||||
FENNEC_SYMBOL(void, wl_egl_window_get_attached_size, struct wl_egl_window *egl_window, int *width, int *height);
|
||||
|
||||
#undef FENNEC_LIB
|
||||
#undef FENNEC_SYMBOL
|
||||
#undef FENNEC_GLOBAL
|
||||
|
||||
|
||||
|
||||
2004
include/fennec/platform/linux/wayland/lib/wayland-client.h
Normal file
2004
include/fennec/platform/linux/wayland/lib/wayland-client.h
Normal file
File diff suppressed because it is too large
Load Diff
198
include/fennec/platform/linux/wayland/lib/wayland-util.h
Normal file
198
include/fennec/platform/linux/wayland/lib/wayland-util.h
Normal file
@@ -0,0 +1,198 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_UTIL_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_UTIL_H
|
||||
|
||||
/*
|
||||
* Copyright © 2008 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_EXPORT __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define WL_EXPORT
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ >= 202311L
|
||||
#define WL_DEPRECATED [[deprecated]]
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_DEPRECATED __attribute__ ((deprecated))
|
||||
#else
|
||||
#define WL_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_PRINTF(x, y) __attribute__((__format__(__printf__, x, y)))
|
||||
#else
|
||||
#define WL_PRINTF(x, y)
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ >= 202311L
|
||||
#define WL_TYPEOF(expr) typeof(expr)
|
||||
#else
|
||||
#define WL_TYPEOF(expr) __typeof__(expr)
|
||||
#endif
|
||||
|
||||
struct wl_message {
|
||||
const char *name;
|
||||
const char *signature;
|
||||
const struct wl_interface **types;
|
||||
};
|
||||
|
||||
struct wl_interface {
|
||||
const char *name;
|
||||
int version;
|
||||
int method_count;
|
||||
const struct wl_message *methods;
|
||||
int event_count;
|
||||
const struct wl_message *events;
|
||||
};
|
||||
|
||||
struct wl_list {
|
||||
struct wl_list *prev;
|
||||
struct wl_list *next;
|
||||
};
|
||||
|
||||
#define wl_container_of(ptr, sample, member) \
|
||||
(WL_TYPEOF(sample))((char *)(ptr) - \
|
||||
offsetof(WL_TYPEOF(*sample), member))
|
||||
|
||||
#define wl_list_for_each(pos, head, member) \
|
||||
for (pos = wl_container_of((head)->next, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = wl_container_of(pos->member.next, pos, member))
|
||||
|
||||
#define wl_list_for_each_safe(pos, tmp, head, member) \
|
||||
for (pos = wl_container_of((head)->next, pos, member), \
|
||||
tmp = wl_container_of((pos)->member.next, tmp, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = wl_container_of(pos->member.next, tmp, member))
|
||||
|
||||
#define wl_list_for_each_reverse(pos, head, member) \
|
||||
for (pos = wl_container_of((head)->prev, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = wl_container_of(pos->member.prev, pos, member))
|
||||
|
||||
#define wl_list_for_each_reverse_safe(pos, tmp, head, member) \
|
||||
for (pos = wl_container_of((head)->prev, pos, member), \
|
||||
tmp = wl_container_of((pos)->member.prev, tmp, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = wl_container_of(pos->member.prev, tmp, member))
|
||||
|
||||
struct wl_array {
|
||||
size_t size;
|
||||
size_t alloc;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void
|
||||
wl_array_init(struct wl_array *array);
|
||||
|
||||
void
|
||||
wl_array_release(struct wl_array *array);
|
||||
|
||||
void *
|
||||
wl_array_add(struct wl_array *array, size_t size);
|
||||
|
||||
int
|
||||
wl_array_copy(struct wl_array *array, struct wl_array *source);
|
||||
|
||||
#define wl_array_for_each(pos, array) \
|
||||
for (pos = (array)->data; \
|
||||
(array)->size != 0 && \
|
||||
(const char *) pos < ((const char *) (array)->data + (array)->size); \
|
||||
(pos)++)
|
||||
|
||||
typedef int32_t wl_fixed_t;
|
||||
|
||||
static inline double
|
||||
wl_fixed_to_double(wl_fixed_t f)
|
||||
{
|
||||
return f / 256.0;
|
||||
}
|
||||
|
||||
static inline wl_fixed_t
|
||||
wl_fixed_from_double(double d)
|
||||
{
|
||||
return (wl_fixed_t) (d * 256.0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
wl_fixed_to_int(wl_fixed_t f)
|
||||
{
|
||||
return f / 256;
|
||||
}
|
||||
|
||||
static inline wl_fixed_t
|
||||
wl_fixed_from_int(int i)
|
||||
{
|
||||
return i * 256;
|
||||
}
|
||||
|
||||
union wl_argument {
|
||||
int32_t i;
|
||||
uint32_t u;
|
||||
wl_fixed_t f;
|
||||
const char *s;
|
||||
struct wl_object *o;
|
||||
uint32_t n;
|
||||
struct wl_array *a;
|
||||
int32_t h;
|
||||
};
|
||||
|
||||
typedef int (*wl_dispatcher_func_t)(const void *user_data, void *target,
|
||||
uint32_t opcode, const struct wl_message *msg,
|
||||
union wl_argument *args);
|
||||
|
||||
typedef void (*wl_log_func_t)(const char *fmt, va_list args) WL_PRINTF(1, 0);
|
||||
|
||||
enum wl_iterator_result {
|
||||
WL_ITERATOR_STOP,
|
||||
WL_ITERATOR_CONTINUE
|
||||
};
|
||||
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_UTIL_H
|
||||
@@ -19,13 +19,40 @@
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
|
||||
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_window {
|
||||
class wayland_window : window {
|
||||
public:
|
||||
bool running() override;
|
||||
void configure(const config& config) override;
|
||||
bool initialize(bool modal) override;
|
||||
bool shutdown() override;
|
||||
|
||||
bool set_title(const cstring& title) override;
|
||||
bool set_title(const string& title) override;
|
||||
bool set_width(size_t w) override;
|
||||
bool set_height(size_t h) override;
|
||||
bool set_size(size_t w, size_t h) override;
|
||||
bool set_fullscreen_mode(fullscreen_mode mode) override;
|
||||
bool set_resizable(bool e) override;
|
||||
bool grab_keyboard(bool e) override;
|
||||
bool grab_mouse(bool e) override;
|
||||
bool block_screensaver(bool e) override;
|
||||
|
||||
wayland_window(wayland_display* display, wayland_window* parent);
|
||||
~wayland_window() override;
|
||||
|
||||
private:
|
||||
wl_surface* _surface;
|
||||
wl_shell_surface* _shell;
|
||||
wl_callback* _callback;
|
||||
gfxcontext* _context;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
44
include/fennec/platform/opengl/egl/context.h
Normal file
44
include/fennec/platform/opengl/egl/context.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_EGL_CONTEXT_H
|
||||
#define FENNEC_PLATFORM_EGL_CONTEXT_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <fennec/platform/interface/displaydev.h>
|
||||
#include <fennec/platform/interface/gfxcontext.h>
|
||||
|
||||
#if FENNEC_HAS_WAYLAND
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#endif
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglcontext : gfxcontext {
|
||||
public:
|
||||
eglcontext(displaydev* device);
|
||||
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLConfig config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_EGL_CONTEXT_H
|
||||
43
include/fennec/platform/opengl/egl/surface.h
Normal file
43
include/fennec/platform/opengl/egl/surface.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
#define FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include <fennec/platform/interface/gfxsurface.h>
|
||||
#include <fennec/platform/opengl/egl/context.h>
|
||||
|
||||
#if FENNEC_HAS_WAYLAND
|
||||
|
||||
#endif
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglsurface : gfxsurface {
|
||||
public:
|
||||
eglsurface(eglcontext* context);
|
||||
|
||||
EGLSurface surface;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
Reference in New Issue
Block a user