Files
absinthe/include/types.h
T

286 lines
6.5 KiB
C
Raw Normal View History

#ifndef __TYPES_H_
#define __TYPES_H_
2026-01-02 22:53:34 +07:00
#include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_keyboard.h>
2026-01-02 22:53:34 +07:00
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output_management_v1.h>
2026-01-02 22:53:34 +07:00
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_seat.h>
2026-01-04 18:07:28 +07:00
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_shell.h>
2026-01-02 22:53:34 +07:00
2026-04-04 16:42:55 +07:00
#ifdef XWAYLAND
#include <wlr/xwayland.h>
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#endif
2026-01-06 01:41:46 +07:00
2026-05-14 18:16:40 +07:00
#define BTN_LEFT 0x110
#define BTN_RIGHT 0x111
2026-05-08 19:19:43 +07:00
#define BTN_MIDDLE 0x112
2026-05-08 19:15:07 +07:00
2026-05-14 18:16:40 +07:00
#define MAX(A, B) (A) > (B) ? (A) : (B)
#define MIN(A, B) (A) < (B) ? (A) : (B)
2026-05-06 21:24:08 +07:00
/* macro for adding listener for event */
2026-05-17 20:03:02 +07:00
#define LISTEN(L, C, E) \
do { \
(L).notify = (C); \
wl_signal_add(&(E), &(L)); \
2026-05-14 18:16:40 +07:00
} while (0);
#define UNUSED(X) (void)(X)
2026-05-09 18:38:24 +07:00
#define CLEANMASK(M) (M & ~WLR_MODIFIER_CAPS)
2026-05-06 21:24:08 +07:00
/* cursor mode */
enum {
2026-05-14 18:16:40 +07:00
CURSOR_PASSTHROUGH,
CURSOR_MOVE,
CURSOR_RESIZE,
2026-01-02 22:53:34 +07:00
};
2026-05-06 21:24:08 +07:00
/* resizing corners */
enum {
2026-05-14 18:16:40 +07:00
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT,
2026-01-02 22:53:34 +07:00
};
2026-05-06 21:24:08 +07:00
/* toplevel types */
enum {
2026-05-14 18:16:40 +07:00
TOPLEVEL_XDG,
TOPLEVEL_X11,
LAYER_SURFACE,
2026-04-03 17:13:34 +07:00
};
2026-05-06 21:24:08 +07:00
/* layers for wlr layer shell */
enum {
2026-05-14 18:16:40 +07:00
LAYER_BACKGROUND,
LAYER_BOTTOM,
LAYER_TILE,
LAYER_FLOAT,
LAYER_FULLSCREEN,
LAYER_TOP,
LAYER_OVERLAY,
LAYERS_COUNT,
2026-04-03 17:13:34 +07:00
};
2026-05-10 20:06:05 +07:00
static const int layermap[] = {
2026-05-14 18:16:40 +07:00
LAYER_BACKGROUND,
LAYER_BOTTOM,
LAYER_TOP,
2026-05-17 20:03:02 +07:00
LAYER_OVERLAY,
2026-05-10 20:06:05 +07:00
};
enum {
2026-05-14 18:16:40 +07:00
LAYOUT_TILE,
LAYOUT_TILELEFT,
LAYOUT_TILETOP,
LAYOUT_TILEBOTTOM,
LAYOUT_MONOCLE,
LAYOUT_SPIRAL,
LAYOUT_DWINDLE,
LAYOUT_VGRID,
LAYOUT_HGRID,
2026-05-10 20:06:05 +07:00
};
2026-05-06 21:24:08 +07:00
typedef struct absn_output absn_output;
typedef struct absn_toplevel absn_toplevel;
2026-01-10 23:16:46 +07:00
2026-05-10 23:02:22 +07:00
typedef struct {
2026-05-14 18:16:40 +07:00
int layout;
const char *name;
absn_output *output;
int count;
float size;
2026-05-10 23:02:22 +07:00
} absn_workspace;
2026-05-06 21:24:08 +07:00
typedef struct {
2026-05-14 18:16:40 +07:00
struct wl_display *display;
struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
struct wlr_compositor *compositor;
struct wlr_scene *scene;
struct wlr_scene_output_layout *scene_layout;
struct wlr_scene_rect *bg;
struct wlr_xdg_shell *xdg_shell;
struct wl_listener new_xdg_toplevel;
struct wl_listener new_xdg_popup;
struct wlr_xdg_decoration_manager_v1 *xdg_deco_mgr;
struct wl_listener new_xdg_deco;
struct wlr_layer_shell_v1 *layer_shell;
struct wl_listener new_layer_surface;
struct wlr_scene_tree *layers[LAYERS_COUNT];
2026-01-02 22:53:34 +07:00
2026-04-06 23:38:06 +07:00
#ifdef XWAYLAND
2026-05-14 18:16:40 +07:00
struct wlr_xwayland *xwayland;
struct wl_listener xw_new_surface;
struct wl_listener xw_ready;
2026-04-06 23:38:06 +07:00
#endif
2026-05-14 18:16:40 +07:00
struct wlr_cursor *cursor;
struct wlr_xcursor_manager *cursor_mgr;
struct wl_listener cursor_motion;
struct wl_listener cursor_motion_abs;
struct wl_listener cursor_button;
struct wl_listener cursor_axis;
struct wl_listener cursor_frame;
struct wlr_seat *seat;
struct wl_listener new_input;
struct wl_listener request_cursor;
struct wl_listener pointer_focus_change;
struct wl_listener request_set_selection;
struct wl_list keyboards;
int cursor_mode;
int resize_corner;
struct wlr_box grab_geom;
int32_t grab_x, grab_y;
struct wl_list toplevels;
struct wl_list focus_stack;
absn_toplevel *focused_toplevel;
2026-05-17 20:03:02 +07:00
void *exclusive_focus;
2026-05-14 18:16:40 +07:00
absn_output *focused_output;
struct wl_list outputs;
struct wl_listener new_output;
struct wlr_output_layout *output_layout;
struct wl_listener layout_change;
struct wlr_output_manager_v1 *output_mgr;
struct wl_listener mgr_apply;
struct wl_listener mgr_test;
int workspaces_count;
absn_workspace *workspaces;
2026-05-10 23:02:22 +07:00
} absn_server;
2026-05-10 20:06:05 +07:00
2026-05-06 21:24:08 +07:00
struct absn_output {
2026-05-14 18:16:40 +07:00
struct wl_list link;
absn_server *server;
2026-05-14 18:16:40 +07:00
absn_workspace *workspace;
2026-05-10 23:02:22 +07:00
2026-05-14 18:16:40 +07:00
struct wlr_box geom;
struct wlr_box usable_area;
2026-05-14 18:16:40 +07:00
struct wlr_output *wlr;
struct wl_listener frame;
struct wl_listener request_state;
struct wl_listener destroy;
2026-04-25 14:09:14 +07:00
2026-05-17 20:03:02 +07:00
struct wl_list layers[4];
};
2026-05-06 21:24:08 +07:00
typedef struct {
2026-05-14 18:16:40 +07:00
struct wl_list link;
2026-05-10 20:06:05 +07:00
2026-05-14 18:16:40 +07:00
absn_server *server;
absn_output *output;
2026-05-17 20:03:02 +07:00
bool mapped;
2026-05-14 18:16:40 +07:00
struct wlr_scene_tree *scene_tree;
struct wlr_scene_layer_surface_v1 *scene_layer;
2026-05-17 20:03:02 +07:00
struct wlr_scene_tree *popups;
2026-05-14 18:16:40 +07:00
struct wlr_layer_surface_v1 *wlr;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener commit;
struct wl_listener new_popup;
struct wl_listener destroy;
2026-05-06 21:24:08 +07:00
} absn_layer_surface;
2026-04-25 14:09:14 +07:00
2026-05-06 21:24:08 +07:00
struct absn_toplevel {
2026-05-14 18:16:40 +07:00
struct wl_list link;
struct wl_list flink; /* link for focus stack */
uint32_t tag;
absn_server *server;
absn_output *output;
absn_workspace *workspace;
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *scene_surface;
int32_t bw;
struct wlr_scene_rect *border[4];
struct wlr_xdg_toplevel_decoration_v1 *deco;
bool floating;
bool fullscreen;
bool urgent;
uint32_t resizing;
struct wlr_box geom;
struct wlr_box prev_geom;
int type;
union {
struct wlr_xdg_toplevel *xdg;
struct wlr_xwayland_surface *xw;
};
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener commit;
struct wl_listener destroy;
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener request_fullscreen;
struct wl_listener deco_request_mode;
struct wl_listener deco_destroy;
2026-04-04 16:42:55 +07:00
#ifdef XWAYLAND
2026-05-14 18:16:40 +07:00
struct wl_listener xw_activate;
struct wl_listener xw_associate;
struct wl_listener xw_dissociate;
struct wl_listener xw_configure;
struct wl_listener xw_set_hints;
2026-04-04 16:42:55 +07:00
#endif
2026-01-02 22:53:34 +07:00
};
2026-05-06 21:24:08 +07:00
typedef struct {
2026-05-14 18:16:40 +07:00
struct wlr_xdg_popup *wlr;
2026-05-17 20:03:02 +07:00
int parent_type;
void *parent;
2026-05-14 18:16:40 +07:00
struct wl_listener commit;
2026-05-06 21:24:08 +07:00
} absn_popup;
2026-01-02 22:53:34 +07:00
2026-05-06 21:24:08 +07:00
typedef struct {
2026-05-14 18:16:40 +07:00
struct wl_list link;
absn_server *server;
2026-05-06 21:24:08 +07:00
2026-05-14 18:16:40 +07:00
struct wlr_keyboard *wlr;
struct wl_listener modifiers;
struct wl_listener key;
struct wl_listener destroy;
2026-05-06 21:24:08 +07:00
} absn_keyboard;
2026-05-09 18:38:24 +07:00
typedef struct {
2026-05-14 18:16:40 +07:00
int i;
float f;
const void *v;
2026-05-09 18:38:24 +07:00
} absn_arg;
typedef struct {
2026-05-14 18:16:40 +07:00
uint32_t mods;
xkb_keysym_t keysym;
void (*cb)(absn_server *, const absn_arg *);
const absn_arg arg;
2026-05-09 18:38:24 +07:00
} absn_keybind;
#endif /* __TYPES_H_ */