diff options
| author | tslil clingman <tslil@posteo.de> | 2023-10-21 16:02:23 +0200 |
|---|---|---|
| committer | tslil clingman <tslil@posteo.de> | 2023-10-21 16:02:23 +0200 |
| commit | 4e7f0d014f4b1ffc2b0a302e64c19e440c6bbe68 (patch) | |
| tree | 16787ca463e90aa5e872322d9229c8f84b7e7ea9 /dwl | |
| parent | 8607fd0b5d3cb9efcd4bd805321128713823271d (diff) | |
[dwl] merge changes from upstream
Diffstat (limited to 'dwl')
| -rw-r--r-- | dwl/Makefile | 7 | ||||
| -rw-r--r-- | dwl/README.md | 30 | ||||
| -rw-r--r-- | dwl/client.h | 8 | ||||
| -rw-r--r-- | dwl/config.def.h | 18 | ||||
| -rw-r--r-- | dwl/config.h | 11 | ||||
| -rw-r--r-- | dwl/config.mk | 1 | ||||
| -rw-r--r-- | dwl/dwl.1 | 9 | ||||
| -rw-r--r-- | dwl/dwl.c | 56 | ||||
| -rw-r--r-- | dwl/dwl.desktop | 5 |
9 files changed, 104 insertions, 41 deletions
diff --git a/dwl/Makefile b/dwl/Makefile index ccca079..5320e42 100644 --- a/dwl/Makefile +++ b/dwl/Makefile @@ -40,7 +40,7 @@ clean: dist: clean mkdir -p dwl-$(VERSION) cp -R LICENSE* Makefile README.md client.h config.def.h\ - config.mk protocols dwl.1 dwl.c util.c util.h\ + config.mk protocols dwl.1 dwl.c util.c util.h dwl.desktop\ dwl-$(VERSION) tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION) rm -rf dwl-$(VERSION) @@ -52,8 +52,11 @@ install: dwl mkdir -p $(DESTDIR)$(MANDIR)/man1 cp -f dwl.1 $(DESTDIR)$(MANDIR)/man1 chmod 644 $(DESTDIR)$(MANDIR)/man1/dwl.1 + mkdir -p $(DESTDIR)$(DATADIR)/wayland-sessions + cp -f dwl.desktop $(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop + chmod 644 $(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 + rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 $(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop .SUFFIXES: .c .o .c.o: diff --git a/dwl/README.md b/dwl/README.md index 05f149c..62ae872 100644 --- a/dwl/README.md +++ b/dwl/README.md @@ -1,6 +1,7 @@ # dwl - dwm for Wayland -Join us on our [Discord server] or at [#dwl] on irc.libera.chat. +Join us on our IRC channel: [#dwl on Libera Chat] +Or on our [Discord server]. dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is intended to fill the same space in the Wayland world that dwm does in X11, @@ -26,7 +27,7 @@ given the base on which it is built. Implemented default features are: monitoring - Provide information to external status bars via stdout/stdin - Urgency hints via xdg-activate protocol -- Support screen lockers via input-inhibitor protocol +- Support screen lockers via ext-session-lock-v1 protocol - Various Wayland protocols - XWayland support as provided by wlroots (can be enabled in `config.mk`) - Zero flickering - Wayland users naturally expect that "every frame is perfect" @@ -49,14 +50,28 @@ Feature *non-goals* for the main codebase include: ## Building dwl -dwl has only two dependencies: `wlroots` and `wayland-protocols`. +dwl has the following dependencies: +``` +libinput +wayland +wlroots (compiled with the libinput backend) +xkbcommon +wayland-protocols (compile-time only) +pkg-config (compile-time only) +``` +If you enable X11 support: +``` +libxcb +libxcb-wm +wlroots (compiled with X11 support) +Xwayland (runtime only) +``` Simply install these (and their `-devel` versions if your distro has separate development packages) and run `make`. If you wish to build against a Git version of wlroots, check out the [wlroots-next branch]. -To enable XWayland, you should also install xorg-xwayland and uncomment its flag -in `config.mk`. +To enable XWayland, you should uncomment its flags in `config.mk`. ## Configuration @@ -82,6 +97,7 @@ When dwl is run with no arguments, it will launch the server and begin handling any shortcuts configured in `config.h`. There is no status bar or other decoration initially; these are instead clients that can be run within the Wayland session. +Do note that the background color is black. If you would like to run a script or command automatically at startup, you can specify the command using the `-s` option. This command will be executed as a @@ -105,7 +121,7 @@ automatically, you will need to configure it prior to launching `dwl`, e.g.: ### Status information -Information about selected layouts, current window title, and +Information about selected layouts, current window title, app-id, and selected/occupied/urgent tags is written to the stdin of the `-s` command (see the `printstatus()` function for details). This information can be used to populate an external status bar with a script that parses the information. @@ -143,7 +159,7 @@ inspiration, and to the various contributors to the project, including: [Discord server]: https://discord.gg/jJxZnrGPWN -[#dwl]: https://web.libera.chat/?channels=#dwl +[#dwl on Libera Chat]: https://web.libera.chat/?channels=#dwl [Wayland]: https://wayland.freedesktop.org/ [wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots/ [wlroots-next branch]: https://github.com/djpohly/dwl/tree/wlroots-next diff --git a/dwl/client.h b/dwl/client.h index 5a45edc..cf1ed85 100644 --- a/dwl/client.h +++ b/dwl/client.h @@ -324,6 +324,14 @@ client_send_close(Client *c) } static inline void +client_set_border_color(Client *c, const float color[static 4]) +{ + int i; + for (i = 0; i < 4; i++) + wlr_scene_rect_set_color(c->border[i], color); +} + +static inline void client_set_fullscreen(Client *c, int fullscreen) { #ifdef XWAYLAND diff --git a/dwl/config.def.h b/dwl/config.def.h index be26d3c..91f48d8 100644 --- a/dwl/config.def.h +++ b/dwl/config.def.h @@ -1,15 +1,23 @@ +/* Taken from https://github.com/djpohly/dwl/issues/466 */ +#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \ + ((hex >> 16) & 0xFF) / 255.0f, \ + ((hex >> 8) & 0xFF) / 255.0f, \ + (hex & 0xFF) / 255.0f } /* 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 unsigned int borderpx = 1; /* border pixel of windows */ -static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0}; -static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0}; +static const float bordercolor[] = COLOR(0x444444ff); +static const float focuscolor[] = COLOR(0x005577ff); +static const float urgentcolor[] = COLOR(0xff0000ff); /* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */ -static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; +static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* You can also use glsl colors */ -/* tagging - tagcount must be no greater than 31 */ +/* tagging - TAGCOUNT must be no greater than 31 */ #define TAGCOUNT (9) -static const int tagcount = TAGCOUNT; + +/* logging */ +static int log_level = WLR_ERROR; static const Rule rules[] = { /* app_id title tags mask isfloating monitor */ diff --git a/dwl/config.h b/dwl/config.h index 57da994..0b5e03f 100644 --- a/dwl/config.h +++ b/dwl/config.h @@ -1,3 +1,11 @@ +static int log_level = WLR_ERROR; + +/* Taken from https://github.com/djpohly/dwl/issues/466 */ +#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \ + ((hex >> 16) & 0xFF) / 255.0f, \ + ((hex >> 8) & 0xFF) / 255.0f, \ + (hex & 0xFF) / 255.0f } + /* 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 */ @@ -6,11 +14,12 @@ static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0}; static const unsigned int gap = 10; /* inner gap between windows */ static const float bordercolor[] = {0.266, 0.266, 0.266, 1.0}; // 44 44 44 static const float focuscolor[] = {1.000, 0.549, 0.000, 1.0}; // ff 8c 00 +static const float urgentcolor[] = COLOR(0xff0000ff); /* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* tagging */ -#define tagcount 8 +#define TAGCOUNT 8 static const Rule rules[] = { /* app_id title tags mask isfloating monitor keep_focus */ diff --git a/dwl/config.mk b/dwl/config.mk index f50156f..4bc9b9d 100644 --- a/dwl/config.mk +++ b/dwl/config.mk @@ -6,6 +6,7 @@ PKG_CONFIG = pkg-config # paths PREFIX = /usr/local MANDIR = $(PREFIX)/share/man +DATADIR = $(PREFIX)/share XWAYLAND = XLIBS = @@ -7,6 +7,7 @@ .Sh SYNOPSIS .Nm .Op Fl v +.Op Fl d .Op Fl s Ar startup command .Sh DESCRIPTION .Nm @@ -22,6 +23,12 @@ option, writes its name and version to standard error and exits unsuccessfully. .Pp When given the +.Fl d +option, +.Nm +enables full wlroots logging, including debug information. +.Pp +When given the .Fl s option, .Nm @@ -101,7 +108,7 @@ These environment variables are used by A directory where temporary user files, such as the Wayland socket, are stored. .It Ev XDG_CONFIG_DIR -A directory containung configuration of various programs and +A directory containing configuration of various programs and libraries, including libxkbcommon. .It Ev DISPLAY , WAYLAND_DISPLAY , WAYLAND_SOCKET Tell how to connect to an underlying X11 or Wayland server. @@ -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 diff --git a/dwl/dwl.desktop b/dwl/dwl.desktop new file mode 100644 index 0000000..e1380f7 --- /dev/null +++ b/dwl/dwl.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=dwl +Comment=dwm for Wayland +Exec=dwl +Type=Application |
