From 88b8c199e3524b7c4e2667db3683c77d70f34a26 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 29 Sep 2021 10:53:41 -0700 Subject: feat(wm): working prototype --- sys/cmd/wm/wm.h | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 114 insertions(+), 9 deletions(-) (limited to 'sys/cmd/wm/wm.h') diff --git a/sys/cmd/wm/wm.h b/sys/cmd/wm/wm.h index b9731e9..e1d3670 100644 --- a/sys/cmd/wm/wm.h +++ b/sys/cmd/wm/wm.h @@ -10,21 +10,39 @@ #include #include +#include #include +#include +#include #include #include #include #include #include +#include +#include +#include #include +#include +#include +#include #include +#include #include +#include +#include +#include #include #include #include +// ----------------------------------------------------------------------- +// macros + +#define ROUND(x) ((int)((x)+0.5)) + // ----------------------------------------------------------------------- // types @@ -35,11 +53,45 @@ enum CursorResize, }; +typedef union Arg Arg; +typedef struct Button Button; +typedef struct Key Key; typedef struct Keyboard Keyboard; typedef struct Client Client; +typedef struct Layout Layout; typedef struct Monitor Monitor; typedef struct Server Server; +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 mod; + uint button; + void (*func)(const Arg *); + const Arg arg; +}; + struct Keyboard { struct wl_list link; @@ -47,21 +99,41 @@ struct Keyboard struct { struct wl_listener press; struct wl_listener modify; + struct wl_listener destroy; } event; }; struct Client { struct wl_list link; + struct wl_list stack; + struct wlr_xdg_surface *xdg; + struct { struct wl_listener map; struct wl_listener unmap; 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; - int x, y, mapped; + + struct wlr_box geo, oldgeo; + + uint tags; + int border : 4; + int ismapped : 1; + int isfloating : 1; + int isurgent : 1; + int isfullscreen : 1; +}; + +struct Layout +{ + char *symbol; + void (*arrange)(Monitor *); }; struct Monitor @@ -70,20 +142,45 @@ struct Monitor struct wlr_output *output; struct { struct wl_listener render; + struct wl_listener destroy; } event; }; +struct MonitorRule +{ + char *name; + float mfact; + int nmaster; + float scale; + const Layout *lt; + enum wl_output_transform rr; + int x; + int y; +}; + +struct Rule +{ + char *id; + char *title; + uint tags; + int floating; + int monitor; +}; + struct Server { - struct wl_display *display; - struct wlr_backend *backend; - struct wlr_renderer *renderer; + struct wl_display *display; + struct wlr_backend *backend; + struct wlr_renderer *renderer; + struct wlr_presentation *present; struct { struct wlr_xdg_shell *xdg; } shell; struct wl_list clients; + struct wl_list stack; + Client *selected; struct { Client *client; @@ -95,7 +192,7 @@ struct Server struct { struct wlr_output_layout *layout; struct wl_list list; - } output; + } monitor; struct { struct wlr_cursor *dot; @@ -109,9 +206,10 @@ struct Server } input; struct { - struct wl_listener make_output; 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 cursor_move; struct wl_listener cursor_move_abs; @@ -129,8 +227,11 @@ extern struct Server server; // ----------------------------------------------------------------------- // functions +/* util.c */ +void scale_box(struct wlr_box *, float); + /* output.c */ -void make_output(struct wl_listener *, void *); +void make_monitor(struct wl_listener *, void *); /* xdg.c */ void make_xdg_surface(struct wl_listener *, void *); @@ -149,6 +250,10 @@ void request_set_selection(struct wl_listener *, void *); /* client.c */ void focus(Client *client, struct wlr_surface *new); -Client* clientat(double, double, struct wlr_surface **, double *, double *); -int clienthas(Client *, double, double, struct wlr_surface **, double *, double *); +Client* client_at(double, double, struct wlr_surface **, double *, double *); +int client_has(Client *, double, double, struct wlr_surface **, double *, double *); void setinteractive(Client *client, int mode, uint32 edges); + +#define CONFIG(a,b,...) extern a cfg·##b +#include "config.h" +#undef CONFIG -- cgit v1.2.1