diyac/diyac.h

228 lines
5.8 KiB
C
Raw Normal View History

2024-03-30 00:18:51 +01:00
#ifndef DIYAC_H
#define DIYAC_H
#include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/types/wlr_layer_shell_v1.h>
2024-03-31 16:09:01 +02:00
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/render/allocator.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection_v1.h>
#include <wlr/types/wlr_primary_selection.h>
2024-04-01 22:12:35 +02:00
#include <wlr/types/wlr_fractional_scale_v1.h>
2024-04-12 21:18:42 +02:00
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
2024-03-31 16:09:01 +02:00
#define LAYER_TREE_SZ 4
2024-04-15 13:56:11 +02:00
2024-03-30 00:18:51 +01:00
enum diyac_cursor_mode
{
2024-03-31 16:09:01 +02:00
DIYAC_CURSOR_PASSTHROUGH,
DIYAC_CURSOR_MOVE,
DIYAC_CURSOR_RESIZE,
2024-03-30 00:18:51 +01:00
};
2024-03-31 16:09:01 +02:00
enum diyac_node_descriptor_type
{
DIYAC_NODE_NONE = 0,
DIYAC_NODE_VIEW,
DIYAC_NODE_XDG_POPUP,
DIYAC_NODE_LAYER_SURFACE,
DIYAC_NODE_LAYER_POPUP,
DIYAC_NODE_TREE,
// DIYAC_NODE_MENUITEM,
// LAB_NODE_TREE,
// LAB_NODE_SSD_BUTTON,
};
struct diyac_view_state
2024-03-31 16:09:01 +02:00
{
bool maximized;
bool fullscreen;
bool minimized;
/**
2024-04-12 21:18:42 +02:00
* if neither state is on, it means that
* the current state is normal
2024-04-12 21:18:42 +02:00
*/
2024-03-31 16:09:01 +02:00
};
struct diyac_seat
{
struct wlr_seat *wlr_seat;
struct diyac_server *server;
struct wlr_cursor *cursor;
enum diyac_cursor_mode cursor_mode;
struct wlr_xcursor_manager *cursor_mgr;
struct wlr_layer_surface_v1 *focused_layer;
struct wl_listener cursor_motion;
struct wl_listener cursor_motion_absolute;
struct wl_listener cursor_button;
struct wl_listener cursor_axis;
struct wl_listener cursor_frame;
struct wl_listener new_input;
struct wl_listener request_cursor;
struct wl_listener request_set_selection;
struct wl_listener request_set_primary_selection;
2024-03-31 16:09:01 +02:00
struct wl_list keyboards;
};
struct diyac_popup
{
struct wlr_xdg_popup *wlr_popup;
struct wlr_scene_tree *scene_tree;
struct wl_listener commit;
struct wl_listener destroy;
struct wl_listener new_popup;
struct wlr_box output_toplevel_sx_box;
void *parent;
};
2024-04-15 13:56:11 +02:00
struct diyac_output_scenes
2024-03-31 16:09:01 +02:00
{
struct wlr_scene_tree *background;
struct wlr_scene_tree *bottom;
struct wlr_scene_tree *top;
struct wlr_scene_tree *overlay;
struct wlr_scene_tree *popup;
struct wlr_scene_tree *session;
};
struct diyac_node_descriptor
{
enum diyac_node_descriptor_type type;
void *data;
struct wl_listener destroy;
2024-03-30 00:18:51 +01:00
};
struct diyac_server
{
2024-03-31 16:09:01 +02:00
struct wl_display *wl_display;
struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
2024-04-13 05:17:28 +02:00
struct wl_event_loop *wl_event_loop;
2024-03-31 16:09:01 +02:00
struct wlr_scene *scene;
struct wlr_scene_output_layout *scene_layout;
struct wlr_xdg_shell *xdg_shell;
struct wlr_layer_shell_v1 *layer_shell;
struct wl_listener new_xdg_surface;
struct wl_listener new_layer_surface;
struct wl_list views;
2024-04-12 21:18:42 +02:00
struct diyac_view * active_view;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
2024-04-01 22:12:35 +02:00
2024-03-31 16:09:01 +02:00
/*
* Popups need to be rendered above always-on-top views, so we reparent
* them to this dedicated tree
*/
struct wlr_scene_tree *xdg_popup_tree;
struct wlr_scene_tree *view_tree;
struct diyac_seat seat;
struct diyac_view *grabbed_view;
double grab_x, grab_y;
struct wlr_box grab_geobox;
uint32_t resize_edges;
struct wlr_output_layout *output_layout;
struct wl_list outputs;
struct wl_listener new_output;
2024-03-30 00:18:51 +01:00
};
struct diyac_layer_surface
{
2024-03-31 16:09:01 +02:00
struct wlr_scene_layer_surface_v1 *scene_layer_surface;
struct diyac_server *server;
bool mapped;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener surface_commit;
struct wl_listener output_destroy;
struct wl_listener node_destroy;
struct wl_listener new_popup;
2024-03-30 00:18:51 +01:00
};
struct diyac_output
{
2024-03-31 16:09:01 +02:00
struct wl_list link;
struct diyac_server *server;
struct wlr_output *wlr_output;
struct wl_listener frame;
struct wl_listener request_state;
struct wl_listener destroy;
struct wlr_box usable_area;
// layer output
2024-04-15 13:56:11 +02:00
struct diyac_output_scenes scenes;
// alias to diyac_output_scenes elements
2024-03-31 16:09:01 +02:00
struct wlr_scene_tree *layer_tree[LAYER_TREE_SZ];
2024-03-30 00:18:51 +01:00
};
2024-04-12 21:18:42 +02:00
struct foreign_toplevel
{
struct wlr_foreign_toplevel_handle_v1 *handle;
struct wl_listener maximize;
struct wl_listener minimize;
struct wl_listener fullscreen;
struct wl_listener activate;
struct wl_listener close;
struct wl_listener destroy;
};
2024-03-31 16:09:01 +02:00
struct diyac_view
2024-03-30 00:18:51 +01:00
{
2024-03-31 16:09:01 +02:00
struct wl_list link;
struct diyac_server *server;
struct wlr_xdg_surface *xdg_surface;
struct wlr_xdg_toplevel *xdg_toplevel;
struct wlr_scene_tree *scene_tree;
struct diyac_view_state state;
struct diyac_view_state requested;
2024-04-13 05:17:28 +02:00
uint32_t configuration_serial;
struct wl_event_source * configuration_timeout;
2024-03-31 16:09:01 +02:00
/*
2024-04-01 15:38:57 +02:00
* Geometry of the wlr_surface contained within the view, as
* currently displayed. Should be kept in sync with the
* scene-graph at all times.
*/
struct wlr_box original;
2024-04-13 05:17:28 +02:00
struct wlr_box pending_size;
2024-04-01 15:38:57 +02:00
bool mapped;
struct diyac_output *output;
2024-04-13 05:17:28 +02:00
struct wl_listener commit;
2024-03-31 16:09:01 +02:00
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener request_move;
struct wl_listener request_resize;
2024-04-01 15:38:57 +02:00
struct wl_listener request_minimize;
2024-03-31 16:09:01 +02:00
struct wl_listener request_maximize;
struct wl_listener request_fullscreen;
2024-04-15 13:56:11 +02:00
struct wl_listener set_app_id;
2024-03-31 16:09:01 +02:00
struct wl_listener new_popup;
struct wl_listener set_title;
2024-04-12 21:18:42 +02:00
struct foreign_toplevel toplevel;
2024-03-30 00:18:51 +01:00
};
struct diyac_keyboard
{
2024-03-31 16:09:01 +02:00
struct wl_list link;
struct diyac_server *server;
struct wlr_keyboard *wlr_keyboard;
2024-03-30 00:18:51 +01:00
2024-03-31 16:09:01 +02:00
struct wl_listener modifiers;
struct wl_listener key;
struct wl_listener destroy;
2024-03-30 00:18:51 +01:00
};
#endif