2020-08-03 20:56:38 +01:00
|
|
|
#ifndef __LABWC_H
|
|
|
|
|
#define __LABWC_H
|
2019-11-19 21:00:26 +00:00
|
|
|
|
2020-06-29 19:27:59 +01:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
2019-11-19 21:00:26 +00:00
|
|
|
#include <getopt.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#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_cursor.h>
|
|
|
|
|
#include <wlr/types/wlr_compositor.h>
|
|
|
|
|
#include <wlr/types/wlr_data_device.h>
|
|
|
|
|
#include <wlr/types/wlr_input_device.h>
|
|
|
|
|
#include <wlr/types/wlr_keyboard.h>
|
|
|
|
|
#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>
|
|
|
|
|
#include <wlr/types/wlr_xcursor_manager.h>
|
|
|
|
|
#include <wlr/types/wlr_xdg_shell.h>
|
2020-05-13 20:51:13 +01:00
|
|
|
#include <wlr/types/wlr_server_decoration.h>
|
|
|
|
|
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
2019-11-19 21:00:26 +00:00
|
|
|
#include <wlr/util/log.h>
|
|
|
|
|
#include <wlr/xwayland.h>
|
|
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
|
2020-08-03 20:56:38 +01:00
|
|
|
#include "config/rcxml.h"
|
|
|
|
|
#include "config/keybind.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
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_shell *xdg_shell;
|
|
|
|
|
struct wl_listener new_xdg_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;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
struct wlr_cursor *cursor;
|
|
|
|
|
struct wlr_xcursor_manager *cursor_mgr;
|
|
|
|
|
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 wlr_seat *seat;
|
|
|
|
|
struct wl_listener new_input;
|
|
|
|
|
struct wl_listener request_cursor;
|
2020-05-12 21:00:33 +01:00
|
|
|
struct wl_listener request_set_selection;
|
2019-11-19 21:00:26 +00:00
|
|
|
struct wl_list keyboards;
|
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 wlr_output_layout *output_layout;
|
|
|
|
|
struct wl_list outputs;
|
|
|
|
|
struct wl_listener new_output;
|
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
|
|
|
};
|
|
|
|
|
|
2020-09-04 20:25:20 +01:00
|
|
|
extern struct server server;
|
|
|
|
|
|
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;
|
|
|
|
|
struct wl_listener frame;
|
|
|
|
|
};
|
|
|
|
|
|
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-03 20:50:35 +01:00
|
|
|
void (*map)(struct view *view);
|
|
|
|
|
void (*unmap)(struct view *view);
|
2020-09-02 20:20:52 +01:00
|
|
|
};
|
|
|
|
|
|
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-08-31 08:12:44 +01:00
|
|
|
int x, y, w, h;
|
|
|
|
|
bool show_server_side_deco;
|
|
|
|
|
|
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 {
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-27 20:48:58 +00:00
|
|
|
struct keyboard {
|
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_input_device *device;
|
|
|
|
|
|
|
|
|
|
struct wl_listener modifiers;
|
|
|
|
|
struct wl_listener key;
|
|
|
|
|
};
|
|
|
|
|
|
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-04 20:25:20 +01:00
|
|
|
void xwayland_unmanaged_create(struct wlr_xwayland_surface *xsurface);
|
2019-12-26 21:37:31 +00:00
|
|
|
|
2020-06-01 19:42:15 +01:00
|
|
|
void view_init_position(struct view *view);
|
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-05-16 12:18:00 +01:00
|
|
|
void view_focus(struct view *view);
|
2020-09-07 19:47:11 +01:00
|
|
|
struct view *view_next(struct view *current);
|
2020-06-15 21:44:57 +01:00
|
|
|
bool view_hasfocus(struct view *view);
|
2020-05-16 12:04:12 +01:00
|
|
|
struct view *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-09-04 20:25:20 +01:00
|
|
|
void seat_focus_surface(struct wlr_surface *surface);
|
|
|
|
|
|
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-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-05-29 22:10:41 +01:00
|
|
|
void cursor_motion(struct wl_listener *listener, void *data);
|
|
|
|
|
void cursor_motion_absolute(struct wl_listener *listener, void *data);
|
|
|
|
|
void cursor_button(struct wl_listener *listener, void *data);
|
|
|
|
|
void cursor_axis(struct wl_listener *listener, void *data);
|
|
|
|
|
void cursor_frame(struct wl_listener *listener, void *data);
|
2020-05-29 22:18:03 +01:00
|
|
|
void cursor_new(struct server *server, struct wlr_input_device *device);
|
2020-05-29 22:10:41 +01:00
|
|
|
|
|
|
|
|
void keyboard_new(struct server *server, struct wlr_input_device *device);
|
2020-05-29 21:44:50 +01:00
|
|
|
|
2019-12-26 21:37:31 +00:00
|
|
|
void output_frame(struct wl_listener *listener, void *data);
|
2020-05-29 22:18:03 +01:00
|
|
|
void output_new(struct wl_listener *listener, void *data);
|
2019-12-26 21:37:31 +00:00
|
|
|
|
2020-05-04 22:21:30 +01:00
|
|
|
struct wlr_box deco_max_extents(struct view *view);
|
|
|
|
|
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-06-18 20:18:01 +01:00
|
|
|
void action(struct server *server, struct keybind *keybind);
|
|
|
|
|
|
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 */
|