2020-08-03 20:56:38 +01:00
|
|
|
#ifndef __LABWC_H
|
|
|
|
|
#define __LABWC_H
|
2019-11-19 21:00:26 +00:00
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdio.h>
|
2020-09-28 20:41:41 +01:00
|
|
|
#include <stdlib.h>
|
2019-11-19 21:00:26 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <wayland-server-core.h>
|
|
|
|
|
#include <wlr/backend.h>
|
|
|
|
|
#include <wlr/render/wlr_renderer.h>
|
|
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2020-09-28 20:41:41 +01:00
|
|
|
#include <wlr/types/wlr_cursor.h>
|
2019-11-19 21:00:26 +00:00
|
|
|
#include <wlr/types/wlr_data_device.h>
|
|
|
|
|
#include <wlr/types/wlr_input_device.h>
|
|
|
|
|
#include <wlr/types/wlr_keyboard.h>
|
2020-10-02 21:19:56 +01:00
|
|
|
#include <wlr/types/wlr_keyboard_group.h>
|
2019-11-19 21:00:26 +00:00
|
|
|
#include <wlr/types/wlr_matrix.h>
|
|
|
|
|
#include <wlr/types/wlr_output.h>
|
|
|
|
|
#include <wlr/types/wlr_output_layout.h>
|
|
|
|
|
#include <wlr/types/wlr_pointer.h>
|
|
|
|
|
#include <wlr/types/wlr_seat.h>
|
2020-05-13 20:51:13 +01:00
|
|
|
#include <wlr/types/wlr_server_decoration.h>
|
2020-09-28 20:41:41 +01:00
|
|
|
#include <wlr/types/wlr_xcursor_manager.h>
|
2020-05-13 20:51:13 +01:00
|
|
|
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
2020-09-28 20:41:41 +01:00
|
|
|
#include <wlr/types/wlr_xdg_shell.h>
|
2019-11-19 21:00:26 +00:00
|
|
|
#include <wlr/util/log.h>
|
|
|
|
|
#include <wlr/xwayland.h>
|
|
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
|
2020-09-25 20:25:45 +01:00
|
|
|
#include "common/log.h"
|
2020-08-03 20:56:38 +01:00
|
|
|
#include "config/keybind.h"
|
2020-09-28 20:41:41 +01:00
|
|
|
#include "config/rcxml.h"
|
2020-06-18 20:18:01 +01:00
|
|
|
|
2019-11-19 21:00:26 +00:00
|
|
|
#define XCURSOR_DEFAULT "left_ptr"
|
|
|
|
|
#define XCURSOR_SIZE 24
|
|
|
|
|
#define XCURSOR_MOVE "grabbing"
|
|
|
|
|
|
2019-12-27 20:48:58 +00:00
|
|
|
enum cursor_mode {
|
2020-05-29 22:26:16 +01:00
|
|
|
LAB_CURSOR_PASSTHROUGH,
|
|
|
|
|
LAB_CURSOR_MOVE,
|
|
|
|
|
LAB_CURSOR_RESIZE,
|
2019-11-19 21:00:26 +00:00
|
|
|
};
|
|
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
struct input {
|
|
|
|
|
struct wlr_input_device *wlr_input_device;
|
|
|
|
|
struct seat *seat;
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
struct wl_list link; /* seat::inputs */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct seat {
|
|
|
|
|
struct wlr_seat *seat;
|
|
|
|
|
struct server *server;
|
|
|
|
|
struct wlr_keyboard_group *keyboard_group;
|
|
|
|
|
struct wlr_cursor *cursor;
|
|
|
|
|
struct wlr_xcursor_manager *xcursor_manager;
|
|
|
|
|
|
|
|
|
|
struct wl_list inputs;
|
|
|
|
|
struct wl_listener new_input;
|
|
|
|
|
|
|
|
|
|
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 request_cursor;
|
|
|
|
|
struct wl_listener request_set_selection;
|
|
|
|
|
|
|
|
|
|
struct wl_listener keyboard_key;
|
|
|
|
|
struct wl_listener keyboard_modifiers;
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-27 20:48:58 +00:00
|
|
|
struct server {
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_display *wl_display;
|
|
|
|
|
struct wlr_renderer *renderer;
|
2020-09-29 19:53:46 +01:00
|
|
|
struct wlr_backend *backend;
|
2019-11-19 21:00:26 +00:00
|
|
|
|
|
|
|
|
struct wlr_xdg_shell *xdg_shell;
|
2020-09-30 17:18:20 +01:00
|
|
|
struct wlr_layer_shell_v1 *layer_shell;
|
|
|
|
|
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_listener new_xdg_surface;
|
2020-09-30 17:18:20 +01:00
|
|
|
struct wl_listener new_layer_surface;
|
|
|
|
|
|
2020-05-13 20:51:13 +01:00
|
|
|
struct wl_listener xdg_toplevel_decoration;
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wlr_xwayland *xwayland;
|
|
|
|
|
struct wl_listener new_xwayland_surface;
|
2020-10-02 21:19:56 +01:00
|
|
|
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_list views;
|
2020-09-04 20:25:20 +01:00
|
|
|
struct wl_list unmanaged_surfaces;
|
2019-11-19 21:00:26 +00:00
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
struct seat seat;
|
2020-05-18 20:54:25 +01:00
|
|
|
|
|
|
|
|
/* cursor interactive */
|
2019-12-27 20:48:58 +00:00
|
|
|
enum cursor_mode cursor_mode;
|
|
|
|
|
struct view *grabbed_view;
|
2019-11-19 21:00:26 +00:00
|
|
|
double grab_x, grab_y;
|
2020-05-12 20:37:05 +01:00
|
|
|
struct wlr_box grab_box;
|
2019-11-19 21:00:26 +00:00
|
|
|
uint32_t resize_edges;
|
|
|
|
|
|
|
|
|
|
struct wl_list outputs;
|
|
|
|
|
struct wl_listener new_output;
|
2020-10-02 21:19:56 +01:00
|
|
|
struct wlr_output_layout *output_layout;
|
2020-05-25 13:42:40 +01:00
|
|
|
|
2020-09-04 20:25:20 +01:00
|
|
|
/* Set when in cycle (alt-tab) mode */
|
2020-05-25 13:42:40 +01:00
|
|
|
struct view *cycle_view;
|
2019-11-19 21:00:26 +00:00
|
|
|
};
|
|
|
|
|
|
2019-12-27 20:48:58 +00:00
|
|
|
struct output {
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_list link;
|
2019-12-27 20:48:58 +00:00
|
|
|
struct server *server;
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wlr_output *wlr_output;
|
2020-09-30 17:18:20 +01:00
|
|
|
struct wl_list layers[4];
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_listener frame;
|
2020-09-29 19:53:46 +01:00
|
|
|
struct wl_listener destroy;
|
2019-11-19 21:00:26 +00:00
|
|
|
};
|
|
|
|
|
|
2019-12-27 21:22:45 +00:00
|
|
|
enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW };
|
2019-11-19 21:00:26 +00:00
|
|
|
|
2020-05-30 21:28:17 +01:00
|
|
|
enum deco_part {
|
2020-09-02 21:04:31 +01:00
|
|
|
LAB_DECO_NONE = 0,
|
|
|
|
|
LAB_DECO_BUTTON_CLOSE,
|
2020-07-06 21:58:51 +01:00
|
|
|
LAB_DECO_BUTTON_MAXIMIZE,
|
|
|
|
|
LAB_DECO_BUTTON_ICONIFY,
|
2020-06-29 19:27:59 +01:00
|
|
|
LAB_DECO_PART_TITLE,
|
2020-05-30 21:28:17 +01:00
|
|
|
LAB_DECO_PART_TOP,
|
|
|
|
|
LAB_DECO_PART_RIGHT,
|
|
|
|
|
LAB_DECO_PART_BOTTOM,
|
|
|
|
|
LAB_DECO_PART_LEFT,
|
2020-09-02 21:04:31 +01:00
|
|
|
LAB_DECO_END_MARKER
|
2020-05-30 21:28:17 +01:00
|
|
|
};
|
2020-05-04 22:21:30 +01:00
|
|
|
|
2020-09-02 20:20:52 +01:00
|
|
|
struct view_impl {
|
|
|
|
|
void (*configure)(struct view *view, struct wlr_box geo);
|
2020-09-02 21:00:28 +01:00
|
|
|
void (*close)(struct view *view);
|
2020-09-29 20:48:50 +01:00
|
|
|
void (*for_each_surface)(struct view *view,
|
|
|
|
|
wlr_surface_iterator_func_t iterator, void *data);
|
2020-09-03 20:50:35 +01:00
|
|
|
void (*map)(struct view *view);
|
|
|
|
|
void (*unmap)(struct view *view);
|
2020-09-02 20:20:52 +01:00
|
|
|
};
|
|
|
|
|
|
2020-09-15 20:41:01 +01:00
|
|
|
struct border {
|
|
|
|
|
int top;
|
|
|
|
|
int right;
|
|
|
|
|
int bottom;
|
|
|
|
|
int left;
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-27 20:48:58 +00:00
|
|
|
struct view {
|
2020-09-02 20:20:52 +01:00
|
|
|
struct server *server;
|
2019-11-19 21:00:26 +00:00
|
|
|
enum view_type type;
|
2020-09-02 20:20:52 +01:00
|
|
|
const struct view_impl *impl;
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_list link;
|
2020-09-02 20:20:52 +01:00
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
struct wlr_xdg_surface *xdg_surface;
|
|
|
|
|
struct wlr_xwayland_surface *xwayland_surface;
|
|
|
|
|
};
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wlr_surface *surface;
|
2020-08-31 08:12:44 +01:00
|
|
|
|
|
|
|
|
bool mapped;
|
|
|
|
|
bool been_mapped;
|
2020-09-07 19:47:11 +01:00
|
|
|
bool minimized;
|
2020-09-15 20:41:01 +01:00
|
|
|
|
|
|
|
|
/* geometry of the wlr_surface contained within the view */
|
2020-08-31 08:12:44 +01:00
|
|
|
int x, y, w, h;
|
2020-09-15 20:41:01 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* margin refers to the space between the extremities of the view and
|
|
|
|
|
* wlr_surface - typically made up of decoration.
|
|
|
|
|
* For xdg-shell views, the margin is typically negative.
|
|
|
|
|
*/
|
|
|
|
|
struct border margin;
|
|
|
|
|
|
|
|
|
|
int xdg_grab_offset;
|
|
|
|
|
|
2020-09-15 21:10:02 +01:00
|
|
|
bool server_side_deco;
|
2020-08-31 08:12:44 +01:00
|
|
|
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_listener map;
|
|
|
|
|
struct wl_listener unmap;
|
|
|
|
|
struct wl_listener destroy;
|
2020-08-31 08:12:44 +01:00
|
|
|
struct wl_listener commit;
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_listener request_move;
|
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
|
struct wl_listener request_configure;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-04 20:25:20 +01:00
|
|
|
struct xwayland_unmanaged {
|
2020-09-08 20:18:12 +01:00
|
|
|
struct server *server;
|
2020-09-04 20:25:20 +01:00
|
|
|
struct wlr_xwayland_surface *xwayland_surface;
|
|
|
|
|
struct wl_list link;
|
|
|
|
|
int lx, ly;
|
|
|
|
|
|
|
|
|
|
struct wl_listener request_configure;
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
|
struct wl_listener map;
|
|
|
|
|
struct wl_listener unmap;
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-13 20:51:13 +01:00
|
|
|
void xdg_toplevel_decoration(struct wl_listener *listener, void *data);
|
2019-12-26 21:37:31 +00:00
|
|
|
void xdg_surface_new(struct wl_listener *listener, void *data);
|
|
|
|
|
|
2020-09-04 20:32:41 +01:00
|
|
|
void xwayland_surface_new(struct wl_listener *listener, void *data);
|
2020-09-08 20:18:12 +01:00
|
|
|
void xwayland_unmanaged_create(struct server *server,
|
2020-10-02 21:19:56 +01:00
|
|
|
struct wlr_xwayland_surface *xsurface);
|
2019-12-26 21:37:31 +00:00
|
|
|
|
2020-05-26 12:56:33 +01:00
|
|
|
/**
|
|
|
|
|
* view_get_surface_geometry - geometry relative to view
|
|
|
|
|
* @view: toplevel containing the surface to process
|
|
|
|
|
* Note: XDG views sometimes have an invisible border, so x and y can be
|
|
|
|
|
* greater than zero.
|
|
|
|
|
*/
|
|
|
|
|
struct wlr_box view_get_surface_geometry(struct view *view);
|
|
|
|
|
struct wlr_box view_geometry(struct view *view);
|
|
|
|
|
void view_resize(struct view *view, struct wlr_box geo);
|
2020-09-08 20:51:33 +01:00
|
|
|
void view_minimize(struct view *view);
|
|
|
|
|
void view_unminimize(struct view *view);
|
2020-09-29 20:48:50 +01:00
|
|
|
void view_for_each_surface(struct view *view,
|
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
2020-09-11 20:48:28 +01:00
|
|
|
|
2020-10-08 20:08:41 +01:00
|
|
|
void desktop_focus_view(struct seat *seat, struct view *view);
|
2020-09-11 20:48:28 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* desktop_next_view - return next view
|
|
|
|
|
* @current: view used as reference point for defining 'next'
|
|
|
|
|
* Note: If current==NULL, the list's second view is returned
|
|
|
|
|
*/
|
|
|
|
|
struct view *desktop_next_view(struct server *server, struct view *current);
|
2020-09-18 20:28:48 +01:00
|
|
|
void desktop_focus_next_mapped_view(struct view *current);
|
2020-09-11 20:48:28 +01:00
|
|
|
struct view *desktop_view_at(struct server *server, double lx, double ly,
|
|
|
|
|
struct wlr_surface **surface, double *sx,
|
|
|
|
|
double *sy, int *view_area);
|
2019-12-26 21:37:31 +00:00
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
void cursor_init(struct seat *seat);
|
2020-10-06 21:31:01 +01:00
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
void keyboard_init(struct seat *seat);
|
2020-10-06 21:31:01 +01:00
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
void seat_init(struct server *server);
|
|
|
|
|
void seat_finish(struct server *server);
|
2020-10-08 20:22:52 +01:00
|
|
|
void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
|
2020-09-04 20:25:20 +01:00
|
|
|
|
2020-05-29 21:27:34 +01:00
|
|
|
void interactive_begin(struct view *view, enum cursor_mode mode,
|
2020-05-22 21:13:43 +01:00
|
|
|
uint32_t edges);
|
2020-05-29 21:27:34 +01:00
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
void output_init(struct server *server);
|
|
|
|
|
|
2020-06-03 18:39:46 +01:00
|
|
|
void server_init(struct server *server);
|
|
|
|
|
void server_start(struct server *server);
|
|
|
|
|
void server_finish(struct server *server);
|
2019-12-26 21:37:31 +00:00
|
|
|
|
2020-09-17 21:11:54 +01:00
|
|
|
struct border deco_thickness(struct view *view);
|
|
|
|
|
struct wlr_box deco_max_extents(struct view *view);
|
2020-05-04 22:21:30 +01:00
|
|
|
struct wlr_box deco_box(struct view *view, enum deco_part deco_part);
|
|
|
|
|
enum deco_part deco_at(struct view *view, double lx, double ly);
|
|
|
|
|
|
2020-09-25 19:37:51 +01:00
|
|
|
void action(struct server *server, const char *action, const char *command);
|
2020-06-18 20:18:01 +01:00
|
|
|
|
2020-06-03 18:39:46 +01:00
|
|
|
void dbg_show_one_view(struct view *view);
|
|
|
|
|
void dbg_show_views(struct server *server);
|
2020-06-18 20:39:55 +01:00
|
|
|
void dbg_show_keybinds();
|
2020-06-03 18:39:46 +01:00
|
|
|
|
2020-08-03 20:56:38 +01:00
|
|
|
#endif /* __LABWC_H */
|