~ruther/dwl

abb36e85f111be5c68ad0018e448a0b1490a548c — Rutherther 8 months ago 366c7fc + 6e09446
Merge branch 'v0.7/patched-base' into v0.7/patched-keycodes
1 files changed, 49 insertions(+), 2 deletions(-)

M dwl.c
M dwl.c => dwl.c +49 -2
@@ 32,6 32,7 @@
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_keyboard_group.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_output.h>


@@ 136,6 137,7 @@ struct Client {
	struct wl_listener destroy_decoration;
	struct wlr_box prev; /* layout-relative, includes border */
	struct wlr_box bounds;
	struct wlr_box prev_bounds;
#ifdef XWAYLAND
	struct wl_listener activate;
	struct wl_listener associate;


@@ 301,6 303,7 @@ static void createpointer(struct wlr_pointer *pointer);
static void createpointerconstraint(struct wl_listener *listener, void *data);
static void createpopup(struct wl_listener *listener, void *data);
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void createshortcutsinhibitor(struct wl_listener *listener, void *data);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
static void destroydecoration(struct wl_listener *listener, void *data);


@@ 314,6 317,7 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static void destroyshortcutsinhibitmgr(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id);
static void dwl_ipc_manager_destroy(struct wl_resource *resource);


@@ 345,6 349,7 @@ static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keycode_t keycode);
static int modekeybinding(uint32_t mods, xkb_keysym_t sym);
static int modekeybinding(uint32_t mods, xkb_keycode_t sym);
static int is_inbounds(struct wlr_box *box, struct wlr_box *bounds);
static void keypress(struct wl_listener *listener, void *data);
static void keypressmod(struct wl_listener *listener, void *data);
static int keyrepeat(void *data);


@@ 445,6 450,7 @@ static struct wl_list clients; /* tiling order */
static struct wl_list fstack;  /* focus order */
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_keyboard_shortcuts_inhibit_manager_v1 *shortcuts_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr;
static struct wlr_gamma_control_manager_v1 *gamma_control_mgr;


@@ 465,6 471,7 @@ static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock;
static struct wl_listener lock_listener = {.notify = locksession};
static struct wl_listener new_shortcuts_inhibitor = {.notify = createshortcutsinhibitor};

static struct wlr_seat *seat;
static KeyboardGroup *kb_group;


@@ 510,6 517,13 @@ struct Pertag {
	const Layout *ltidxs[TAGCOUNT + 1][2]; /* matrix of tags and layouts indexes  */
};

int
is_inbounds(struct wlr_box *box, struct wlr_box *bounds)
{
	return box->x >= bounds->x && box->y >= bounds->y &&
		box->x + box->width <= bounds->x + bounds->width && box->y + box->height <= bounds->y + bounds->height;
}

/* function implementations */
void
applybounds(Client *c, struct wlr_box *bbox)


@@ 518,6 532,12 @@ applybounds(Client *c, struct wlr_box *bbox)
	c->geom.width = MAX(1 + 2 * (int)c->bw, c->geom.width);
	c->geom.height = MAX(1 + 2 * (int)c->bw, c->geom.height);

	if (c->isfloating && c->prev_bounds.width && c->prev_bounds.height &&
		is_inbounds(&c->geom, &c->prev_bounds) && !is_inbounds(&c->geom, bbox)) {
		c->geom.x = bbox->x + (c->geom.x - c->prev_bounds.x) * (bbox->width / c->prev_bounds.width);
		c->geom.y = bbox->y + (c->geom.y - c->prev_bounds.y) * (bbox->height / c->prev_bounds.height);
	}

	if (c->geom.x >= bbox->x + bbox->width)
		c->geom.x = bbox->x + bbox->width - c->geom.width;
	if (c->geom.y >= bbox->y + bbox->height)


@@ 585,6 605,10 @@ applyrules(Client *c)
			mon = p->mon;
			newtags = p->tags;
		}
  }
	if (mon) {
		c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x;
		c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y;
	}
	setmon(c, mon, newtags);
	attachclients(mon);


@@ 1295,6 1319,10 @@ createpointer(struct wlr_pointer *pointer)
	wlr_cursor_attach_input_device(cursor, &pointer->base);
}

void createshortcutsinhibitor(struct wl_listener *listener, void *data) {
    wlr_keyboard_shortcuts_inhibitor_v1_activate(data);
}

void
createpointerconstraint(struct wl_listener *listener, void *data)
{


@@ 1500,6 1528,11 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
	free(group);
}

void destroyshortcutsinhibitmgr(struct wl_listener *listener, void *data) {
    wl_list_remove(&new_shortcuts_inhibitor.link);
    wl_list_remove(&listener->link);
}

Monitor *
dirtomon(enum wlr_direction dir)
{


@@ 2188,7 2221,9 @@ keypress(struct wl_listener *listener, void *data)

	/* On _press_ if there is no active screen locker,
	 * attempt to process a compositor keybinding. */
	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
	if (!locked
    && event->state == WL_KEYBOARD_KEY_STATE_PRESSED
    && wl_list_empty(&shortcuts_inhibit_mgr->inhibitors)) {
		handled = keybinding(mods, keycode);
	}



@@ 2323,6 2358,10 @@ mapnotify(struct wl_listener *listener, void *data)
	 * try to apply rules for them */
	if ((p = client_get_parent(c))) {
		c->isfloating = 1;
		if (p->mon) {
			c->geom.x = (p->mon->w.width - c->geom.width) / 2 + p->mon->m.x;
			c->geom.y = (p->mon->w.height - c->geom.height) / 2 + p->mon->m.y;
		}
		setmon(c, p->mon, p->tags);
	} else {
		applyrules(c);


@@ 2992,10 3031,13 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
		return;
	c->mon = m;
	c->prev = c->geom;
	c->prev_bounds = (struct wlr_box){.x = 0, .y = 0, .width = 0, .height = 0};

	/* Scene graph sends surface leave/enter events on move and resize */
	if (oldmon)
	if (oldmon) {
		arrange(oldmon);
		c->prev_bounds = oldmon->w;
	}
	if (m) {
		/* Make sure window actually overlaps with the monitor */
		resize(c, c->geom, 0);


@@ 3003,6 3045,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
		setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
		setfloating(c, c->isfloating);
	}
	c->prev_bounds = (struct wlr_box){.x = 0, .y = 0, .width = 0, .height = 0};
	focusclient(focustop(selmon), 1);
}



@@ 3173,6 3216,10 @@ setup(void)
			(float [4]){0.1f, 0.1f, 0.1f, 1.0f});
	wlr_scene_node_set_enabled(&locked_bg->node, 0);

    shortcuts_inhibit_mgr = wlr_keyboard_shortcuts_inhibit_v1_create(dpy);
    wl_signal_add(&shortcuts_inhibit_mgr->events.new_inhibitor, &new_shortcuts_inhibitor);
    LISTEN_STATIC(&shortcuts_inhibit_mgr->events.destroy, destroyshortcutsinhibitmgr);

	/* Use decoration protocols to negotiate server-side decorations */
	wlr_server_decoration_manager_set_default_mode(
			wlr_server_decoration_manager_create(dpy),

Do not follow this link