Compare commits

...

8 Commits

Author SHA1 Message Date
1f3a4e7bac
Tweak default config to match dwm 2024-12-05 09:24:16 +00:00
Leonardo Hernández Hernández
f60125f98c
don't draw borders if there is only one window
Co-authored-by: A Frederick Christensen <dwl@ivories.org>
Co-authored-by: Andrey Proskurin <andreyproskurin@protonmail.com>
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
2024-12-05 09:23:47 +00:00
choc
71f88511be
implement dwl-ipc-unstable-v2 https://codeberg.org/dwl/dwl-patches/wiki/ipc 2024-12-05 09:19:41 +00:00
Leonardo Hernández Hernández
0a15d26bd3
port autostart patch from dwm
https://dwm.suckless.org/patches/cool_autostart/
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
2024-12-05 09:17:41 +00:00
wochap
c4b11e4365
implement bottomstack 2024-12-05 09:17:14 +00:00
wochap
1ad39f72eb
implement centeredmaster layout
inspiration: https://github.com/djpohly/dwl/wiki/centeredmaster
2024-12-05 09:17:01 +00:00
5bfb3a78e0
Apply gaplessgrid 2024-12-05 09:16:48 +00:00
korei999
0057f1e99e
handle minimize request for xwayland clients 2024-12-05 09:16:37 +00:00
5 changed files with 804 additions and 93 deletions

View File

@ -17,12 +17,14 @@ DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CF
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
all: dwl
dwl: dwl.o util.o
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
dwl: dwl.o util.o dwl-ipc-unstable-v2-protocol.o
$(CC) dwl.o util.o dwl-ipc-unstable-v2-protocol.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
dwl-ipc-unstable-v2-protocol.h
util.o: util.c util.h
dwl-ipc-unstable-v2-protocol.o: dwl-ipc-unstable-v2-protocol.c dwl-ipc-unstable-v2-protocol.h
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
@ -45,6 +47,12 @@ wlr-output-power-management-unstable-v1-protocol.h:
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
dwl-ipc-unstable-v2-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/dwl-ipc-unstable-v2.xml $@
dwl-ipc-unstable-v2-protocol.c:
$(WAYLAND_SCANNER) private-code \
protocols/dwl-ipc-unstable-v2.xml $@
config.h:
cp config.def.h $@

View File

@ -94,9 +94,12 @@ client_activate_surface(struct wlr_surface *s, int activated)
{
struct wlr_xdg_toplevel *toplevel;
#ifdef XWAYLAND
struct wlr_xwayland_surface *xsurface;
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
wlr_xwayland_surface_activate(xsurface, activated);
struct wlr_xwayland_surface *surface;
if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
if (activated && surface->minimized)
wlr_xwayland_surface_set_minimized(surface, false);
wlr_xwayland_surface_activate(surface, activated);
return;
}
#endif

View File

