summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--config.def.h2
-rw-r--r--config.mk2
-rw-r--r--dwl.c45
4 files changed, 28 insertions, 23 deletions
diff --git a/README.md b/README.md
index 79a7d8f..1389803 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Join us on our [Discord server](https://discord.gg/jJxZnrGPWN)!
-dwl is a compact, hackable compositor for Wayland based on [wlroots](https://github.com/swaywm/wlroots). It is intended to fill the same space in the Wayland world that dwm does in X11, primarily in terms of philosophy, and secondarily in terms of functionality. Like dwm, dwl is:
+dwl is a compact, hackable compositor for Wayland based on [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots/). It is intended to fill the same space in the Wayland world that dwm does in X11, primarily in terms of philosophy, and secondarily in terms of functionality. Like dwm, dwl is:
- Easy to understand, hack on, and extend with patches
- One C source file (or a very small number) configurable via `config.h`
diff --git a/config.def.h b/config.def.h
index 738a3ca..8408659 100644
--- a/config.def.h
+++ b/config.def.h
@@ -84,7 +84,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
- { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, 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} },
diff --git a/config.mk b/config.mk
index cd4e821..d1b161e 100644
--- a/config.mk
+++ b/config.mk
@@ -2,7 +2,7 @@
PREFIX = /usr/local
# Default compile flags (overridable by environment)
-CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wdeclaration-after-statement
+CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement
# Uncomment to build XWayland support
#CFLAGS += -DXWAYLAND
diff --git a/dwl.c b/dwl.c
index 1b9260b..9991c95 100644
--- a/dwl.c
+++ b/dwl.c
@@ -57,7 +57,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) ((C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
+#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
#define TAGMASK ((1 << LENGTH(tags)) - 1)
@@ -101,7 +101,7 @@ typedef struct {
struct wl_listener destroy;
struct wl_listener set_title;
struct wl_listener fullscreen;
- struct wlr_box geom; /* layout-relative, includes border */
+ struct wlr_box geom, prev; /* layout-relative, includes border */
Monitor *mon;
#ifdef XWAYLAND
unsigned int type;
@@ -112,19 +112,10 @@ typedef struct {
unsigned int tags;
int isfloating, isurgent;
uint32_t resize; /* configure serial of a pending resize */
- int prevx;
- int prevy;
- int prevwidth;
- int prevheight;
int isfullscreen;
} Client;
typedef struct {
- struct wl_listener request_mode;
- struct wl_listener destroy;
-} Decoration;
-
-typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
void (*func)(const Arg *);
@@ -725,10 +716,11 @@ cleanupmon(struct wl_listener *listener, void *data)
wl_list_remove(&m->link);
wlr_output_layout_remove(output_layout, m->wlr_output);
- nmons = wl_list_length(&mons);
- do // don't switch to disabled mons
- selmon = wl_container_of(mons.prev, selmon, link);
- while (!selmon->wlr_output->enabled && i++ < nmons);
+ if ((nmons = wl_list_length(&mons)))
+ do // don't switch to disabled mons
+ selmon = wl_container_of(mons.prev, selmon, link);
+ while (!selmon->wlr_output->enabled && i++ < nmons);
+
focusclient(focustop(selmon), 1);
closemon(m);
free(m);
@@ -869,6 +861,16 @@ createmon(struct wl_listener *listener, void *data)
wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);
sgeom = *wlr_output_layout_get_box(output_layout, NULL);
+ /* If length == 1 we need update selmon.
+ * Maybe it will change in run(). */
+ if (wl_list_length(&mons) == 1) {
+ Client *c;
+ selmon = m;
+ /* If there is any client, set c->mon to this monitor */
+ wl_list_for_each(c, &clients, link)
+ setmon(c, m, c->tags);
+ }
+
/* When adding monitors, the geometries of all monitors must be updated */
wl_list_for_each(m, &mons, link) {
/* The first monitor in the list is the most recently added */
@@ -1037,15 +1039,12 @@ setfullscreen(Client *c, int fullscreen)
client_set_fullscreen(c, fullscreen);
if (fullscreen) {
- c->prevx = c->geom.x;
- c->prevy = c->geom.y;
- c->prevheight = c->geom.height;
- c->prevwidth = c->geom.width;
+ c->prev = c->geom;
resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 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->prevx, c->prevy, c->prevwidth, c->prevheight, 0);
+ resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0);
arrange(c->mon);
}
}
@@ -1328,6 +1327,7 @@ mapnotify(struct wl_listener *listener, void *data)
/* Set initial monitor, tags, floating status, and focus */
applyrules(c);
+ printstatus();
}
void
@@ -2293,6 +2293,10 @@ unmapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is unmapped, and should no longer be shown. */
Client *c = wl_container_of(listener, c, unmap);
+ if (c == grabc) {
+ cursor_mode = CurNormal;
+ grabc = NULL;
+ }
wl_list_remove(&c->link);
if (client_is_unmanaged(c))
return;
@@ -2300,6 +2304,7 @@ unmapnotify(struct wl_listener *listener, void *data)
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
wl_list_remove(&c->slink);
+ printstatus();
}
void