summaryrefslogtreecommitdiff
path: root/keepfloatingposition.c
blob: f888df2fc4ec730d9385889859c4c1ed0d39b7b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
static void
keepfloatingposition(Client *c) {
	Monitor *m;
	int cmmx = c->mon->mx;
	int cmmy = c->mon->my;
	int cmmw = c->mon->mw;
	int cmmh = c->mon->mh;
	int mmx, mmy;
	if(!(cmmx <= c->x &&
				cmmx + cmmw - 1 >= c->x &&
				cmmy <= c->y &&
				cmmy + cmmh - 1 >= c->y))
		for(m = mons; m; m = m->next) {
			mmx = m->mx;
			mmy = m->my;
			if(mmx <= c->x &&
					mmx + m->mw - 1 >= c->x &&
					mmy <= c->y &&
					mmy + m->mh - 1 >= c->y) {
				c->x = c->x - mmx + cmmx;
				c->y = c->y - mmy + cmmy;
				if(c->x + c->w  + 2 * c->bw > cmmx + cmmw - 1)
					c->x -= c->x + c->w + 2 * c->bw - cmmx - cmmw;
				if(c->y + c->h + 2 * c->bw > cmmy + cmmh - 1)
					c->y -= c->y + c->h + 2 * c->bw - cmmy - cmmh;
				resizeclient(c, c->x, c->y, c->w, c->h);
				break;
			}
		}
}