milsko/include/Mw/LowLevel/Wayland.h

137 lines
2.9 KiB
C

/*!
* @file Mw/LowLevel/Wayland.h
* @brief Wayland Backend
* @warning This is used internally
*/
#ifndef __MW_LOWLEVEL_WAYLAND_H__
#define __MW_LOWLEVEL_WAYLAND_H__
#include "Mw/BaseTypes.h"
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
#include <wayland-client-protocol.h>
#include <wayland-egl.h>
#include <cairo/cairo.h>
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
#include <assert.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input-event-codes.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <wayland-client-protocol.h>
#include "Mw/BaseTypes.h"
#include "Mw/LowLevel.h"
#include <sys/mman.h>
#include <wayland-egl-core.h>
#include <wayland-util.h>
/* TODO: find out what FreeBSD and such wants us to include */
#include <linux/input.h>
MWDECL int MwLLWaylandCallInit(void);
#ifndef WL_PROTOCOLS_DEFINED
#define WL_PROTOCOLS_DEFINED
#include "Wayland/xdg-shell-client-protocol.h"
#include "Wayland/xdg-decoration-client-protocol.h"
#include "Wayland/cursor-shape-client-protocol.h"
#endif
typedef struct wayland_protocol {
void* listener;
void* context;
} wayland_protocol_t;
typedef wayland_protocol_t*(wl_setup_func)(MwU32, struct _MwLLWayland*);
struct _MwLLWaylandTopLevel {
struct xdg_surface* xdg_surface;
struct xdg_toplevel* xdg_top_level;
struct xdg_toplevel_listener xdg_toplevel_listener;
struct xdg_surface_listener xdg_surface_listener;
struct xkb_context* xkb_context;
MwBool compositor_created;
MwBool xdg_wm_base_created;
MwBool xdg_surface_created;
};
struct _MwLLWayland {
struct _MwLLCommon common;
union {
struct _MwLLWaylandTopLevel* toplevel;
struct wl_subsurface* subsurface;
};
enum {
MWLL_WAYLAND_TOPLEVEL = 0,
MWLL_WAYLAND_SUBSURFACE = 1,
} type;
struct {
const char* key;
wl_setup_func* value;
}* wl_protocol_setup_map;
struct {
const char* key;
wayland_protocol_t* value;
}* wl_protocol_map;
struct wl_display* display;
struct wl_registry* registry;
struct wl_compositor* compositor;
struct wl_subcompositor* subcompositor;
struct wl_surface* surface;
struct wl_shm* shm;
struct wl_registry_listener registry_listener;
struct wl_pointer* pointer;
MwLL* subwidgets;
MwBool configured;
MwBool force_redraw;
MwBool egl_setup;
MwBool egl_do_resetup;
MwU32 x, y, ww, wh;
MwPoint cur_mouse_pos;
cairo_surface_t* cairo_surface;
void* mapped_buffer;
MwLL parent;
// GLuint fbo;
// unsigned int fbo_texture;
// EGLNativeWindowType egl_window_native;
// EGLDisplay egl_display;
// EGLContext egl_context;
// EGLSurface egl_surface;
// EGLConfig egl_config;
};
struct _MwLLWaylandColor {
struct _MwLLCommonColor common;
};
struct _MwLLWaylandPixmap {
struct _MwLLCommonPixmap common;
// GLuint texture;
};
#endif