~ruther/dwl

98c5534bbd843e57d782bddb29808ee03cc9e44a — Rutherther 11 months ago 0fcadfe + 4c24a81
Merge branch 'v0.6-a/patched-base' into v0.6-a/patched-keycodes
1 files changed, 17 insertions(+), 4 deletions(-)

M dwl.c
M dwl.c => dwl.c +17 -4
@@ 140,6 140,7 @@ struct Client {
	struct wl_listener fdestroy;
	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;


@@ 340,6 341,7 @@ static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keycode_t keycode);
static int is_inbounds(struct wlr_box *box, struct wlr_box *bounds);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
static int modekeybinding(uint32_t mods, xkb_keycode_t sym);
static void keypress(struct wl_listener *listener, void *data);


@@ 517,6 519,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)


@@ 525,8 534,11 @@ 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);

	printf("Current pos: %d,%d, %dx%d\n", c->geom.x, c->geom.y, c->geom.width, c->geom.height);
	printf("Applying bounds: %d,%d, %dx%d\n", bbox->x, bbox->y, bbox->width, bbox->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;


@@ 536,8 548,6 @@ applybounds(Client *c, struct wlr_box *bbox)
		c->geom.x = bbox->x;
	if (c->geom.y < bbox->y)
		c->geom.y = bbox->y;

	printf("Updated pos: %d,%d, %dx%d\n", c->geom.x, c->geom.y, c->geom.width, c->geom.height);
}

void


@@ 2854,12 2864,14 @@ 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 (c->foreign_toplevel)
			wlr_foreign_toplevel_handle_v1_output_leave(c->foreign_toplevel, oldmon->wlr_output);
		arrange(oldmon);
		c->prev_bounds = oldmon->w;
	}
	if (m) {
		/* Make sure window actually overlaps with the monitor */


@@ 2870,6 2882,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);
}


Do not follow this link