Files
fennec/include/fennec/platform/linux/wayland/server.h

94 lines
2.7 KiB
C++

// =====================================================================================================================
// 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/>.
// =====================================================================================================================
///
/// \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))
///
///
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
#include <fennec/platform/linux/wayland/fwd.h>
#include <fennec/platform/interface/display_server.h>
// forward defs to avoid flooding global namespace
struct wl_display;
struct wl_shm;
struct wl_compositor;
struct wl_registry;
struct wl_seat;
struct wp_viewporter;
struct xdg_wm_base;
namespace fennec
{
///
/// \brief Class for handling the Wayland Display Server
class wayland_server : public display_server_base<wayland_server, wayland_window> {
public:
explicit wayland_server(fennec::platform* p);
~wayland_server() override;
void connect() override;
void disconnect() override;
bool connected() const override;
void dispatch() override;
window* create_window(const window::config& conf) override;
void* get_native_handle() override { return display; }
private:
wl_display* display;
wl_registry* registry;
wl_compositor* compositor;
xdg_wm_base* xdg;
wl_seat* seat;
bool fifo, libdecor;
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_capabilities(void*, wl_seat*, uint32_t);
static void listen_seat_name(void*, wl_seat*, const char*);
static void listen_xdg_ping(void*, xdg_wm_base*, uint32_t);
FENNEC_RTTI_CLASS_ENABLE(display_server) {
display_server::register_type<wayland_server>(1);
}
friend class wayland_window;
};
}
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H