aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/wm/wm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/wm/wm.h')
-rw-r--r--src/cmd/wm/wm.h350
1 files changed, 350 insertions, 0 deletions
diff --git a/src/cmd/wm/wm.h b/src/cmd/wm/wm.h
new file mode 100644
index 0000000..a263804
--- /dev/null
+++ b/src/cmd/wm/wm.h
@@ -0,0 +1,350 @@
+#pragma once
+
+#include <u.h>
+#include <base.h>
+#include <wayland-server-core.h>
+#include <linux/input-event-codes.h>
+
+#define WLR_USE_UNSTABLE
+#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_control_v1.h>
+#include <wlr/types/wlr_data_device.h>
+#include <wlr/types/wlr_export_dmabuf_v1.h>
+#include <wlr/types/wlr_gamma_control_v1.h>
+#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_idle.h>
+#include <wlr/types/wlr_layer_shell_v1.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_output_damage.h>
+#include <wlr/types/wlr_output_management_v1.h>
+#include <wlr/types/wlr_primary_selection.h>
+#include <wlr/types/wlr_primary_selection_v1.h>
+#include <wlr/types/wlr_pointer.h>
+#include <wlr/types/wlr_presentation_time.h>
+#include <wlr/types/wlr_screencopy_v1.h>
+#include <wlr/types/wlr_server_decoration.h>
+#include <wlr/types/wlr_seat.h>
+#include <wlr/types/wlr_viewporter.h>
+#include <wlr/types/wlr_xcursor_manager.h>
+#include <wlr/types/wlr_xdg_activation_v1.h>
+#include <wlr/types/wlr_xdg_decoration_v1.h>
+#include <wlr/types/wlr_xdg_output_v1.h>
+#include <wlr/types/wlr_xdg_shell.h>
+
+#include <wlr/util/log.h>
+
+#include <xkbcommon/xkbcommon.h>
+
+// -----------------------------------------------------------------------
+// macros
+
+#define ROUND(x) ((int)((x)+0.5))
+#define VISIBLE_ON(C,M) ((C)->monitor == (M) && ((C)->tags & (M)->tag.set[(M)->tag.selected]))
+
+// -----------------------------------------------------------------------
+// types
+
+enum
+{
+ CursorNormal,
+ CursorMove,
+ CursorResize,
+};
+
+typedef union Arg Arg;
+typedef struct Button Button;
+typedef struct Key Key;
+typedef struct Keyboard Keyboard;
+typedef struct Layer Layer;
+typedef struct Client Client;
+typedef struct Layout Layout;
+typedef struct Monitor Monitor;
+typedef struct Server Server;
+
+typedef struct Rule Rule;
+typedef struct MonitorRule MonitorRule;
+
+struct Rectangle
+{
+ int x, y;
+ int w, h;
+};
+
+union Arg
+{
+ int i;
+ uint ui;
+ float f;
+ void *v;
+};
+
+struct Key
+{
+ uint modifier;
+ xkb_keysym_t sym;
+ void (*action)(Arg *);
+ Arg arg;
+};
+
+struct Button
+{
+ uint modifier;
+ uint code;
+ void (*function)(Arg *);
+ Arg arg;
+};
+
+struct Keyboard
+{
+ struct wl_list link;
+ struct wlr_input_device *device;
+ struct {
+ struct wl_listener press;
+ struct wl_listener modify;
+ struct wl_listener destroy;
+ } event;
+};
+
+struct Layer
+{
+ struct wl_list link;
+ struct wlr_layer_surface_v1 *surface;
+ enum zwlr_layer_shell_v1_layer type;
+
+ struct wlr_box geometry;
+
+ struct {
+ struct wl_listener map;
+ struct wl_listener unmap;
+ struct wl_listener commit;
+ struct wl_listener destroy;
+ } event;
+};
+
+struct Client
+{
+ struct wl_list link;
+ struct wl_list stack;
+ struct wl_list focus;
+
+ struct wlr_xdg_surface *xdg;
+
+ struct {
+ 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_title;
+ struct wl_listener request_resize;
+ struct wl_listener request_fullscreen;
+ } event;
+
+ struct wlr_box geometry, oldgeometry;
+
+ Monitor *monitor;
+
+ uint tags;
+ int border : 4;
+ int ismapped : 1;
+ int isfloating : 1;
+ int isurgent : 1;
+ int isfullscreen : 1;
+
+ uint32 resize;
+};
+
+struct Layout
+{
+ char *symbol;
+ void (*arrange)(Monitor *);
+};
+
+struct Monitor
+{
+ struct wl_list link;
+ struct wlr_output *output;
+ struct {
+ struct wl_listener render;
+ struct wl_listener destroy;
+ } event;
+
+ struct wlr_box geometry;
+ struct wlr_box window;
+ struct wl_list layer[4];
+
+ Layout *layout, *layouts[2];
+ struct {
+ uint set[2];
+ uint selected;
+ } tag;
+ struct {
+ double frac;
+ int len;
+ } master;
+};
+
+struct MonitorRule
+{
+ char *name;
+ Layout *layout;
+ int x, y;
+ float scale;
+ enum wl_output_transform transform;
+ struct {
+ double frac;
+ int len;
+ } master;
+};
+
+struct Rule
+{
+ char *id;
+ char *title;
+ uint tags;
+ int isfloating;
+ int monitor;
+};
+
+struct Server
+{
+ struct wl_display *display;
+ struct wlr_backend *backend;
+ struct wlr_renderer *renderer;
+ struct wlr_presentation *present;
+ struct wlr_xdg_activation_v1 *activate;
+
+ struct {
+ struct wlr_xdg_shell *xdg;
+ struct wlr_layer_shell_v1 *layer;
+ } shell;
+
+ struct {
+ struct wl_list list;
+ struct wl_list stack;
+ struct wl_list focus;
+ } client;
+ Client *selected;
+
+ struct {
+ Client *client;
+ double x, y;
+ struct wlr_box box;
+ } grab;
+ uint32 resize;
+
+ struct {
+ struct wlr_output_layout *layout;
+ struct wl_list list;
+ struct wlr_box geometry;
+ struct wlr_output_manager_v1 *manager;
+ Monitor *selected;
+ } monitor;
+
+ struct {
+ struct wlr_cursor *dot;
+ struct wlr_xcursor_manager *manager;
+ int mode;
+ } cursor;
+
+ struct {
+ struct wlr_seat *seat;
+ struct wl_list keyboards;
+ struct wlr_idle *idle;
+ } input;
+
+ struct {
+ struct wl_listener make_input;
+ struct wl_listener make_monitor;
+ struct wl_listener make_xdg_surface;
+ struct wl_listener make_layer_surface;
+
+ struct wl_listener monitor_test;
+ struct wl_listener monitor_apply;
+ struct wl_listener monitor_change;
+
+ struct wl_listener cursor_move;
+ struct wl_listener cursor_move_abs;
+ struct wl_listener cursor_button;
+ struct wl_listener cursor_axis;
+ struct wl_listener cursor_frame;
+
+ struct wl_listener request_cursor;
+ struct wl_listener request_activate;
+ struct wl_listener request_set_selection;
+ } event;
+};
+
+extern struct Server server;
+
+// -----------------------------------------------------------------------
+// functions
+
+/* util.c */
+void scale_box(struct wlr_box *, float);
+void exclude(struct wlr_box *, uint32, int32, int32, int32, int32, int32 );
+
+/* render.c */
+void render_monitor(struct wl_listener *, void *);
+
+/* xdg.c */
+void make_xdg_surface(struct wl_listener *, void *);
+
+/* layer.c */
+void make_layer_surface(struct wl_listener *, void *);
+
+/* input.c */
+void make_input(struct wl_listener *, void *);
+void notify_move(uint32 time);
+
+void cursor_axis(struct wl_listener *, void *);
+void cursor_frame(struct wl_listener *, void *);
+void cursor_button(struct wl_listener *, void *);
+void cursor_move(struct wl_listener *, void *);
+void cursor_move_abs(struct wl_listener *, void *);
+
+void request_cursor(struct wl_listener *, void *);
+void request_set_selection(struct wl_listener *, void *);
+
+/* client.c */
+void rules(Client *);
+void focus(Client *, int lift);
+void resize(Client *, int x, int y, int w, int h, int interact);
+void attach(Client *, Monitor *, uint tags);
+void floating(Client *, int);
+
+void move_client(Arg *arg);
+void float_client(Arg *arg);
+void resize_client(Arg *arg);
+
+void request_activate(struct wl_listener *, void *);
+
+Client *selected_client(void);
+Client *client_at(double x, double y);
+struct wlr_surface *client_surface_at(Client *, double cx, double cy, double *sx, double *sy);
+struct wlr_surface *top_surface(Client *);
+
+/* monitor.c */
+void tile(Monitor *);
+void arrange(Monitor *);
+void stratify(Monitor *);
+Client *focused_client(Monitor *);
+Monitor *monitor_at(double x, double y);
+
+void monitor_test(struct wl_listener *, void *);
+void monitor_apply(struct wl_listener *, void *);
+void monitor_change(struct wl_listener *, void *);
+
+void free_monitor(struct wl_listener *, void *);
+void make_monitor(struct wl_listener *, void *);
+
+#define CONFIG(a,b,...) extern a cfg·##b
+#include "config.h"
+#undef CONFIG