minimized fork

This commit is contained in:
λmolinae 2025-05-26 23:29:37 -06:00
parent 24ad12f106
commit 86f980a95e
6 changed files with 254 additions and 543 deletions

464
dwl.c
View file

@ -69,14 +69,6 @@
#include <xcb/xcb_icccm.h>
#endif
#ifdef __FreeBSD__
#define __BSD_VISIBLE
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#endif
#include "util.h"
#include "drwl.h"
@ -84,7 +76,7 @@
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]) && !(C)->swallowedby)
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && (((C)->tags & (M)->tagset[(M)->seltags]) || C->issticky) && !(C)->swallowedby)
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
#define TAGMASK ((1u << LENGTH(tags)) - 1)
@ -92,7 +84,6 @@
#define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
#define BORDERPX(C) (borderpx + ((C)->swallowing ? (int)ceilf(swallowborder * (C)->swallowing->bw) : 0))
#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad)
#define PREFIX(str, prefix) !strncmp(str, prefix, strlen(prefix))
/* enums */
enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
@ -126,7 +117,6 @@ typedef struct Client Client;
struct Client {
/* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */
int interact;
struct wlr_box geom; /* layout-relative, includes border */
Monitor *mon;
struct wlr_scene_tree *scene;
@ -159,12 +149,12 @@ struct Client {
#endif
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen, issticky;
int isfloating, isurgent, isfullscreen, issticky;
int isterm, noswallow;
uint32_t resize; /* configure serial of a pending resize */
pid_t pid;
Client *swallowing; /* client being hidden */
Client *swallowedby;
uint32_t resize; /* configure serial of a pending resize */
pid_t pid;
Client *swallowing; /* client being hidden */
Client *swallowedby;
};
typedef struct {
@ -244,11 +234,12 @@ struct Monitor {
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */
const Layout *lt[2];
Pertag *pertag;
int gappih; /* horizontal gap between windows */
int enablegaps; /* enable gaps, used by togglegaps */
int gappih; /* horizontal gap between windows */
int gappiv; /* vertical gap between windows */
int gappoh; /* horizontal outer gaps */
int gappov; /* vertical outer gaps */
Pertag *pertag;
unsigned int seltags;
unsigned int sellt;
uint32_t tagset[2];
@ -305,6 +296,7 @@ typedef struct {
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
static void arrange(Monitor *m);
void arrangegaps(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
@ -318,13 +310,11 @@ static void bufdataend(struct wlr_buffer *buffer);
static Buffer *bufmon(Monitor *m);
static void bufrelease(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);
static void cleanupmon(struct wl_listener *listener, void *data);
static void closemon(Monitor *m);
static void col(Monitor *m);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data);
static void commitpopup(struct wl_listener *listener, void *data);
@ -345,7 +335,6 @@ static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
static void defaultgaps(const Arg *arg);
static void deck(Monitor *m);
static void destroydecoration(struct wl_listener *listener, void *data);
static void destroydragicon(struct wl_listener *listener, void *data);
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
@ -360,7 +349,6 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void drawbar(Monitor *m);
static void drawbars(void);
static int drawstatus(Monitor *m);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@ -386,7 +374,6 @@ static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
static void monocle(Monitor *m);
static void movestack(const Arg *arg);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
double sy, double sx_unaccel, double sy_unaccel);
@ -399,14 +386,14 @@ static void outputmgrtest(struct wl_listener *listener, void *data);
static pid_t parentpid(pid_t pid);
static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time);
static void preparegaps(Monitor *m);
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg);
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 resizeapply(Client *c, struct wlr_box geo, int interact);
static void resizenoapply(Client *c, struct wlr_box geo, int interact);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
@ -425,7 +412,6 @@ static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void swallow(Client *c, Client *toswallow);
static int statusin(int fd, unsigned int mask, void *data);
static void switchxkbrule(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static Client *termforwin(Client *c);
@ -505,7 +491,6 @@ static struct wl_listener lock_listener = {.notify = locksession};
static struct wlr_seat *seat;
static KeyboardGroup *kb_group;
static unsigned int cursor_mode;
static unsigned int xkb_rule_index = 0;
static Client *grabc;
static int grabcx, grabcy; /* client-relative */
@ -514,7 +499,7 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
static char stext[512];
static char stext[256];
static struct wl_event_source *status_event_source;
static const struct wlr_buffer_impl buffer_impl = {
@ -523,19 +508,14 @@ static const struct wlr_buffer_impl buffer_impl = {
.end_data_ptr_access = bufdataend,
};
static int enablegaps = 1; /* enables gaps, used by togglegaps */
static void (*resize)(Client *c, struct wlr_box geo, int interact) = resizeapply;
static struct libinput_device *togglepointerdevice = NULL;
static const struct xkb_rule_names en_rules = {.layout = "us"};
static struct xkb_context *en_context;
static struct xkb_keymap *en_keymap;
static struct xkb_state *en_state;
static struct xkb_context *en_context;
static struct xkb_keymap *en_keymap;
static struct xkb_state *en_state;
static int resizelock = 0; /* do not actually resize during arrange */
static struct libinput_device *togglepointerdevice = NULL;
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@ -630,25 +610,9 @@ applyrules(Client *c)
setmon(c, mon, newtags);
}
void
applygaps(Client *c)
{
struct wlr_box geom = c->geom;
if (!c->mon)
return;
geom.x += c->mon->gappih + c->mon->gappoh;
geom.y += c->mon->gappiv + c->mon->gappov;
geom.width -= c->mon->gappih;
geom.height -= c->mon->gappiv;
resize(c, geom, 0);
}
void
arrange(Monitor *m)
{
int save_width, save_height;
Client *c;
if (!m->wlr_output->enabled)
@ -681,29 +645,51 @@ arrange(Monitor *m)
}
if (m->lt[m->sellt]->arrange) {
save_width = m->w.width;
save_height = m->w.height;
if (enablegaps) {
m->w.width -= m->gappih + 2 * m->gappoh;
m->w.height -= m->gappiv + 2 * m->gappov;
}
resize = resizenoapply;
preparegaps(m);
m->lt[m->sellt]->arrange(m);
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (enablegaps)
applygaps(c);
resizeapply(c, c->geom, c->interact);
}
m->w.width = save_width;
m->w.height = save_height;
resize = resizeapply;
arrangegaps(m);
}
motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL);
}
void
arrangegaps(Monitor *m)
{
Client *c;
int n, gaps;
if (!m->enablegaps)
return;
resizelock = 0;
n = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
n++;
}
gaps = !(smartgaps && n == 1) &&
(monoclegaps || m->lt[m->sellt]->arrange != monocle);
if (gaps) {
m->w.width += m->gappih + 2 * m->gappoh;
m->w.height += m->gappiv + 2 * m->gappov;
}
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (gaps) {
c->geom.x += c->mon->gappih + c->mon->gappoh;
c->geom.y += c->mon->gappiv + c->mon->gappov;
c->geom.width -= c->mon->gappih;
c->geom.height -= c->mon->gappiv;
}
resize(c, c->geom, 0);
}
}
void
arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive)
{
@ -911,7 +897,7 @@ buttonpress(struct wl_listener *listener, void *data)
(node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) &&
(buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) {
cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale;
wl_list_for_each(c, &clients, link) {
wl_list_for_each(c, &clients, link) {
if (c->mon != selmon)
continue;
occ |= c->tags == TAGMASK ? 0 : c->tags;
@ -967,69 +953,6 @@ 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)
{
@ -1158,33 +1081,6 @@ closemon(Monitor *m)
drawbars();
}
void
col(Monitor *m)
{
Client *c;
unsigned int n = 0, i = 0;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
n++;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
resize(
c,
(struct wlr_box){
.x = m->w.x + i * m->w.width / n,
.y = m->w.y,
.width = m->w.width / n,
.height = m->w.height
},
0
);
i++;
}
}
void
commitlayersurfacenotify(struct wl_listener *listener, void *data)
{
@ -1234,8 +1130,10 @@ commitnotify(struct wl_listener *listener, void *data)
* a wrong monitor.
*/
applyrules(c);
wlr_surface_set_preferred_buffer_scale(client_surface(c), (int)ceilf(c->mon->wlr_output->scale));
wlr_fractional_scale_v1_notify_scale(client_surface(c), c->mon->wlr_output->scale);
if (c->mon) {
wlr_surface_set_preferred_buffer_scale(client_surface(c), (int)ceilf(c->mon->wlr_output->scale));
wlr_fractional_scale_v1_notify_scale(client_surface(c), c->mon->wlr_output->scale);
}
setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
@ -1324,7 +1222,7 @@ createkeyboardgroup(void)
/* Prepare an XKB keymap and assign it to the keyboard group. */
context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[xkb_rule_index],
if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules,
XKB_KEYMAP_COMPILE_NO_FLAGS)))
die("failed to compile keymap");
@ -1420,13 +1318,14 @@ createmon(struct wl_listener *listener, void *data)
for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]);
wlr_output_state_init(&state);
/* Initialize monitor state using configured rules */
m->enablegaps = enablegaps;
m->gappih = gappih;
m->gappiv = gappiv;
m->gappoh = gappoh;
m->gappov = gappov;
wlr_output_state_init(&state);
/* Initialize monitor state using configured rules */
m->tagset[0] = m->tagset[1] = 1;
for (r = monrules; r < END(monrules); r++) {
if (!r->name || strstr(wlr_output->name, r->name)) {
@ -1659,46 +1558,10 @@ defaultgaps(const Arg *arg)
setgaps(gappoh, gappov, gappih, gappiv);
}
void
deck(Monitor *m)
{
unsigned int mw, my;
int i, n = 0;
Client *c;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
n++;
if (n == 0)
return;
if (n > m->nmaster)
mw = m->nmaster ? round(m->w.width * m->mfact) : 0;
else
mw = m->w.width;
i = my = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
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);
my += c->geom.height;
} else {
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y,
.width = m->w.width - mw, .height = m->w.height}, 0);
if (c == focustop(m))
wlr_scene_node_raise_to_top(&c->scene->node);
}
i++;
}
}
void
destroydecoration(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, destroy_decoration);
c->decoration = NULL;
wl_list_remove(&c->destroy_decoration.link);
wl_list_remove(&c->set_decoration_mode.link);
@ -1875,8 +1738,11 @@ drawbar(Monitor *m)
return;
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) /* status is only drawn on selected monitor */
tw = drawstatus(m);
if (m == selmon) { /* status is only drawn on selected monitor */
drwl_setscheme(m->drw, colors[SchemeNorm]);
tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */
drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
}
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
@ -1928,88 +1794,6 @@ drawbars(void)
drawbar(m);
}
int
drawstatus(Monitor *m)
{
int x, tw, iw;
char rstext[512] = "";
char *p, *argstart, *argend, *itext;
uint32_t scheme[3], *color;
/* calculate real width of stext */
for (p = stext; *p; p++) {
if (PREFIX(p, "^^")) {
strncat(rstext, p, 2);
p++;
} else if (PREFIX(p, "^fg(") || PREFIX(p, "^bg(")) {
argend = strchr(p, ')');
if (!argend) { /* ignore this command */
argstart = strchr(p, '(') + 1;
strncat(rstext, p, argstart - p);
p = argstart - 1;
} else {
p = argend;
}
} else {
strncat(rstext, p, 1);
}
}
tw = TEXTW(m, rstext) - m->lrpad;
x = m->b.width - tw;
itext = stext;
scheme[0] = colors[SchemeNorm][0];
scheme[1] = colors[SchemeNorm][1];
drwl_setscheme(m->drw, scheme);
for (p = stext; *p; p++) {
if (PREFIX(p, "^^")) {
p++;
} else if (PREFIX(p, "^fg(") || PREFIX(p, "^bg(")) {
argstart = strchr(p, '(') + 1;
argend = strchr(argstart, ')');
if (!argend) { /* ignore this command */
p = argstart - 1;
continue;
}
*p = '\0';
iw = TEXTW(m, itext) - m->lrpad;
if (*itext) /* only draw text if there is something to draw */
x = drwl_text(m->drw, x, 0, iw, m->b.height, 0, itext, 0);
*p = '^';
if (PREFIX(p, "^fg("))
color = &scheme[0];
else
color = &scheme[1];
if (argend != argstart) {
*argend = '\0';
*color = strtoul(argstart, NULL, 16);
*color = *color << 8 | 0xff; /* add alpha channel */
*argend = ')';
} else {
*color = 0; /* reset */
}
/* reset color back to normal if none was provided */
if (!scheme[0])
scheme[0] = colors[SchemeNorm][0];
if (!scheme[1])
scheme[1] = colors[SchemeNorm][1];
itext = argend + 1;
drwl_setscheme(m->drw, scheme);
p = argend;
}
}
iw = TEXTW(m, itext) - m->lrpad;
if (*itext)
drwl_text(m->drw, x, 0, iw, m->b.height, 0, itext, 0);
return tw;
}
void
focusclient(Client *c, int lift)
{
@ -2579,48 +2363,6 @@ monocle(Monitor *m)
wlr_scene_node_raise_to_top(&c->scene->node);
}
void
movestack(const Arg *arg)
{
Client *c, *sel = focustop(selmon);
if (!sel) {
return;
}
if (wl_list_length(&clients) <= 1) {
return;
}
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
if (&c->link == &clients) {
c = wl_container_of(&clients, c, link);
break; /* wrap past the sentinel node */
}
if (VISIBLEON(c, selmon) || &c->link == &clients) {
break; /* found it */
}
}
} else {
wl_list_for_each_reverse(c, &sel->link, link) {
if (&c->link == &clients) {
c = wl_container_of(&clients, c, link);
break; /* wrap past the sentinel node */
}
if (VISIBLEON(c, selmon) || &c->link == &clients) {
break; /* found it */
}
}
/* backup one client */
c = wl_container_of(c->link.prev, c, link);
}
wl_list_remove(&sel->link);
wl_list_insert(&c->link, &sel->link);
arrange(selmon);
}
void
motionabsolute(struct wl_listener *listener, void *data)
{
@ -2852,6 +2594,31 @@ outputmgrtest(struct wl_listener *listener, void *data)
outputmgrapplyortest(config, 1);
}
void
preparegaps(Monitor *m)
{
Client *c;
int n;
if (!m->enablegaps)
return;
n = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
n++;
}
resizelock = 1;
if ((smartgaps && n == 1) || (!monoclegaps && m->lt[m->sellt]->arrange == monocle))
return;
m->w.width -= m->gappih + 2 * m->gappoh;
m->w.height -= m->gappiv + 2 * m->gappov;
}
pid_t
parentpid(pid_t pid)
{
@ -3000,11 +2767,16 @@ requestmonstate(struct wl_listener *listener, void *data)
}
void
resizeapply(Client *c, struct wlr_box geo, int interact)
resize(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox;
struct wlr_box clip;
if (resizelock) {
c->geom = geo;
return;
}
if (!c->mon || !client_surface(c)->mapped)
return;
@ -3032,13 +2804,6 @@ resizeapply(Client *c, struct wlr_box geo, int interact)
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
}
void
resizenoapply(Client *c, struct wlr_box geo, int interact)
{
c->geom = geo;
c->interact = interact;
}
void
run(char *startup_cmd)
{
@ -3342,8 +3107,7 @@ setup(void)
wlr_export_dmabuf_manager_v1_create(dpy);
wlr_screencopy_manager_v1_create(dpy);
wlr_data_control_manager_v1_create(dpy);
if (enable_primary_selection)
wlr_primary_selection_v1_device_manager_create(dpy);
wlr_primary_selection_v1_device_manager_create(dpy);
wlr_viewporter_create(dpy);
wlr_single_pixel_buffer_manager_v1_create(dpy);
wlr_fractional_scale_manager_v1_create(dpy, 1);
@ -3467,8 +3231,7 @@ setup(void)
seat = wlr_seat_create(dpy, "seat0");
LISTEN_STATIC(&seat->events.request_set_cursor, setcursor);
LISTEN_STATIC(&seat->events.request_set_selection, setsel);
if (enable_primary_selection)
LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
LISTEN_STATIC(&seat->events.request_start_drag, requeststartdrag);
LISTEN_STATIC(&seat->events.start_drag, startdrag);
@ -3551,21 +3314,6 @@ statusin(int fd, unsigned int mask, void *data)
return 0;
}
void
switchxkbrule(const Arg *arg)
{
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
struct xkb_keymap *keymap;
xkb_rule_index = (xkb_rule_index + 1) % LENGTH(xkb_rules);
if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[xkb_rule_index],
XKB_KEYMAP_COMPILE_NO_FLAGS)))
die("failed to compile keymap");
wlr_keyboard_set_keymap(&kb_group->wlr_group->keyboard, keymap);
xkb_keymap_unref(keymap);
xkb_context_unref(context);
}
void
swallow(Client *c, Client *toswallow)
{
@ -3721,7 +3469,9 @@ togglefullscreen(const Arg *arg)
void
togglegaps(const Arg *arg)
{
enablegaps = !enablegaps;
if (!selmon)
return;
selmon->enablegaps = !selmon->enablegaps;
arrange(selmon);
}
@ -4295,7 +4045,7 @@ sethints(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, set_hints);
struct wlr_surface *surface = client_surface(c);
if (c == focustop(selmon))
if (c == focustop(selmon) || !c->surface.xwayland->hints)
return;
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);