@ -6,16 +6,17 @@
/* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const int smartborders = 1;
static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
static const float rootcolor[] = COLOR(0x000000ff);
static const float bordercolor[] = COLOR(0xC3B495ff);
static const float focuscolor[] = COLOR(0xCC838Cff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
#define TAGCOUNT (6)
/* logging */
static int log_level = WLR_ERROR;
@ -23,9 +24,7 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
/* examples: */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
{ NULL, NULL, 0, 0, -1 },
};
/* layout(s) */
@ -34,6 +33,10 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "-|_", gaplessgrid },
{ "|M|", centeredmaster },
{ "TTT", bstack },
{ "===", bstackhoriz },
};
/* monitors */
@ -53,11 +56,8 @@ static const MonitorRule monrules[] = {
/* keyboard */
static const struct xkb_rule_names xkb_rules = {
/* can specify fields: rules, model, layout, variant, options */
/* example:
.options = "ctrl:nocaps",
*/
.options = NULL,
.layout = "us,de",
.options = "grp:alt_shift_toggle",
};
static const int repeat_rate = 25;
@ -97,7 +97,7 @@ static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
*/
static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
static const double accel_speed = 0.0;
/* You can choose between:
@ -107,7 +107,7 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_ALT
#define MODKEY WLR_MODIFIER_LOGO
#define TAGKEYS(KEY,SKEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
@ -116,17 +116,66 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#define SHWRAP(cmd) (const char*[]){ "/bin/sh", "-c", cmd, NULL }
#define TERMWRAP(cmd) (const char*[]){ "foot", cmd, NULL }
#define MPVSOCK(cmd) SHWRAP("echo '" cmd "' | socat -u - ~/.mpvsock")
#define LOCKER "swaylock", "-f", "-F", "-c", "000000"
/* commands */
static const char *termcmd[] = { "foot", NULL };
static const char *menucmd[] = { "wmenu-run", NULL };
static const char *menucmd[] = {
"bemenu-run",
"-p", "spawn",
"--list", "30",
"-W", "0.7",
"--scrollbar", "autohide",
"-c",
"--tb", "#CC838C",
"--tf", "#000000",
"--nb", "#000000",
"--nf", "#CC838C",
"--hb", "#CC838C",
"--hf", "#000000",
"--ab", "#101010",
"--af", "#CC838C",
"--scb", "#000000",
"--scf", "#CC838C",
NULL
};
static const char *lock[] = { LOCKER };
static const char *screenshot[] = SHWRAP("wayshot -s $(slurp) --file /tmp/out.png");
static const char *audiomixer[] = TERMWRAP("pulsemixer");
/* Autostart */
// NOTE: While this is a ugly hack, unfortunately it is not yet possible to pass the desired IPC socket path + WAYLAND_DISPLAY as a parameter, but it would be highly appreciated
// Once associating/grouping services by a well-known path is easily possible without passing env via alternative ways, this should go away
static const char *const autostart[] = {
"waybar", NULL,
"swayidle", "-w",
"timeout", "300", LOCKER,
"timeout", "600", "swaymsg \"output * power off\"",
"resume", "swaymsg \"output * power on\"",
"before-sleep", LOCKER, NULL,
NULL /* terminate */
};
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
/* software */
{ MODKEY, XKB_KEY_space, spawn, {.v = menucmd} },
{ MODKEY, XKB_KEY_c, spawn, {.v = termcmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_l, spawn, {.v = lock} },
{ 0, XKB_KEY_Print, spawn, {.v = screenshot} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_v, spawn, {.v = audiomixer} },
/* mpv controls */
{ 0, XKB_KEY_XF86AudioPlay, spawn, {.v = MPVSOCK("keypress space") },
{ 0, XKB_KEY_XF86AudioPrev, spawn, {.v = MPVSOCK("playlist-prev") },
{ 0, XKB_KEY_XF86AudioPlay, spawn, {.v = MPVSOCK("playlist-next") },
/* window management */
{ MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
@ -136,12 +185,15 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_T, setlayout, {.v = &layouts[0]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_F, setlayout, {.v = &layouts[1]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_M, setlayout, {.v = &layouts[2]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_G, setlayout, {.v = &layouts[3]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, setlayout, {.v = &layouts[4]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_U, setlayout, {.v = &layouts[5]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, setlayout, {.v = &layouts[6]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, togglefullscreen,{0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
@ -155,15 +207,8 @@ static const Key keys[] = {
TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4),
TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5),
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
* do not remove them.
*/
#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),

584
dwl.c
View File

@ -58,6 +58,7 @@
#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/box.h>
#include <wlr/util/log.h>
#include <wlr/util/region.h>
#include <xkbcommon/xkbcommon.h>
@ -67,6 +68,7 @@
#include <xcb/xcb_icccm.h>
#endif
#include "dwl-ipc-unstable-v2-protocol.h"
#include "util.h"
/* macros */
@ -133,6 +135,7 @@ typedef struct {
#ifdef XWAYLAND
struct wl_listener activate;
struct wl_listener associate;
struct wl_listener minimize;
struct wl_listener dissociate;
struct wl_listener configure;
struct wl_listener set_hints;
@ -143,6 +146,12 @@ typedef struct {
uint32_t resize; /* configure serial of a pending resize */
} Client;
typedef struct {
struct wl_list link;
struct wl_resource *resource;
Monitor *mon;
} DwlIpcOutput;
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
@ -188,6 +197,7 @@ typedef struct {
struct Monitor {
struct wl_list link;
struct wl_list dwl_ipc_outputs;
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
@ -249,8 +259,10 @@ static void arrange(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static void autostartexec(void);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void centeredmaster(Monitor *m);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void);
@ -285,12 +297,24 @@ static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id);
static void dwl_ipc_manager_destroy(struct wl_resource *resource);
static void dwl_ipc_manager_get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output);
static void dwl_ipc_manager_release(struct wl_client *client, struct wl_resource *resource);
static void dwl_ipc_output_destroy(struct wl_resource *resource);
static void dwl_ipc_output_printstatus(Monitor *monitor);
static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output);
static void dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *resource, uint32_t and_tags, uint32_t xor_tags);
static void dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index);
static void dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset);
static void dwl_ipc_output_release(struct wl_client *client, struct wl_resource *resource);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@ -320,7 +344,7 @@ static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void resize(Client *c, struct wlr_box geo, int interact, int draw_borders);
static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
@ -338,6 +362,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@ -355,6 +380,8 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg);
static void bstack(Monitor *m);
static void bstackhoriz(Monitor *m);
/* variables */
static const char broken[] = "broken";
@ -413,6 +440,9 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output};
static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags};
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@ -420,6 +450,7 @@ static void configurex11(struct wl_listener *listener, void *data);
static void createnotifyx11(struct wl_listener *listener, void *data);
static void dissociatex11(struct wl_listener *listener, void *data);
static xcb_atom_t getatom(xcb_connection_t *xc, const char *name);
static void minimizenotify(struct wl_listener *listener, void *data);
static void sethints(struct wl_listener *listener, void *data);
static void xwaylandready(struct wl_listener *listener, void *data);
static struct wlr_xwayland *xwayland;
@ -432,6 +463,9 @@ static xcb_atom_t netatom[NetLast];
/* attempt to encapsulate suck into one file */
#include "client.h"
static pid_t *autostart_pids;
static size_t autostart_len;
/* function implementations */
void
applybounds(Client *c, struct wlr_box *bbox)
@ -580,6 +614,27 @@ arrangelayers(Monitor *m)
}
}
void
autostartexec(void) {
const char *const *p;
size_t i = 0;
/* count entries */
for (p = autostart; *p; autostart_len++, p++)
while (*++p);
autostart_pids = calloc(autostart_len, sizeof(pid_t));
for (p = autostart; *p; i++, p++) {
if ((autostart_pids[i] = fork()) == 0) {
setsid();
execvp(*p, (char *const *)p);
die("dwl: execvp %s:", *p);
}
/* skip arguments */
while (*++p);
}
}
void
axisnotify(struct wl_listener *listener, void *data)
{
@ -649,6 +704,69 @@ buttonpress(struct wl_listener *listener, void *data)
event->time_msec, event->button, event->state);
}
void
centeredmaster(Monitor *m)
{
unsigned int h, mw, mx, my, oty, ety, tw;
int i, n;
Client *c;
n = 0;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
n++;
if (n == 0)
return;
/* initialize areas */
mw = m->w.width;
mx = 0;
my = 0;
tw = mw;
if (n > m->nmaster) {
/* go mfact box in the center if more than nmaster clients */
mw = ROUND(m->nmaster ? m->w.width * m->mfact : 0);
tw = m->w.width - mw;
if (n - m->nmaster > 1) {
/* only one client */
mx = (m->w.width - mw) / 2;
tw = (m->w.width - mw) / 2;
}
}
i = 0;
oty = 0;
ety = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (i < m->nmaster) {
/* nmaster clients are stacked vertically, in the center
* of the screen */
h = (m->w.height - my) / (MIN(n, m->nmaster) - i);
resize(c, (struct wlr_box){.x = m->w.x + mx, .y = m->w.y + my, .width = mw,
.height = h}, 0);
my += c->geom.height;
} else {
/* stack clients are stacked vertically */
if ((i - m->nmaster) % 2) {
h = (m->w.height - ety) / ( (1 + n - i) / 2);
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + ety, .width = tw,
.height = h}, 0);
ety += c->geom.height;
} else {
h = (m->w.height - oty) / ((1 + n - i) / 2);
resize(c, (struct wlr_box){.x = m->w.x + mx + mw, .y = m->w.y + oty, .width = tw,
.height = h}, 0);
oty += c->geom.height;
}
}
i++;
}
}
void
chvt(const Arg *arg)
{
@ -676,11 +794,21 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
size_t i;
#ifdef XWAYLAND
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
#endif
wl_display_destroy_clients(dpy);
/* kill child processes */
for (i = 0; i < autostart_len; i++) {
if (0 < autostart_pids[i]) {
kill(autostart_pids[i], SIGTERM);
waitpid(autostart_pids[i], NULL, 0);
}
}
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
@ -706,6 +834,10 @@ cleanupmon(struct wl_listener *listener, void *data)
LayerSurface *l, *tmp;
size_t i;
DwlIpcOutput *ipc_output, *ipc_output_tmp;
wl_list_for_each_safe(ipc_output, ipc_output_tmp, &m->dwl_ipc_outputs, link)
wl_resource_destroy(ipc_output->resource);
/* m->layers[i] are intentionally not unlinked */
for (i = 0; i < LENGTH(m->layers); i++) {
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
@ -746,7 +878,7 @@ closemon(Monitor *m)
wl_list_for_each(c, &clients, link) {
if (c->isfloating && c->geom.x > m->m.width)
resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
.width = c->geom.width, .height = c->geom.height}, 0);
.width = c->geom.width, .height = c->geom.height}, 0, 1);
if (c->mon == m)
setmon(c, selmon, c->tags);
}
@ -816,8 +948,11 @@ commitnotify(struct wl_listener *listener, void *data)
return;
}
if (client_surface(c)->mapped && c->mon)
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
if (client_surface(c)->mapped && c->mon && c->mon->lt[c->mon->sellt]->arrange
&& !c->isfullscreen && !c->isfloating)
c->mon->lt[c->mon->sellt]->arrange(c->mon);
else
resize(c, c->geom, (c->isfloating && !c->isfullscreen), (c->isfloating && !c->isfullscreen));
/* mark a pending resize as completed */
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
@ -988,6 +1123,8 @@ createmon(struct wl_listener *listener, void *data)
m = wlr_output->data = ecalloc(1, sizeof(*m));
m->wlr_output = wlr_output;
wl_list_init(&m->dwl_ipc_outputs);
for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]);
@ -1270,6 +1407,7 @@ destroynotify(struct wl_listener *listener, void *data)
wl_list_remove(&c->activate.link);
wl_list_remove(&c->associate.link);
wl_list_remove(&c->configure.link);
wl_list_remove(&c->minimize.link);
wl_list_remove(&c->dissociate.link);
wl_list_remove(&c->set_hints.link);
} else
@ -1338,6 +1476,192 @@ dirtomon(enum wlr_direction dir)
return selmon;
}
void
dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
{
struct wl_resource *manager_resource = wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id);
if (!manager_resource) {
wl_client_post_no_memory(client);
return;
}
wl_resource_set_implementation(manager_resource, &dwl_manager_implementation, NULL, dwl_ipc_manager_destroy);
zdwl_ipc_manager_v2_send_tags(manager_resource, TAGCOUNT);
for (unsigned int i = 0; i < LENGTH(layouts); i++)
zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol);
}
void
dwl_ipc_manager_destroy(struct wl_resource *resource)
{
/* No state to destroy */
}
void
dwl_ipc_manager_get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output)
{
DwlIpcOutput *ipc_output;
Monitor *monitor = wlr_output_from_resource(output)->data;
struct wl_resource *output_resource = wl_resource_create(client, &zdwl_ipc_output_v2_interface, wl_resource_get_version(resource), id);
if (!output_resource)
return;
ipc_output = ecalloc(1, sizeof(*ipc_output));
ipc_output->resource = output_resource;
ipc_output->mon = monitor;
wl_resource_set_implementation(output_resource, &dwl_output_implementation, ipc_output, dwl_ipc_output_destroy);
wl_list_insert(&monitor->dwl_ipc_outputs, &ipc_output->link);
dwl_ipc_output_printstatus_to(ipc_output);
}
void
dwl_ipc_manager_release(struct wl_client *client, struct wl_resource *resource)
{
wl_resource_destroy(resource);
}
static void
dwl_ipc_output_destroy(struct wl_resource *resource)
{
DwlIpcOutput *ipc_output = wl_resource_get_user_data(resource);
wl_list_remove(&ipc_output->link);
free(ipc_output);
}
void
dwl_ipc_output_printstatus(Monitor *monitor)
{
DwlIpcOutput *ipc_output;
wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link)
dwl_ipc_output_printstatus_to(ipc_output);
}
void
dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output)
{
Monitor *monitor = ipc_output->mon;
Client *c, *focused;
int tagmask, state, numclients, focused_client, tag;
const char *title, *appid;
focused = focustop(monitor);
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
for (tag = 0 ; tag < TAGCOUNT; tag++) {
numclients = state = focused_client = 0;
tagmask = 1 << tag;
if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
wl_list_for_each(c, &clients, link) {
if (c->mon != monitor)
continue;
if (!(c->tags & tagmask))
continue;
if (c == focused)
focused_client = 1;
if (c->isurgent)
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
numclients++;
}
zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients, focused_client);
}
title = focused ? client_get_title(focused) : "";
appid = focused ? client_get_appid(focused) : "";
zdwl_ipc_output_v2_send_layout(ipc_output->resource, monitor->lt[monitor->sellt] - layouts);
zdwl_ipc_output_v2_send_title(ipc_output->resource, title ? title : broken);
zdwl_ipc_output_v2_send_appid(ipc_output->resource, appid ? appid : broken);
zdwl_ipc_output_v2_send_layout_symbol(ipc_output->resource, monitor->ltsymbol);
if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) {
zdwl_ipc_output_v2_send_fullscreen(ipc_output->resource, focused ? focused->isfullscreen : 0);
}
if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) {
zdwl_ipc_output_v2_send_floating(ipc_output->resource, focused ? focused->isfloating : 0);
}
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
}
void
dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *resource, uint32_t and_tags, uint32_t xor_tags)
{
DwlIpcOutput *ipc_output;
Monitor *monitor;
Client *selected_client;
unsigned int newtags = 0;
ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output)
return;
monitor = ipc_output->mon;
selected_client = focustop(monitor);
if (!selected_client)
return;
newtags = (selected_client->tags & and_tags) ^ xor_tags;
if (!newtags)
return;
selected_client->tags = newtags;
if (selmon == monitor)
focusclient(focustop(monitor), 1);
arrange(selmon);
printstatus();
}
void
dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index)
{
DwlIpcOutput *ipc_output;
Monitor *monitor;
ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output)
return;
monitor = ipc_output->mon;
if (index >= LENGTH(layouts))
return;
if (index != monitor->lt[monitor->sellt] - layouts)
monitor->sellt ^= 1;
monitor->lt[monitor->sellt] = &layouts[index];
arrange(monitor);
printstatus();
}
void
dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset)
{
DwlIpcOutput *ipc_output;
Monitor *monitor;
unsigned int newtags = tagmask & TAGMASK;
ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output)
return;
monitor = ipc_output->mon;
if (!newtags || newtags == monitor->tagset[monitor->seltags])
return;
if (toggle_tagset)
monitor->seltags ^= 1;
monitor->tagset[monitor->seltags] = newtags;
if (selmon == monitor)
focusclient(focustop(monitor), 1);
arrange(monitor);
printstatus();
}
void
dwl_ipc_output_release(struct wl_client *client, struct wl_resource *resource)
{
wl_resource_destroy(resource);
}
void
focusclient(Client *c, int lift)
{
@ -1500,23 +1824,86 @@ void
handlesig(int signo)
{
if (signo == SIGCHLD) {
#ifdef XWAYLAND
siginfo_t in;
/* wlroots expects to reap the XWayland process itself, so we
* use WNOWAIT to keep the child waitable until we know it's not
* XWayland.
*/
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
&& (!xwayland || in.si_pid != xwayland->server->pid))
waitpid(in.si_pid, NULL, 0);
#else
while (waitpid(-1, NULL, WNOHANG) > 0);
#ifdef XWAYLAND
&& (!xwayland || in.si_pid != xwayland->server->pid)
#endif
) {
pid_t *p, *lim;
waitpid(in.si_pid, NULL, 0);
if (in.si_pid == child_pid)
child_pid = -1;
if (!(p = autostart_pids))
continue;
lim = &p[autostart_len];
for (; p < lim; p++) {
if (*p == in.si_pid) {
*p = -1;
break;
}
}
}
} else if (signo == SIGINT || signo == SIGTERM) {
quit(NULL);
}
}
void
gaplessgrid(Monitor *m)
{
unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
Client *c;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
/* grid dimensions */
for (cols = 0; cols <= (n / 2); cols++)
if ((cols * cols) >= n)
break;
if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
/* widescreen is better if 3 columns */
if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
cols = 3;
rows = n / cols;
/* window geometries */
cw = cols ? m->w.width / cols : m->w.width;
cn = 0; /* current column number */
rn = 0; /* current row number */
wl_list_for_each(c, &clients, link) {
unsigned int cx, cy;
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if ((i / rows + 1) > (cols - n % cols))
rows = n / cols + 1;
ch = rows ? m->w.height / rows : m->w.height;
cx = m->w.x + cn * cw;
cy = m->w.y + rn * ch;
resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
rn++;
if (rn >= rows) {
rn = 0;
cn++;
}
i++;
}
}
void
incnmaster(const Arg *arg)
{
@ -1777,7 +2164,7 @@ monocle(Monitor *m)
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
resize(c, m->w, 0);
resize(c, m->w, 0, !smartborders);
n++;
}
if (n)
@ -1869,11 +2256,11 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
if (cursor_mode == CurMove) {
/* Move the grabbed client to the new position. */
resize(grabc, (struct wlr_box){.x = (int)round(cursor->x) - grabcx, .y = (int)round(cursor->y) - grabcy,
.width = grabc->geom.width, .height = grabc->geom.height}, 1);
.width = grabc->geom.width, .height = grabc->geom.height}, 1, 1);
return;
} else if (cursor_mode == CurResize) {
resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
.width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
.width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1, 1);
return;
}
@ -2038,41 +2425,9 @@ void
printstatus(void)
{
Monitor *m = NULL;
Client *c;
uint32_t occ, urg, sel;
const char *appid, *title;
wl_list_for_each(m, &mons, link) {
occ = urg = 0;
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
}
if ((c = focustop(m))) {
title = client_get_title(c);
appid = client_get_appid(c);
printf("%s title %s\n", m->wlr_output->name, title ? title : broken);
printf("%s appid %s\n", m->wlr_output->name, appid ? appid : broken);
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
printf("%s floating %d\n", m->wlr_output->name, c->isfloating);
sel = c->tags;
} else {
printf("%s title \n", m->wlr_output->name);
printf("%s appid \n", m->wlr_output->name);
printf("%s fullscreen \n", m->wlr_output->name);
printf("%s floating \n", m->wlr_output->name);
sel = 0;
}
printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
printf("%s tags %"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"\n",
m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg);
printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol);
}
fflush(stdout);
wl_list_for_each(m, &mons, link)
dwl_ipc_output_printstatus(m);
}
void
@ -2180,7 +2535,7 @@ requestmonstate(struct wl_listener *listener, void *data)
}
void
resize(Client *c, struct wlr_box geo, int interact)
resize(Client *c, struct wlr_box geo, int interact, int draw_borders)
{
struct wlr_box *bbox;
struct wlr_box clip;
@ -2192,6 +2547,7 @@ resize(Client *c, struct wlr_box geo, int interact)
client_set_bounds(c, geo.width, geo.height);
c->geom = geo;
c->bw = draw_borders ? borderpx : 0;
applybounds(c, bbox);
/* Update scene-graph, including borders */
@ -2227,6 +2583,7 @@ run(char *startup_cmd)
die("startup: backend_start");
/* Now that the socket exists and the backend is started, run the startup command */
autostartexec();
if (startup_cmd) {
int piperw[2];
if (pipe(piperw) < 0)
@ -2316,6 +2673,8 @@ setfloating(Client *c, int floating)
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]);
if (c->isfloating && !c->bw)
resize(c, c->mon->m, 0, 1);
arrange(c->mon);
printstatus();
}
@ -2333,11 +2692,11 @@ setfullscreen(Client *c, int fullscreen)
if (fullscreen) {
c->prev = c->geom;
resize(c, c->mon->m, 0);
resize(c, c->mon->m, 0, 0);
} else {
/* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
resize(c, c->prev, 0, 1);
}
arrange(c->mon);
printstatus();
@ -2364,6 +2723,12 @@ setlayout(const Arg *arg)
if (arg && arg->v)
selmon->lt[selmon->sellt] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
if (!selmon->lt[selmon->sellt]->arrange) {
/* floating layout, draw borders around all clients */
Client *c;
wl_list_for_each(c, &clients, link)
resize(c, c->mon->m, 0, 1);
}
arrange(selmon);
printstatus();
}
@ -2398,7 +2763,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
arrange(oldmon);
if (m) {
/* Make sure window actually overlaps with the monitor */
resize(c, c->geom, 0);
resize(c, c->geom, 0, 1);
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
@ -2627,6 +2992,8 @@ setup(void)
LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply);
LISTEN_STATIC(&output_mgr->events.test, outputmgrtest);
wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, dwl_ipc_manager_bind);
/* Make sure XWayland clients don't connect to the parent X server,
* e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */
@ -2693,7 +3060,7 @@ tagmon(const Arg *arg)
void
tile(Monitor *m)
{
unsigned int mw, my, ty;
unsigned int mw, my, ty, draw_borders = 1;
int i, n = 0;
Client *c;
@ -2703,6 +3070,9 @@ tile(Monitor *m)
if (n == 0)
return;
if (n == smartborders)
draw_borders = 0;
if (n > m->nmaster)
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
else
@ -2713,17 +3083,24 @@ tile(Monitor *m)
continue;
if (i < m->nmaster) {
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0, draw_borders);
my += c->geom.height;
} else {
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0, draw_borders);
ty += c->geom.height;
}
i++;
}
}
void
togglebar(const Arg *arg) {
DwlIpcOutput *ipc_output;
wl_list_for_each(ipc_output, &selmon->dwl_ipc_outputs, link)
zdwl_ipc_output_v2_send_toggle_visibility(ipc_output->resource);
}
void
togglefloating(const Arg *arg)
{
@ -2886,7 +3263,7 @@ updatemons(struct wl_listener *listener, void *data)
arrange(m);
/* make sure fullscreen clients have the right size */
if ((c = focustop(m)) && c->isfullscreen)
resize(c, m->m, 0);
resize(c, m->m, 0, 0);
/* Try to re-set the gamma LUT when updating monitors,
* it's only really needed when enabling a disabled output, but meh. */
@ -3089,7 +3466,7 @@ configurex11(struct wl_listener *listener, void *data)
}
if (c->isfloating || client_is_unmanaged(c))
resize(c, (struct wlr_box){.x = event->x, .y = event->y,
.width = event->width + c->bw * 2, .height = event->height + c->bw * 2}, 0);
.width = event->width + c->bw * 2, .height = event->height + c->bw * 2}, 0, 1);
else
arrange(c->mon);
}
@ -3111,6 +3488,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
@ -3138,6 +3516,21 @@ getatom(xcb_connection_t *xc, const char *name)
return atom;
}
void
minimizenotify(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, minimize);
struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
struct wlr_xwayland_minimize_event *e = data;
int focused;
if (xsurface->surface == NULL || !xsurface->surface->mapped)
return;
focused = seat->keyboard_state.focused_surface == xsurface->surface;
wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
}
void
sethints(struct wl_listener *listener, void *data)
{
@ -3215,3 +3608,84 @@ main(int argc, char *argv[])
usage:
die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
}
static void
bstack(Monitor *m)
{
int w, h, mh, mx, tx, ty, tw;
int i, n = 0;
Client *c;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
if (n > m->nmaster) {
mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
tw = m->w.width / (n - m->nmaster);
ty = m->w.y + mh;
} else {
mh = m->w.height;
tw = m->w.width;
ty = m->w.y;
}
i = mx = 0;
tx = m-> w.x;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating)
continue;
if (i < m->nmaster) {
w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
mx += c->geom.width;
} else {
h = m->w.height - mh;
resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = tw, .height = h }, 0);
if (tw != m->w.width)
tx += c->geom.width;
}
i++;
}
}
static void
bstackhoriz(Monitor *m) {
int w, mh, mx, tx, ty, th;
int i, n = 0;
Client *c;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating)
n ++;
if (n == 0)
return;
if (n > m->nmaster) {
mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
th = (m->w.height - mh) / (n - m->nmaster);
ty = m->w.y + mh;
} else {
th = mh = m->w.height;
ty = m->w.y;
}
i = mx = 0;
tx = m-> w.x;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c,m) || c->isfloating)
continue;
if (i < m->nmaster) {
w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
mx += c->geom.width;
} else {
resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = m->w.width, .height = th }, 0);
if (th != m->w.height)
ty += c->geom.height;
}
i++;
}
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This is largely ripped from somebar's ipc patchset; just with some personal modifications.
I would probably just submit raphi's patchset but I don't think that would be polite.
-->
<protocol name="dwl_ipc_unstable_v2">
<description summary="inter-proccess-communication about dwl's state">
This protocol allows clients to update and get updates from dwl.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible
changes may be added together with the corresponding interface
version bump.
Backward incompatible changes are done by bumping the version
number in the protocol and interface names and resetting the
interface version. Once the protocol is to be declared stable,
the 'z' prefix and the version number in the protocol and
interface names are removed and the interface version number is
reset.
</description>
<interface name="zdwl_ipc_manager_v2" version="2">
<description summary="manage dwl state">
This interface is exposed as a global in wl_registry.
Clients can use this interface to get a dwl_ipc_output.
After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events.
The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client.
</description>
<request name="release" type="destructor">
<description summary="release dwl_ipc_manager">
Indicates that the client will not the dwl_ipc_manager object anymore.
Objects created through this instance are not affected.
</description>
</request>
<request name="get_output">
<description summary="get a dwl_ipc_outout for a wl_output">
Get a dwl_ipc_outout for the specified wl_output.
</description>
<arg name="id" type="new_id" interface="zdwl_ipc_output_v2"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<event name="tags">
<description summary="Announces tag amount">
This event is sent after binding.
A roundtrip after binding guarantees the client recieved all tags.
</description>
<arg name="amount" type="uint"/>
</event>
<event name="layout">
<description summary="Announces a layout">
This event is sent after binding.
A roundtrip after binding guarantees the client recieved all layouts.
</description>
<arg name="name" type="string"/>
</event>
</interface>
<interface name="zdwl_ipc_output_v2" version="2">
<description summary="control dwl output">
Observe and control a dwl output.
Events are double-buffered:
Clients should cache events and redraw when a dwl_ipc_output.frame event is sent.
Request are not double-buffered:
The compositor will update immediately upon request.
</description>
<enum name="tag_state">
<entry name="none" value="0" summary="no state"/>
<entry name="active" value="1" summary="tag is active"/>
<entry name="urgent" value="2" summary="tag has at least one urgent client"/>
</enum>
<request name="release" type="destructor">
<description summary="release dwl_ipc_outout">
Indicates to that the client no longer needs this dwl_ipc_output.
</description>
</request>
<event name="toggle_visibility">
<description summary="Toggle client visibilty">
Indicates the client should hide or show themselves.
If the client is visible then hide, if hidden then show.
</description>
</event>
<event name="active">
<description summary="Update the selected output.">
Indicates if the output is active. Zero is invalid, nonzero is valid.
</description>
<arg name="active" type="uint"/>
</event>
<event name="tag">
<description summary="Update the state of a tag.">
Indicates that a tag has been updated.
</description>
<arg name="tag" type="uint" summary="Index of the tag"/>
<arg name="state" type="uint" enum="tag_state" summary="The state of the tag."/>
<arg name="clients" type="uint" summary="The number of clients in the tag."/>
<arg name="focused" type="uint" summary="If there is a focused client. Nonzero being valid, zero being invalid."/>
</event>
<event name="layout">
<description summary="Update the layout.">
Indicates a new layout is selected.
</description>
<arg name="layout" type="uint" summary="Index of the layout."/>
</event>
<event name="title">
<description summary="Update the title.">
Indicates the title has changed.
</description>
<arg name="title" type="string" summary="The new title name."/>
</event>
<event name="appid" since="1">
<description summary="Update the appid.">
Indicates the appid has changed.
</description>
<arg name="appid" type="string" summary="The new appid."/>
</event>
<event name="layout_symbol" since="1">
<description summary="Update the current layout symbol">
Indicates the layout has changed. Since layout symbols are dynamic.
As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying.
You can ignore the zdwl_ipc_output.layout event.
</description>
<arg name="layout" type="string" summary="The new layout"/>
</event>
<event name="frame">
<description summary="The update sequence is done.">
Indicates that a sequence of status updates have finished and the client should redraw.
</description>
</event>
<request name="set_tags">
<description summary="Set the active tags of this output"/>
<arg name="tagmask" type="uint" summary="bitmask of the tags that should be set."/>
<arg name="toggle_tagset" type="uint" summary="toggle the selected tagset, zero for invalid, nonzero for valid."/>
</request>
<request name="set_client_tags">
<description summary="Set the tags of the focused client.">
The tags are updated as follows:
new_tags = (current_tags AND and_tags) XOR xor_tags
</description>
<arg name="and_tags" type="uint"/>
<arg name="xor_tags" type="uint"/>
</request>
<request name="set_layout">
<description summary="Set the layout of this output"/>
<arg name="index" type="uint" summary="index of a layout recieved by dwl_ipc_manager.layout"/>
</request>
<!-- Version 2 -->
<event name="fullscreen" since="2">
<description summary="Update fullscreen status">
Indicates if the selected client on this output is fullscreen.
</description>
<arg name="is_fullscreen" type="uint" summary="If the selected client is fullscreen. Nonzero is valid, zero invalid"/>
</event>
<event name="floating" since="2">
<description summary="Update the floating status">
Indicates if the selected client on this output is floating.
</description>
<arg name="is_floating" type="uint" summary="If the selected client is floating. Nonzero is valid, zero invalid"/>
</event>
</interface>
</protocol>