diyac/diyac.h

257 lines
6.5 KiB
C

#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>
#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>
#include <wlr/types/wlr_fractional_scale_v1.h>
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_session_lock_v1.h>
#define LAYER_TREE_SZ 4
enum diyac_cursor_mode
{
DIYAC_CURSOR_PASSTHROUGH,
DIYAC_CURSOR_MOVE,
DIYAC_CURSOR_RESIZE,
};
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
{
bool maximized;
bool fullscreen;
bool minimized;
/**
* if neither state is on, it means that
* the current state is normal
*/
};
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;
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;
};
struct diyac_output_scenes
{
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;
};
struct diyac_session_lock
{
bool abandoned;
struct wlr_surface * focused;
struct wlr_session_lock_v1* wlr_session_lock;
struct wl_listener new_surface;
struct wl_listener unlock;
struct wl_listener destroy;
//struct wl_listener new_output;
};
struct diyac_server
{
struct wl_display *wl_display;
struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
struct wl_event_loop *wl_event_loop;
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;
struct diyac_view * active_view;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
/*
* 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;
struct diyac_session_lock * lock;
};
struct diyac_layer_surface
{
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;
};
struct diyac_output_lock_handle
{
struct wlr_scene_tree *tree;
struct wlr_scene_rect *background;
struct wlr_session_lock_surface_v1 *surface;
struct diyac_output * output;
struct wl_listener surface_destroy;
struct wl_listener surface_map;
struct wl_listener commit;
};
struct diyac_output
{
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
struct diyac_output_scenes scenes;
// alias to diyac_output_scenes elements
struct wlr_scene_tree *layer_tree[LAYER_TREE_SZ];
// lock handle
struct diyac_output_lock_handle * lock_handle;
};
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;
};
struct diyac_view
{
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;
uint32_t configuration_serial;
struct wl_event_source * configuration_timeout;
/*
* 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;
struct wlr_box pending_size;
bool mapped;
struct diyac_output *output;
struct wl_listener commit;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_minimize;
struct wl_listener request_maximize;
struct wl_listener request_fullscreen;
struct wl_listener set_app_id;
struct wl_listener new_popup;
struct wl_listener set_title;
struct foreign_toplevel toplevel;
};
struct diyac_keyboard
{
struct wl_list link;
struct diyac_server *server;
struct wlr_keyboard *wlr_keyboard;
struct wl_listener modifiers;
struct wl_listener key;
struct wl_listener destroy;
};
#endif