// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  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_CLIENT_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_CLIENT_H

#include <wayland-client-core.h>

#define FENNEC_LIB(name)            extern "C" bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using WAYLAND_sym_##fn = ret(*)(__VA_ARGS__); \
                                    extern "C" WAYLAND_sym_##fn WAYLAND_##fn;
#define FENNEC_GLOBAL(type, name)   extern "C" type* WAYLAND_##name;
#include <fennec/platform/linux/wayland/lib/sym.h>

#define wl_proxy_marshal                       WAYLAND_wl_proxy_marshal
#define wl_proxy_marshal_flags                 WAYLAND_wl_proxy_marshal_flags
#define wl_proxy_create                        WAYLAND_wl_proxy_create
#define wl_proxy_destroy                       WAYLAND_wl_proxy_destroy
#define wl_proxy_add_listener                  WAYLAND_wl_proxy_add_listener
#define wl_proxy_set_user_data                 WAYLAND_wl_proxy_set_user_data
#define wl_proxy_get_user_data                 WAYLAND_wl_proxy_get_user_data
#define wl_proxy_get_version                   WAYLAND_wl_proxy_get_version
#define wl_proxy_get_id                        WAYLAND_wl_proxy_get_id
#define wl_proxy_get_class                     WAYLAND_wl_proxy_get_class
#define wl_proxy_set_queue                     WAYLAND_wl_proxy_set_queue
#define wl_proxy_create_wrapper                WAYLAND_wl_proxy_create_wrapper
#define wl_proxy_wrapper_destroy               WAYLAND_wl_proxy_wrapper_destroy
#define wl_proxy_marshal_constructor           WAYLAND_wl_proxy_marshal_constructor
#define wl_proxy_marshal_constructor_versioned WAYLAND_wl_proxy_marshal_constructor_versioned
#define wl_proxy_set_tag                       WAYLAND_wl_proxy_set_tag
#define wl_proxy_get_tag                       WAYLAND_wl_proxy_get_tag

#define wl_event_queue_destroy    WAYLAND_wl_event_queue_destroy
#define wl_log_set_handler_client WAYLAND_wl_log_set_handler_client
#define wl_list_init              WAYLAND_wl_list_init
#define wl_list_insert            WAYLAND_wl_list_insert
#define wl_list_remove            WAYLAND_wl_list_remove
#define wl_list_length            WAYLAND_wl_list_length
#define wl_list_empty             WAYLAND_wl_list_empty
#define wl_list_insert_list       WAYLAND_wl_list_insert_list

#define wl_display_connect                WAYLAND_wl_display_connect
#define wl_display_connect_to_fd          WAYLAND_wl_display_connect_to_fd
#define wl_display_reconnect              WAYLAND_wl_display_reconnect
#define wl_display_disconnect             WAYLAND_wl_display_disconnect
#define wl_display_get_fd                 WAYLAND_wl_display_get_fd
#define wl_display_dispatch               WAYLAND_wl_display_dispatch
#define wl_display_dispatch_queue         WAYLAND_wl_display_dispatch_queue
#define wl_display_dispatch_queue_pending WAYLAND_wl_display_dispatch_queue_pending
#define wl_display_dispatch_pending       WAYLAND_wl_display_dispatch_pending
#define wl_display_prepare_read           WAYLAND_wl_display_prepare_read
#define wl_display_prepare_read_queue     WAYLAND_wl_display_prepare_read_queue
#define wl_display_read_events            WAYLAND_wl_display_read_events
#define wl_display_cancel_read            WAYLAND_wl_display_cancel_read
#define wl_display_get_error              WAYLAND_wl_display_get_error
#define wl_display_flush                  WAYLAND_wl_display_flush
#define wl_display_roundtrip              WAYLAND_wl_display_roundtrip
#define wl_display_create_queue           WAYLAND_wl_display_create_queue

#define wl_seat_interface                *WAYLAND_wl_seat_interface
#define wl_surface_interface             *WAYLAND_wl_surface_interface
#define wl_shm_pool_interface            *WAYLAND_wl_shm_pool_interface
#define wl_buffer_interface              *WAYLAND_wl_buffer_interface
#define wl_registry_interface            *WAYLAND_wl_registry_interface
#define wl_region_interface              *WAYLAND_wl_region_interface
#define wl_pointer_interface             *WAYLAND_wl_pointer_interface
#define wl_keyboard_interface            *WAYLAND_wl_keyboard_interface
#define wl_compositor_interface          *WAYLAND_wl_compositor_interface
#define wl_output_interface              *WAYLAND_wl_output_interface
#define wl_shm_interface                 *WAYLAND_wl_shm_interface
#define wl_data_device_interface         *WAYLAND_wl_data_device_interface
#define wl_data_offer_interface          *WAYLAND_wl_data_offer_interface
#define wl_data_source_interface         *WAYLAND_wl_data_source_interface
#define wl_data_device_manager_interface *WAYLAND_wl_data_device_manager_interface

#define wl_egl_window_create            WAYLAND_wl_egl_window_create
#define wl_egl_window_destroy           WAYLAND_wl_egl_window_destroy
#define wl_egl_window_resize            WAYLAND_wl_egl_window_resize
#define wl_egl_window_get_attached_size WAYLAND_wl_egl_window_get_attached_size

#include <fennec/platform/linux/wayland/lib/headers/wayland-client-protocols.h>

#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_CLIENT_H