summaryrefslogtreecommitdiff
path: root/src/window_wayland.h
blob: ad0f5728e9a222aa82f59a62fbc155ac7703b041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once

#include <al/lib.h>
#include <al/array.h>
#include <nnwt/socket.h>

#include <wayland-client-core.h>
#include <wayland-client-protocol.h>
#include <wayland-egl-core.h>
#include <wayland-egl.h>
#include <xdg-shell-client-protocol.h>
#include <xdg-decoration-unstable-v1-client-protocol.h>
#include <cursor-shape-v1-client-protocol.h>
#include <xdg-toplevel-icon-v1-client-protocol.h>
#include <wlr-layer-shell-unstable-v1-client-protocol.h>
//#include <presentation-time-client-protocol.h>
#include <linux/input.h>

#include "window.h"
#if defined STELA_API_VULKAN
#include "vk_common.h"
#elif defined STELA_API_OPENGL
#include "egl_common.h"
#endif

#define STELA_WAYLAND_KEY_MAX KEY_MAX
#define STELA_WAYLAND_KEY_COUNT KEY_CNT

struct stl_wayland_global {
    struct wl_display *display;
    struct {
        u8 *data;
        u32 size;
    } icon;
    s32 display_fd;
    struct wl_registry *registry;
    u16 keycodes[STELA_WAYLAND_KEY_COUNT];
    array(struct stl_monitor *) monitors;
#if defined STELA_API_VULKAN
    const char **vk_extensions;
#elif defined STELA_API_OPENGL
    struct stl_egl_global egl;
#endif
    void (*output_discovered)(void *, struct stl_monitor *);
    void *userdata;
};

struct stl_monitor_wayland {
    struct stl_monitor m;
    struct wl_output *output;
    struct zxdg_output_v1 *xdg_output;
};

struct stl_window_wayland {
    struct stl_window w;
    struct wl_display *display;
    struct wl_registry *registry;
    struct wl_compositor *compositor;
    struct wl_shm *shm;
    struct wl_seat *seat;
    struct wl_pointer *pointer;
    struct wl_keyboard *keyboard;
    struct wl_surface *surface;
    struct xdg_wm_base *xdg_wm_base;
    struct xdg_surface *xdg_surface;
    struct xdg_toplevel *xdg_toplevel;
    struct zxdg_decoration_manager_v1 *zxdg_decoration_manager;
    struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
    struct wp_cursor_shape_device_v1 *cursor_shape_device;
    struct {
        struct xdg_toplevel_icon_manager_v1 *manager;
        struct wl_shm_pool *pool;
        struct wl_buffer *buffer;
        struct xdg_toplevel_icon_v1 *icon;
    } icon;
    struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration;
    struct zwlr_layer_shell_v1 *layer_shell;
    struct stl_monitor_wayland *monitor;
    struct zwlr_layer_surface_v1 *layer_surface;
    struct wl_egl_window *egl_window;
#if defined STELA_API_OPENGL
    struct stl_egl egl;
#endif
#if defined STELA_POLL_INLINE && defined STELA_PAUSE
    struct nn_pollfd fds[2];
#else
    struct nn_pollfd fds[1];
#endif
    s32 geom_width;
    s32 geom_height;
    bool pending_configure;
    struct {
        u32 serial;
        struct wl_pointer *pointer;
        u8 shape;
#ifdef STELA_MOUSE2_DRAG
        bool grabbed_by_toplevel_move;
#endif
    } cursor;
    bool decorated;
    struct {
        f64 pointer_x;
        f64 pointer_y;
        f64 scroll_x;
        f64 scroll_y;
    } frame;
};