Ejemplo n.º 1
0
Archivo: root.c Proyecto: bartman/wmii
static void
motion_event(Window *w, XMotionEvent *e) {
	Rectangle r, r2;

	r = rectsetorigin(Rect(0, 0, 1, 1), Pt(e->x_root, e->y_root));
	r2 = constrain(r, 0);
	if(!eqrect(r, r2))
		warppointer(r2.min);
}
Ejemplo n.º 2
0
void
column_settle(Area *a) {
	Frame *f;
	uint yoff, yoffcr;
	int surplus, n_uncol, n;

	n_uncol = 0;
	surplus = column_surplus(a);
	for(f=a->frame; f; f=f->anext)
		if(!f->collapsed) n_uncol++;

	if(n_uncol == 0) {
		fprint(2, "%s: Badness: No uncollapsed frames, column %d, view %q\n",
				argv0, area_idx(a), a->view->name);
		return;
	}
	if(surplus < 0)
		fprint(2, "%s: Badness: surplus = %d in column_settle, column %d, view %q\n",
				argv0, surplus, area_idx(a), a->view->name);

	yoff = a->r.min.y;
	yoffcr = yoff;
	n = surplus % n_uncol;
	surplus /= n_uncol;
	for(f=a->frame; f; f=f->anext) {
		f->r = rectsetorigin(f->r, Pt(a->r.min.x, yoff));
		f->colr = rectsetorigin(f->colr, Pt(a->r.min.x, yoffcr));
		f->r.min.x = a->r.min.x;
		f->r.max.x = a->r.max.x;
		if(def.incmode == ISqueeze && !resizing)
		if(!f->collapsed) {
			f->r.max.y += surplus;
			if(n-- > 0)
				f->r.max.y++;
		}
		yoff = f->r.max.y;
		yoffcr = f->colr.max.y;
	}
}
Ejemplo n.º 3
0
static void
float_placeframe(Frame *f) {
	static Vector_rect vec;
	Vector_rect *vp;
	Rectangle r;
	Point dim, p;
	Area *a, *sel;
	Client *c;
	Frame *ff;
	View *v;
	long area, l;
	int i, s;

	v = f->view;
	a = f->area;
	c = f->client;

	/*
	if(c->trans)
		return;
	*/

	if(c->fullscreen >= 0 || c->w.hints->position || starting) {
		f->r = f->floatr;
		return;
	}

	/* Find all rectangles on the floating layer into which
	 * the new frame would fit.
	 */
	vec.n = 0;
	for(ff=a->frame; ff; ff=ff->anext)
		/* TODO: Find out why this check is needed.
		 * The frame hasn't been inserted yet, but somehow,
		 * its old rectangle winds up in the list.
		 */
		if(ff->client != f->client)
			vector_rpush(&vec, ff->r);

	/* Decide which screen we want to place this on.
	 * Ideally, it should probably Do the Right Thing
	 * when a screen fills, but what's the right thing?
	 * I think usage will show...
	 */
	s = -1;
	ff = client_groupframe(c, f->view);
	if(f->screen >= 0)
		s = f->screen;
	else if(ff)
		s = ownerscreen(ff->r);
	else if(selclient())
		s = ownerscreen(selclient()->sel->r);
	else {
		sel = view_findarea(a->view, a->view->selscreen, a->view->selcol, false);
		if(sel)
			s = sel->screen;
	}

	if (s == -1)
		r = a->r;
	else
		r = v->r[s];

	vp = unique_rects(&vec, r);

	area = LONG_MAX;
	dim.x = Dx(f->r);
	dim.y = Dy(f->r);
	p = ZP;

	for(i=0; i < vp->n; i++) {
		r = vp->ary[i];
		if(Dx(r) < dim.x || Dy(r) < dim.y)
			continue;
		l = Dx(r) * Dy(r);
		if(l < area) {
			area = l;
			p = r.min;
		}
	}

	if(area == LONG_MAX) {
		/* Cascade. */
		s = max(s, 0);
		ff = a->sel;
		if(ff)
			p = addpt(ff->r.min, Pt(Dy(ff->titlebar), Dy(ff->titlebar)));
		if(p.x + Dx(f->r) > screens[s]->r.max.x ||
		   p.y + Dy(f->r) > screens[s]->r.max.y)
			p = screens[s]->r.min;
	}

	f->floatr = rectsetorigin(f->r, p);
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: bartman/wmii
void
init_screens(void) {
	Rectangle *rects;
	View *v;
	int i, n, m;

#ifdef notdef
	d.x = Dx(scr.rect) - Dx(screen->r);
	d.y = Dy(scr.rect) - Dy(screen->r);
	for(v=view; v; v=v->next) {
		v->r.max.x += d.x;
		v->r.max.y += d.y;
	}
#endif

	/* Reallocate screens, zero any new ones. */
	rects = xinerama_screens(&n);
	m = max(n, nscreens);
	screens = erealloc(screens, (m + 1) * sizeof *screens);
	screens[m] = nil;
	for(v=view; v; v=v->next) {
		v->areas = erealloc(v->areas, m * sizeof *v->areas);
		v->r = erealloc(v->r, m * sizeof *v->r);
		v->pad = erealloc(v->pad, m * sizeof *v->pad);
	}

	for(i=nscreens; i < m; i++) {
		screens[i] = emallocz(sizeof *screens[i]);
		for(v=view; v; v=v->next)
			view_init(v, i);
	}

	nscreens = m;

	/* Reallocate buffers. */
	freeimage(ibuf);
	freeimage(ibuf32);
	ibuf = allocimage(Dx(scr.rect), Dy(scr.rect), scr.depth);
	ibuf32 = nil; /* Probably shouldn't do this until it's needed. */
	if(render_visual)
		ibuf32 = allocimage(Dx(scr.rect), Dy(scr.rect), 32);
	disp.ibuf = ibuf;
	disp.ibuf32 = ibuf32;

	/* Resize and initialize screens. */
	for(i=0; i < nscreens; i++) {
		screen = screens[i];
		screen->idx = i;

		screen->showing = i < n;
		if(screen->showing)
			screen->r = rects[i];
		else
			screen->r = rectsetorigin(screen->r, scr.rect.max);
		def.snap = Dy(screen->r) / 63;
		bar_init(screens[i]);
	}
	screen = screens[0];
	if(selview)
		view_update(selview);
}