Commit 8ee24a21 authored by Peter Kovář's avatar Peter Kovář

[WIP] Added Wayland

parent 273c949f
Pipeline #18056 failed with stage
......@@ -52,6 +52,13 @@
} \
}
#if defined(__GNUC__)
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
// ------------------------------------------------------- typedef & struct ---
typedef struct vertex_s
{
......@@ -3339,7 +3346,7 @@ static const struct wl_seat_listener seat_listener = {
};
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface,
uint32_t version UNUSED) {
uint32_t version) {
demo_t *demo = data;
// pickup wayland objects when they appear
if (strcmp(interface, "wl_compositor") == 0) {
......@@ -3352,7 +3359,7 @@ static void registry_handle_global(void *data, struct wl_registry *registry, uin
}
}
static void registry_handle_global_remove(void *data UNUSED, struct wl_registry *registry UNUSED, uint32_t name UNUSED) {}
static void registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {}
static const struct wl_registry_listener registry_listener = {registry_handle_global, registry_handle_global_remove};
#endif
......@@ -3506,7 +3513,60 @@ static void create_xcb_window(demo_t *demo)
const uint32_t coords[] = {100, 100};
xcb_configure_window(demo->connection, demo->xcb_window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords);
}
#endif // VK_USE_PLATFORM_XCB_KHR
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
static void run(demo_t *demo)
{
while (!demo->quit)
{
if (demo->pause)
{
wl_display_dispatch(demo->display); // block and wait for input
}
else
{
wl_display_dispatch_pending(demo->display); // don't block
draw(demo);
demo->curFrame++;
if (demo->frameCount != INT32_MAX && demo->curFrame == demo->frameCount) demo->quit = true;
}
}
}
static void handle_ping(void *data UNUSED, struct wl_shell_surface *shell_surface, uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
}
static void handle_configure(void *data UNUSED, struct wl_shell_surface *shell_surface UNUSED, uint32_t edges UNUSED,
int32_t width UNUSED, int32_t height UNUSED) {}
static void handle_popup_done(void *data UNUSED, struct wl_shell_surface *shell_surface UNUSED) {}
static const struct wl_shell_surface_listener shell_surface_listener = {handle_ping, handle_configure, handle_popup_done};
static void create_window(demo_t *demo)
{
demo->window = wl_compositor_create_surface(demo->compositor);
if (!demo->window)
{
printf("Can not create wayland_surface from compositor!\n");
fflush(stdout);
exit(1);
}
demo->shell_surface = wl_shell_get_shell_surface(demo->shell, demo->window);
if (!demo->shell_surface)
{
printf("Can not get shell_surface from wayland_surface!\n");
fflush(stdout);
exit(1);
}
wl_shell_surface_add_listener(demo->shell_surface, &shell_surface_listener, demo);
wl_shell_surface_set_toplevel(demo->shell_surface);
wl_shell_surface_set_title(demo->shell_surface, APP_SHORT_NAME);
}
#endif
static void init (demo_t *demo, int argc, char **argv)
{
......
......@@ -2,12 +2,20 @@ TARGET = Cube
CFILES = $(TARGET).c
HEADERS = ../../Headers
SHADERS = ../../Shaders
FREETYPE = freetype2
HARFBUZZ = harfbuzz
RAQM = raqm
COMPONENTS = $(FONTCONFIG) $(FREETYPE) $(HARFBUZZ) $(RAQM)
CFLAGS = `$(PKGCONFIG) --cflags $(COMPONENTS)`
CFLAGS += --lto
CFLAGS += -I$(HEADERS) -I$(SHADERS)
LIBS = -lFontasy -lvulkan -lm
LIBS += `$(PKGCONFIG) --libs $(COMPONENTS)`
Linux_CFLAGS += -DVK_USE_PLATFORM_XCB_KHR
Linux_LIBS = -lxcb
#Linux_CFLAGS += -DVK_USE_PLATFORM_XCB_KHR
#Linux_LIBS = -lxcb
Linux_CFLAGS += -DVK_USE_PLATFORM_WAYLAND_KHR
Linux_LIBS = -lwayland-client
include $(PEAK)/include/make/definitions
include $(PROGRAMRULES)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment