summaryrefslogtreecommitdiff
path: root/dwl/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl/dwl.c')
-rw-r--r--dwl/dwl.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/dwl/dwl.c b/dwl/dwl.c
index 83afe99..29b3c62 100644
--- a/dwl/dwl.c
+++ b/dwl/dwl.c
@@ -55,7 +55,7 @@
#include <xkbcommon/xkbcommon.h>
#ifdef XWAYLAND
#include <wlr/xwayland.h>
-#include <X11/Xlib.h>
+#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#endif
@@ -68,7 +68,7 @@
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
-#define TAGMASK ((1u << tagcount) - 1)
+#define TAGMASK ((1u << TAGCOUNT) - 1)
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
#define IDLE_NOTIFY_ACTIVITY wlr_idle_notify_activity(idle, seat), wlr_idle_notifier_v1_notify_activity(idle_notifier, seat)
@@ -403,13 +403,13 @@ static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmg
static void activatex11(struct wl_listener *listener, void *data);
static void configurex11(struct wl_listener *listener, void *data);
static void createnotifyx11(struct wl_listener *listener, void *data);
-static Atom getatom(xcb_connection_t *xc, const char *name);
+static xcb_atom_t getatom(xcb_connection_t *xc, const char *name);
static void sethints(struct wl_listener *listener, void *data);
static void xwaylandready(struct wl_listener *listener, void *data);
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland;
-static Atom netatom[NetLast];
+static xcb_atom_t netatom[NetLast];
#endif
/* configuration, allows nested code to access above variables */
@@ -419,15 +419,15 @@ static Atom netatom[NetLast];
#include "client.h"
struct Pertag {
- int nmasters[tagcount + 1]; /* number of windows in master area */
- float mfacts[tagcount + 1]; /* mfacts per tag */
- unsigned int sellts[tagcount + 1]; /* selected layouts */
- const Layout *ltidxs[tagcount + 1]; /* matrix of tags and layouts indexes */
+ int nmasters[TAGCOUNT + 1]; /* number of windows in master area */
+ float mfacts[TAGCOUNT + 1]; /* mfacts per tag */
+ unsigned int sellts[TAGCOUNT + 1]; /* selected layouts */
+ const Layout *ltidxs[TAGCOUNT + 1]; /* matrix of tags and layouts indexes */
};
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags {
- char limitexceeded[tagcount > 31 ? -1 : 1];
+ char limitexceeded[TAGCOUNT > 31 ? -1 : 1];
};
/* function implementations */
@@ -989,7 +989,7 @@ createmon(struct wl_listener *listener, void *data)
m->pertag = calloc(1, sizeof(Pertag));
m->curtag = m->prevtag = 1;
- for (i = 0; i <= tagcount; i++) {
+ for (i = 0; i <= TAGCOUNT; i++) {
m->pertag->nmasters[i] = m->nmaster;
m->pertag->mfacts[i] = m->mfact;
@@ -1243,7 +1243,7 @@ void
focusclient(Client *c, int lift)
{
struct wlr_surface *old = seat->keyboard_state.focused_surface;
- int i, unused_lx, unused_ly, old_client_type;
+ int unused_lx, unused_ly, old_client_type;
Client *old_c = NULL;
LayerSurface *old_l = NULL;
@@ -1270,12 +1270,10 @@ focusclient(Client *c, int lift)
selmon = c->mon;
c->isurgent = 0;
client_restack_surface(c);
-
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
if (!exclusive_focus && !seat->drag)
- for (i = 0; i < 4; i++)
- wlr_scene_rect_set_color(c->border[i], focuscolor);
+ client_set_border_color(c, focuscolor);
}
/* Deactivate old client if focus is changing */
@@ -1292,9 +1290,7 @@ focusclient(Client *c, int lift)
/* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
- for (i = 0; i < 4; i++)
- wlr_scene_rect_set_color(old_c->border[i], bordercolor);
- client_activate_surface(old, 0);
+ client_set_border_color(old_c, bordercolor);
}
}
printstatus();
@@ -2074,7 +2070,8 @@ setfloating(Client *c, int floating)
c->isfloating = floating;
if (!c->mon)
return;
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
+ ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon);
printstatus();
}
@@ -2087,7 +2084,7 @@ setfullscreen(Client *c, int fullscreen)
return;
c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen);
- wlr_scene_node_reparent(&c->scene->node, layers[fullscreen
+ wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
if (fullscreen) {
@@ -2186,6 +2183,8 @@ setup(void)
for (i = 0; i < LENGTH(sig); i++)
sigaction(sig[i], &sa, NULL);
+ wlr_log_init(log_level, NULL);
+
/* The Wayland display is managed by libwayland. It handles accepting
* clients from the Unix socket, manging Wayland globals, and so on. */
dpy = wl_display_create();
@@ -2484,7 +2483,6 @@ void
toggleview(const Arg *arg)
{
uint32_t newtagset = selmon ? selmon->tagset ^ (arg->ui & TAGMASK) : 0;
- uint32_t i;
if (!newtagset)
return;
@@ -2657,6 +2655,8 @@ urgent(struct wl_listener *listener, void *data)
if (!c || c == focustop(selmon))
return;
+ if (client_is_mapped(c))
+ client_set_border_color(c, urgentcolor);
c->isurgent = 1;
printstatus();
}
@@ -2821,10 +2821,10 @@ createnotifyx11(struct wl_listener *listener, void *data)
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
}
-Atom
+xcb_atom_t
getatom(xcb_connection_t *xc, const char *name)
{
- Atom atom = 0;
+ xcb_atom_t atom = 0;
xcb_intern_atom_reply_t *reply;
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(xc, 0, strlen(name), name);
if ((reply = xcb_intern_atom_reply(xc, cookie, NULL)))
@@ -2842,6 +2842,10 @@ sethints(struct wl_listener *listener, void *data)
return;
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
+
+ if (c->isurgent && client_is_mapped(c))
+ client_set_border_color(c, urgentcolor);
+
printstatus();
}
@@ -2882,9 +2886,11 @@ main(int argc, char *argv[])
char *startup_cmd = NULL;
int c;
- while ((c = getopt(argc, argv, "s:hv")) != -1) {
+ while ((c = getopt(argc, argv, "s:hdv")) != -1) {
if (c == 's')
startup_cmd = optarg;
+ else if (c == 'd')
+ log_level = WLR_DEBUG;
else if (c == 'v')
die("dwl " VERSION);
else
@@ -2901,8 +2907,8 @@ main(int argc, char *argv[])
cleanup();
return EXIT_SUCCESS;
-usage:
- die("Usage: %s [-v] [-s startup command]", argv[0]);
+ usage:
+ die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
}
static void