~ruther/dwl

f9f3f3432b00599bf7264d4dd7b68e37b109759e — Devin J. Pohly 3 years ago 34521ea + d8cf65c
Merge branch 'xdg-activation' into wlroots-next
2 files changed, 43 insertions(+), 11 deletions(-)

M README.md
M dwl.c
M README.md => README.md +2 -2
@@ 15,6 15,7 @@ dwl is not meant to provide every feature under the sun. Instead, like dwm, it s
- Configurable multi-monitor layout support, including position and rotation
- Configurable HiDPI/multi-DPI support
- Provide information to external status bars via stdout/stdin
- Urgency hints via xdg-activate 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"


@@ 22,7 23,6 @@ dwl is not meant to provide every feature under the sun. Instead, like dwm, it s
Features under consideration (possibly as patches) are:

- Protocols made trivial by wlroots
- Implement urgent/focus-request once the xdg-activation protocol [hits wlroots](https://github.com/swaywm/wlroots/pull/2718)
- Implement the input-inhibitor protocol to support screen lockers
- Implement the idle-inhibit protocol which lets applications such as mpv disable idle monitoring
- Layer shell popups (used by Waybar)


@@ 38,7 38,7 @@ Feature *non-goals* for the main codebase include:

## Building dwl

dwl has only two dependencies: wlroots-git and wayland-protocols. Simply install these (and their `-devel` versions if your distro has separate development packages) and run `make`.
dwl has only two dependencies: wlroots and wayland-protocols. 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](https://github.com/djpohly/dwl/tree/wlroots-next).

To enable XWayland, you should also install xorg-xwayland and uncomment its flag in `config.mk`.


M dwl.c => dwl.c +41 -9
@@ 37,6 37,7 @@
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_activation_v1.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_output_v1.h>
#include <wlr/types/wlr_xdg_shell.h>


@@ 107,7 108,7 @@ typedef struct {
#endif
	int bw;
	unsigned int tags;
	int isfloating;
	int isfloating, isurgent;
	uint32_t resize; /* configure serial of a pending resize */
	int prevx;
	int prevy;


@@ 291,6 292,7 @@ static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
static void unmapnotify(struct wl_listener *listener, void *data);
static void updatemons(struct wl_listener *listener, void *data);
static void updatetitle(struct wl_listener *listener, void *data);
static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg);
static void virtualkeyboard(struct wl_listener *listener, void *data);
static Client *xytoclient(double x, double y);


@@ 307,6 309,7 @@ static struct wlr_renderer *drw;
static struct wlr_compositor *compositor;

static struct wlr_xdg_shell *xdg_shell;
static struct wlr_xdg_activation_v1 *activation;
static struct wl_list clients; /* tiling order */
static struct wl_list fstack;  /* focus order */
static struct wl_list stack;   /* stacking z-order */


@@ 348,6 351,7 @@ static struct wl_listener new_xdg_surface = {.notify = createnotify};
static struct wl_listener new_layer_shell_surface = {.notify = createlayersurface};
static struct wl_listener output_mgr_apply = {.notify = outputmgrapply};
static struct wl_listener output_mgr_test = {.notify = outputmgrtest};
static struct wl_listener request_activate = {.notify = urgent};
static struct wl_listener request_cursor = {.notify = setcursor};
static struct wl_listener request_set_psel = {.notify = setpsel};
static struct wl_listener request_set_sel = {.notify = setsel};


@@ 1077,6 1081,7 @@ focusclient(Client *c, int lift)
		wl_list_remove(&c->flink);
		wl_list_insert(&fstack, &c->flink);
		selmon = c->mon;
		c->isurgent = 0;
	}
	printstatus();



@@ 1552,22 1557,29 @@ void
printstatus(void)
{
	Monitor *m = NULL;
	Client *c = NULL;
	unsigned int activetags;
	Client *c;
	unsigned int occ, urg, sel;

	wl_list_for_each(m, &mons, link) {
		activetags=0;
		occ = urg = 0;
		wl_list_for_each(c, &clients, link) {
			if (c->mon == m)
				activetags |= c->tags;
			if (c->mon != m)
				continue;
			occ |= c->tags;
			if (c->isurgent)
				urg |= c->tags;
		}
		if (focustop(m))
		if ((c = focustop(m))) {
			printf("%s title %s\n", m->wlr_output->name, client_get_title(focustop(m)));
		else
			sel = c->tags;
		} else {
			printf("%s title \n", m->wlr_output->name);
			sel = 0;
		}

		printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
		printf("%s tags %u %u\n", m->wlr_output->name, activetags, m->tagset[m->seltags]);
		printf("%s tags %u %u %u %u\n", m->wlr_output->name, occ, m->tagset[m->seltags],
				sel, urg);
		printf("%s layout %s\n", m->wlr_output->name, m->lt[m->sellt]->symbol);
	}
	fflush(stdout);


@@ 1819,6 1831,7 @@ run(char *startup_cmd)
	}
	/* If nobody is reading the status output, don't terminate */
	signal(SIGPIPE, SIG_IGN);
	printstatus();

	/* Start the backend. This will enumerate outputs and inputs, become the DRM
	 * master, etc */


@@ 2009,6 2022,10 @@ setup(void)
	wlr_primary_selection_v1_device_manager_create(dpy);
	wlr_viewporter_create(dpy);

	/* Initializes the interface used to implement urgency hints */
	activation = wlr_xdg_activation_v1_create(dpy);
	wl_signal_add(&activation->events.request_activate, &request_activate);

	/* Creates an output layout, which a wlroots utility for working with an
	 * arrangement of screens in a physical layout. */
	output_layout = wlr_output_layout_create();


@@ 2323,6 2340,21 @@ updatetitle(struct wl_listener *listener, void *data)
}

void
urgent(struct wl_listener *listener, void *data)
{
	struct wlr_xdg_activation_v1_request_activate_event *event = data;
	Client *c;

	if (!wlr_surface_is_xdg_surface(event->surface))
		return;
	c = wlr_xdg_surface_from_wlr_surface(event->surface)->data;
	if (c != selclient()) {
		c->isurgent = 1;
		printstatus();
	}
}

void
view(const Arg *arg)
{
	if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])

Do not follow this link