mirror of https://github.com/0intro/wmii
First commit to test branch
This commit is contained in:
parent
61db117898
commit
aeacaf7589
|
@ -14,7 +14,6 @@ OBJ = area \
|
|||
bar \
|
||||
client \
|
||||
column \
|
||||
draw \
|
||||
event \
|
||||
frame \
|
||||
fs \
|
||||
|
@ -25,6 +24,7 @@ OBJ = area \
|
|||
rule \
|
||||
printevent\
|
||||
view \
|
||||
x11 \
|
||||
../util
|
||||
|
||||
include ${ROOT}/mk/one.mk
|
||||
|
|
128
cmd/wmii/area.c
128
cmd/wmii/area.c
|
@ -27,7 +27,7 @@ create_area(View *v, Area *pos, uint w) {
|
|||
uint minwidth;
|
||||
Area *a, **p;
|
||||
|
||||
minwidth = screen->rect.width/NCOL;
|
||||
minwidth = Dx(screen->rect)/NCOL;
|
||||
|
||||
p = &v->area;
|
||||
if(pos)
|
||||
|
@ -45,37 +45,40 @@ create_area(View *v, Area *pos, uint w) {
|
|||
if(colnum) {
|
||||
w = newcolw_of_view(v, max(i-1, 0));
|
||||
if (w == 0)
|
||||
w = screen->rect.width / (colnum + 1);
|
||||
w = Dx(screen->rect) / (colnum + 1);
|
||||
}
|
||||
else w = screen->rect.width;
|
||||
else w = Dx(screen->rect);
|
||||
}
|
||||
|
||||
if(w < minwidth)
|
||||
w = minwidth;
|
||||
if(colnum && (colnum * minwidth + w) > screen->rect.width)
|
||||
if(colnum && (colnum * minwidth + w) > Dx(screen->rect))
|
||||
return nil;
|
||||
if(pos)
|
||||
scale_view(v, screen->rect.width - w);
|
||||
scale_view(v, Dx(screen->rect) - w);
|
||||
|
||||
a = emallocz(sizeof(Area));
|
||||
a->view = v;
|
||||
a->id = id++;
|
||||
a->rect = screen->rect;
|
||||
a->rect.height = screen->rect.height - screen->brect.height;
|
||||
a->mode = def.colmode;
|
||||
a->rect.width = w;
|
||||
a->frame = nil;
|
||||
a->sel = nil;
|
||||
|
||||
a->rect = screen->rect;
|
||||
a->rect.max.x = a->rect.min.x + w;
|
||||
a->rect.max.x = screen->brect.min.y;
|
||||
|
||||
a->next = *p;
|
||||
*p = a;
|
||||
|
||||
if(a == v->area)
|
||||
a->floating = True;
|
||||
if((!v->sel) ||
|
||||
(v->sel->floating && v->area->next == a && a->next == nil))
|
||||
|
||||
if((!v->sel)
|
||||
|| (v->sel->floating && v->area->next == a && a->next == nil))
|
||||
focus_area(a);
|
||||
|
||||
if(i)
|
||||
if(!a->floating)
|
||||
write_event("CreateColumn %d\n", i);
|
||||
return a;
|
||||
}
|
||||
|
@ -115,14 +118,18 @@ destroy_area(Area *a) {
|
|||
void
|
||||
send_to_area(Area *to, Frame *f) {
|
||||
Area *from;
|
||||
|
||||
assert(to->view == f->view);
|
||||
|
||||
from = f->area;
|
||||
|
||||
if(to->floating != from->floating) {
|
||||
XRectangle temp = f->revert;
|
||||
Rectangle temp = f->revert;
|
||||
f->revert = f->rect;
|
||||
f->rect = temp;
|
||||
}
|
||||
f->client->revert = from;
|
||||
|
||||
detach_from_area(f);
|
||||
attach_to_area(to, f, True);
|
||||
}
|
||||
|
@ -147,8 +154,10 @@ attach_to_area(Area *a, Frame *f, Bool send) {
|
|||
n_frame = 1;
|
||||
|
||||
c->floating = a->floating;
|
||||
if(!a->floating)
|
||||
f->rect.height = a->rect.height / n_frame;
|
||||
if(!a->floating) {
|
||||
f->rect = a->rect;
|
||||
f->rect.max.y = f->rect.min.y + Dx(a->rect) / n_frame;
|
||||
}
|
||||
|
||||
insert_frame(a->sel, f, False);
|
||||
|
||||
|
@ -156,13 +165,11 @@ attach_to_area(Area *a, Frame *f, Bool send) {
|
|||
place_frame(f);
|
||||
|
||||
focus_frame(f, False);
|
||||
resize_frame(f, &f->rect);
|
||||
resize_frame(f, f->rect);
|
||||
restack_view(a->view);
|
||||
|
||||
if(!a->floating)
|
||||
arrange_column(a, False);
|
||||
else
|
||||
resize_frame(f, &f->rect);
|
||||
|
||||
update_client_grab(f->client);
|
||||
if(a->frame)
|
||||
|
@ -202,18 +209,20 @@ detach_from_area(Frame *f) {
|
|||
i = 0;
|
||||
for(ta=v->area; ta && ta != a; ta=ta->next)
|
||||
i++;
|
||||
|
||||
if(v->area->next->next)
|
||||
destroy_area(a);
|
||||
else if(!a->frame && v->area->frame)
|
||||
/* focus floating area if it contains something */
|
||||
else if((a->frame == nil) && (v->area->frame))
|
||||
focus_area(v->area);
|
||||
|
||||
arrange_view(v);
|
||||
}
|
||||
}
|
||||
else if(!a->frame) {
|
||||
if(c->trans) {
|
||||
/* focus area of transient, if possible */
|
||||
Client *cl = win2client(c->trans);
|
||||
Client *cl;
|
||||
|
||||
cl = win2client(c->trans);
|
||||
if(cl && cl->frame) {
|
||||
a = cl->sel->area;
|
||||
if(a->view == v)
|
||||
|
@ -227,7 +236,7 @@ detach_from_area(Frame *f) {
|
|||
}
|
||||
|
||||
static void
|
||||
bit_twiddle(uint *field, uint width, uint x, uint y, Bool set) {
|
||||
bit_set(uint *field, uint width, uint x, uint y, Bool set) {
|
||||
enum { devisor = sizeof(uint) * 8 };
|
||||
uint bx, mask;
|
||||
|
||||
|
@ -254,12 +263,13 @@ static void
|
|||
place_frame(Frame *f) {
|
||||
enum { devisor = sizeof(uint) * 8 };
|
||||
enum { dx = 8, dy = 8 };
|
||||
|
||||
static uint mwidth, mx, my;
|
||||
static uint *field = nil;
|
||||
BlitzAlign align;
|
||||
Align align;
|
||||
XPoint p1 = {0, 0};
|
||||
XPoint p2 = {0, 0};
|
||||
XRectangle *rects;
|
||||
Rectangle *rects;
|
||||
Frame *fr;
|
||||
Client *c;
|
||||
Area *a;
|
||||
|
@ -267,7 +277,7 @@ place_frame(Frame *f) {
|
|||
uint i, j, x, y, cx, cy, maxx, maxy, diff, num;
|
||||
int snap;
|
||||
|
||||
snap = screen->rect.height / 66;
|
||||
snap = Dy(screen->rect) / 66;
|
||||
num = 0;
|
||||
fit = False;
|
||||
align = CENTER;
|
||||
|
@ -277,43 +287,53 @@ place_frame(Frame *f) {
|
|||
|
||||
if(c->trans)
|
||||
return;
|
||||
if(c->rect.width >= a->rect.width
|
||||
|| c->rect.height >= a->rect.height
|
||||
if(Dx(c->rect) >= Dx(a->rect)
|
||||
|| Dy(c->rect) >= Dy(a->rect)
|
||||
|| c->size.flags & USPosition
|
||||
|| c->size.flags & PPosition)
|
||||
return;
|
||||
if(!field) {
|
||||
mx = screen->rect.width / dx;
|
||||
my = screen->rect.height / dy;
|
||||
mx = Dx(screen->rect) / dx;
|
||||
my = Dy(screen->rect) / dy;
|
||||
mwidth = ceil((float)mx / devisor);
|
||||
field = emallocz(sizeof(uint) * mwidth * my);
|
||||
}
|
||||
|
||||
memset(field, ~0, (sizeof(uint) * mwidth * my));
|
||||
for(fr=a->frame; fr; fr=fr->anext) {
|
||||
if(fr == f) {
|
||||
cx = f->rect.width / dx;
|
||||
cy = f->rect.height / dy;
|
||||
cx = Dx(f->rect) / dx;
|
||||
cy = Dx(f->rect) / dy;
|
||||
continue;
|
||||
}
|
||||
if(fr->rect.x < 0)
|
||||
|
||||
if(fr->rect.min.x < 0)
|
||||
x = 0;
|
||||
else
|
||||
x = fr->rect.x / dx;
|
||||
if(fr->rect.y < 0)
|
||||
x = fr->rect.min.x / dx;
|
||||
|
||||
if(fr->rect.min.y < 0)
|
||||
y = 0;
|
||||
else
|
||||
y = fr->rect.y / dy;
|
||||
maxx = r_east(&fr->rect) / dx;
|
||||
maxy = r_south(&fr->rect) / dy;
|
||||
y = fr->rect.min.y / dy;
|
||||
|
||||
maxx = fr->rect.max.x / dx;
|
||||
maxy = fr->rect.max.y / dy;
|
||||
for(j = y; j < my && j < maxy; j++)
|
||||
for(i = x; i < mx && i < maxx; i++)
|
||||
bit_twiddle(field, mwidth, i, j, False);
|
||||
bit_set(field, mwidth, i, j, False);
|
||||
}
|
||||
|
||||
for(y = 0; y < my; y++)
|
||||
for(x = 0; x < mx; x++) {
|
||||
if(bit_get(field, mwidth, x, y)) {
|
||||
for(i = x; (i < mx) && bit_get(field, mwidth, i, y); i++);
|
||||
for(j = y; (j < my) && bit_get(field, mwidth, x, j); j++);
|
||||
for(i = x; i < mx; i++)
|
||||
if(bit_get(field, mwidth, i, y) == 0)
|
||||
break;
|
||||
for(j = y; j < my; j++)
|
||||
if(bit_get(field, mwidth, x, j) == 0)
|
||||
break;
|
||||
|
||||
if(((i - x) * (j - y) > (p2.x - p1.x) * (p2.y - p1.y))
|
||||
&& (i - x > cx) && (j - y > cy))
|
||||
{
|
||||
|
@ -325,23 +345,25 @@ place_frame(Frame *f) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fit) {
|
||||
p1.x *= dx;
|
||||
p1.y *= dy;
|
||||
}
|
||||
if(fit && (p1.x + f->rect.width < r_south(&a->rect)))
|
||||
f->rect.x = p1.x;
|
||||
else {
|
||||
diff = a->rect.width - f->rect.width;
|
||||
f->rect.x = a->rect.x + (random() % (diff ? diff : 1));
|
||||
|
||||
if(!fit || (p1.x + Dx(f->rect) > a->rect.max.x)) {
|
||||
diff = Dx(a->rect) - Dx(f->rect);
|
||||
p1.x = a->rect.min.x + (random() % min(diff, 1));
|
||||
}
|
||||
if(fit && (p1.y + f->rect.height < (r_south(&a->rect))))
|
||||
f->rect.y = p1.y;
|
||||
else {
|
||||
diff = a->rect.height - f->rect.height;
|
||||
f->rect.y = a->rect.y + (random() % (diff ? diff : 1));
|
||||
|
||||
if(!fit && (p1.y + Dy(f->rect) > a->rect.max.y)) {
|
||||
diff = Dy(a->rect) - Dy(f->rect);
|
||||
p1.y = a->rect.min.y + (random() % min(diff, 1));
|
||||
}
|
||||
|
||||
p1 = subpt(p1, f->rect.min);
|
||||
f->rect = rectaddpt(f->rect, p1);
|
||||
|
||||
rects = rects_of_view(a->view, &num, nil);
|
||||
snap_rect(rects, num, &f->rect, &align, snap);
|
||||
if(rects)
|
||||
|
@ -377,10 +399,10 @@ focus_area(Area *a) {
|
|||
i = 0;
|
||||
for(a = v->area; a != v->sel; a = a->next)
|
||||
i++;
|
||||
if(i)
|
||||
write_event("ColumnFocus %d\n", i);
|
||||
else
|
||||
if(a->floating)
|
||||
write_event("FocusFloating\n");
|
||||
else
|
||||
write_event("ColumnFocus %d\n", i);
|
||||
if(a->frame)
|
||||
write_event("ClientFocus 0x%x\n", a->sel->client->win);
|
||||
}
|
||||
|
|
100
cmd/wmii/bar.c
100
cmd/wmii/bar.c
|
@ -2,6 +2,7 @@
|
|||
* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <util.h>
|
||||
#include "dat.h"
|
||||
|
@ -10,12 +11,14 @@
|
|||
Bar *free_bars = nil;
|
||||
|
||||
Bar *
|
||||
create_bar(Bar **b_link, char *name) {
|
||||
create_bar(Bar **bp, char *name) {
|
||||
static uint id = 1;
|
||||
Bar **i, *b = bar_of_name(*b_link, name);;
|
||||
Bar *b;
|
||||
|
||||
b = bar_of_name(*bp, name);;
|
||||
if(b)
|
||||
return b;
|
||||
|
||||
if(free_bars) {
|
||||
b = free_bars;
|
||||
free_bars = b->next;
|
||||
|
@ -23,26 +26,28 @@ create_bar(Bar **b_link, char *name) {
|
|||
}
|
||||
else
|
||||
b = emallocz(sizeof(Bar));
|
||||
|
||||
b->id = id++;
|
||||
strncpy(b->name, name, sizeof(b->name));
|
||||
b->brush = screen->bbrush;
|
||||
b->brush.color = def.normcolor;
|
||||
for(i = b_link; *i; i = &(*i)->next)
|
||||
if(strcmp((*i)->name, name) >= 0)
|
||||
b->col = def.normcolor;
|
||||
|
||||
for(; *bp; bp = &(*bp)->next)
|
||||
if(strcmp((*bp)->name, name) >= 0)
|
||||
break;
|
||||
b->next = *i;
|
||||
*i = b;
|
||||
b->next = *bp;
|
||||
*bp = b;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_bar(Bar **b_link, Bar *b) {
|
||||
destroy_bar(Bar **bp, Bar *b) {
|
||||
Bar **p;
|
||||
|
||||
for(p = b_link; *p; p = &(*p)->next)
|
||||
for(p = bp; *p; p = &(*p)->next)
|
||||
if(*p == b) break;
|
||||
*p = b->next;
|
||||
|
||||
b->next = free_bars;
|
||||
free_bars = b;
|
||||
}
|
||||
|
@ -52,11 +57,11 @@ resize_bar(WMScreen *s) {
|
|||
View *v;
|
||||
|
||||
s->brect = s->rect;
|
||||
s->brect.height = labelh(&def.font);
|
||||
s->brect.y = s->rect.height - s->brect.height;
|
||||
s->brect.min.y = s->brect.max.y - labelh(def.font);
|
||||
|
||||
XMoveResizeWindow(blz.dpy, s->barwin, s->brect.x, s->brect.y, s->brect.width, s->brect.height);
|
||||
XSync(blz.dpy, False);
|
||||
reshapewin(s->barwin, s->brect);
|
||||
|
||||
XSync(display, False);
|
||||
draw_bar(s);
|
||||
for(v = view; v; v = v->next)
|
||||
arrange_view(v);
|
||||
|
@ -64,11 +69,13 @@ resize_bar(WMScreen *s) {
|
|||
|
||||
void
|
||||
draw_bar(WMScreen *s) {
|
||||
Bar *b, *tb, *largest, **pb;
|
||||
Rectangle r;
|
||||
Align align;
|
||||
uint width, tw, nb, size;
|
||||
float shrink;
|
||||
Bar *b, *tb, *largest, **pb;
|
||||
|
||||
draw_tile(&s->bbrush);
|
||||
fill(screen->ibuf, s->brect, def.normcolor.bg);
|
||||
if(!s->bar[BarLeft] && !s->bar[BarRight])
|
||||
goto MapBar;
|
||||
|
||||
|
@ -76,62 +83,67 @@ draw_bar(WMScreen *s) {
|
|||
tw = width = nb = size = 0;
|
||||
for(nb = 0; nb < nelem(s->bar); nb++)
|
||||
for(b = s->bar[nb]; b; b=b->next) {
|
||||
b->brush.rect.x = b->brush.rect.y = 0;
|
||||
b->brush.rect.width = def.font.height & ~1;
|
||||
b->r.min = ZP;
|
||||
b->r.max.y = Dy(s->brect);
|
||||
b->r.max.x = def.font->height & ~1;
|
||||
if(b->text && strlen(b->text))
|
||||
b->brush.rect.width += textwidth(b->brush.font, b->text);
|
||||
b->brush.rect.height = s->brect.height;
|
||||
width += b->brush.rect.width;
|
||||
b->r.max.x += textwidth(def.font, b->text);
|
||||
|
||||
width += Dx(b->r);
|
||||
}
|
||||
|
||||
/* Not enough room. Shrink bars until they all fit */
|
||||
if(width > s->brect.width) {
|
||||
if(width > Dx(s->brect)) {
|
||||
for(nb = 0; nb < nelem(s->bar); nb++)
|
||||
for(b = s->bar[nb]; b; b=b->next) {
|
||||
for(pb = &largest; *pb; pb = &(*pb)->smaller)
|
||||
if((*pb)->brush.rect.width < b->brush.rect.width)
|
||||
if(Dx((*pb)->r) < Dx(b->r))
|
||||
break;
|
||||
b->smaller = *pb;
|
||||
*pb = b;
|
||||
}
|
||||
for(tb = largest; tb; tb = tb->smaller) {
|
||||
width -= tb->brush.rect.width;
|
||||
tw += tb->brush.rect.width;
|
||||
shrink = (s->brect.width - width) / (float)tw;
|
||||
width -= Dx(tb->r);
|
||||
tw += Dx(tb->r);
|
||||
shrink = (Dx(s->brect) - width) / (float)tw;
|
||||
if(tb->smaller)
|
||||
if(tb->brush.rect.width * shrink >= tb->smaller->brush.rect.width)
|
||||
break;
|
||||
if(Dx(tb->r) * shrink >= Dx(tb->smaller->r))
|
||||
break;
|
||||
}
|
||||
if(tb)
|
||||
for(b = largest; b != tb->smaller; b = b->smaller)
|
||||
b->brush.rect.width = (int)(b->brush.rect.width * shrink);
|
||||
for(b = largest; b != tb->smaller; b = b->smaller)
|
||||
b->r.max.x *= shrink;
|
||||
width += tw * shrink;
|
||||
tb = nil;
|
||||
}
|
||||
|
||||
for(nb = 0; nb < nelem(s->bar); nb++)
|
||||
for(b = s->bar[nb]; b; tb=b, b=b->next) {
|
||||
if(b == s->bar[BarRight]) {
|
||||
b->brush.align = EAST;
|
||||
b->brush.rect.width += (s->brect.width - width);
|
||||
align = EAST;
|
||||
b->r.max.x += Dx(s->brect) - width;
|
||||
}else
|
||||
b->brush.align = CENTER;
|
||||
align = CENTER;
|
||||
|
||||
if(tb)
|
||||
b->brush.rect.x = tb->brush.rect.x + tb->brush.rect.width;
|
||||
draw_label(&b->brush, b->text);
|
||||
draw_border(&b->brush);
|
||||
b->r = rectaddpt(b->r, Pt( tb->r.max.x, 0));
|
||||
|
||||
fill(screen->ibuf, b->r, b->col.bg);
|
||||
drawstring(screen->ibuf, def.font, b->r, align, b->text, b->col.fg);
|
||||
border(screen->ibuf, b->r, 1, b->col.border);
|
||||
}
|
||||
MapBar:
|
||||
XCopyArea(blz.dpy, s->bbrush.drawable, s->barwin, s->bbrush.gc, 0, 0,
|
||||
s->brect.width, s->brect.height, 0, 0);
|
||||
XSync(blz.dpy, False);
|
||||
r = rectsubpt(s->brect, s->brect.min);
|
||||
copyimage(s->barwin, r, screen->ibuf, ZP);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
Bar *
|
||||
bar_of_name(Bar *b_link, const char *name) {
|
||||
static char buf[256];
|
||||
bar_of_name(Bar *bp, const char *name) {
|
||||
Bar *b;
|
||||
|
||||
strncpy(buf, name, sizeof(buf));
|
||||
for(b = b_link; b; b = b->next)
|
||||
if(!strncmp(b->name, name, sizeof(b->name))) break;
|
||||
for(b = bp; b; b = b->next)
|
||||
if(!strncmp(b->name, name, sizeof(b->name)))
|
||||
break;
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -26,26 +26,26 @@ enum {
|
|||
};
|
||||
|
||||
Client *
|
||||
create_client(Window w, XWindowAttributes *wa) {
|
||||
create_client(XWindow w, XWindowAttributes *wa) {
|
||||
Client **t, *c;
|
||||
XSetWindowAttributes fwa;
|
||||
WinAttr fwa;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
c->win = w;
|
||||
c->rect.x = wa->x;
|
||||
c->rect.y = wa->y;
|
||||
c->border = wa->border_width;
|
||||
c->rect.width = wa->width;
|
||||
c->rect.height = wa->height;
|
||||
c->rect.min = Pt(wa->x, wa->y);
|
||||
c->rect.max = addpt(c->rect.min, Pt(wa->width, wa->height));
|
||||
|
||||
c->proto = win_proto(c->win);
|
||||
c->win.type = WWindow;
|
||||
c->win.w = w;
|
||||
|
||||
c->proto = winprotocols(&c->win);
|
||||
prop_client(c, XA_WM_TRANSIENT_FOR);
|
||||
prop_client(c, XA_WM_NORMAL_HINTS);
|
||||
prop_client(c, XA_WM_HINTS);
|
||||
prop_client(c, XA_WM_NAME);
|
||||
|
||||
XSetWindowBorderWidth(blz.dpy, c->win, 0);
|
||||
XAddToSaveSet(blz.dpy, c->win);
|
||||
XSetWindowBorderWidth(display, w, 0);
|
||||
XAddToSaveSet(display, w);
|
||||
|
||||
fwa.override_redirect = True;
|
||||
fwa.background_pixmap = ParentRelative;
|
||||
|
@ -59,23 +59,12 @@ create_client(Window w, XWindowAttributes *wa) {
|
|||
| KeyPressMask
|
||||
| ButtonPressMask
|
||||
| ButtonReleaseMask;
|
||||
c->framewin = XCreateWindow(
|
||||
/* display */ blz.dpy,
|
||||
/* parent */ blz.root,
|
||||
/* x */ c->rect.x,
|
||||
/* y */ c->rect.y,
|
||||
/* width */ c->rect.width + 2 * def.border,
|
||||
/* height */ c->rect.height + def.border + labelh(&def.font),
|
||||
/* border */ 0,
|
||||
/* depth */ DefaultDepth(blz.dpy, blz.screen),
|
||||
/* class */ CopyFromParent,
|
||||
/* visual */ DefaultVisual(blz.dpy, blz.screen),
|
||||
/* valuemask */ CWOverrideRedirect | CWEventMask | CWBackPixmap | CWBackingStore,
|
||||
/* attributes */&fwa
|
||||
);
|
||||
|
||||
c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
|
||||
XSync(blz.dpy, False);
|
||||
c->framewin = createwindow(&scr.root, c->rect, scr.depth, InputOutput, &fwa,
|
||||
CWOverrideRedirect
|
||||
| CWEventMask
|
||||
| CWBackPixmap
|
||||
| CWBackingStore);
|
||||
XSync(display, False);
|
||||
|
||||
for(t=&client ;; t=&(*t)->next)
|
||||
if(!*t) {
|
||||
|
@ -99,7 +88,7 @@ destroy_client(Client *c) {
|
|||
Client **tc;
|
||||
XEvent ev;
|
||||
|
||||
XGrabServer(blz.dpy);
|
||||
XGrabServer(display);
|
||||
/* In case the client is already unmapped */
|
||||
XSetErrorHandler(dummy_error_handler);
|
||||
|
||||
|
@ -114,18 +103,17 @@ destroy_client(Client *c) {
|
|||
|
||||
unmap_client(c, WithdrawnState);
|
||||
gravitate_client(c, True);
|
||||
reparent_client(c, blz.root, c->rect.x, c->rect.y);
|
||||
reparent_client(c, &scr.root, c->rect.min);
|
||||
|
||||
XFreeGC(blz.dpy, c->gc);
|
||||
XDestroyWindow(blz.dpy, c->framewin);
|
||||
XSync(blz.dpy, False);
|
||||
destroywindow(c->framewin);
|
||||
XSync(display, False);
|
||||
|
||||
XSetErrorHandler(wmii_error_handler);
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabServer(display);
|
||||
flushevents(EnterWindowMask, False);
|
||||
|
||||
while(XCheckMaskEvent(blz.dpy, StructureNotifyMask, &ev))
|
||||
if(ev.type != UnmapNotify || ev.xunmap.window != c->win)
|
||||
while(XCheckMaskEvent(display, StructureNotifyMask, &ev))
|
||||
if(ev.type != UnmapNotify || ev.xunmap.window != c->win.w)
|
||||
dispatch_event(&ev);
|
||||
|
||||
write_event("DestroyClient 0x%x\n", c->win);
|
||||
|
@ -137,7 +125,7 @@ manage_client(Client *c) {
|
|||
XTextProperty tags = { 0 };
|
||||
Client *trans;
|
||||
|
||||
XGetTextProperty(blz.dpy, c->win, &tags, atom[TagsAtom]);
|
||||
XGetTextProperty(display, c->win.w, &tags, atom[TagsAtom]);
|
||||
|
||||
if((trans = win2client(c->trans)))
|
||||
strncpy(c->tags, trans->tags, sizeof(c->tags));
|
||||
|
@ -146,7 +134,7 @@ manage_client(Client *c) {
|
|||
XFree(tags.value);
|
||||
|
||||
gravitate_client(c, False);
|
||||
reparent_client(c, c->framewin, def.border, labelh(&def.font));
|
||||
reparent_client(c, c->framewin, Pt(def.border, labelh(def.font)));
|
||||
|
||||
if(!strlen(c->tags))
|
||||
apply_rules(c);
|
||||
|
@ -155,7 +143,7 @@ manage_client(Client *c) {
|
|||
|
||||
if(!starting)
|
||||
update_views();
|
||||
XSync(blz.dpy, False);
|
||||
XSync(display, False);
|
||||
|
||||
if(c->sel->view == screen->sel)
|
||||
focus(c, True);
|
||||
|
@ -170,18 +158,18 @@ selclient() {
|
|||
}
|
||||
|
||||
Client *
|
||||
win2client(Window w) {
|
||||
win2client(XWindow w) {
|
||||
Client *c;
|
||||
for(c=client; c; c=c->next)
|
||||
if(c->win == w) break;
|
||||
if(c->win.w == w) break;
|
||||
return c;
|
||||
}
|
||||
|
||||
Frame *
|
||||
win2frame(Window w) {
|
||||
win2frame(XWindow w) {
|
||||
Client *c;
|
||||
for(c=client; c; c=c->next)
|
||||
if(c->framewin == w) break;
|
||||
if(c->framewin->w == w) break;
|
||||
if(c)
|
||||
return c->sel;
|
||||
return nil;
|
||||
|
@ -196,15 +184,15 @@ update_client_name(Client *c) {
|
|||
|
||||
name.nitems = 0;
|
||||
c->name[0] = 0;
|
||||
XGetTextProperty(blz.dpy, c->win, &name, atom[NetWMName]);
|
||||
XGetTextProperty(display, c->win.w, &name, atom[NetWMName]);
|
||||
if(!name.nitems)
|
||||
XGetWMName(blz.dpy, c->win, &name);
|
||||
XGetWMName(display, c->win.w, &name);
|
||||
if(!name.nitems)
|
||||
return;
|
||||
if(name.encoding == XA_STRING)
|
||||
strncpy(c->name, (char *)name.value, sizeof(c->name));
|
||||
else {
|
||||
if(XmbTextPropertyToTextList(blz.dpy, &name, &list, &n) >= Success
|
||||
if(XmbTextPropertyToTextList(display, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
{
|
||||
strncpy(c->name, *list, sizeof(c->name));
|
||||
|
@ -212,7 +200,7 @@ update_client_name(Client *c) {
|
|||
}
|
||||
}
|
||||
XFree(name.value);
|
||||
if(XGetClassHint(blz.dpy, c->win, &ch)) {
|
||||
if(XGetClassHint(display, c->win.w, &ch)) {
|
||||
snprintf(c->props, sizeof(c->props),
|
||||
"%s:%s:%s",
|
||||
str_nil(ch.res_class),
|
||||
|
@ -233,13 +221,13 @@ update_client_grab(Client *c) {
|
|||
|| (f->area->floating && f != f->area->stack)) {
|
||||
if(verbose)
|
||||
fprintf(stderr, "update_client_grab(%p) AnyButton => %s\n", c, str_nil(c->name));
|
||||
grab_button(c->framewin, AnyButton, AnyModifier);
|
||||
grab_button(c->framewin->w, AnyButton, AnyModifier);
|
||||
}else {
|
||||
if(verbose)
|
||||
fprintf(stderr, "update_client_grab(%p) def.mod => %s\n", c, str_nil(c->name));
|
||||
XUngrabButton(blz.dpy, AnyButton, AnyModifier, c->framewin);
|
||||
grab_button(c->framewin, Button1, def.mod);
|
||||
grab_button(c->framewin, Button3, def.mod);
|
||||
XUngrabButton(display, AnyButton, AnyModifier, c->framewin->w);
|
||||
grab_button(c->framewin->w, Button1, def.mod);
|
||||
grab_button(c->framewin->w, Button3, def.mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,8 +235,8 @@ void
|
|||
set_client_state(Client * c, int state) {
|
||||
long data[] = { state, None };
|
||||
XChangeProperty(
|
||||
/* display */ blz.dpy,
|
||||
/* parent */ c->win,
|
||||
/* display */ display,
|
||||
/* parent */ c->win.w,
|
||||
/* property */ atom[WMState],
|
||||
/* type */ atom[WMState],
|
||||
/* format */ 32,
|
||||
|
@ -261,9 +249,9 @@ set_client_state(Client * c, int state) {
|
|||
void
|
||||
map_client(Client *c) {
|
||||
if(!c->mapped) {
|
||||
XSelectInput(blz.dpy, c->win, ClientMask & ~StructureNotifyMask);
|
||||
XMapWindow(blz.dpy, c->win);
|
||||
XSelectInput(blz.dpy, c->win, ClientMask);
|
||||
XSelectInput(display, c->win.w, ClientMask & ~StructureNotifyMask);
|
||||
XMapWindow(display, c->win.w);
|
||||
XSelectInput(display, c->win.w, ClientMask);
|
||||
set_client_state(c, NormalState);
|
||||
c->mapped = 1;
|
||||
}
|
||||
|
@ -273,74 +261,72 @@ void
|
|||
unmap_client(Client *c, int state) {
|
||||
if(c->mapped) {
|
||||
c->unmapped++;
|
||||
XSelectInput(blz.dpy, c->win, ClientMask & ~StructureNotifyMask);
|
||||
XUnmapWindow(blz.dpy, c->win);
|
||||
XSelectInput(blz.dpy, c->win, ClientMask);
|
||||
XSelectInput(display, c->win.w, ClientMask & ~StructureNotifyMask);
|
||||
XUnmapWindow(display, c->win.w);
|
||||
XSelectInput(display, c->win.w, ClientMask);
|
||||
set_client_state(c, state);
|
||||
c->mapped = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
map_frame(Client *c) {
|
||||
if(!c->frame_mapped) {
|
||||
XMapWindow(blz.dpy, c->framewin);
|
||||
c->frame_mapped = True;
|
||||
}
|
||||
return mapwin(c->framewin);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
unmap_frame(Client *c) {
|
||||
if(c->frame_mapped) {
|
||||
XUnmapWindow(blz.dpy, c->framewin);
|
||||
c->frame_mapped = False;
|
||||
}
|
||||
return unmapwin(c->framewin);
|
||||
}
|
||||
|
||||
void
|
||||
reparent_client(Client *c, Window w, int x, int y) {
|
||||
XSelectInput(blz.dpy, c->win, ClientMask & ~StructureNotifyMask);
|
||||
XReparentWindow(blz.dpy, c->win, w, x, y);
|
||||
XSelectInput(blz.dpy, c->win, ClientMask);
|
||||
reparent_client(Client *c, Window *w, Point pt) {
|
||||
XSelectInput(display, c->win.w, ClientMask & ~StructureNotifyMask);
|
||||
XReparentWindow(display, c->win.w, w->w, pt.x, pt.y);
|
||||
XSelectInput(display, c->win.w, ClientMask);
|
||||
}
|
||||
|
||||
void
|
||||
set_cursor(Client *c, Cursor cur) {
|
||||
XSetWindowAttributes wa;
|
||||
WinAttr wa;
|
||||
|
||||
if(c->cursor != cur) {
|
||||
c->cursor = cur;
|
||||
wa.cursor = cur;
|
||||
XChangeWindowAttributes(blz.dpy, c->framewin, CWCursor, &wa);
|
||||
setwinattr(c->framewin, &wa, CWCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
configure_client(Client *c) {
|
||||
XConfigureEvent e;
|
||||
Rectangle r;
|
||||
Frame *f;
|
||||
|
||||
f = c->sel;
|
||||
if(!f)
|
||||
return;
|
||||
|
||||
r = rectaddpt(f->crect, f->rect.min);
|
||||
r = insetrect(r, -c->border);
|
||||
|
||||
e.type = ConfigureNotify;
|
||||
e.event = c->win;
|
||||
e.window = c->win;
|
||||
e.x = f->crect.x + f->rect.x - c->border;
|
||||
e.y = f->crect.y + f->rect.y - c->border;
|
||||
e.width = f->crect.width;
|
||||
e.height = f->crect.height;
|
||||
e.event = c->win.w;
|
||||
e.window = c->win.w;
|
||||
e.x = r.min.x;
|
||||
e.y = r.max.x;
|
||||
e.width = Dx(r);
|
||||
e.height = Dy(r);
|
||||
e.border_width = c->border;
|
||||
e.above = None;
|
||||
e.override_redirect = False;
|
||||
XSendEvent(blz.dpy, c->win, False,
|
||||
XSendEvent(display, c->win.w, False,
|
||||
StructureNotifyMask, (XEvent *) & e);
|
||||
XSync(blz.dpy, False);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
send_client_message(Window w, Atom a, long value) {
|
||||
send_client_message(XWindow w, Atom a, long value) {
|
||||
XEvent e;
|
||||
|
||||
e.type = ClientMessage;
|
||||
|
@ -349,16 +335,16 @@ send_client_message(Window w, Atom a, long value) {
|
|||
e.xclient.format = 32;
|
||||
e.xclient.data.l[0] = value;
|
||||
e.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(blz.dpy, w, False, NoEventMask, &e);
|
||||
XSync(blz.dpy, False);
|
||||
XSendEvent(display, w, False, NoEventMask, &e);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
void
|
||||
kill_client(Client * c) {
|
||||
if(c->proto & WM_PROTOCOL_DELWIN)
|
||||
send_client_message(c->win, atom[WMProtocols], atom[WMDelete]);
|
||||
send_client_message(c->win.w, atom[WMProtocols], atom[WMDelete]);
|
||||
else
|
||||
XKillClient(blz.dpy, c->win);
|
||||
XKillClient(display, c->win.w);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -393,13 +379,13 @@ set_urgent(Client *c, Bool urgent, Bool write) {
|
|||
}
|
||||
|
||||
if(write) {
|
||||
wmh = XGetWMHints(blz.dpy, c->win);
|
||||
wmh = XGetWMHints(display, c->win.w);
|
||||
if(wmh) {
|
||||
if(urgent)
|
||||
wmh->flags |= XUrgencyHint;
|
||||
else
|
||||
wmh->flags &= ~XUrgencyHint;
|
||||
XSetWMHints(blz.dpy, c->win, wmh);
|
||||
XSetWMHints(display, c->win.w, wmh);
|
||||
XFree(wmh);
|
||||
}
|
||||
}
|
||||
|
@ -411,18 +397,19 @@ prop_client(Client *c, Atom a) {
|
|||
long msize;
|
||||
|
||||
if(a == atom[WMProtocols])
|
||||
c->proto = win_proto(c->win);
|
||||
c->proto = winprotocols(&c->win);
|
||||
else if(a== atom[NetWMName]) {
|
||||
wmname:
|
||||
update_client_name(c);
|
||||
if(c->frame)
|
||||
draw_frame(c->sel);
|
||||
}else switch (a) {
|
||||
}
|
||||
else switch (a) {
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
XGetTransientForHint(blz.dpy, c->win, &c->trans);
|
||||
XGetTransientForHint(display, c->win.w, &c->trans);
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
if(!XGetWMNormalHints(blz.dpy, c->win, &c->size, &msize) || !c->size.flags)
|
||||
if(!XGetWMNormalHints(display, c->win.w, &c->size, &msize) || !c->size.flags)
|
||||
c->size.flags = PSize;
|
||||
c->fixedsize = False;
|
||||
if((c->size.flags & PMinSize) && (c->size.flags & PMaxSize)
|
||||
|
@ -431,7 +418,7 @@ wmname:
|
|||
c->fixedsize = True;
|
||||
break;
|
||||
case XA_WM_HINTS:
|
||||
wmh = XGetWMHints(blz.dpy, c->win);
|
||||
wmh = XGetWMHints(display, c->win.w);
|
||||
if(wmh) {
|
||||
set_urgent(c, (wmh->flags & XUrgencyHint) != 0, False);
|
||||
XFree(wmh);
|
||||
|
@ -444,7 +431,7 @@ wmname:
|
|||
|
||||
void
|
||||
gravitate_client(Client *c, Bool invert) {
|
||||
int dx, dy;
|
||||
Point d;
|
||||
int gravity;
|
||||
|
||||
gravity = NorthWestGravity;
|
||||
|
@ -452,68 +439,66 @@ gravitate_client(Client *c, Bool invert) {
|
|||
gravity = c->size.win_gravity;
|
||||
}
|
||||
|
||||
dy = 0;
|
||||
d.y = 0;
|
||||
switch (gravity) {
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case NorthGravity:
|
||||
case NorthEastGravity:
|
||||
dy = labelh(&def.font);
|
||||
d.y = labelh(def.font);
|
||||
break;
|
||||
case EastGravity:
|
||||
case CenterGravity:
|
||||
case WestGravity:
|
||||
dy = -(c->rect.height / 2) + labelh(&def.font);
|
||||
d.y = -(Dy(c->rect) / 2) + labelh(def.font);
|
||||
break;
|
||||
case SouthEastGravity:
|
||||
case SouthGravity:
|
||||
case SouthWestGravity:
|
||||
dy = -c->rect.height;
|
||||
d.y = -Dy(c->rect);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dx = 0;
|
||||
d.x = 0;
|
||||
switch (gravity) {
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
dx = def.border;
|
||||
d.x = def.border;
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
dx = -(c->rect.width / 2) + def.border;
|
||||
d.x = -(Dx(c->rect) / 2) + def.border;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
dx = -(c->rect.width + def.border);
|
||||
d.x = -(Dy(c->rect) + def.border);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(invert) {
|
||||
dx = -dx;
|
||||
dy = -dy;
|
||||
}
|
||||
c->rect.x += dx;
|
||||
c->rect.y += dy;
|
||||
if(invert)
|
||||
rectsubpt(c->rect, d);
|
||||
else
|
||||
rectaddpt(c->rect, d);
|
||||
}
|
||||
|
||||
void
|
||||
apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign sticky) {
|
||||
apply_sizehints(Client *c, Rectangle *r, Bool floating, Bool frame, Align sticky) {
|
||||
XSizeHints *s;
|
||||
XRectangle orig;
|
||||
Rectangle r2;
|
||||
uint bw, bh;
|
||||
|
||||
s = &c->size;
|
||||
orig = *r;
|
||||
r2 = rectsubpt(*r, r->min);
|
||||
if(frame)
|
||||
frame2client(c->sel, r);
|
||||
r2 = frame2client(c->sel, r2);
|
||||
bw = 0;
|
||||
bh = 0;
|
||||
|
||||
|
@ -521,17 +506,17 @@ apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign
|
|||
bw = s->min_width;
|
||||
bh = s->min_height;
|
||||
if(floating) {
|
||||
if(r->width < s->min_width)
|
||||
r->width = s->min_width;
|
||||
if(r->height < s->min_height)
|
||||
r->height = s->min_height;
|
||||
if(Dx(r2) < s->min_width)
|
||||
r2.max.x = s->min_width;
|
||||
if(Dy(r2) < s->min_height)
|
||||
r2.max.y = s->min_height;
|
||||
}
|
||||
}
|
||||
if(s->flags & PMaxSize) {
|
||||
if(r->width > s->max_width)
|
||||
r->width = s->max_width;
|
||||
if(r->height > s->max_height)
|
||||
r->height = s->max_height;
|
||||
if(Dx(r2) > s->max_width)
|
||||
r2.max.x = s->min_width;
|
||||
if(Dy(r2) > s->max_height)
|
||||
r2.max.y = s->min_height;
|
||||
}
|
||||
|
||||
if(s->flags & PBaseSize) {
|
||||
|
@ -541,9 +526,9 @@ apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign
|
|||
|
||||
if(s->flags & PResizeInc) {
|
||||
if(s->width_inc > 0)
|
||||
r->width -= (r->width - bw) % s->width_inc;
|
||||
r2.max.x -= (Dx(r2) - bw) % s->width_inc;
|
||||
if(s->height_inc > 0)
|
||||
r->height -= (r->height - bh) % s->height_inc;
|
||||
r2.max.y -= (Dy(r2) - bh) % s->height_inc;
|
||||
}
|
||||
|
||||
if((s->flags & (PBaseSize|PMinSize)) == PMinSize) {
|
||||
|
@ -556,27 +541,29 @@ apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign
|
|||
|
||||
min = (double)s->min_aspect.x / s->min_aspect.y;
|
||||
max = (double)s->max_aspect.x / s->max_aspect.y;
|
||||
initial = (double)(r->width - bw) / (r->height - bh);
|
||||
initial = (double)(Dx(r2) - bw) / (Dy(r2) - bh);
|
||||
if(initial < min)
|
||||
r->height = bh + (r->width - bw) / min;
|
||||
r2.max.y = bh + (Dx(r2) - bw) / min;
|
||||
if(initial > max)
|
||||
r->width = bw + (r->height - bh) * max;
|
||||
r2.max.x = bw + (Dy(r2) - bh) * max;
|
||||
}
|
||||
|
||||
if(frame)
|
||||
client2frame(c->sel, r);
|
||||
r2 = client2frame(c->sel, r2);
|
||||
|
||||
if(!(s->flags & PMinSize) || !floating) {
|
||||
if(r->width > orig.width)
|
||||
r->width = orig.width;
|
||||
if(r->height > orig.height)
|
||||
r->height = orig.height;
|
||||
/* Not allowed to grow */
|
||||
if(Dx(r2) > Dx(*r))
|
||||
r2.max.x =Dx(*r);
|
||||
if(Dy(r2) > Dy(*r))
|
||||
r2.max.y = Dy(*r);
|
||||
}
|
||||
|
||||
|
||||
if((sticky & (EAST|WEST)) == EAST)
|
||||
r->x = r_east(&orig) - r->width;
|
||||
r->min.x = r->max.x - Dx(r2);
|
||||
if((sticky & (NORTH|SOUTH)) == SOUTH)
|
||||
r->y = r_south(&orig) - r->height;
|
||||
r->min.y = r->max.y - Dy(r2);
|
||||
*r = rectaddpt(r2, r->min);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -605,21 +592,21 @@ focus_client(Client *c) {
|
|||
fprintf(stderr, "\t%s => %s\n", (screen->focus ? screen->focus->name : "<nil>"),
|
||||
(c ? c->name : "<nil>"));
|
||||
if(c) {
|
||||
XSetInputFocus(blz.dpy, c->win, RevertToParent, CurrentTime);
|
||||
XSetInputFocus(display, c->win.w, RevertToParent, CurrentTime);
|
||||
update_client_grab(c);
|
||||
}else
|
||||
XSetInputFocus(blz.dpy, screen->barwin, RevertToParent, CurrentTime);
|
||||
XSetInputFocus(display, screen->barwin->w, RevertToParent, CurrentTime);
|
||||
}
|
||||
|
||||
flushevents(FocusChangeMask, True);
|
||||
}
|
||||
|
||||
void
|
||||
resize_client(Client *c, XRectangle *r) {
|
||||
resize_client(Client *c, Rectangle *r) {
|
||||
Frame *f;
|
||||
|
||||
f = c->sel;
|
||||
resize_frame(f, r);
|
||||
resize_frame(f, *r);
|
||||
|
||||
if(f->area->view != screen->sel) {
|
||||
unmap_client(c, IconicState);
|
||||
|
@ -627,27 +614,20 @@ resize_client(Client *c, XRectangle *r) {
|
|||
return;
|
||||
}
|
||||
|
||||
c->rect = f->crect;
|
||||
c->rect.x += f->rect.x;
|
||||
c->rect.y += f->rect.y;
|
||||
c->rect = rectaddpt(f->crect, f->rect.min);
|
||||
|
||||
if((f->area->mode == Colmax)
|
||||
&& (f->area->sel != f)) {
|
||||
unmap_frame(c);
|
||||
unmap_client(c, IconicState);
|
||||
}else if(f->collapsed) {
|
||||
XMoveResizeWindow(blz.dpy, c->framewin,
|
||||
f->rect.x, f->rect.y,
|
||||
f->rect.width, f->rect.height);
|
||||
reshapewin(c->framewin, f->rect);
|
||||
map_frame(c);
|
||||
unmap_client(c, IconicState);
|
||||
}else {
|
||||
XMoveResizeWindow(blz.dpy, c->win,
|
||||
f->crect.x, f->crect.y,
|
||||
f->crect.width, f->crect.height);
|
||||
reshapewin(&c->win, f->crect);
|
||||
map_client(c);
|
||||
XMoveResizeWindow(blz.dpy, c->framewin,
|
||||
f->rect.x, f->rect.y,
|
||||
f->rect.width, f->rect.height);
|
||||
reshapewin(c->framewin, f->rect);
|
||||
map_frame(c);
|
||||
configure_client(c);
|
||||
}
|
||||
|
@ -893,7 +873,7 @@ apply_tags(Client *c, const char *tags) {
|
|||
toks[n] = nil;
|
||||
|
||||
update_client_views(c, toks);
|
||||
XChangeProperty(blz.dpy, c->win, atom[TagsAtom], XA_STRING, 8,
|
||||
XChangeProperty(display, c->win.w, atom[TagsAtom], XA_STRING, 8,
|
||||
PropModeReplace, (uchar *)c->tags, strlen(c->tags));
|
||||
}
|
||||
|
||||
|
@ -917,11 +897,11 @@ apply_rules(Client *c) {
|
|||
|
||||
char *
|
||||
message_client(Client *c, char *message) {
|
||||
if(!strncmp(message, "kill", 5))
|
||||
if(!strcmp(message, "kill"))
|
||||
kill_client(c);
|
||||
else if(!strncmp(message, "Urgent", 7))
|
||||
else if(!strcmp(message, "Urgent"))
|
||||
set_urgent(c, True, True);
|
||||
else if(!strncmp(message, "NotUrgent", 10))
|
||||
else if(!strcmp(message, "NotUrgent"))
|
||||
set_urgent(c, False, True);
|
||||
else
|
||||
return Ebadcmd;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
#include <util.h>
|
||||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
@ -22,11 +21,11 @@ char *modes[] = {
|
|||
};
|
||||
|
||||
Divide *
|
||||
win2div(Window w) {
|
||||
win2div(XWindow w) {
|
||||
Divide *d;
|
||||
|
||||
for(d = divs; d; d = d->next)
|
||||
if(d->w == w) return d;
|
||||
if(d->w->w == w) return d;
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -41,60 +40,45 @@ str2colmode(const char *str) {
|
|||
}
|
||||
|
||||
static void
|
||||
draw_pmap(Pixmap pm, GC gc, Bool color) {
|
||||
XPoint pt[4];
|
||||
draw_pmap(Image *img, ulong cbg, ulong cborder) {
|
||||
Point pt[6];
|
||||
|
||||
pt[0] = (XPoint){ 0, 0 };
|
||||
pt[1] = (XPoint){ divw/2 - 1, divw/2 - 1 };
|
||||
pt[2] = (XPoint){ divw/2, divw/2 - 1 };
|
||||
pt[3] = (XPoint){ divw - 1, 0 };
|
||||
pt[0] = Pt(0, 0);
|
||||
pt[1] = Pt(divw/2 - 1, divw/2 - 1);
|
||||
|
||||
if(color)
|
||||
XSetForeground(blz.dpy, gc, def.normcolor.bg);
|
||||
else {
|
||||
XSetForeground(blz.dpy, gc, 0);
|
||||
XFillRectangle(blz.dpy, pm, gc, 0, 0, divw, divh);
|
||||
XSetForeground(blz.dpy, gc, 1);
|
||||
}
|
||||
pt[2] = Pt(pt[1].x, divh);
|
||||
pt[3] = Pt(divw/2, pt[2].y);
|
||||
|
||||
XFillPolygon(blz.dpy, pm, gc, pt, nelem(pt), Convex, CoordModeOrigin);
|
||||
pt[4] = Pt(pt[3].x, divw/2 - 1);
|
||||
pt[5] = Pt(divw - 1, 0);
|
||||
|
||||
if(color)
|
||||
XSetForeground(blz.dpy, gc, def.normcolor.border);
|
||||
|
||||
XDrawLines(blz.dpy, pm, gc, pt, nelem(pt), CoordModeOrigin);
|
||||
XDrawRectangle(blz.dpy, pm, gc, pt[1].x, pt[1].y, 1, screen->rect.height);
|
||||
fillpoly(img, pt, nelem(pt), cbg);
|
||||
drawpoly(img, pt, nelem(pt), CapNotLast, 1, cborder);
|
||||
}
|
||||
|
||||
void
|
||||
update_dividers() {
|
||||
if(divmap) {
|
||||
XFreePixmap(blz.dpy, divmap);
|
||||
XFreePixmap(blz.dpy, divmask);
|
||||
XFreeGC(blz.dpy, divgc);
|
||||
XFreeGC(blz.dpy, maskgc);
|
||||
if(divimg) {
|
||||
freeimage(divimg);
|
||||
freeimage(divmask);
|
||||
}
|
||||
|
||||
divw = 2 * (labelh(&def.font) / 3);
|
||||
divw = 2 * (labelh(def.font) / 3);
|
||||
divw = max(divw, 10);
|
||||
divh = screen->rect.height;
|
||||
divh = Dy(screen->rect);
|
||||
|
||||
divmap = XCreatePixmap(blz.dpy, blz.root,
|
||||
divw, divh,
|
||||
DefaultDepth(blz.dpy, blz.screen));
|
||||
divmask = XCreatePixmap(blz.dpy, blz.root,
|
||||
divw, divh,
|
||||
1);
|
||||
divgc = XCreateGC(blz.dpy, divmap, 0, 0);
|
||||
maskgc = XCreateGC(blz.dpy, divmask, 0, 0);
|
||||
divimg = allocimage(divw, divh, scr.depth);
|
||||
divmask = allocimage(divw, divh, 1);
|
||||
|
||||
draw_pmap(divmap, divgc, True);
|
||||
draw_pmap(divmask, maskgc, False);
|
||||
fill(divmask, divmask->r, 0);
|
||||
|
||||
draw_pmap(divimg, def.normcolor.bg, def.normcolor.border);
|
||||
draw_pmap(divmask, 1, 1);
|
||||
}
|
||||
|
||||
static Divide*
|
||||
get_div(Divide **dp) {
|
||||
XSetWindowAttributes wa;
|
||||
WinAttr wa;
|
||||
Divide *d;
|
||||
|
||||
if(*dp)
|
||||
|
@ -103,27 +87,16 @@ get_div(Divide **dp) {
|
|||
d = emallocz(sizeof *d);
|
||||
|
||||
wa.override_redirect = True;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.cursor = cursor[CurDHArrow];
|
||||
wa.event_mask =
|
||||
SubstructureRedirectMask
|
||||
| ExposureMask
|
||||
ExposureMask
|
||||
| EnterWindowMask
|
||||
| PointerMotionMask
|
||||
| ButtonPressMask
|
||||
| ButtonReleaseMask;
|
||||
d->w = XCreateWindow(
|
||||
/* display */ blz.dpy,
|
||||
/* parent */ blz.root,
|
||||
/* x, y */ 0, 0,
|
||||
/* w, h */ 1, 1,
|
||||
/* border */ 0,
|
||||
/* depth */ DefaultDepth(blz.dpy, blz.screen),
|
||||
/* class */ CopyFromParent,
|
||||
/* visual */ DefaultVisual(blz.dpy, blz.screen),
|
||||
/* valuemask */ CWOverrideRedirect | CWEventMask | CWBackPixmap | CWCursor,
|
||||
/* attributes */&wa
|
||||
);
|
||||
d->w = createwindow(&scr.root, Rect(0, 0, 1, 1), scr.depth, InputOutput, &wa,
|
||||
CWOverrideRedirect
|
||||
| CWEventMask
|
||||
| CWCursor);
|
||||
|
||||
*dp = d;
|
||||
return d;
|
||||
|
@ -131,26 +104,23 @@ get_div(Divide **dp) {
|
|||
|
||||
static void
|
||||
map_div(Divide *d) {
|
||||
if(!d->mapped)
|
||||
XMapWindow(blz.dpy, d->w);
|
||||
d->mapped = 1;
|
||||
mapwin(d->w);
|
||||
}
|
||||
|
||||
static void
|
||||
unmap_div(Divide *d) {
|
||||
if(d->mapped)
|
||||
XUnmapWindow(blz.dpy, d->w);
|
||||
d->mapped = 0;
|
||||
unmapwin(d->w);
|
||||
}
|
||||
|
||||
static void
|
||||
move_div(Divide *d, int x) {
|
||||
d->x = x - divw/2;
|
||||
void
|
||||
setdiv(Divide *d, int x) {
|
||||
Rectangle r;
|
||||
|
||||
XMoveResizeWindow(blz.dpy,
|
||||
d->w,
|
||||
d->x, 0,
|
||||
divw, divh);
|
||||
d->x = x;
|
||||
r = rectaddpt(divimg->r, Pt(x - divw/2, 0));
|
||||
r.max.y = screen->brect.min.y;
|
||||
|
||||
reshapewin(d->w, r);
|
||||
map_div(d);
|
||||
}
|
||||
|
||||
|
@ -161,18 +131,18 @@ update_divs() {
|
|||
View *v;
|
||||
|
||||
update_dividers();
|
||||
|
||||
|
||||
v = screen->sel;
|
||||
dp = &divs;
|
||||
for(a = v->area->next; a; a = a->next) {
|
||||
d = get_div(dp);
|
||||
dp = &d->next;
|
||||
d->x = a->rect.x - divw/2;
|
||||
move_div(d, a->rect.x);
|
||||
setdiv(d, a->rect.min.x);
|
||||
|
||||
if(!a->next) {
|
||||
d = get_div(dp);
|
||||
dp = &d->next;
|
||||
move_div(d, r_east(&a->rect));
|
||||
setdiv(d, a->rect.max.x);
|
||||
}
|
||||
}
|
||||
for(d = *dp; d; d = d->next)
|
||||
|
@ -181,22 +151,22 @@ update_divs() {
|
|||
|
||||
void
|
||||
draw_div(Divide *d) {
|
||||
XCopyArea(
|
||||
blz.dpy,
|
||||
divmap, d->w,
|
||||
divgc,
|
||||
/* x, y */ 0, 0,
|
||||
/* w, h */ divw, divh,
|
||||
/* dest x, y */ 0, 0
|
||||
);
|
||||
XShapeCombineMask (
|
||||
/* dpy */ blz.dpy,
|
||||
/* dst */ d->w,
|
||||
/* type */ ShapeBounding,
|
||||
/* off x, y */ 0, 0,
|
||||
/* src */ divmask,
|
||||
/* op */ ShapeSet
|
||||
);
|
||||
copyimage(d->w, divimg->r, divimg, ZP);
|
||||
setshapemask(d->w, divmask, ZP);
|
||||
}
|
||||
|
||||
Area *
|
||||
new_column(View *v, Area *pos, uint w) {
|
||||
Area *a;
|
||||
|
||||
a = create_area(v, pos, w);
|
||||
if(!a)
|
||||
return nil;
|
||||
|
||||
arrange_view(v);
|
||||
if(v == screen->sel)
|
||||
focus_view(screen, v);
|
||||
return a;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -217,8 +187,8 @@ scale_column(Area *a) {
|
|||
* increment gaps can be equalized later */
|
||||
/* Frames that can't be accomodated are pushed to the floating layer */
|
||||
|
||||
minh = labelh(&def.font);
|
||||
colh = labelh(&def.font);
|
||||
minh = labelh(def.font);
|
||||
colh = labelh(def.font);
|
||||
uncolh = minh + frame_delta_h();
|
||||
|
||||
ncol = 0;
|
||||
|
@ -230,7 +200,7 @@ scale_column(Area *a) {
|
|||
else
|
||||
nuncol++;
|
||||
|
||||
surplus = a->rect.height;
|
||||
surplus = Dy(a->rect);
|
||||
surplus -= ncol * colh;
|
||||
surplus -= nuncol * uncolh;
|
||||
if(surplus < 0) {
|
||||
|
@ -252,17 +222,19 @@ scale_column(Area *a) {
|
|||
i = ncol - 1;
|
||||
j = nuncol - 1;
|
||||
for(f=a->frame; f; f=f->anext) {
|
||||
f->rect = rectsubpt(f->rect, f->rect.min);
|
||||
f->crect = rectsubpt(f->crect, f->crect.min);
|
||||
if(f == a->sel)
|
||||
j++;
|
||||
if(!f->collapsed) {
|
||||
if(j < 0 && f != a->sel)
|
||||
f->collapsed = True;
|
||||
else {
|
||||
if(f->crect.height <= minh)
|
||||
f->crect.height = 1;
|
||||
if(Dx(f->crect) <= minh)
|
||||
f->crect.max.x = 1;
|
||||
else
|
||||
f->crect.height -= minh;
|
||||
dy += f->crect.height;
|
||||
f->crect.max.x = minh;
|
||||
dy += Dy(f->crect);
|
||||
}
|
||||
j--;
|
||||
}
|
||||
|
@ -284,37 +256,36 @@ scale_column(Area *a) {
|
|||
|
||||
i = nuncol;
|
||||
for(f=a->frame; f; f=f->anext) {
|
||||
f->rect.x = a->rect.x;
|
||||
f->rect.width = a->rect.width;
|
||||
f->rect.max.x = Dx(a->rect);
|
||||
if(!f->collapsed) {
|
||||
i--;
|
||||
f->rect.height = (float)f->crect.height / dy * surplus;
|
||||
if(!i)
|
||||
f->rect.height = surplus;
|
||||
f->rect.height += minh + frame_delta_h();
|
||||
apply_sizehints(f->client, &f->rect, False, True, NWEST);
|
||||
if(i)
|
||||
f->rect.max.y = (float)Dy(f->crect) / dy * surplus;
|
||||
else
|
||||
f->rect.max.y = surplus;
|
||||
f->rect.max.y += minh + frame_delta_h();
|
||||
|
||||
dy -= f->crect.height;
|
||||
surplus -= f->rect.height - frame_delta_h() - minh;
|
||||
apply_sizehints(f->client, &f->rect, False, True, NWEST);
|
||||
dy -= Dy(f->crect);
|
||||
resize_frame(f, f->rect);
|
||||
|
||||
surplus -= Dy(f->rect) - frame_delta_h() - minh;
|
||||
}else
|
||||
f->rect.height = labelh(&def.font);
|
||||
f->rect.max.y = labelh(def.font);
|
||||
}
|
||||
|
||||
yoff = a->rect.y;
|
||||
yoff = a->rect.min.y;
|
||||
i = nuncol;
|
||||
for(f=a->frame; f; f=f->anext) {
|
||||
f->rect.y = yoff;
|
||||
f->rect.x = a->rect.x;
|
||||
f->rect.width = a->rect.width;
|
||||
if(f->collapsed)
|
||||
yoff += f->rect.height;
|
||||
else{
|
||||
f->rect = rectaddpt(f->rect, Pt(a->rect.min.x, yoff));
|
||||
f->rect.max.x = a->rect.max.x;
|
||||
if(!f->collapsed) {
|
||||
i--;
|
||||
f->rect.height += surplus / nuncol;
|
||||
f->rect.max.y += surplus / nuncol;
|
||||
if(!i)
|
||||
f->rect.height += surplus % nuncol;
|
||||
yoff += f->rect.height;
|
||||
f->rect.max.y += surplus % nuncol;
|
||||
}
|
||||
yoff = f->rect.max.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +301,7 @@ arrange_column(Area *a, Bool dirty) {
|
|||
for(f=a->frame; f; f=f->anext) {
|
||||
f->collapsed = False;
|
||||
if(dirty)
|
||||
f->crect.height = 100;
|
||||
f->crect = Rect(0, 0, 100, 100);
|
||||
}
|
||||
break;
|
||||
case Colstack:
|
||||
|
@ -370,60 +341,51 @@ resize_column(Area *a, int w) {
|
|||
an = a->next;
|
||||
assert(an != nil);
|
||||
|
||||
dw = w - a->rect.width;
|
||||
a->rect.width += dw;
|
||||
an->rect.width -= dw;
|
||||
dw = w - Dx(a->rect);
|
||||
a->rect.max.x += dw;
|
||||
an->rect.min.x += dw;
|
||||
|
||||
arrange_view(a->view);
|
||||
focus_view(screen, a->view);
|
||||
}
|
||||
|
||||
static void
|
||||
resize_colframeh(Frame *f, XRectangle *r) {
|
||||
resize_colframeh(Frame *f, Rectangle *r) {
|
||||
Area *a;
|
||||
Frame *fa, *fb;
|
||||
uint minh;
|
||||
int dy, dh, maxy;
|
||||
|
||||
minh = 2 * labelh(def.font);
|
||||
|
||||
a = f->area;
|
||||
maxy = r_south(r);
|
||||
|
||||
minh = 2 * labelh(&def.font);
|
||||
|
||||
fa = f->anext;
|
||||
for(fb = a->frame; fb; fb = fb->anext)
|
||||
if(fb->anext == f) break;
|
||||
|
||||
if(fb)
|
||||
r->y = max(r->y, fb->rect.y + minh);
|
||||
r->min.y = max(r->min.y, fb->rect.min.y + minh);
|
||||
else
|
||||
r->y = a->rect.y;
|
||||
r->min.y = max(r->min.y, a->rect.min.y);
|
||||
|
||||
if(fa) {
|
||||
if(maxy > r_south(&fa->rect) - minh)
|
||||
maxy = r_south(&fa->rect) - minh;
|
||||
}
|
||||
if(fa)
|
||||
r->max.y = min(r->max.y, fa->rect.max.y - minh);
|
||||
else
|
||||
if(r_south(r) >= r_south(&a->rect))
|
||||
maxy = r_south(&a->rect) - 1;
|
||||
r->max.y = min(r->max.y, a->rect.max.y);
|
||||
|
||||
dy = f->rect.y - r->y;
|
||||
dh = maxy - r_south(&f->rect);
|
||||
if(fb) {
|
||||
fb->rect.height -= dy;
|
||||
resize_frame(fb, &fb->rect);
|
||||
fb->rect.max.y = r->min.y;
|
||||
resize_frame(fb, fb->rect);
|
||||
}
|
||||
if(fa) {
|
||||
fa->rect.height -= dh;
|
||||
resize_frame(fa, &fa->rect);
|
||||
fa->rect.min.y = r->max.y;
|
||||
resize_frame(fa, fa->rect);
|
||||
}
|
||||
|
||||
f->rect.height = maxy - r->y;
|
||||
resize_frame(f, &f->rect);
|
||||
resize_frame(f, *r);
|
||||
}
|
||||
|
||||
void
|
||||
resize_colframe(Frame *f, XRectangle *r) {
|
||||
resize_colframe(Frame *f, Rectangle *r) {
|
||||
Area *a, *al, *ar;
|
||||
View *v;
|
||||
uint minw;
|
||||
|
@ -431,51 +393,42 @@ resize_colframe(Frame *f, XRectangle *r) {
|
|||
|
||||
a = f->area;
|
||||
v = a->view;
|
||||
maxx = r_east(r);
|
||||
maxx = r->max.x;
|
||||
|
||||
minw = screen->rect.width/NCOL;
|
||||
minw = Dx(screen->rect) / NCOL;
|
||||
|
||||
ar = a->next;
|
||||
for(al = v->area->next; al; al = al->next)
|
||||
if(al->next == a) break;
|
||||
|
||||
if(al)
|
||||
r->x = max(r->x, al->rect.x + minw);
|
||||
r->min.x = max(r->min.x, al->rect.min.x + minw);
|
||||
else
|
||||
r->x = max(r->x, 0);
|
||||
r->min.x = max(r->min.x, 0);
|
||||
|
||||
if(ar) {
|
||||
if(maxx >= r_east(&ar->rect) - minw)
|
||||
maxx = r_east(&ar->rect) - minw;
|
||||
if(maxx >= ar->rect.max.x - minw)
|
||||
maxx = ar->rect.max.x - minw;
|
||||
}
|
||||
else
|
||||
if(maxx > screen->rect.width)
|
||||
maxx = screen->rect.width - 1;
|
||||
if(maxx > screen->rect.max.x)
|
||||
maxx = screen->rect.max.x;
|
||||
|
||||
dx = a->rect.x - r->x;
|
||||
dw = maxx - r_east(&a->rect);
|
||||
if(dx) {
|
||||
al->rect.width -= dx;
|
||||
dx = a->rect.min.x - r->min.x;
|
||||
dw = maxx - a->rect.max.x;
|
||||
if(al) {
|
||||
al->rect.max.x -= dx;
|
||||
arrange_column(al, False);
|
||||
}
|
||||
if(dw) {
|
||||
ar->rect.width -= dw;
|
||||
if(ar) {
|
||||
ar->rect.max.x -= dw;
|
||||
arrange_column(ar, False);
|
||||
}
|
||||
|
||||
resize_colframeh(f, r);
|
||||
|
||||
a->rect.width = maxx - r->x;
|
||||
a->rect.max.x = maxx;
|
||||
arrange_view(a->view);
|
||||
|
||||
focus_view(screen, v);
|
||||
}
|
||||
|
||||
Area *
|
||||
new_column(View *v, Area *pos, uint w) {
|
||||
Area *a = create_area(v, pos, w);
|
||||
if(!a)
|
||||
return nil;
|
||||
arrange_view(v);
|
||||
return a;
|
||||
}
|
||||
|
|
115
cmd/wmii/dat.h
115
cmd/wmii/dat.h
|
@ -2,27 +2,17 @@
|
|||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <regex.h>
|
||||
#include <ixp.h>
|
||||
#include "x11.h"
|
||||
|
||||
#define BLITZ_FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
|
||||
#define BLITZ_FOCUSCOLORS "#ffffff #335577 #447799"
|
||||
#define BLITZ_NORMCOLORS "#222222 #eeeeee #666666"
|
||||
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
|
||||
#define FOCUSCOLORS "#ffffff #335577 #447799"
|
||||
#define NORMCOLORS "#222222 #eeeeee #666666"
|
||||
|
||||
typedef struct Blitz Blitz;
|
||||
typedef struct BlitzColor BlitzColor;
|
||||
typedef struct BlitzFont BlitzFont;
|
||||
typedef struct BlitzBrush BlitzBrush;
|
||||
typedef struct CTuple CTuple;
|
||||
|
||||
struct Blitz {
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
};
|
||||
|
||||
enum BlitzAlign {
|
||||
enum Align {
|
||||
NORTH = 0x01,
|
||||
EAST = 0x02,
|
||||
SOUTH = 0x04,
|
||||
|
@ -34,50 +24,26 @@ enum BlitzAlign {
|
|||
CENTER = NEAST | SWEST
|
||||
};
|
||||
|
||||
typedef enum BlitzAlign BlitzAlign;
|
||||
typedef enum Align Align;
|
||||
|
||||
struct BlitzColor {
|
||||
vlong bg;
|
||||
vlong fg;
|
||||
vlong border;
|
||||
struct CTuple {
|
||||
ulong bg;
|
||||
ulong fg;
|
||||
ulong border;
|
||||
char colstr[24]; /* #RRGGBB #RRGGBB #RRGGBB */
|
||||
};
|
||||
|
||||
struct BlitzFont {
|
||||
XFontStruct *xfont;
|
||||
XFontSet set;
|
||||
int ascent;
|
||||
int descent;
|
||||
uint height;
|
||||
char *fontstr;
|
||||
};
|
||||
|
||||
struct BlitzBrush {
|
||||
Blitz *blitz;
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
int border;
|
||||
BlitzColor color;
|
||||
BlitzAlign align;
|
||||
BlitzFont *font;
|
||||
XRectangle rect; /* relative rect */
|
||||
};
|
||||
|
||||
enum {
|
||||
/* WM atom */
|
||||
WMState, WMProtocols, WMDelete,
|
||||
/* NET atom */
|
||||
NetSupported, NetWMName,
|
||||
/* Other */
|
||||
TagsAtom,
|
||||
/* Last atom */
|
||||
AtomLast
|
||||
};
|
||||
|
||||
/* Column modes */
|
||||
enum { Coldefault, Colstack, Colmax };
|
||||
enum {
|
||||
Coldefault, Colstack, Colmax
|
||||
};
|
||||
|
||||
/* Cursor */
|
||||
enum {
|
||||
CurNormal,
|
||||
CurNECorner, CurNWCorner, CurSECorner, CurSWCorner,
|
||||
|
@ -86,8 +52,10 @@ enum {
|
|||
CurLast
|
||||
};
|
||||
|
||||
enum { NCOL = 16 };
|
||||
enum { WM_PROTOCOL_DELWIN = 1 };
|
||||
enum {
|
||||
NCOL = 16,
|
||||
WM_PROTOCOL_DELWIN = 1
|
||||
};
|
||||
|
||||
/* Data Structures */
|
||||
typedef struct View View;
|
||||
|
@ -119,7 +87,7 @@ struct Area {
|
|||
Bool floating;
|
||||
ushort id;
|
||||
int mode;
|
||||
XRectangle rect;
|
||||
Rectangle rect;
|
||||
};
|
||||
|
||||
struct Frame {
|
||||
|
@ -129,13 +97,13 @@ struct Frame {
|
|||
View *view;
|
||||
Area *area;
|
||||
ushort id;
|
||||
XRectangle rect;
|
||||
XRectangle crect;
|
||||
XRectangle revert;
|
||||
Rectangle rect;
|
||||
Rectangle crect;
|
||||
Rectangle revert;
|
||||
Client *client;
|
||||
Bool collapsed;
|
||||
XRectangle grabbox;
|
||||
XRectangle titlebar;
|
||||
Rectangle grabbox;
|
||||
Rectangle titlebar;
|
||||
};
|
||||
|
||||
struct Client {
|
||||
|
@ -156,17 +124,17 @@ struct Client {
|
|||
Bool frame_mapped;
|
||||
int unmapped;
|
||||
Window win;
|
||||
Window trans;
|
||||
Window framewin;
|
||||
XWindow trans;
|
||||
Window *framewin;
|
||||
Cursor cursor;
|
||||
XRectangle rect;
|
||||
Rectangle rect;
|
||||
XSizeHints size;
|
||||
GC gc;
|
||||
};
|
||||
|
||||
struct Divide {
|
||||
Divide *next;
|
||||
Window w;
|
||||
Window *w;
|
||||
Bool mapped;
|
||||
int x;
|
||||
};
|
||||
|
@ -188,7 +156,8 @@ struct Bar {
|
|||
char text[256];
|
||||
char name[256];
|
||||
ushort id;
|
||||
BlitzBrush brush;
|
||||
Rectangle r;
|
||||
CTuple col;
|
||||
};
|
||||
|
||||
struct Rule {
|
||||
|
@ -205,9 +174,9 @@ struct Ruleset {
|
|||
|
||||
/* global variables */
|
||||
struct {
|
||||
BlitzColor focuscolor;
|
||||
BlitzColor normcolor;
|
||||
BlitzFont font;
|
||||
CTuple focuscolor;
|
||||
CTuple normcolor;
|
||||
Font *font;
|
||||
uint border;
|
||||
uint snap;
|
||||
char *keys;
|
||||
|
@ -219,18 +188,20 @@ struct {
|
|||
int colmode;
|
||||
} def;
|
||||
|
||||
enum { BarLeft, BarRight };
|
||||
enum {
|
||||
BarLeft, BarRight
|
||||
};
|
||||
|
||||
struct WMScreen {
|
||||
Bar *bar[2];
|
||||
View *sel;
|
||||
Client *focus;
|
||||
Client *hasgrab;
|
||||
Window barwin;
|
||||
Window *barwin;
|
||||
Image *ibuf;
|
||||
|
||||
XRectangle rect;
|
||||
XRectangle brect;
|
||||
BlitzBrush bbrush;
|
||||
Rectangle rect;
|
||||
Rectangle brect;
|
||||
} *screens, *screen;
|
||||
|
||||
Client *client;
|
||||
|
@ -252,10 +223,8 @@ uint valid_mask;
|
|||
uint num_lock_mask;
|
||||
Bool sel_screen;
|
||||
|
||||
Blitz blz;
|
||||
GC xorgc;
|
||||
Pixmap pmap;
|
||||
Pixmap divmap, divmask;
|
||||
Image xor;
|
||||
Image *divimg, *divmask;
|
||||
|
||||
Atom atom[AtomLast];
|
||||
Cursor cursor[CurLast];
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
uint
|
||||
textwidth_l(BlitzFont *font, char *text, uint len) {
|
||||
if(font->set) {
|
||||
XRectangle r;
|
||||
Rectangle r;
|
||||
XmbTextExtents(font->set, text, len, &r, nil);
|
||||
return r.width;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ draw_label(BlitzBrush *b, char *text) {
|
|||
uint x, y, w, h, len;
|
||||
Bool shortened = False;
|
||||
static char buf[2048];
|
||||
XRectangle r = {0};
|
||||
Rectangle r = {0};
|
||||
XGCValues gcv;
|
||||
|
||||
draw_tile(b);
|
||||
|
@ -151,7 +151,7 @@ draw_label(BlitzBrush *b, char *text) {
|
|||
}
|
||||
|
||||
void
|
||||
drawbg(Display *dpy, Drawable drawable, GC gc, XRectangle *rect,
|
||||
drawbg(Display *dpy, Drawable drawable, GC gc, Rectangle *rect,
|
||||
BlitzColor c, Bool fill, int border)
|
||||
{
|
||||
if(fill) {
|
||||
|
@ -166,32 +166,6 @@ drawbg(Display *dpy, Drawable drawable, GC gc, XRectangle *rect,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
drawcursor(Display *dpy, Drawable drawable, GC gc,
|
||||
int x, int y, uint h, BlitzColor c)
|
||||
{
|
||||
XSegment s[5];
|
||||
|
||||
XSetForeground(dpy, gc, c.fg);
|
||||
XSetLineAttributes(dpy, gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
s[0].x1 = x - 1;
|
||||
s[0].y1 = s[0].y2 = y;
|
||||
s[0].x2 = x + 2;
|
||||
s[1].x1 = x - 1;
|
||||
s[1].y1 = s[1].y2 = y + 1;
|
||||
s[1].x2 = x + 2;
|
||||
s[2].x1 = s[2].x2 = x;
|
||||
s[2].y1 = y;
|
||||
s[2].y2 = y + h;
|
||||
s[3].x1 = x - 1;
|
||||
s[3].y1 = s[3].y2 = y + h;
|
||||
s[3].x2 = x + 2;
|
||||
s[4].x1 = x - 1;
|
||||
s[4].y1 = s[4].y2 = y + h - 1;
|
||||
s[4].x2 = x + 2;
|
||||
XDrawSegments(dpy, drawable, gc, s, 5);
|
||||
}
|
||||
|
||||
static ulong
|
||||
xloadcolor(Blitz *blitz, char *colstr) {
|
||||
XColor color;
|
||||
|
|
|
@ -20,7 +20,7 @@ flushevents(long event_mask, Bool dispatch) {
|
|||
XEvent ev;
|
||||
uint n = 0;
|
||||
|
||||
while(XCheckMaskEvent(blz.dpy, event_mask, &ev)) {
|
||||
while(XCheckMaskEvent(display, event_mask, &ev)) {
|
||||
if(dispatch)
|
||||
dispatch_event(&ev);
|
||||
n++;
|
||||
|
@ -35,20 +35,20 @@ buttonrelease(XEvent *e) {
|
|||
Bar *b;
|
||||
|
||||
ev = &e->xbutton;
|
||||
if(ev->window == screen->barwin) {
|
||||
if(ev->window == screen->barwin->w) {
|
||||
for(b=screen->bar[BarLeft]; b; b=b->next)
|
||||
if(ptinrect(ev->x, ev->y, &b->brush.rect)) {
|
||||
if(ptinrect(Pt(ev->x, ev->y), b->r)) {
|
||||
write_event("LeftBarClick %d %s\n", ev->button, b->name);
|
||||
return;
|
||||
}
|
||||
for(b=screen->bar[BarRight]; b; b=b->next)
|
||||
if(ptinrect(ev->x, ev->y, &b->brush.rect)) {
|
||||
if(ptinrect(Pt(ev->x, ev->y), b->r)) {
|
||||
write_event("RightBarClick %d %s\n", ev->button, b->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if((f = win2frame(ev->window)))
|
||||
write_event("ClientClick 0x%x %d\n", f->client->win, ev->button);
|
||||
write_event("ClientClick 0x%x %d\n", f->client->win.w, ev->button);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -69,50 +69,50 @@ buttonpress(XEvent *e) {
|
|||
break;
|
||||
case Button3:
|
||||
do_mouse_resize(f->client, False,
|
||||
quadrant(&f->rect, ev->x_root, ev->y_root));
|
||||
quadrant(f->rect, Pt(ev->x_root, ev->y_root)));
|
||||
frame_to_top(f);
|
||||
focus(f->client, True);
|
||||
break;
|
||||
default: break;
|
||||
XAllowEvents(blz.dpy, ReplayPointer, ev->time);
|
||||
XAllowEvents(display, ReplayPointer, ev->time);
|
||||
}
|
||||
}else{
|
||||
if(ev->button == Button1) {
|
||||
if(frame_to_top(f))
|
||||
restack_view(f->view);
|
||||
|
||||
else if(ptinrect(ev->x, ev->y, &f->grabbox))
|
||||
else if(ptinrect(Pt(ev->x, ev->y), f->grabbox))
|
||||
do_mouse_resize(f->client, True, CENTER);
|
||||
else if(f->area->floating)
|
||||
if(!ev->subwindow && !ptinrect(ev->x, ev->y, &f->titlebar))
|
||||
if(!ev->subwindow && !ptinrect(Pt(ev->x, ev->y), f->titlebar))
|
||||
do_mouse_resize(f->client, False,
|
||||
quadrant(&f->rect, ev->x_root, ev->y_root));
|
||||
quadrant(f->rect, Pt(ev->x_root, ev->y_root)));
|
||||
|
||||
if(f->client != selclient())
|
||||
focus(f->client, True);
|
||||
}
|
||||
if(ev->subwindow)
|
||||
XAllowEvents(blz.dpy, ReplayPointer, ev->time);
|
||||
XAllowEvents(display, ReplayPointer, ev->time);
|
||||
else {
|
||||
/* Ungrab so a menu can receive events before the button is released */
|
||||
XUngrabPointer(blz.dpy, ev->time);
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabPointer(display, ev->time);
|
||||
XSync(display, False);
|
||||
|
||||
write_event("ClientMouseDown 0x%x %d\n", f->client->win, ev->button);
|
||||
write_event("ClientMouseDown 0x%x %d\n", f->client->win.w, ev->button);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if((d = win2div(ev->window)))
|
||||
mouse_resizecol(d);
|
||||
else
|
||||
XAllowEvents(blz.dpy, ReplayPointer, ev->time);
|
||||
XAllowEvents(display, ReplayPointer, ev->time);
|
||||
}
|
||||
|
||||
static void
|
||||
configurerequest(XEvent *e) {
|
||||
XConfigureRequestEvent *ev;
|
||||
XWindowChanges wc;
|
||||
XRectangle *frect;
|
||||
Rectangle *frect;
|
||||
Client *c;
|
||||
Frame *f;
|
||||
|
||||
|
@ -122,19 +122,19 @@ configurerequest(XEvent *e) {
|
|||
f = c->sel;
|
||||
gravitate_client(c, True);
|
||||
if(ev->value_mask & CWX)
|
||||
c->rect.x = ev->x;
|
||||
c->rect.min.x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
c->rect.y = ev->y;
|
||||
c->rect.min.y = ev->y;
|
||||
if(ev->value_mask & CWWidth)
|
||||
c->rect.width = ev->width;
|
||||
c->rect.max.x = c->rect.min.x + ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->rect.height = ev->height;
|
||||
c->rect.max.y = c->rect.min.y + ev->height;
|
||||
if(ev->value_mask & CWBorderWidth)
|
||||
c->border = ev->border_width;
|
||||
gravitate_client(c, False);
|
||||
|
||||
if((c->rect.height == screen->rect.height)
|
||||
&& (c->rect.width == screen->rect.width)) {
|
||||
if((Dx(c->rect) == Dx(screen->rect))
|
||||
&& (Dy(c->rect) == Dy(screen->rect))) {
|
||||
c->fullscreen = True;
|
||||
if(c->sel) {
|
||||
if(!c->sel->area->floating)
|
||||
|
@ -149,11 +149,8 @@ configurerequest(XEvent *e) {
|
|||
else
|
||||
frect=&c->sel->revert;
|
||||
|
||||
*frect = c->rect;
|
||||
frect->y -= labelh(&def.font);
|
||||
frect->x -= def.border;
|
||||
frect->width += 2 * def.border;
|
||||
frect->height += frame_delta_h();
|
||||
*frect = insetrect(c->rect, -def.border);
|
||||
frect->min.y -= labelh(def.font);
|
||||
|
||||
if(c->sel->area->floating || c->fullscreen)
|
||||
resize_client(c, frect);
|
||||
|
@ -168,8 +165,8 @@ configurerequest(XEvent *e) {
|
|||
wc.sibling = ev->above;
|
||||
wc.stack_mode = ev->detail;
|
||||
ev->value_mask &= ~(CWStackMode|CWSibling);
|
||||
XConfigureWindow(blz.dpy, ev->window, ev->value_mask, &wc);
|
||||
XSync(blz.dpy, False);
|
||||
XConfigureWindow(display, ev->window, ev->value_mask, &wc);
|
||||
XSync(display, False);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,9 +205,9 @@ enternotify(XEvent *e) {
|
|||
if(f->area->floating || !f->collapsed)
|
||||
focus(f->client, False);
|
||||
}
|
||||
set_frame_cursor(f, ev->x, ev->y);
|
||||
set_frame_cursor(f, Pt(ev->x, ev->y));
|
||||
}
|
||||
else if(ev->window == blz.root) {
|
||||
else if(ev->window == scr.root.w) {
|
||||
sel_screen = True;
|
||||
draw_frames();
|
||||
}
|
||||
|
@ -221,7 +218,7 @@ leavenotify(XEvent *e) {
|
|||
XCrossingEvent *ev;
|
||||
|
||||
ev = &e->xcrossing;
|
||||
if((ev->window == blz.root) && !ev->same_screen) {
|
||||
if((ev->window == scr.root.w) && !ev->same_screen) {
|
||||
sel_screen = True;
|
||||
draw_frames();
|
||||
}
|
||||
|
@ -247,7 +244,7 @@ focusin(XEvent *e) {
|
|||
ev = &e->xfocus;
|
||||
/* Yes, we're focusing in on nothing, here. */
|
||||
if(ev->detail == NotifyDetailNone) {
|
||||
XSetInputFocus(blz.dpy, screen->barwin, RevertToParent, CurrentTime);
|
||||
XSetInputFocus(display, screen->barwin->w, RevertToParent, CurrentTime);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,12 +272,12 @@ focusin(XEvent *e) {
|
|||
if(old && old->sel)
|
||||
draw_frame(old->sel);
|
||||
}
|
||||
}else if(ev->window == screen->barwin) {
|
||||
}else if(ev->window == screen->barwin->w) {
|
||||
print_focus(nil, "<nil>");
|
||||
screen->focus = nil;
|
||||
}else if(ev->mode == NotifyGrab) {
|
||||
if(ev->window == blz.root)
|
||||
if(XCheckMaskEvent(blz.dpy, KeyPressMask, &me)) {
|
||||
if(ev->window == scr.root.w)
|
||||
if(XCheckMaskEvent(display, KeyPressMask, &me)) {
|
||||
/* wmii has grabbed focus */
|
||||
screen->hasgrab = &c_root;
|
||||
dispatch_event(&me);
|
||||
|
@ -337,7 +334,7 @@ expose(XEvent *e) {
|
|||
|
||||
ev = &e->xexpose;
|
||||
if(ev->count == 0) {
|
||||
if(ev->window == screen->barwin)
|
||||
if(ev->window == screen->barwin->w)
|
||||
draw_bar(screen);
|
||||
else if((f = win2frame(ev->window)))
|
||||
draw_frame(f);
|
||||
|
@ -352,8 +349,8 @@ keypress(XEvent *e) {
|
|||
|
||||
ev = &e->xkey;
|
||||
ev->state &= valid_mask;
|
||||
if(ev->window == blz.root)
|
||||
kpress(blz.root, ev->state, (KeyCode) ev->keycode);
|
||||
if(ev->window == scr.root.w)
|
||||
kpress(scr.root.w, ev->state, (KeyCode) ev->keycode);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -372,10 +369,10 @@ maprequest(XEvent *e) {
|
|||
static XWindowAttributes wa;
|
||||
|
||||
ev = &e->xmaprequest;
|
||||
if(!XGetWindowAttributes(blz.dpy, ev->window, &wa))
|
||||
if(!XGetWindowAttributes(display, ev->window, &wa))
|
||||
return;
|
||||
if(wa.override_redirect) {
|
||||
XSelectInput(blz.dpy, ev->window,
|
||||
XSelectInput(display, ev->window,
|
||||
(StructureNotifyMask | PropertyChangeMask));
|
||||
return;
|
||||
}
|
||||
|
@ -390,7 +387,7 @@ motionnotify(XEvent *e) {
|
|||
|
||||
ev = &e->xmotion;
|
||||
if((f = win2frame(ev->window)))
|
||||
set_frame_cursor(f, ev->x, ev->y);
|
||||
set_frame_cursor(f, Pt(ev->x, ev->y));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -450,12 +447,12 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
|||
void
|
||||
check_x_event(IxpConn *c) {
|
||||
XEvent ev;
|
||||
while(XPending(blz.dpy)) {
|
||||
XNextEvent(blz.dpy, &ev);
|
||||
while(XPending(display)) {
|
||||
XNextEvent(display, &ev);
|
||||
if(verbose)
|
||||
printevent(&ev);
|
||||
dispatch_event(&ev);
|
||||
/* Hack to alleviate an apparant Xlib bug */
|
||||
XPending(blz.dpy);
|
||||
XPending(display);
|
||||
}
|
||||
}
|
||||
|
|
112
cmd/wmii/fns.h
112
cmd/wmii/fns.h
|
@ -20,12 +20,11 @@ Client *area_selclient(Area*);
|
|||
Bar *create_bar(Bar **b_link, char *name);
|
||||
void destroy_bar(Bar **b_link, Bar*);
|
||||
void draw_bar(WMScreen *s);
|
||||
void draw_border(BlitzBrush*);
|
||||
void resize_bar();
|
||||
Bar *bar_of_name(Bar *b_link, const char *name);
|
||||
|
||||
/* client.c */
|
||||
Client *create_client(Window, XWindowAttributes*);
|
||||
Client *create_client(XWindow, XWindowAttributes*);
|
||||
void destroy_client(Client*);
|
||||
void configure_client(Client*);
|
||||
void prop_client(Client *c, Atom);
|
||||
|
@ -33,54 +32,38 @@ void kill_client(Client*);
|
|||
void gravitate_client(Client*, Bool invert);
|
||||
void map_client(Client*);
|
||||
void unmap_client(Client*, int state);
|
||||
void map_frame(Client*);
|
||||
void unmap_frame(Client*);
|
||||
int map_frame(Client*);
|
||||
int unmap_frame(Client*);
|
||||
void set_cursor(Client*, Cursor cur);
|
||||
void focus_frame(Frame*, Bool restack);
|
||||
void reparent_client(Client*, Window w, int x, int y);
|
||||
void reparent_client(Client*, Window*, Point);
|
||||
void manage_client(Client*);
|
||||
void focus(Client*, Bool restack);
|
||||
void focus_client(Client*);
|
||||
void resize_client(Client*, XRectangle*);
|
||||
void apply_sizehints(Client*, XRectangle*, Bool floating, Bool frame, BlitzAlign sticky);
|
||||
void resize_client(Client*, Rectangle*);
|
||||
void apply_sizehints(Client*, Rectangle*, Bool floating, Bool frame, Align sticky);
|
||||
char *send_client(Frame*, char*, Bool swap);
|
||||
char * message_client(Client*, char*);
|
||||
void move_client(Client*, char *arg);
|
||||
void size_client(Client*, char *arg);
|
||||
Client *selclient();
|
||||
Frame *win2frame(Window);
|
||||
Client *win2client(Window);
|
||||
Frame *win2frame(XWindow);
|
||||
Client *win2client(XWindow);
|
||||
void update_client_grab(Client*);
|
||||
void apply_rules(Client*);
|
||||
void apply_tags(Client*, const char*);
|
||||
|
||||
/* column.c */
|
||||
Divide *win2div(Window);
|
||||
Divide *win2div(XWindow);
|
||||
void update_dividers();
|
||||
void update_divs();
|
||||
void draw_div(Divide*);
|
||||
void arrange_column(Area*, Bool dirty);
|
||||
void resize_column(Area*, int w);
|
||||
void resize_colframe(Frame*, XRectangle*);
|
||||
void resize_colframe(Frame*, Rectangle*);
|
||||
int str2colmode(const char *str);
|
||||
Area *new_column(View*, Area *pos, uint w);
|
||||
|
||||
/* draw.c */
|
||||
int loadcolor(Blitz *, BlitzColor *);
|
||||
void draw_label(BlitzBrush *, char *text);
|
||||
void draw_tile(BlitzBrush *);
|
||||
void draw_rect(BlitzBrush *);
|
||||
|
||||
void drawbg(Display*, Drawable, GC,
|
||||
XRectangle*, BlitzColor, Bool fill, Bool border);
|
||||
void drawcursor(Display*, Drawable, GC,
|
||||
int x, int y, uint h, BlitzColor);
|
||||
uint textwidth(BlitzFont*, char *text);
|
||||
uint textwidth_l(BlitzFont*, char *text, uint len);
|
||||
void loadfont(Blitz*, BlitzFont*);
|
||||
uint labelh(BlitzFont *font);
|
||||
char *parse_colors(char **buf, int *buflen, BlitzColor*);
|
||||
|
||||
/* event.c */
|
||||
void dispatch_event(XEvent*);
|
||||
void check_x_event(IxpConn*);
|
||||
|
@ -90,18 +73,18 @@ uint flushevents(long even_mask, Bool dispatch);
|
|||
Frame *create_frame(Client*, View*);
|
||||
void remove_frame(Frame*);
|
||||
void insert_frame(Frame *pos, Frame*, Bool before);
|
||||
void resize_frame(Frame*, XRectangle*);
|
||||
void resize_frame(Frame*, Rectangle);
|
||||
Bool frame_to_top(Frame *f);
|
||||
void set_frame_cursor(Frame*, int x, int y);
|
||||
void set_frame_cursor(Frame*, Point);
|
||||
void swap_frames(Frame*, Frame*);
|
||||
int frame_delta_h();
|
||||
void frame2client(Frame*, XRectangle*);
|
||||
void client2frame(Frame*, XRectangle*);
|
||||
Rectangle frame2client(Frame*, Rectangle);
|
||||
Rectangle client2frame(Frame*, Rectangle);
|
||||
int ingrabbox(Frame*, int x, int y);
|
||||
void draw_frame(Frame*);
|
||||
void draw_frames();
|
||||
void update_frame_widget_colors(Frame*);
|
||||
void check_frame_constraints(XRectangle*);
|
||||
Rectangle constrain(Rectangle);
|
||||
|
||||
/* fs.c */
|
||||
void fs_attach(Ixp9Req*);
|
||||
|
@ -118,28 +101,25 @@ void fs_write(Ixp9Req*);
|
|||
void write_event(char*, ...);
|
||||
|
||||
/* geom.c */
|
||||
Bool ptinrect(int x, int y, XRectangle*);
|
||||
BlitzAlign quadrant(XRectangle*, int x, int y);
|
||||
Cursor cursor_of_quad(BlitzAlign);
|
||||
int strtorect(XRectangle*, const char*);
|
||||
BlitzAlign get_sticky(XRectangle *src, XRectangle *dst);
|
||||
int r_east(XRectangle*);
|
||||
int r_south(XRectangle*);
|
||||
Bool ptinrect(Point, Rectangle);
|
||||
Align quadrant(Rectangle, Point);
|
||||
Cursor cursor_of_quad(Align);
|
||||
Align get_sticky(Rectangle src, Rectangle dst);
|
||||
|
||||
/* key.c */
|
||||
void kpress(Window, ulong mod, KeyCode);
|
||||
void kpress(XWindow, ulong mod, KeyCode);
|
||||
void update_keys();
|
||||
void init_lock_keys();
|
||||
ulong mod_key_of_str(char*);
|
||||
|
||||
/* mouse.c */
|
||||
void mouse_resizecol(Divide*);
|
||||
void do_mouse_resize(Client*, Bool opaque, BlitzAlign);
|
||||
void grab_mouse(Window, ulong mod, ulong button);
|
||||
void ungrab_mouse(Window, ulong mod, uint button);
|
||||
BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current,
|
||||
BlitzAlign *mask, int snapw);
|
||||
void grab_button(Window, uint button, ulong mod);
|
||||
void do_mouse_resize(Client*, Bool opaque, Align);
|
||||
void grab_mouse(XWindow, ulong mod, ulong button);
|
||||
void ungrab_mouse(XWindow, ulong mod, uint button);
|
||||
Align snap_rect(Rectangle *rects, int num, Rectangle *current,
|
||||
Align *mask, int snapw);
|
||||
void grab_button(XWindow, uint button, ulong mod);
|
||||
|
||||
/* rule.c */
|
||||
void update_rules(Rule**, const char*);
|
||||
|
@ -147,12 +127,12 @@ void trim(char *str, const char *chars);
|
|||
|
||||
/* view.c */
|
||||
void arrange_view(View*);
|
||||
void scale_view(View*, float w);
|
||||
void scale_view(View*, int w);
|
||||
View *get_view(const char*);
|
||||
View *create_view(const char*);
|
||||
void focus_view(WMScreen*, View*);
|
||||
void update_client_views(Client*, char**);
|
||||
XRectangle *rects_of_view(View*, uint *num, Frame *ignore);
|
||||
Rectangle *rects_of_view(View*, uint *num, Frame *ignore);
|
||||
View *view_of_id(ushort);
|
||||
void select_view(const char*);
|
||||
void attach_to_view(View*, Frame*);
|
||||
|
@ -167,3 +147,39 @@ uint newcolw_of_view(View*, int i);
|
|||
/* wm.c */
|
||||
int wmii_error_handler(Display*, XErrorEvent *error);
|
||||
int win_proto(Window);
|
||||
|
||||
/* x11.c */
|
||||
XRectangle XRect(Rectangle r);
|
||||
int eqrect(Rectangle a, Rectangle b);
|
||||
Point addpt(Point p, Point q);
|
||||
Point subpt(Point p, Point q);
|
||||
Rectangle insetrect(Rectangle r, int n);
|
||||
Rectangle rectaddpt(Rectangle r, Point p);
|
||||
Rectangle rectsubpt(Rectangle r, Point p);
|
||||
void initdisplay();
|
||||
Image * allocimage(int w, int h, int depth);
|
||||
void freeimage(Image *img);
|
||||
Window *createwindow(Window *parent, Rectangle r, int depth, uint class, WinAttr *wa, int valuemask);
|
||||
void destroywindow(Window *w);
|
||||
void setwinattr(Window *w, WinAttr *wa, int valmask);
|
||||
void reshapewin(Window *w, Rectangle r);
|
||||
void movewin(Window *w, Point pt);
|
||||
int mapwin(Window *w);
|
||||
int unmapwin(Window *w);
|
||||
uint winprotocols(Window *w);
|
||||
void setshapemask(Window *dst, Image *src, Point pt);
|
||||
void border(Image *dst, Rectangle r, int w, ulong col);
|
||||
void fill(Image *dst, Rectangle r, ulong col);
|
||||
void drawpoly(Image *dst, Point *pt, int np, int cap, int w, ulong col);
|
||||
void fillpoly(Image *dst, Point *pt, int np, ulong col);
|
||||
void drawline(Image *dst, Point p1, Point p2, int cap, int w, ulong col);
|
||||
void drawstring(Image *dst, Font *font, Rectangle r, Align align, char *text, ulong col);
|
||||
void copyimage(Image *dst, Rectangle r, Image *src, Point p);
|
||||
Bool namedcolor(char *name, ulong *ret);
|
||||
Bool loadcolor(CTuple *c, char *str);
|
||||
Font * loadfont(char *name);
|
||||
void freefont(Font *f);
|
||||
uint textwidth_l(Font *font, char *text, uint len);
|
||||
uint textwidth(Font *font, char *text);
|
||||
uint labelh(Font *font);
|
||||
Atom xatom(char *name);
|
||||
|
|
282
cmd/wmii/frame.c
282
cmd/wmii/frame.c
|
@ -10,20 +10,23 @@
|
|||
Frame *
|
||||
create_frame(Client *c, View *v) {
|
||||
static ushort id = 1;
|
||||
Frame *f = emallocz(sizeof(Frame));
|
||||
|
||||
Frame *f;
|
||||
|
||||
f = emallocz(sizeof *f);
|
||||
f->id = id++;
|
||||
f->client = c;
|
||||
f->view = v;
|
||||
|
||||
if(c->sel) {
|
||||
f->revert = c->sel->revert;
|
||||
f->rect = c->sel->rect;
|
||||
}
|
||||
else{
|
||||
c->sel = f;
|
||||
f->revert = f->rect = c->rect;
|
||||
f->revert.width = f->rect.width += 2 * def.border;
|
||||
f->revert.height = f->rect.height += frame_delta_h();
|
||||
f->rect = c->rect;
|
||||
f->rect.max.x += 2 * def.border;
|
||||
f->rect.max.y += frame_delta_h();
|
||||
f->revert = f->rect;
|
||||
}
|
||||
f->collapsed = False;
|
||||
|
||||
|
@ -73,90 +76,90 @@ insert_frame(Frame *pos, Frame *f, Bool before) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
frame2client(Frame *f, XRectangle *r) {
|
||||
Rectangle
|
||||
frame2client(Frame *f, Rectangle r) {
|
||||
if(f->area->floating) {
|
||||
r->width = max(r->width - def.border * 2, 1);
|
||||
r->height = max(r->height - frame_delta_h(), 1);
|
||||
r.max.x -= def.border * 2;
|
||||
r.max.y -= frame_delta_h();
|
||||
}else {
|
||||
r->width = max(r->width - 2, 1);
|
||||
r->height = max(r->height - labelh(&def.font) - 1, 1);
|
||||
r.max.x -= 2;
|
||||
r.max.y -= labelh(def.font) - 1;
|
||||
}
|
||||
r.max.x = max(r.min.x+1, r.max.x);
|
||||
r.max.y = max(r.min.y+1, r.max.y);
|
||||
return r;
|
||||
}
|
||||
|
||||
Rectangle
|
||||
client2frame(Frame *f, Rectangle r) {
|
||||
if(f->area->floating) {
|
||||
r.max.x += def.border * 2;
|
||||
r.max.y += frame_delta_h();
|
||||
}else {
|
||||
r.max.y += 2;
|
||||
r.max.x +=labelh(def.font) + 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
client2frame(Frame *f, XRectangle *r) {
|
||||
if(f->area->floating) {
|
||||
r->width += def.border * 2;
|
||||
r->height += frame_delta_h();
|
||||
}else {
|
||||
r->width += 2;
|
||||
r->height +=labelh(&def.font) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
resize_frame(Frame *f, XRectangle *r) {
|
||||
BlitzAlign stickycorner;
|
||||
resize_frame(Frame *f, Rectangle r) {
|
||||
Align stickycorner;
|
||||
Point pt;
|
||||
Client *c;
|
||||
|
||||
c = f->client;
|
||||
stickycorner = get_sticky(&f->rect, r);
|
||||
stickycorner = get_sticky(f->rect, r);
|
||||
|
||||
f->rect = *r;
|
||||
f->crect = *r;
|
||||
f->crect = r;
|
||||
apply_sizehints(c, &f->crect, f->area->floating, True, stickycorner);
|
||||
|
||||
if(Dx(r) <= 0 || Dy(r) <= 0)
|
||||
asm("int $3");
|
||||
|
||||
if(f->area->floating)
|
||||
f->rect = f->crect;
|
||||
|
||||
frame2client(f, &f->crect);
|
||||
|
||||
if(f->crect.height < labelh(&def.font))
|
||||
f->collapsed = True;
|
||||
else
|
||||
f->collapsed = False;
|
||||
f->rect = r;
|
||||
|
||||
if(f->crect.width < labelh(&def.font)) {
|
||||
f->rect.width = frame_delta_h();
|
||||
f->crect = frame2client(f, f->crect);
|
||||
f->crect = rectsubpt(f->crect, f->crect.min);
|
||||
|
||||
if(Dx(f->crect) < labelh(def.font)) {
|
||||
f->rect.max.x = f->rect.min.x + frame_delta_h();
|
||||
f->collapsed = True;
|
||||
}
|
||||
|
||||
if(f->collapsed) {
|
||||
f->rect.height = labelh(&def.font);
|
||||
f->rect.max.y= f->rect.min.y + labelh(def.font);
|
||||
f->crect = f->rect;
|
||||
}
|
||||
f->crect.y = labelh(&def.font);
|
||||
f->crect.x = (f->rect.width - f->crect.width) / 2;
|
||||
|
||||
|
||||
pt.y = labelh(def.font);
|
||||
|
||||
if(f->area->floating) {
|
||||
if(c->fullscreen) {
|
||||
f->crect.width = screen->rect.width;
|
||||
f->crect.height = screen->rect.height;
|
||||
|
||||
f->rect = f->crect;
|
||||
f->rect.x = -def.border;
|
||||
f->rect.y = -labelh(&def.font);
|
||||
client2frame(f, &f->rect);
|
||||
f->crect = screen->rect;
|
||||
f->rect = client2frame(f, f->crect);
|
||||
pt.x = (Dx(f->rect) - Dx(f->crect)) / 2;
|
||||
f->rect = rectsubpt(f->rect, pt);
|
||||
}else
|
||||
check_frame_constraints(&f->rect);
|
||||
f->rect = constrain(f->rect);
|
||||
}
|
||||
pt.x = (Dx(f->rect) - Dx(f->crect)) / 2;
|
||||
f->crect = rectaddpt(f->crect, pt);
|
||||
}
|
||||
|
||||
void
|
||||
set_frame_cursor(Frame *f, int x, int y) {
|
||||
XRectangle r;
|
||||
set_frame_cursor(Frame *f, Point pt) {
|
||||
Rectangle r;
|
||||
Cursor cur;
|
||||
|
||||
if(f->area->floating
|
||||
&& !ptinrect(x, y, &f->titlebar)
|
||||
&& !ptinrect(x, y, &f->crect)
|
||||
&& !ingrabbox(f, x, y)) {
|
||||
r = f->rect;
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
cur = cursor_of_quad(quadrant(&r, x, y));
|
||||
&& !ptinrect(pt, f->titlebar)
|
||||
&& !ptinrect(pt, f->crect)) {
|
||||
r = rectsubpt(f->rect, f->rect.min);
|
||||
cur = cursor_of_quad(quadrant(r, pt));
|
||||
set_cursor(f->client, cur);
|
||||
} else
|
||||
set_cursor(f->client, cursor[CurNormal]);
|
||||
|
@ -170,18 +173,21 @@ frame_to_top(Frame *f) {
|
|||
a = f->area;
|
||||
if(!a->floating || f == a->stack)
|
||||
return False;
|
||||
|
||||
for(tf=&a->stack; *tf; tf=&(*tf)->snext)
|
||||
if(*tf == f) break;
|
||||
*tf = f->snext;
|
||||
|
||||
f->snext = a->stack;
|
||||
a->stack = f;
|
||||
|
||||
update_client_grab(f->client);
|
||||
return True;
|
||||
}
|
||||
|
||||
void
|
||||
swap_frames(Frame *fa, Frame *fb) {
|
||||
XRectangle trect;
|
||||
Rectangle trect;
|
||||
Area *a;
|
||||
Frame **fp_a, **fp_b, *ft;
|
||||
|
||||
|
@ -259,124 +265,60 @@ focus_frame(Frame *f, Bool restack) {
|
|||
|
||||
int
|
||||
frame_delta_h() {
|
||||
return def.border + labelh(&def.font);
|
||||
}
|
||||
|
||||
int
|
||||
ingrabbox(Frame *f, int x, int y) {
|
||||
int dx, h;
|
||||
|
||||
if(f->area->floating)
|
||||
return 0;
|
||||
|
||||
h = labelh(&def.font) / 3;
|
||||
h = max(h, 4);
|
||||
|
||||
if((f == f->area->frame) && f->area->next)
|
||||
if(x >= f->rect.width - h) {
|
||||
dx = x - (f->rect.width - h);
|
||||
if(y <= dx)
|
||||
return 1;
|
||||
}
|
||||
if((f == f->area->frame) && (f->area != f->view->area->next))
|
||||
if(x <= h && y <= h - x)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return def.border + labelh(def.font);
|
||||
}
|
||||
|
||||
void
|
||||
draw_frame(Frame *f) {
|
||||
BlitzBrush br = { 0 };
|
||||
Rectangle r, fr;
|
||||
CTuple *col;
|
||||
Frame *tf;
|
||||
|
||||
if(f->view != screen->sel)
|
||||
return;
|
||||
|
||||
br.blitz = &blz;
|
||||
br.font = &def.font;
|
||||
br.drawable = pmap;
|
||||
br.gc = f->client->gc;
|
||||
if(f->client == screen->focus)
|
||||
br.color = def.focuscolor;
|
||||
col = &def.focuscolor;
|
||||
else
|
||||
br.color = def.normcolor;
|
||||
col = &def.normcolor;
|
||||
if(!f->area->floating && f->area->mode == Colmax)
|
||||
for(tf = f->area->frame; tf; tf=tf->anext)
|
||||
if(tf->client == screen->focus) {
|
||||
br.color = def.focuscolor;
|
||||
col = &def.focuscolor;
|
||||
break;
|
||||
}
|
||||
|
||||
br.rect = f->rect;
|
||||
br.rect.x = 0;
|
||||
br.rect.y = 0;
|
||||
draw_tile(&br);
|
||||
/* background */
|
||||
fr = rectsubpt(f->rect, f->rect.min);
|
||||
r = fr;
|
||||
fill(screen->ibuf, r, col->bg);
|
||||
border(screen->ibuf, r, 1, col->border);
|
||||
|
||||
br.rect.x += def.font.height - 3;
|
||||
br.rect.width -= br.rect.x;
|
||||
br.rect.height = labelh(&def.font);
|
||||
draw_label(&br, f->client->name);
|
||||
r.max.y = r.min.y + labelh(def.font);
|
||||
border(screen->ibuf, r, 1, col->border);
|
||||
|
||||
br.border = 1;
|
||||
br.rect.width += br.rect.x;
|
||||
br.rect.x = 0;
|
||||
f->titlebar.x = br.rect.x + 3;
|
||||
f->titlebar.height = br.rect.height - 3;
|
||||
f->titlebar.y = br.rect.y + 3;
|
||||
f->titlebar.width = br.rect.width - 6;
|
||||
draw_border(&br);
|
||||
br.rect.height = f->rect.height;
|
||||
if(def.border)
|
||||
draw_border(&br);
|
||||
f->titlebar = insetrect(r, 3);
|
||||
f->titlebar.max.y += 3;
|
||||
|
||||
/* grabbox */
|
||||
r.min = Pt(2, 2);
|
||||
r.max.x = r.min.x + def.font->height - 3;
|
||||
r.max.y -= 2;
|
||||
f->grabbox = r;
|
||||
|
||||
if(f->client->urgent)
|
||||
br.color.bg = br.color.fg;
|
||||
br.rect.x = 2;
|
||||
br.rect.y = 2;
|
||||
br.rect.height = labelh(&def.font) - 4;
|
||||
br.rect.width = def.font.height - 3;
|
||||
f->grabbox = br.rect;
|
||||
draw_tile(&br);
|
||||
fill(screen->ibuf, r, col->fg);
|
||||
border(screen->ibuf, r, 1, col->border);
|
||||
|
||||
#if 0
|
||||
if(!f->area->floating) {
|
||||
XSetLineAttributes(blz.dpy, br.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
h = labelh(&def.font) / 3;
|
||||
h = max(h, 4);
|
||||
if((f == f->area->frame) && f->area->next) {
|
||||
pt[0] = (XPoint){ f->rect.width - h, 0 };
|
||||
pt[1] = (XPoint){ f->rect.width, h };
|
||||
pt[2] = (XPoint){ f->rect.width, 0 };
|
||||
XSetForeground(blz.dpy, br.gc, def.normcolor.bg);
|
||||
XFillPolygon(blz.dpy, br.drawable, br.gc, pt, 3, Convex, CoordModeOrigin);
|
||||
XSetForeground(blz.dpy, br.gc, br.color.border);
|
||||
XDrawLines(blz.dpy, br.drawable, br.gc, pt, 2, CoordModeOrigin);
|
||||
}
|
||||
if((f == f->area->frame) && (f->area != f->view->area->next)) {
|
||||
pt[0] = (XPoint){ h, 0 };
|
||||
pt[1] = (XPoint){ 0, h };
|
||||
pt[2] = (XPoint){ 0, 0 };
|
||||
XSetForeground(blz.dpy, br.gc, def.normcolor.bg);
|
||||
XFillPolygon(blz.dpy, br.drawable, br.gc, pt, 3, Convex, CoordModeOrigin);
|
||||
XSetForeground(blz.dpy, br.gc, br.color.border);
|
||||
XDrawLines(blz.dpy, br.drawable, br.gc, pt, 2, CoordModeOrigin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
r.min.x = r.max.x;
|
||||
r.max.x = fr.max.x;
|
||||
r.min.y = 0;
|
||||
r.max.y = labelh(def.font);
|
||||
drawstring(screen->ibuf, def.font, r, WEST,
|
||||
f->client->name, col->fg);
|
||||
|
||||
XCopyArea(
|
||||
/* display */ blz.dpy,
|
||||
/* src */ pmap,
|
||||
/* dest */ f->client->framewin,
|
||||
/* gc */ f->client->gc,
|
||||
/* x, y */ 0, 0,
|
||||
/* width */ f->rect.width,
|
||||
/* height */ f->rect.height,
|
||||
/* dest_x */ 0,
|
||||
/* dest_y */ 0
|
||||
);
|
||||
XSync(blz.dpy, False);
|
||||
copyimage(f->client->framewin, fr, screen->ibuf, ZP);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -388,24 +330,26 @@ draw_frames() {
|
|||
draw_frame(c->sel);
|
||||
}
|
||||
|
||||
void
|
||||
check_frame_constraints(XRectangle *rect) {
|
||||
int max_height;
|
||||
Rectangle
|
||||
constrain(Rectangle r) {
|
||||
Rectangle sr;
|
||||
int barheight;
|
||||
|
||||
barheight = screen->brect.height;
|
||||
max_height = screen->rect.height - barheight;
|
||||
sr = screen->rect;
|
||||
barheight = Dy(screen->brect);
|
||||
sr.max.y -= barheight;
|
||||
|
||||
if(rect->height > max_height)
|
||||
rect->height = max_height;
|
||||
if(rect->width > screen->rect.width)
|
||||
rect->width = screen->rect.width;
|
||||
if(rect->x + barheight > screen->rect.width)
|
||||
rect->x = screen->rect.width - barheight;
|
||||
if(rect->y + barheight > max_height)
|
||||
rect->y = max_height - barheight;
|
||||
if(r_east(rect) < barheight)
|
||||
rect->x = barheight - rect->width;
|
||||
if(r_south(rect) < barheight)
|
||||
rect->y = barheight - rect->height;
|
||||
if(Dx(r) > Dx(sr))
|
||||
r.max.x = r.min.x + Dx(sr);
|
||||
if(Dy(r) > Dy(sr))
|
||||
r.max.y = r.min.y + Dy(sr);
|
||||
if(r.min.x > sr.max.x - barheight)
|
||||
rectsubpt(r, Pt(sr.min.x - sr.max.x + barheight, 0));
|
||||
if(r.min.y > sr.max.y - barheight)
|
||||
rectsubpt(r, Pt(0, sr.min.y - sr.max.y + barheight));
|
||||
if(r.max.x < barheight)
|
||||
rectaddpt(r, Pt(barheight - sr.max.x, 0));
|
||||
if(r.max.y < barheight)
|
||||
rectaddpt(r, Pt(0, barheight - sr.max.y));
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <regex.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -38,7 +40,7 @@ struct FileId {
|
|||
View *view;
|
||||
Client *client;
|
||||
Ruleset *rule;
|
||||
BlitzColor *col;
|
||||
CTuple *col;
|
||||
} content;
|
||||
uint id;
|
||||
uint index;
|
||||
|
@ -218,6 +220,33 @@ data_to_cstring(Ixp9Req *r) {
|
|||
r->ifcall.data[i - 1] = '\0';
|
||||
}
|
||||
|
||||
/* Should be somewhere else */
|
||||
char *
|
||||
parse_colors(char **buf, int *buflen, CTuple *col) {
|
||||
static regex_t reg;
|
||||
static Bool compiled;
|
||||
|
||||
if(!compiled) {
|
||||
compiled = 1;
|
||||
regcomp(®, "^#[0-9a-f]{6} #[0-9a-f]{6} #[0-9a-f]{6}([[:space:]]|$)",
|
||||
REG_EXTENDED|REG_NOSUB|REG_ICASE);
|
||||
}
|
||||
|
||||
if(*buflen < 23 || regexec(®, *buf, 0, 0, 0))
|
||||
return "bad value";
|
||||
|
||||
(*buf)[23] = '\0';
|
||||
loadcolor(col, *buf);
|
||||
|
||||
*buf += 23;
|
||||
*buflen -= 23;
|
||||
if(*buflen > 0) {
|
||||
(*buf)++;
|
||||
(*buflen)--;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
char *
|
||||
message_root(char *message)
|
||||
{
|
||||
|
@ -253,9 +282,9 @@ message_root(char *message)
|
|||
}
|
||||
else if(!strncmp(message, "font ", 5)) {
|
||||
message += 5;
|
||||
free(def.font.fontstr);
|
||||
def.font.fontstr = estrdup(message);
|
||||
loadfont(&blz, &def.font);
|
||||
freefont(def.font);
|
||||
def.font = loadfont(message);
|
||||
assert(def.font);
|
||||
resize_bar(screen);
|
||||
}
|
||||
else if(!strncmp(message, "border ", 7)) {
|
||||
|
@ -287,7 +316,7 @@ read_root_ctl() {
|
|||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "view %s\n", screen->sel->name);
|
||||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "focuscolors %s\n", def.focuscolor.colstr);
|
||||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "normcolors %s\n", def.normcolor.colstr);
|
||||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "font %s\n", def.font.fontstr);
|
||||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "font %s\n", def.font->name);
|
||||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "grabmod %s\n", def.grabmod);
|
||||
i += snprintf(&buffer[i], (sizeof(buffer) - i), "border %d\n", def.border);
|
||||
return buffer;
|
||||
|
@ -381,8 +410,8 @@ lookup_file(FileId *parent, char *name)
|
|||
*last = file;
|
||||
last = &file->next;
|
||||
file->content.client = c;
|
||||
file->id = c->win;
|
||||
file->index = c->win;
|
||||
file->id = c->win.w;
|
||||
file->index = c->win.w;
|
||||
file->tab = *dir;
|
||||
file->tab.name = estrdup("sel");
|
||||
}if(name) goto LastItem;
|
||||
|
@ -392,16 +421,16 @@ lookup_file(FileId *parent, char *name)
|
|||
if(*name) goto NextItem;
|
||||
}
|
||||
for(c=client; c; c=c->next) {
|
||||
if(!name || c->win == id) {
|
||||
if(!name || c->win.w == id) {
|
||||
file = get_file();
|
||||
*last = file;
|
||||
last = &file->next;
|
||||
file->content.client = c;
|
||||
file->id = c->win;
|
||||
file->index = c->win;
|
||||
file->id = c->win.w;
|
||||
file->index = c->win.w;
|
||||
file->tab = *dir;
|
||||
file->tab.name = emallocz(16);
|
||||
snprintf(file->tab.name, 16, "0x%x", (uint)c->win);
|
||||
snprintf(file->tab.name, 16, "0x%x", (uint)c->win.w);
|
||||
if(name) goto LastItem;
|
||||
}
|
||||
}
|
||||
|
@ -917,7 +946,7 @@ fs_clunk(Ixp9Req *r) {
|
|||
case FsFBar:
|
||||
buf = f->content.bar->buf;
|
||||
i = strlen(f->content.bar->buf);
|
||||
parse_colors(&buf, &i, &f->content.bar->brush.color);
|
||||
parse_colors(&buf, &i, &f->content.bar->col);
|
||||
while(i > 0 && buf[i - 1] == '\n')
|
||||
buf[--i] = '\0';
|
||||
strncpy(f->content.bar->text, buf, sizeof(f->content.bar->text));
|
||||
|
|
|
@ -7,31 +7,31 @@
|
|||
#include "fns.h"
|
||||
|
||||
Bool
|
||||
ptinrect(int x, int y, XRectangle * r) {
|
||||
return (x >= r->x) && (x < r_east(r))
|
||||
&& (y >= r->y) && (y < r_south(r));
|
||||
ptinrect(Point pt, Rectangle r) {
|
||||
return (pt.x >= r.min.x) && (pt.x < r.max.x)
|
||||
&& (pt.y >= r.min.y) && (pt.y < r.max.y);
|
||||
}
|
||||
|
||||
BlitzAlign
|
||||
quadrant(XRectangle *rect, int x, int y) {
|
||||
BlitzAlign ret = 0;
|
||||
x -= rect->x;
|
||||
y -= rect->y;
|
||||
Align
|
||||
quadrant(Rectangle r, Point pt) {
|
||||
Align ret = 0;
|
||||
|
||||
if(x >= rect->width * .5)
|
||||
pt = subpt(pt, r.min);
|
||||
|
||||
if(pt.x >= Dx(r) * .5)
|
||||
ret |= EAST;
|
||||
if(x <= rect->width * .5)
|
||||
if(pt.x <= Dx(r) * .5)
|
||||
ret |= WEST;
|
||||
if(y <= rect->height * .5)
|
||||
if(pt.y <= Dy(r) * .5)
|
||||
ret |= NORTH;
|
||||
if(y >= rect->height * .5)
|
||||
if(pt.y >= Dy(r) * .5)
|
||||
ret |= SOUTH;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Cursor
|
||||
cursor_of_quad(BlitzAlign align) {
|
||||
cursor_of_quad(Align align) {
|
||||
switch(align) {
|
||||
case NEAST:
|
||||
return cursor[CurNECorner];
|
||||
|
@ -46,39 +46,15 @@ cursor_of_quad(BlitzAlign align) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Syntax: <x> <y> <width> <height> */
|
||||
int
|
||||
strtorect(XRectangle *r, const char *val) {
|
||||
XRectangle new;
|
||||
if (!val)
|
||||
return -1;
|
||||
Align
|
||||
get_sticky(Rectangle src, Rectangle dst) {
|
||||
Align stickycorner = 0;
|
||||
|
||||
if(sscanf(val, "%hd %hd %hu %hu", &new.x, &new.y, &new.width, &new.height) != 4)
|
||||
return -1;
|
||||
|
||||
*r = new;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
r_east(XRectangle *r) {
|
||||
return r->x + r->width;
|
||||
}
|
||||
|
||||
int
|
||||
r_south(XRectangle *r) {
|
||||
return r->y + r->height;
|
||||
}
|
||||
|
||||
BlitzAlign
|
||||
get_sticky(XRectangle *src, XRectangle *dst) {
|
||||
BlitzAlign stickycorner = 0;
|
||||
|
||||
if(src->x != dst->x && r_east(src) == r_east(dst))
|
||||
if(src.min.x != dst.min.x && src.max.x == dst.max.x)
|
||||
stickycorner |= EAST;
|
||||
else
|
||||
stickycorner |= WEST;
|
||||
if(src->y != dst->y && r_south(src) == r_south(dst))
|
||||
if(src.min.y != dst.min.y && src.max.y == dst.max.y)
|
||||
stickycorner |= SOUTH;
|
||||
else
|
||||
stickycorner |= NORTH;
|
||||
|
|
|
@ -19,8 +19,8 @@ init_lock_keys() {
|
|||
int i;
|
||||
|
||||
num_lock_mask = 0;
|
||||
modmap = XGetModifierMapping(blz.dpy);
|
||||
num_lock = XKeysymToKeycode(blz.dpy, XStringToKeysym("Num_Lock"));
|
||||
modmap = XGetModifierMapping(display);
|
||||
num_lock = XKeysymToKeycode(display, XStringToKeysym("Num_Lock"));
|
||||
if(modmap && modmap->max_keypermod > 0) {
|
||||
int max = (sizeof(masks) / sizeof(int)) * modmap->max_keypermod;
|
||||
for(i = 0; i < max; i++)
|
||||
|
@ -54,25 +54,25 @@ mod_key_of_str(char *val) {
|
|||
|
||||
static void
|
||||
grab_key(Key *k) {
|
||||
XGrabKey(blz.dpy, k->key, k->mod, blz.root,
|
||||
XGrabKey(display, k->key, k->mod, scr.root.w,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
if(num_lock_mask) {
|
||||
XGrabKey(blz.dpy, k->key, k->mod | num_lock_mask, blz.root,
|
||||
XGrabKey(display, k->key, k->mod | num_lock_mask, scr.root.w,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(blz.dpy, k->key, k->mod | num_lock_mask | LockMask, blz.root,
|
||||
XGrabKey(display, k->key, k->mod | num_lock_mask | LockMask, scr.root.w,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
XSync(blz.dpy, False);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
ungrab_key(Key *k) {
|
||||
XUngrabKey(blz.dpy, k->key, k->mod, blz.root);
|
||||
XUngrabKey(display, k->key, k->mod, scr.root.w);
|
||||
if(num_lock_mask) {
|
||||
XUngrabKey(blz.dpy, k->key, k->mod | num_lock_mask, blz.root);
|
||||
XUngrabKey(blz.dpy, k->key, k->mod | num_lock_mask | LockMask, blz.root);
|
||||
XUngrabKey(display, k->key, k->mod | num_lock_mask, scr.root.w);
|
||||
XUngrabKey(display, k->key, k->mod | num_lock_mask | LockMask, scr.root.w);
|
||||
}
|
||||
XSync(blz.dpy, False);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
static Key *
|
||||
|
@ -111,7 +111,7 @@ get_key(const char *name) {
|
|||
kstr++;
|
||||
else
|
||||
kstr = seq[i];
|
||||
k->key = XKeysymToKeycode(blz.dpy, XStringToKeysym(kstr));
|
||||
k->key = XKeysymToKeycode(display, XStringToKeysym(kstr));
|
||||
k->mod = mod_key_of_str(seq[i]);
|
||||
}
|
||||
if(r) {
|
||||
|
@ -130,30 +130,30 @@ next_keystroke(ulong *mod, KeyCode *code) {
|
|||
*mod = 0;
|
||||
|
||||
do {
|
||||
XMaskEvent(blz.dpy, KeyPressMask, &e);
|
||||
XMaskEvent(display, KeyPressMask, &e);
|
||||
*mod |= e.xkey.state & valid_mask;
|
||||
*code = (KeyCode) e.xkey.keycode;
|
||||
sym = XKeycodeToKeysym(blz.dpy, e.xkey.keycode, 0);
|
||||
sym = XKeycodeToKeysym(display, e.xkey.keycode, 0);
|
||||
} while(IsModifierKey(sym));
|
||||
}
|
||||
|
||||
static void
|
||||
emulate_key_press(ulong mod, KeyCode key) {
|
||||
XEvent e;
|
||||
Window client_win;
|
||||
XWindow client_win;
|
||||
int revert;
|
||||
|
||||
XGetInputFocus(blz.dpy, &client_win, &revert);
|
||||
XGetInputFocus(display, &client_win, &revert);
|
||||
e.xkey.type = KeyPress;
|
||||
e.xkey.time = CurrentTime;
|
||||
e.xkey.window = client_win;
|
||||
e.xkey.display = blz.dpy;
|
||||
e.xkey.display = display;
|
||||
e.xkey.state = mod;
|
||||
e.xkey.keycode = key;
|
||||
XSendEvent(blz.dpy, client_win, True, KeyPressMask, &e);
|
||||
XSendEvent(display, client_win, True, KeyPressMask, &e);
|
||||
e.xkey.type = KeyRelease;
|
||||
XSendEvent(blz.dpy, client_win, True, KeyReleaseMask, &e);
|
||||
XSync(blz.dpy, False);
|
||||
XSendEvent(display, client_win, True, KeyReleaseMask, &e);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
static Key *
|
||||
|
@ -172,7 +172,7 @@ match_keys(Key *k, ulong mod, KeyCode keycode, Bool seq) {
|
|||
}
|
||||
|
||||
static void
|
||||
kpress_seq(Window w, Key *done) {
|
||||
kpress_seq(XWindow w, Key *done) {
|
||||
ulong mod;
|
||||
KeyCode key;
|
||||
Key *found;
|
||||
|
@ -183,7 +183,7 @@ kpress_seq(Window w, Key *done) {
|
|||
emulate_key_press(mod, key); /* double key */
|
||||
else {
|
||||
if(!found) {
|
||||
XBell(blz.dpy, 0);
|
||||
XBell(display, 0);
|
||||
} /* grabbed but not found */
|
||||
else if(!found->tnext && !found->next)
|
||||
write_event("Key %s\n", found->name);
|
||||
|
@ -193,22 +193,22 @@ kpress_seq(Window w, Key *done) {
|
|||
}
|
||||
|
||||
void
|
||||
kpress(Window w, ulong mod, KeyCode keycode) {
|
||||
kpress(XWindow w, ulong mod, KeyCode keycode) {
|
||||
Key *k, *found;
|
||||
|
||||
for(k=key; k; k=k->lnext)
|
||||
k->tnext=k->lnext;
|
||||
found = match_keys(key, mod, keycode, False);
|
||||
if(!found) {
|
||||
XBell(blz.dpy, 0);
|
||||
XBell(display, 0);
|
||||
} /* grabbed but not found */
|
||||
else if(!found->tnext && !found->next)
|
||||
write_event("Key %s\n", found->name);
|
||||
else {
|
||||
XGrabKeyboard(blz.dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
XGrabKeyboard(display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
kpress_seq(w, found);
|
||||
XUngrabKeyboard(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabKeyboard(display, CurrentTime);
|
||||
XSync(display, False);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,5 +241,5 @@ update_keys() {
|
|||
if((k = get_key(l)))
|
||||
grab_key(k);
|
||||
}
|
||||
XSync(blz.dpy, False);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
|
214
cmd/wmii/main.c
214
cmd/wmii/main.c
|
@ -2,7 +2,6 @@
|
|||
* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <errno.h>
|
||||
|
@ -38,23 +37,23 @@ static void
|
|||
scan_wins() {
|
||||
int i;
|
||||
uint num;
|
||||
Window *wins;
|
||||
XWindow *wins;
|
||||
XWindowAttributes wa;
|
||||
Window d1, d2;
|
||||
XWindow d1, d2;
|
||||
|
||||
if(XQueryTree(blz.dpy, blz.root, &d1, &d2, &wins, &num)) {
|
||||
if(XQueryTree(display, scr.root.w, &d1, &d2, &wins, &num)) {
|
||||
for(i = 0; i < num; i++) {
|
||||
if(!XGetWindowAttributes(blz.dpy, wins[i], &wa))
|
||||
if(!XGetWindowAttributes(display, wins[i], &wa))
|
||||
continue;
|
||||
if(wa.override_redirect || XGetTransientForHint(blz.dpy, wins[i], &d1))
|
||||
if(wa.override_redirect || XGetTransientForHint(display, wins[i], &d1))
|
||||
continue;
|
||||
if(wa.map_state == IsViewable)
|
||||
manage_client(create_client(wins[i], &wa));
|
||||
}
|
||||
for(i = 0; i < num; i++) {
|
||||
if(!XGetWindowAttributes(blz.dpy, wins[i], &wa))
|
||||
if(!XGetWindowAttributes(display, wins[i], &wa))
|
||||
continue;
|
||||
if((XGetTransientForHint(blz.dpy, wins[i], &d1))
|
||||
if((XGetTransientForHint(display, wins[i], &d1))
|
||||
&& (wa.map_state == IsViewable))
|
||||
manage_client(create_client(wins[i], &wa));
|
||||
}
|
||||
|
@ -63,47 +62,6 @@ scan_wins() {
|
|||
XFree(wins);
|
||||
}
|
||||
|
||||
int
|
||||
win_proto(Window w) {
|
||||
Atom *protocols;
|
||||
Atom real;
|
||||
ulong nitems, extra;
|
||||
int i, format, status, protos;
|
||||
|
||||
status = XGetWindowProperty(
|
||||
/* display */ blz.dpy,
|
||||
/* window */ w,
|
||||
/* property */ atom[WMProtocols],
|
||||
/* offset */ 0L,
|
||||
/* length */ 20L,
|
||||
/* delete */ False,
|
||||
/* req_type */ XA_ATOM,
|
||||
/* type_ret */ &real,
|
||||
/* format_ret */&format,
|
||||
/* nitems_ret */&nitems,
|
||||
/* extra_bytes */&extra,
|
||||
/* prop_return */(uchar**)&protocols
|
||||
);
|
||||
|
||||
if(status != Success || protocols == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(nitems == 0) {
|
||||
free(protocols);
|
||||
return 0;
|
||||
}
|
||||
|
||||
protos = 0;
|
||||
for(i = 0; i < nitems; i++) {
|
||||
if(protocols[i] == atom[WMDelete])
|
||||
protos |= WM_PROTOCOL_DELWIN;
|
||||
}
|
||||
|
||||
free(protocols);
|
||||
return protos;
|
||||
}
|
||||
|
||||
static char*
|
||||
ns_display() {
|
||||
char *s, *disp;
|
||||
|
@ -185,27 +143,22 @@ init_environment() {
|
|||
setenv("WMII_ADDRESS", address, True);
|
||||
}
|
||||
|
||||
static void
|
||||
intern_atom(int ident, char *name) {
|
||||
atom[ident] = XInternAtom(blz.dpy, name, False);
|
||||
}
|
||||
|
||||
static void
|
||||
init_atoms() {
|
||||
intern_atom(WMState, "WM_STATE");
|
||||
intern_atom(WMProtocols, "WM_PROTOCOLS");
|
||||
intern_atom(WMDelete, "WM_DELETE_WINDOW");
|
||||
intern_atom(NetSupported, "_NET_SUPPORTED");
|
||||
intern_atom(NetWMName, "_NET_WM_NAME");
|
||||
intern_atom(TagsAtom, "_WIN_TAGS");
|
||||
atom[WMState] = xatom("WM_STATE");
|
||||
atom[WMProtocols] = xatom("WM_PROTOCOLS");
|
||||
atom[WMDelete] = xatom("WM_DELETE_WINDOW");
|
||||
atom[NetSupported] = xatom("_NET_SUPPORTED");
|
||||
atom[NetWMName] = xatom("_NET_WM_NAME");
|
||||
atom[TagsAtom] = xatom("_WIN_TAGS");
|
||||
|
||||
XChangeProperty(blz.dpy, blz.root, atom[NetSupported], XA_ATOM, 32,
|
||||
XChangeProperty(display, scr.root.w, atom[NetSupported], XA_ATOM, 32,
|
||||
PropModeReplace, (uchar *)&atom[NetSupported], 2);
|
||||
}
|
||||
|
||||
static void
|
||||
create_cursor(int ident, uint shape) {
|
||||
cursor[ident] = XCreateFontCursor(blz.dpy, shape);
|
||||
cursor[ident] = XCreateFontCursor(display, shape);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -222,23 +175,24 @@ init_cursors() {
|
|||
create_cursor(CurDHArrow, XC_sb_h_double_arrow);
|
||||
create_cursor(CurInput, XC_xterm);
|
||||
|
||||
XAllocNamedColor(blz.dpy, DefaultColormap(blz.dpy, blz.screen),
|
||||
XAllocNamedColor(display, scr.colormap,
|
||||
"black", &black,
|
||||
&dummy);
|
||||
pix = XCreateBitmapFromData(blz.dpy, blz.root,
|
||||
pix = XCreateBitmapFromData(
|
||||
display, scr.root.w,
|
||||
(char[]){0}, 1, 1);
|
||||
|
||||
cursor[CurInvisible] = XCreatePixmapCursor(blz.dpy,
|
||||
cursor[CurInvisible] = XCreatePixmapCursor(display,
|
||||
pix, pix,
|
||||
&black, &black,
|
||||
0, 0);
|
||||
|
||||
XFreePixmap(blz.dpy, pix);
|
||||
XFreePixmap(display, pix);
|
||||
}
|
||||
|
||||
static void
|
||||
init_screen(WMScreen *screen) {
|
||||
Window w;
|
||||
XWindow w;
|
||||
int ret;
|
||||
unsigned mask;
|
||||
XGCValues gcv;
|
||||
|
@ -248,7 +202,10 @@ init_screen(WMScreen *screen) {
|
|||
gcv.foreground = def.normcolor.bg;
|
||||
gcv.plane_mask = AllPlanes;
|
||||
gcv.graphics_exposures = False;
|
||||
xorgc = XCreateGC(blz.dpy, blz.root,
|
||||
|
||||
xor.type = WImage;
|
||||
xor.image = scr.root.w;
|
||||
xor.gc = XCreateGC(display, scr.root.w,
|
||||
GCForeground
|
||||
| GCGraphicsExposures
|
||||
| GCFunction
|
||||
|
@ -256,12 +213,10 @@ init_screen(WMScreen *screen) {
|
|||
| GCPlaneMask,
|
||||
&gcv);
|
||||
|
||||
screen->rect.x = screen->rect.y = 0;
|
||||
screen->rect.width = DisplayWidth(blz.dpy, blz.screen);
|
||||
screen->rect.height = DisplayHeight(blz.dpy, blz.screen);
|
||||
def.snap = screen->rect.height / 63;
|
||||
screen->rect = scr.rect;
|
||||
def.snap = Dy(scr.rect) / 63;
|
||||
|
||||
sel_screen = XQueryPointer(blz.dpy, blz.root,
|
||||
sel_screen = XQueryPointer(display, scr.root.w,
|
||||
&w, &w,
|
||||
&ret, &ret, &ret, &ret,
|
||||
&mask);
|
||||
|
@ -299,16 +254,19 @@ wmii_error_handler(Display *dpy, XErrorEvent *error) {
|
|||
|
||||
fprintf(stderr, "%s: fatal error: Xrequest code=%d, Xerror code=%d\n",
|
||||
argv0, error->request_code, error->error_code);
|
||||
return x_error_handler(blz.dpy, error); /* calls exit() */
|
||||
return x_error_handler(display, error); /* calls exit() */
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup() {
|
||||
Client *c;
|
||||
|
||||
for(c=client; c; c=c->next)
|
||||
reparent_client(c, blz.root, c->sel->rect.x, c->sel->rect.y);
|
||||
XSync(blz.dpy, False);
|
||||
for(c=client; c; c=c->next) {
|
||||
reparent_client(c, &scr.root, c->sel->rect.min);
|
||||
if(c->sel->view != screen->sel)
|
||||
unmap_client(c, IconicState);
|
||||
}
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -341,18 +299,18 @@ init_traps() {
|
|||
break; /* not reached */
|
||||
case 0:
|
||||
close(fd[1]);
|
||||
close(ConnectionNumber(blz.dpy));
|
||||
close(ConnectionNumber(display));
|
||||
setsid();
|
||||
|
||||
blz.dpy = XOpenDisplay(0);
|
||||
if(!blz.dpy)
|
||||
display = XOpenDisplay(0);
|
||||
if(!display)
|
||||
fatal("Can't open display");
|
||||
|
||||
/* Wait for parent to exit */
|
||||
read(fd[0], buf, 1);
|
||||
|
||||
XSetInputFocus(blz.dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XCloseDisplay(blz.dpy);
|
||||
XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XCloseDisplay(display);
|
||||
exit(0);
|
||||
default:
|
||||
break;
|
||||
|
@ -389,7 +347,7 @@ spawn_command(const char *cmd) {
|
|||
if(setsid() == -1)
|
||||
fatal("Can't setsid:");
|
||||
close(sock);
|
||||
close(ConnectionNumber(blz.dpy));
|
||||
close(ConnectionNumber(display));
|
||||
|
||||
shell = passwd->pw_shell;
|
||||
if(shell[0] != '/')
|
||||
|
@ -424,7 +382,7 @@ int
|
|||
main(int argc, char *argv[]) {
|
||||
char *wmiirc;
|
||||
WMScreen *s;
|
||||
XSetWindowAttributes wa;
|
||||
WinAttr wa;
|
||||
int i;
|
||||
|
||||
wmiirc = "wmiistartrc";
|
||||
|
@ -453,16 +411,12 @@ main(int argc, char *argv[]) {
|
|||
setlocale(LC_CTYPE, "");
|
||||
starting = True;
|
||||
|
||||
blz.dpy = XOpenDisplay(0);
|
||||
if(!blz.dpy)
|
||||
fatal("Can't open display");
|
||||
blz.screen = DefaultScreen(blz.dpy);
|
||||
blz.root = RootWindow(blz.dpy, blz.screen);
|
||||
initdisplay();
|
||||
|
||||
check_other_wm = True;
|
||||
x_error_handler = XSetErrorHandler(wmii_error_handler);
|
||||
XSelectInput(blz.dpy, blz.root, SubstructureRedirectMask | EnterWindowMask);
|
||||
XSync(blz.dpy, False);
|
||||
XSelectInput(display, scr.root.w, SubstructureRedirectMask | EnterWindowMask);
|
||||
XSync(display, False);
|
||||
check_other_wm = False;
|
||||
|
||||
passwd = getpwuid(getuid());
|
||||
|
@ -478,50 +432,47 @@ main(int argc, char *argv[]) {
|
|||
if(wmiirc)
|
||||
spawn_command(wmiirc);
|
||||
|
||||
init_traps();
|
||||
init_atoms();
|
||||
init_cursors();
|
||||
init_lock_keys();
|
||||
|
||||
ixp_listen(&srv, sock, &p9srv, check_9pcon, nil);
|
||||
ixp_listen(&srv, ConnectionNumber(blz.dpy), nil, check_x_event, nil);
|
||||
ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, nil);
|
||||
|
||||
view = nil;
|
||||
client = nil;
|
||||
key = nil;
|
||||
|
||||
def.font.fontstr = estrdup(BLITZ_FONT);
|
||||
def.font = loadfont(FONT);
|
||||
def.border = 1;
|
||||
def.colmode = Coldefault;
|
||||
|
||||
def.mod = Mod1Mask;
|
||||
strncpy(def.grabmod, "Mod1", sizeof(def.grabmod));
|
||||
|
||||
strncpy(def.focuscolor.colstr, BLITZ_FOCUSCOLORS, sizeof(def.focuscolor.colstr));
|
||||
strncpy(def.normcolor.colstr, BLITZ_NORMCOLORS, sizeof(def.normcolor.colstr));
|
||||
loadcolor(&blz, &def.focuscolor);
|
||||
loadcolor(&blz, &def.normcolor);
|
||||
|
||||
init_traps();
|
||||
init_atoms();
|
||||
init_cursors();
|
||||
loadfont(&blz, &def.font);
|
||||
init_lock_keys();
|
||||
loadcolor(&def.focuscolor, FOCUSCOLORS);
|
||||
loadcolor(&def.normcolor, NORMCOLORS);
|
||||
|
||||
num_screens = 1;
|
||||
screens = emallocz(num_screens * sizeof(*screens));
|
||||
screen = &screens[0];
|
||||
for(i = 0; i < num_screens; i++) {
|
||||
s = &screens[i];
|
||||
init_screen(s);
|
||||
pmap = XCreatePixmap(
|
||||
/* display */ blz.dpy,
|
||||
/* drawable */ blz.root,
|
||||
/* width */ s->rect.width,
|
||||
/* height */ s->rect.height,
|
||||
/* depth */ DefaultDepth(blz.dpy, blz.screen)
|
||||
);
|
||||
|
||||
s->ibuf = allocimage(Dx(s->rect), Dy(s->rect), scr.depth);
|
||||
|
||||
wa.event_mask =
|
||||
SubstructureRedirectMask
|
||||
| EnterWindowMask
|
||||
| LeaveWindowMask
|
||||
| FocusChangeMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(blz.dpy, blz.root, CWEventMask | CWCursor, &wa);
|
||||
setwinattr(&scr.root, &wa,
|
||||
CWEventMask
|
||||
| CWCursor);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask =
|
||||
|
@ -530,40 +481,23 @@ main(int argc, char *argv[]) {
|
|||
| FocusChangeMask
|
||||
| SubstructureRedirectMask
|
||||
| SubstructureNotifyMask;
|
||||
|
||||
s->brect = s->rect;
|
||||
s->brect.height = labelh(&def.font);
|
||||
s->brect.y = s->rect.height - s->brect.height;
|
||||
s->barwin = XCreateWindow(
|
||||
/* display */ blz.dpy,
|
||||
/* parent */ RootWindow(blz.dpy, blz.screen),
|
||||
/* x */ s->brect.x,
|
||||
/* y */ s->brect.y,
|
||||
/* width */ s->brect.width,
|
||||
/* height */ s->brect.height,
|
||||
/*border_width*/0,
|
||||
/* depth */ DefaultDepth(blz.dpy, blz.screen),
|
||||
/* class */ CopyFromParent,
|
||||
/* visual */ DefaultVisual(blz.dpy, blz.screen),
|
||||
/* valuemask */ CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
||||
/* attrubutes */&wa
|
||||
);
|
||||
XSync(blz.dpy, False);
|
||||
s->bbrush.blitz = &blz;
|
||||
s->bbrush.gc = XCreateGC(blz.dpy, s->barwin, 0, 0);
|
||||
s->bbrush.drawable = pmap;
|
||||
s->bbrush.rect = s->brect;
|
||||
s->bbrush.rect.x = 0;
|
||||
s->bbrush.rect.y = 0;
|
||||
s->bbrush.color = def.normcolor;
|
||||
s->bbrush.font = &def.font;
|
||||
s->bbrush.border = 1;
|
||||
s->brect.min.y = s->brect.max.y - labelh(def.font);
|
||||
|
||||
s->barwin = createwindow(&scr.root, s->brect, scr.depth, InputOutput, &wa,
|
||||
CWOverrideRedirect
|
||||
| CWBackPixmap
|
||||
| CWEventMask);
|
||||
|
||||
XSync(display, False);
|
||||
draw_bar(s);
|
||||
XMapRaised(blz.dpy, s->barwin);
|
||||
XMapRaised(display, s->barwin->w);
|
||||
}
|
||||
|
||||
screen = &screens[0];
|
||||
screen->focus = nil;
|
||||
XSetInputFocus(blz.dpy, screen->barwin, RevertToParent, CurrentTime);
|
||||
XSetInputFocus(display, screen->barwin->w, RevertToParent, CurrentTime);
|
||||
|
||||
scan_wins();
|
||||
starting = False;
|
||||
|
@ -577,7 +511,7 @@ main(int argc, char *argv[]) {
|
|||
fprintf(stderr, "%s: error: %s\n", argv0, errstr);
|
||||
|
||||
cleanup();
|
||||
XCloseDisplay(blz.dpy);
|
||||
XCloseDisplay(display);
|
||||
ixp_server_close(&srv);
|
||||
close(sleeperfd);
|
||||
|
||||
|
|
425
cmd/wmii/mouse.c
425
cmd/wmii/mouse.c
|
@ -1,4 +1,4 @@
|
|||
/* Copyright ©2006 Kris Maglione <fbsdaemon@gmail.com>
|
||||
/* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
@ -16,92 +16,70 @@ enum {
|
|||
};
|
||||
|
||||
static void
|
||||
rect_morph_xy(XRectangle *rect, int dx, int dy, BlitzAlign *mask) {
|
||||
BlitzAlign nmask;
|
||||
rect_morph_xy(Rectangle *r, Point d, Align *mask) {
|
||||
int n;
|
||||
|
||||
nmask = 0;
|
||||
if(*mask & NORTH) {
|
||||
if(rect->height - dy >= 0 || *mask & SOUTH) {
|
||||
rect->y += dy;
|
||||
rect->height -= dy;
|
||||
}
|
||||
else {
|
||||
rect->y += rect->height;
|
||||
rect->height = dy - rect->height;
|
||||
nmask ^= NORTH|SOUTH;
|
||||
}
|
||||
if(*mask & NORTH)
|
||||
r->min.y += d.y;
|
||||
if(*mask & WEST)
|
||||
r->min.x += d.x;
|
||||
if(*mask & SOUTH)
|
||||
r->max.y += d.y;
|
||||
if(*mask & EAST)
|
||||
r->max.x += d.x;
|
||||
|
||||
if(r->min.x > r->max.x) {
|
||||
n = r->min.x;
|
||||
r->min.x = r->max.x;
|
||||
r->max.x = n;
|
||||
*mask ^= EAST|WEST;
|
||||
}
|
||||
if(*mask & SOUTH) {
|
||||
if(rect->height + dy >= 0 || *mask & NORTH)
|
||||
rect->height += dy;
|
||||
else {
|
||||
rect->height = -dy - rect->height;
|
||||
rect->y -= rect->height;
|
||||
nmask ^= NORTH|SOUTH;
|
||||
}
|
||||
if(r->min.y > r->max.y) {
|
||||
n = r->min.y;
|
||||
r->min.y = r->max.y;
|
||||
r->max.y = n;
|
||||
*mask ^= NORTH|SOUTH;
|
||||
}
|
||||
if(*mask & EAST) {
|
||||
if(rect->width + dx >= 0 || *mask & WEST)
|
||||
rect->width += dx;
|
||||
else {
|
||||
rect->width = -dx - rect->width;
|
||||
rect->x -= rect->width;
|
||||
nmask ^= EAST|WEST;
|
||||
}
|
||||
}
|
||||
if(*mask & WEST) {
|
||||
if(rect->width - dx >= 0 || *mask & EAST) {
|
||||
rect->x += dx;
|
||||
rect->width -= dx;
|
||||
}
|
||||
else {
|
||||
rect->x += rect->width;
|
||||
rect->width = dx - rect->width;
|
||||
nmask ^= EAST|WEST;
|
||||
}
|
||||
}
|
||||
*mask ^= nmask;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
XRectangle *rects;
|
||||
Rectangle *rects;
|
||||
int num;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
Rectangle r;
|
||||
int x, y;
|
||||
int dx, dy;
|
||||
BlitzAlign mask;
|
||||
Align mask;
|
||||
} SnapArgs;
|
||||
|
||||
static void
|
||||
snap_line(SnapArgs *a) {
|
||||
int i, t_xy;
|
||||
Rectangle *r;
|
||||
int i, x, y;
|
||||
|
||||
/* horizontal */
|
||||
if(a->y1 == a->y2 && (a->mask & (NORTH|SOUTH))) {
|
||||
if(a->mask & (NORTH|SOUTH)) {
|
||||
for(i=0; i < a->num; i++) {
|
||||
if(!(r_east(&a->rects[i]) < a->x1) ||
|
||||
(a->rects[i].x > a->x2)) {
|
||||
r = &a->rects[i];
|
||||
if((r->min.x <= a->r.max.x) && (r->max.x >= a->r.min.x)) {
|
||||
y = r->min.y;
|
||||
if(abs(y - a->y) <= abs(a->dy))
|
||||
a->dy = y - a->y;
|
||||
|
||||
if(abs(a->rects[i].y - a->y1) <= abs(a->dy))
|
||||
a->dy = a->rects[i].y - a->y1;
|
||||
|
||||
t_xy = r_south(&a->rects[i]);
|
||||
if(abs(t_xy - a->y1) < abs(a->dy))
|
||||
a->dy = t_xy - a->y1;
|
||||
y = r->max.y;
|
||||
if(abs(y - a->y) <= abs(a->dy))
|
||||
a->dy = y - a->y;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (a->mask & (EAST|WEST)) {
|
||||
}else {
|
||||
for(i=0; i < a->num; i++) {
|
||||
if(!(r_south(&a->rects[i]) < a->y1) ||
|
||||
(a->rects[i].y > a->y2)) {
|
||||
r = &a->rects[i];
|
||||
if((r->min.y <= a->r.max.y) && (r->max.y >= a->r.min.y)) {
|
||||
x = r->min.x;
|
||||
if(abs(x - a->x) <= abs(a->dx))
|
||||
a->dx = x - a->x;
|
||||
|
||||
if(abs(a->rects[i].x - a->x1) <= abs(a->dx))
|
||||
a->dx = a->rects[i].x - a->x1;
|
||||
|
||||
t_xy = r_east(&a->rects[i]);
|
||||
if(abs(t_xy - a->x1) < abs(a->dx))
|
||||
a->dx = t_xy - a->x1;
|
||||
x = r->max.x;
|
||||
if(abs(x - a->x) <= abs(a->dx))
|
||||
a->dx = x - a->x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,92 +89,81 @@ snap_line(SnapArgs *a) {
|
|||
* (the directions that we're resizing in), unless a snap occurs, in which case, it's the
|
||||
* direction of the snap.
|
||||
*/
|
||||
BlitzAlign
|
||||
snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int snap) {
|
||||
Align
|
||||
snap_rect(Rectangle *rects, int num, Rectangle *r, Align *mask, int snap) {
|
||||
SnapArgs a = { 0, };
|
||||
BlitzAlign ret;
|
||||
Align ret;
|
||||
|
||||
a.rects = rects;
|
||||
a.num = num;
|
||||
a.mask = *mask;
|
||||
a.dx = snap + 1;
|
||||
a.dy = snap + 1;
|
||||
a.r = *r;
|
||||
|
||||
a.x1 = current->x;
|
||||
a.x2 = r_east(current);
|
||||
a.mask = NORTH|SOUTH;
|
||||
if(*mask & NORTH) {
|
||||
a.y2 = a.y1 = current->y;
|
||||
a.y = r->min.y;
|
||||
snap_line(&a);
|
||||
}
|
||||
if(*mask & SOUTH) {
|
||||
a.y2 = a.y1 = r_south(current);
|
||||
a.y = r->max.y;
|
||||
snap_line(&a);
|
||||
}
|
||||
|
||||
a.y1 = current->y;
|
||||
a.y2 = r_south(current);
|
||||
a.mask = EAST|WEST;
|
||||
if(*mask & EAST) {
|
||||
a.x1 = a.x2 = r_east(current);
|
||||
a.x = r->max.x;
|
||||
snap_line(&a);
|
||||
}
|
||||
if(*mask & WEST) {
|
||||
a.x1 = a.x2 = current->x;
|
||||
a.x = r->min.x;
|
||||
snap_line(&a);
|
||||
}
|
||||
|
||||
ret = CENTER;
|
||||
if(abs(a.dx) > snap)
|
||||
a.dx = 0;
|
||||
else
|
||||
if(abs(a.dx) <= snap)
|
||||
ret ^= EAST|WEST;
|
||||
|
||||
if(abs(a.dy) > snap)
|
||||
a.dy = 0;
|
||||
else
|
||||
a.dx = 0;
|
||||
|
||||
if(abs(a.dy) <= snap)
|
||||
ret ^= NORTH|SOUTH;
|
||||
else
|
||||
a.dy = 0;
|
||||
|
||||
rect_morph_xy(current, a.dx, a.dy, mask);
|
||||
|
||||
rect_morph_xy(r, Pt(a.dx, a.dy), mask);
|
||||
return ret ^ *mask;
|
||||
}
|
||||
|
||||
static void
|
||||
xorborder(XRectangle *r) {
|
||||
XRectangle xor;
|
||||
xorborder(Rectangle r) {
|
||||
Rectangle r2;
|
||||
ulong col;
|
||||
|
||||
col = def.focuscolor.bg;
|
||||
|
||||
xor = *r;
|
||||
xor.x += 2;
|
||||
xor.y += 2;
|
||||
xor.width = xor.width > 4 ? xor.width - 4 : 0;
|
||||
xor.height = xor.height > 4 ? xor.height - 4 : 0;
|
||||
r2 = insetrect(r, 4);
|
||||
|
||||
XSetLineAttributes(blz.dpy, xorgc, 1, LineSolid, CapNotLast, JoinMiter);
|
||||
XSetForeground(blz.dpy, xorgc, def.focuscolor.bg);
|
||||
if(xor.height > 4 && xor.width > 2)
|
||||
XDrawLine(blz.dpy, blz.root, xorgc,
|
||||
xor.x + 2,
|
||||
xor.y + xor.height / 2,
|
||||
r_east(&xor) - 2,
|
||||
xor.y + xor.height / 2);
|
||||
if(xor.width > 4 && xor.height > 2)
|
||||
XDrawLine(blz.dpy, blz.root, xorgc,
|
||||
xor.x + xor.width / 2,
|
||||
xor.y + 2,
|
||||
xor.x + xor.width / 2,
|
||||
r_south(&xor) - 2);
|
||||
XSetLineAttributes(blz.dpy, xorgc, 4, LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawRectangles(blz.dpy, blz.root, xorgc, &xor, 1);
|
||||
if(Dy(r) > 4 && Dx(r) > 2)
|
||||
drawline(&xor,
|
||||
Pt(r2.min.x, r2.min.y + Dy(r2)/2),
|
||||
Pt(r2.max.x, r2.min.y + Dy(r2)/2),
|
||||
CapNotLast, 1, col);
|
||||
if(Dx(r) > 4 && Dy(r) > 2)
|
||||
drawline(&xor,
|
||||
Pt(r2.min.x + Dx(r2)/2, r.min.y),
|
||||
Pt(r2.min.x + Dx(r2)/2, r.max.y),
|
||||
CapNotLast, 1, col);
|
||||
border(&xor, r, 4, col);
|
||||
}
|
||||
|
||||
static void
|
||||
xorrect(XRectangle *r) {
|
||||
XSetLineAttributes(blz.dpy, xorgc, 1, LineSolid, CapNotLast, JoinMiter);
|
||||
XSetForeground(blz.dpy, xorgc, 0x00888888l);
|
||||
XFillRectangles(blz.dpy, blz.root, xorgc, r, 1);
|
||||
xorrect(Rectangle r) {
|
||||
fill(&xor, r, 0x00888888L);
|
||||
}
|
||||
|
||||
static void
|
||||
find_droppoint(Frame *frame, int x, int y, XRectangle *rect, Bool do_move) {
|
||||
find_droppoint(Frame *frame, int x, int y, Rectangle *r, Bool do_move) {
|
||||
enum { Delta = 5 };
|
||||
View *v;
|
||||
Area *a, *a_prev;
|
||||
|
@ -208,16 +175,16 @@ find_droppoint(Frame *frame, int x, int y, XRectangle *rect, Bool do_move) {
|
|||
/* New column? */
|
||||
a_prev = v->area;
|
||||
for(a = a_prev->next; a && a->next; a = a->next) {
|
||||
if(x < r_east(&a->rect))
|
||||
if(x < a->rect.max.x)
|
||||
break;
|
||||
a_prev = a;
|
||||
}
|
||||
|
||||
rect->y = 0;
|
||||
rect->height = screen->rect.height - screen->brect.height;
|
||||
rect->width = 2 * Delta;
|
||||
if(x < (a->rect.x + labelh(&def.font))) {
|
||||
rect->x = a->rect.x - Delta;
|
||||
r->min.y = screen->rect.min.y;
|
||||
r->max.y = screen->brect.min.y;
|
||||
if(x < (a->rect.min.x + labelh(def.font))) {
|
||||
r->min.x = a->rect.min.x + Delta;
|
||||
r->max.x = a->rect.min.x + Delta;
|
||||
if(do_move) {
|
||||
a = new_column(v, a_prev, 0);
|
||||
send_to_area(a, frame);
|
||||
|
@ -225,8 +192,9 @@ find_droppoint(Frame *frame, int x, int y, XRectangle *rect, Bool do_move) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if(x > (r_east(&a->rect) - labelh(&def.font))) {
|
||||
rect->x = r_east(&a->rect) - Delta;
|
||||
if(x > (a->rect.max.x - labelh(def.font))) {
|
||||
r->min.x = a->rect.max.x + Delta;
|
||||
r->max.x = a->rect.max.x + Delta;
|
||||
if(do_move) {
|
||||
a = new_column(v, a, 0);
|
||||
send_to_area(a, frame);
|
||||
|
@ -236,33 +204,30 @@ find_droppoint(Frame *frame, int x, int y, XRectangle *rect, Bool do_move) {
|
|||
}
|
||||
|
||||
/* Over/under frame? */
|
||||
for(f = a->frame; f; f = f->anext) {
|
||||
if(y < f->rect.y)
|
||||
for(f = a->frame; f; f = f->anext)
|
||||
if(y < f->rect.max.y || f->anext == nil)
|
||||
break;
|
||||
if(y < r_south(&f->rect))
|
||||
break;
|
||||
}
|
||||
|
||||
rect->x = a->rect.x;
|
||||
rect->width = a->rect.width;
|
||||
rect->height = 2 * Delta;
|
||||
if(y < (f->rect.y + labelh(&def.font))) {
|
||||
*r = a->rect;
|
||||
if(y < (f->rect.min.y + labelh(def.font))) {
|
||||
before = True;
|
||||
rect->y = f->rect.y - Delta;
|
||||
r->min.y = f->rect.min.y - Delta;
|
||||
r->max.y = f->rect.min.y + Delta;
|
||||
if(do_move)
|
||||
goto do_move;
|
||||
return;
|
||||
}
|
||||
if(y > r_south(&f->rect) - labelh(&def.font)) {
|
||||
if(y > f->rect.max.y - labelh(def.font)) {
|
||||
before = False;
|
||||
rect->y = r_south(&f->rect) - Delta;
|
||||
r->min.y = f->rect.max.y - Delta;
|
||||
r->max.y = f->rect.max.y + Delta;
|
||||
if(do_move)
|
||||
goto do_move;
|
||||
return;
|
||||
}
|
||||
|
||||
/* No? Swap. */
|
||||
*rect = f->rect;
|
||||
*r = f->rect;
|
||||
if(do_move) {
|
||||
swap_frames(frame, f);
|
||||
focus(frame->client, False);
|
||||
|
@ -282,19 +247,19 @@ do_move:
|
|||
}
|
||||
|
||||
void
|
||||
querypointer(Window w, int *x, int *y) {
|
||||
Window dummy;
|
||||
querypointer(Window *w, int *x, int *y) {
|
||||
XWindow dummy;
|
||||
uint ui;
|
||||
int i;
|
||||
|
||||
XQueryPointer(blz.dpy, w, &dummy, &dummy, &i, &i, x, y, &ui);
|
||||
XQueryPointer(display, w->w, &dummy, &dummy, &i, &i, x, y, &ui);
|
||||
}
|
||||
|
||||
void
|
||||
warppointer(int x, int y) {
|
||||
XWarpPointer(blz.dpy,
|
||||
XWarpPointer(display,
|
||||
/* src_w */ None,
|
||||
/* dest_w */ blz.root,
|
||||
/* dest_w */ scr.root.w,
|
||||
/* src_rect */ 0, 0, 0, 0,
|
||||
/* target */ x, y
|
||||
);
|
||||
|
@ -302,7 +267,7 @@ warppointer(int x, int y) {
|
|||
|
||||
static void
|
||||
do_managed_move(Client *c) {
|
||||
XRectangle frect, ofrect;
|
||||
Rectangle frect, ofrect;
|
||||
XEvent ev;
|
||||
Frame *f;
|
||||
int x, y;
|
||||
|
@ -310,27 +275,29 @@ do_managed_move(Client *c) {
|
|||
focus(c, False);
|
||||
f = c->sel;
|
||||
|
||||
XSync(blz.dpy, False);
|
||||
if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
XSync(display, False);
|
||||
if(XGrabPointer(display, c->framewin->w, False,
|
||||
MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime
|
||||
) != GrabSuccess)
|
||||
return;
|
||||
XGrabServer(blz.dpy);
|
||||
XGrabServer(display);
|
||||
|
||||
querypointer(blz.root, &x, &y);
|
||||
querypointer(&scr.root, &x, &y);
|
||||
|
||||
find_droppoint(f, x, y, &frect, False);
|
||||
xorrect(&frect);
|
||||
xorrect(frect);
|
||||
for(;;) {
|
||||
XMaskEvent(blz.dpy, MouseMask | ExposureMask, &ev);
|
||||
XMaskEvent(display, MouseMask | ExposureMask, &ev);
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
xorrect(&frect);
|
||||
xorrect(frect);
|
||||
|
||||
find_droppoint(f, x, y, &frect, True);
|
||||
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabServer(display);
|
||||
XUngrabPointer(display, CurrentTime);
|
||||
XSync(display, False);
|
||||
return;
|
||||
case MotionNotify:
|
||||
ofrect = frect;
|
||||
|
@ -339,9 +306,9 @@ do_managed_move(Client *c) {
|
|||
|
||||
find_droppoint(f, x, y, &frect, False);
|
||||
|
||||
if(memcmp(&frect, &ofrect, sizeof(frect))) {
|
||||
xorrect(&ofrect);
|
||||
xorrect(&frect);
|
||||
if(!eqrect(frect, ofrect)) {
|
||||
xorrect(ofrect);
|
||||
xorrect(frect);
|
||||
}
|
||||
break;
|
||||
case Expose:
|
||||
|
@ -354,14 +321,14 @@ do_managed_move(Client *c) {
|
|||
|
||||
void
|
||||
mouse_resizecol(Divide *d) {
|
||||
XSetWindowAttributes wa;
|
||||
WinAttr wa;
|
||||
XEvent ev;
|
||||
Window cwin;
|
||||
Window *cwin;
|
||||
Divide *dp;
|
||||
View *v;
|
||||
Area *a;
|
||||
uint w, minw;
|
||||
int x, y;
|
||||
uint minw;
|
||||
int x, y, x2;
|
||||
|
||||
v = screen->sel;
|
||||
|
||||
|
@ -372,47 +339,39 @@ mouse_resizecol(Divide *d) {
|
|||
if(a == nil || a->next == nil)
|
||||
return;
|
||||
|
||||
minw = screen->rect.width/NCOL;
|
||||
minw = Dx(screen->rect)/NCOL;
|
||||
|
||||
querypointer(blz.root, &x, &y);
|
||||
x = a->rect.x + minw;
|
||||
w = r_east(&a->next->rect) - minw;
|
||||
w -= x;
|
||||
querypointer(&scr.root, &x, &y);
|
||||
x = a->rect.min.x + minw;
|
||||
x2 = x + a->next->rect.max.x - minw;
|
||||
|
||||
cwin = XCreateWindow(blz.dpy, blz.root,
|
||||
x, y, w, 1,
|
||||
/* border */ 0,
|
||||
/* depth */ CopyFromParent,
|
||||
/* class */ InputOnly,
|
||||
/* visual */ CopyFromParent,
|
||||
/* valuemask */ 0,
|
||||
/* attrib */ &wa
|
||||
);
|
||||
XMapWindow(blz.dpy, cwin);
|
||||
cwin = createwindow(&scr.root, Rect(x, y, x2, y+1), 0, InputOnly, &wa, 0);
|
||||
mapwin(cwin);
|
||||
|
||||
if(XGrabPointer(
|
||||
blz.dpy, blz.root,
|
||||
display, scr.root.w,
|
||||
/* owner_events*/ False,
|
||||
/* event_mask */ MouseMask,
|
||||
/* kbd, mouse */ GrabModeAsync, GrabModeAsync,
|
||||
/* confine_to */ cwin,
|
||||
/* confine_to */ cwin->w,
|
||||
/* cursor */ cursor[CurInvisible],
|
||||
/* time */ CurrentTime
|
||||
) != GrabSuccess)
|
||||
goto done;
|
||||
|
||||
querypointer(&scr.root, &x, &y);
|
||||
for(;;) {
|
||||
XMaskEvent(blz.dpy, MouseMask | ExposureMask, &ev);
|
||||
XMaskEvent(display, MouseMask | ExposureMask, &ev);
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
resize_column(a, x - a->rect.x);
|
||||
resize_column(a, x - a->rect.min.x);
|
||||
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabPointer(display, CurrentTime);
|
||||
XSync(display, False);
|
||||
goto done;
|
||||
case MotionNotify:
|
||||
x = ev.xmotion.x_root;
|
||||
XMoveWindow(blz.dpy, d->w, x, 0);
|
||||
setdiv(d, x);
|
||||
break;
|
||||
case Expose:
|
||||
dispatch_event(&ev);
|
||||
|
@ -421,16 +380,16 @@ mouse_resizecol(Divide *d) {
|
|||
}
|
||||
}
|
||||
done:
|
||||
XDestroyWindow(blz.dpy, cwin);
|
||||
destroywindow(cwin);
|
||||
}
|
||||
|
||||
void
|
||||
do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
||||
BlitzAlign grav;
|
||||
Window dummy;
|
||||
do_mouse_resize(Client *c, Bool opaque, Align align) {
|
||||
Align grav;
|
||||
XWindow dummy;
|
||||
Cursor cur;
|
||||
XEvent ev;
|
||||
XRectangle *rects, ofrect, frect, origin;
|
||||
Rectangle *rects, ofrect, frect, origin;
|
||||
int snap, dx, dy, pt_x, pt_y, hr_x, hr_y;
|
||||
uint num;
|
||||
Bool floating;
|
||||
|
@ -443,7 +402,7 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
cur = cursor_of_quad(align);
|
||||
if(floating) {
|
||||
rects = rects_of_view(f->area->view, &num, (opaque ? c->frame : nil));
|
||||
snap = screen->rect.height / 66;
|
||||
snap = def.snap;
|
||||
}else{
|
||||
rects = nil;
|
||||
snap = 0;
|
||||
|
@ -459,12 +418,12 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
}
|
||||
|
||||
querypointer(c->framewin, &pt_x, &pt_y);
|
||||
rx = (float)pt_x / frect.width;
|
||||
ry = (float)pt_y / frect.height;
|
||||
rx = (float)pt_x / Dx(frect);
|
||||
ry = (float)pt_y /Dy(frect);
|
||||
|
||||
if(XGrabPointer(
|
||||
/* display */ blz.dpy,
|
||||
/* window */ c->framewin,
|
||||
/* display */ display,
|
||||
/* window */ c->framewin->w,
|
||||
/* owner_events */ False,
|
||||
/* event_mask */ MouseMask,
|
||||
/* pointer_mode */ GrabModeAsync,
|
||||
|
@ -475,18 +434,18 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
) != GrabSuccess)
|
||||
return;
|
||||
|
||||
querypointer(blz.root, &pt_x, &pt_y);
|
||||
querypointer(&scr.root, &pt_x, &pt_y);
|
||||
|
||||
if(align != CENTER) {
|
||||
hr_x = dx = frect.width / 2;
|
||||
hr_y = dy = frect.height / 2;
|
||||
hr_x = dx = Dx(frect) / 2;
|
||||
hr_y = dy = Dy(frect) / 2;
|
||||
if(align&NORTH) dy -= hr_y;
|
||||
if(align&SOUTH) dy += hr_y;
|
||||
if(align&EAST) dx += hr_x;
|
||||
if(align&WEST) dx -= hr_x;
|
||||
|
||||
XTranslateCoordinates(blz.dpy,
|
||||
/* src, dst */ c->framewin, blz.root,
|
||||
XTranslateCoordinates(display,
|
||||
/* src, dst */ c->framewin->w, scr.root.w,
|
||||
/* src x,y */ dx, dy,
|
||||
/* dest x,y */ &pt_x, &pt_y,
|
||||
/* child */ &dummy
|
||||
|
@ -494,33 +453,33 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
warppointer(pt_x, pt_y);
|
||||
}
|
||||
else if(f->client->fullscreen) {
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XUngrabPointer(display, CurrentTime);
|
||||
return;
|
||||
}
|
||||
else if(!opaque) {
|
||||
hrx = (double)(screen->rect.width + frect.width - 2 * labelh(&def.font))
|
||||
/ screen->rect.width;
|
||||
hry = (double)(screen->rect.height + frect.height - 3 * labelh(&def.font))
|
||||
/ screen->rect.height;
|
||||
pt_x = r_east(&frect) - labelh(&def.font);
|
||||
pt_y = r_south(&frect) - labelh(&def.font);
|
||||
hrx = (double)(Dx(screen->rect) + Dx(frect) - 2 * labelh(def.font))
|
||||
/ Dx(screen->rect);
|
||||
hry = (double)(Dy(screen->rect) + Dy(frect) - 3 * labelh(def.font))
|
||||
/ Dy(screen->rect);
|
||||
pt_x = frect.max.x - labelh(def.font);
|
||||
pt_y = frect.max.y - labelh(def.font);
|
||||
warppointer(pt_x / hrx, pt_y / hry);
|
||||
flushevents(PointerMotionMask, False);
|
||||
}
|
||||
|
||||
XSync(blz.dpy, False);
|
||||
XSync(display, False);
|
||||
if(!opaque) {
|
||||
XGrabServer(blz.dpy);
|
||||
xorborder(&frect);
|
||||
XGrabServer(display);
|
||||
xorborder(frect);
|
||||
}else
|
||||
unmap_client(c, IconicState);
|
||||
|
||||
for(;;) {
|
||||
XMaskEvent(blz.dpy, MouseMask | ExposureMask, &ev);
|
||||
XMaskEvent(display, MouseMask | ExposureMask, &ev);
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
if(!opaque)
|
||||
xorborder(&frect);
|
||||
xorborder(frect);
|
||||
|
||||
if(!floating)
|
||||
resize_colframe(f, &frect);
|
||||
|
@ -528,24 +487,24 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
resize_client(c, &frect);
|
||||
|
||||
if(!opaque) {
|
||||
XTranslateCoordinates(blz.dpy,
|
||||
/* src, dst */ c->framewin, blz.root,
|
||||
/* src_x */ (frect.width * rx),
|
||||
/* src_y */ (frect.height * ry),
|
||||
XTranslateCoordinates(display,
|
||||
/* src, dst */ c->framewin->w, scr.root.w,
|
||||
/* src_x */ (Dx(frect) * rx),
|
||||
/* src_y */ (Dy(frect) * ry),
|
||||
/* dest x,y */ &pt_x, &pt_y,
|
||||
/* child */ &dummy
|
||||
);
|
||||
if(pt_y > screen->brect.y)
|
||||
pt_y = screen->brect.y - 1;
|
||||
if(pt_y > screen->brect.min.y)
|
||||
pt_y = screen->brect.min.y - 1;
|
||||
warppointer(pt_x, pt_y);
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabServer(display);
|
||||
}else
|
||||
map_client(c);
|
||||
|
||||
free(rects);
|
||||
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabPointer(display, CurrentTime);
|
||||
XSync(display, False);
|
||||
return;
|
||||
case MotionNotify:
|
||||
ofrect = frect;
|
||||
|
@ -555,31 +514,31 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
if(align == CENTER && !opaque) {
|
||||
dx = (dx * hrx) - pt_x;
|
||||
dy = (dy * hry) - pt_y;
|
||||
}else{
|
||||
}else {
|
||||
dx -= pt_x;
|
||||
dy -= pt_y;
|
||||
}
|
||||
pt_x += dx;
|
||||
pt_y += dy;
|
||||
|
||||
rect_morph_xy(&origin, dx, dy, &align);
|
||||
check_frame_constraints(&origin);
|
||||
rect_morph_xy(&origin, Pt(dx, dy), &align);
|
||||
origin = constrain(origin);
|
||||
frect = origin;
|
||||
|
||||
if(floating)
|
||||
grav = snap_rect(rects, num, &frect, &align, snap);
|
||||
else
|
||||
grav = align ^ CENTER;
|
||||
grav = align^CENTER;
|
||||
|
||||
apply_sizehints(c, &frect, floating, True, grav);
|
||||
check_frame_constraints(&frect);
|
||||
frect = constrain(frect);
|
||||
|
||||
if(opaque) {
|
||||
XMoveWindow(blz.dpy, c->framewin, frect.x, frect.y);
|
||||
XSync(blz.dpy, False);
|
||||
} else {
|
||||
xorborder(&ofrect);
|
||||
xorborder(&frect);
|
||||
movewin(c->framewin, frect.min);
|
||||
XSync(display, False);
|
||||
}else {
|
||||
xorborder(ofrect);
|
||||
xorborder(frect);
|
||||
}
|
||||
break;
|
||||
case Expose:
|
||||
|
@ -592,13 +551,13 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
|
|||
}
|
||||
|
||||
void
|
||||
grab_button(Window w, uint button, ulong mod) {
|
||||
XGrabButton(blz.dpy, button, mod, w, False, ButtonMask,
|
||||
grab_button(XWindow w, uint button, ulong mod) {
|
||||
XGrabButton(display, button, mod, w, False, ButtonMask,
|
||||
GrabModeSync, GrabModeSync, None, None);
|
||||
if((mod != AnyModifier) && (num_lock_mask != 0)) {
|
||||
XGrabButton(blz.dpy, button, mod | num_lock_mask, w, False, ButtonMask,
|
||||
XGrabButton(display, button, mod | num_lock_mask, w, False, ButtonMask,
|
||||
GrabModeSync, GrabModeAsync, None, None);
|
||||
XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False,
|
||||
XGrabButton(display, button, mod | num_lock_mask | LockMask, w, False,
|
||||
ButtonMask, GrabModeSync, GrabModeAsync, None, None);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ can get it touch with me at the following location:
|
|||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <util.h>
|
||||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
//#include "dat.h"
|
||||
//#include "fns.h"
|
||||
#include "printevent.h"
|
||||
|
||||
static char* sep = " ";
|
||||
|
@ -854,11 +854,12 @@ char *eventtype(XEvent *ev)
|
|||
|
||||
void printevent(XEvent *e)
|
||||
{
|
||||
extern Display* display;
|
||||
XAnyEvent *ev = (void*)e;
|
||||
char *name;
|
||||
|
||||
if(ev->window) {
|
||||
XFetchName(blz.dpy, ev->window, &name);
|
||||
XFetchName(display, ev->window, &name);
|
||||
if(name) {
|
||||
fprintf(stderr, "\ttitle=%s\n", name);
|
||||
XFree(name);
|
||||
|
|
159
cmd/wmii/view.c
159
cmd/wmii/view.c
|
@ -62,6 +62,7 @@ create_view(const char *name) {
|
|||
|
||||
v = emallocz(sizeof(View));
|
||||
v->id = id++;
|
||||
|
||||
strncpy(v->name, name, sizeof(v->name));
|
||||
|
||||
write_event("CreateTag %s\n", v->name);
|
||||
|
@ -86,14 +87,19 @@ destroy_view(View *v) {
|
|||
while((a = v->area)) {
|
||||
v->area = a->next;
|
||||
destroy_area(a);
|
||||
};
|
||||
}
|
||||
|
||||
for(i=&view; *i; i=&(*i)->next)
|
||||
if(*i == v) break;
|
||||
*i = v->next;
|
||||
|
||||
write_event("DestroyTag %s\n", v->name);
|
||||
|
||||
if(v == screen->sel) {
|
||||
for(tv=view; tv && tv->next; tv=tv->next)
|
||||
for(tv=view; tv; tv=tv->next)
|
||||
if(tv->next == *i) break;
|
||||
if(tv == nil)
|
||||
tv = view;
|
||||
if(tv)
|
||||
focus_view(screen, tv);
|
||||
}
|
||||
|
@ -117,7 +123,9 @@ focus_view(WMScreen *s, View *v) {
|
|||
Client *c;
|
||||
|
||||
old = screen->sel;
|
||||
XGrabServer(blz.dpy);
|
||||
|
||||
XGrabServer(display);
|
||||
|
||||
assign_sel_view(v);
|
||||
update_frame_selectors(v);
|
||||
update_divs();
|
||||
|
@ -135,8 +143,9 @@ focus_view(WMScreen *s, View *v) {
|
|||
restack_view(v);
|
||||
focus_area(v->sel);
|
||||
draw_frames();
|
||||
XSync(blz.dpy, False);
|
||||
XUngrabServer(blz.dpy);
|
||||
|
||||
XSync(display, False);
|
||||
XUngrabServer(display);
|
||||
flushevents(EnterWindowMask, False);
|
||||
}
|
||||
|
||||
|
@ -146,10 +155,12 @@ select_view(const char *arg) {
|
|||
|
||||
strncpy(buf, arg, sizeof(buf));
|
||||
trim(buf, " \t+/");
|
||||
if(!strlen(buf))
|
||||
|
||||
if(strlen(buf) == 0)
|
||||
return;
|
||||
if(!strncmp(buf, ".", 2) || !strncmp(buf, "..", 3))
|
||||
if(!strcmp(buf, ".") || !strcmp(buf, ".."))
|
||||
return;
|
||||
|
||||
assign_sel_view(get_view(buf));
|
||||
update_views(); /* performs focus_view */
|
||||
}
|
||||
|
@ -168,8 +179,8 @@ attach_to_view(View *v, Frame *f) {
|
|||
|
||||
void
|
||||
restack_view(View *v) {
|
||||
static Window *wins = nil;
|
||||
static uint winssz = 0;
|
||||
static XWindow *wins;
|
||||
static uint winssz;
|
||||
Divide *d;
|
||||
Frame *f;
|
||||
Client *c;
|
||||
|
@ -180,8 +191,6 @@ restack_view(View *v) {
|
|||
return;
|
||||
|
||||
i = 0;
|
||||
n = 0;
|
||||
|
||||
for(c = client; c; c = c->next)
|
||||
i++;
|
||||
if(i == 0)
|
||||
|
@ -195,7 +204,8 @@ restack_view(View *v) {
|
|||
wins = erealloc(wins, sizeof(Window) * winssz);
|
||||
}
|
||||
|
||||
wins[n++] = screen->barwin;
|
||||
n = 0;
|
||||
wins[n++] = screen->barwin->w;
|
||||
for(f = v->area->frame; f; f = f->anext)
|
||||
if(f->client->fullscreen) {
|
||||
n--;
|
||||
|
@ -203,96 +213,110 @@ restack_view(View *v) {
|
|||
}
|
||||
|
||||
for(f=v->area->stack; f; f=f->snext)
|
||||
wins[n++] = f->client->framewin;
|
||||
wins[n++] = f->client->framewin->w;
|
||||
|
||||
for(d = divs; d && d->mapped; d = d->next)
|
||||
wins[n++] = d->w;
|
||||
wins[n++] = d->w->w;
|
||||
|
||||
for(a=v->area->next; a; a=a->next)
|
||||
if(a->frame) {
|
||||
wins[n++] = a->sel->client->framewin;
|
||||
wins[n++] = a->sel->client->framewin->w;
|
||||
for(f=a->frame; f; f=f->anext)
|
||||
if(f != a->sel)
|
||||
wins[n++] = f->client->framewin;
|
||||
wins[n++] = f->client->framewin->w;
|
||||
}
|
||||
if(n)
|
||||
XRestackWindows(blz.dpy, wins, n);
|
||||
XRestackWindows(display, wins, n);
|
||||
}
|
||||
|
||||
void
|
||||
scale_view(View *v, float w) {
|
||||
scale_view(View *v, int w) {
|
||||
uint xoff, num_col;
|
||||
uint min_width;
|
||||
Area *a;
|
||||
float scale, dx = 0;
|
||||
int wdiff = 0;
|
||||
float scale, dx;
|
||||
int wdiff;
|
||||
|
||||
min_width = screen->rect.width/NCOL;
|
||||
min_width = Dx(screen->rect)/NCOL;
|
||||
|
||||
if(!v->area->next)
|
||||
return;
|
||||
|
||||
num_col = 0;
|
||||
for(a=v->area->next; a; a=a->next)
|
||||
num_col++, dx += a->rect.width;
|
||||
dx = 0;
|
||||
for(a=v->area->next; a; a=a->next) {
|
||||
num_col++;
|
||||
dx += Dx(a->rect);
|
||||
}
|
||||
|
||||
scale = w / dx;
|
||||
scale = (float)w / dx;
|
||||
xoff = 0;
|
||||
for(a=v->area->next; a; a=a->next) {
|
||||
a->rect.width *= scale;
|
||||
a->rect.min.x = xoff;
|
||||
a->rect.max.x = xoff + Dx(a->rect) * scale;
|
||||
if(!a->next)
|
||||
a->rect.width = w - xoff;
|
||||
xoff += a->rect.width;
|
||||
a->rect.max.x = w;
|
||||
xoff = a->rect.max.x;
|
||||
}
|
||||
|
||||
/* min_width can only be respected when there is enough space;
|
||||
* the caller should guarantee this */
|
||||
if(num_col * min_width > w)
|
||||
return;
|
||||
|
||||
xoff = 0;
|
||||
for(a=v->area->next, num_col--; a; a=a->next, num_col--) {
|
||||
if(a->rect.width < min_width)
|
||||
a->rect.width = min_width;
|
||||
else if((wdiff = xoff + a->rect.width - w + num_col * min_width) > 0)
|
||||
a->rect.width -= wdiff;
|
||||
a->rect.min.x = xoff;
|
||||
|
||||
if(Dx(a->rect) < min_width)
|
||||
a->rect.max.x = xoff + min_width;
|
||||
else if((wdiff = xoff + Dx(a->rect) - w + num_col * min_width) > 0)
|
||||
a->rect.max.x -= wdiff;
|
||||
if(!a->next)
|
||||
a->rect.width = w - xoff;
|
||||
xoff += a->rect.width;
|
||||
a->rect.max.x = w;
|
||||
|
||||
xoff = a->rect.max.x;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
arrange_view(View *v) {
|
||||
uint xoff = 0;
|
||||
uint xoff;
|
||||
Area *a;
|
||||
|
||||
if(!v->area->next)
|
||||
return;
|
||||
scale_view(v, screen->rect.width);
|
||||
|
||||
scale_view(v, Dx(screen->rect));
|
||||
xoff = 0;
|
||||
for(a=v->area->next; a; a=a->next) {
|
||||
a->rect.x = xoff;
|
||||
a->rect.y = 0;
|
||||
a->rect.height = screen->rect.height - screen->brect.height;
|
||||
xoff += a->rect.width;
|
||||
a->rect.min.x = xoff;
|
||||
a->rect.min.y = 0;
|
||||
a->rect.max.y = screen->brect.min.y;
|
||||
xoff = a->rect.max.x;
|
||||
arrange_column(a, False);
|
||||
}
|
||||
}
|
||||
|
||||
XRectangle *
|
||||
Rectangle *
|
||||
rects_of_view(View *v, uint *num, Frame *ignore) {
|
||||
XRectangle *result;
|
||||
Rectangle *result;
|
||||
Frame *f;
|
||||
int i;
|
||||
|
||||
i = 2;
|
||||
for(f=v->area->frame; f; f=f->anext)
|
||||
i++;
|
||||
result = emallocz(i * sizeof(XRectangle));
|
||||
|
||||
result = emallocz(i * sizeof(Rectangle));
|
||||
|
||||
i = 0;
|
||||
for(f=v->area->frame; f; f=f->anext)
|
||||
if(f != ignore)
|
||||
result[i++] = f->rect;
|
||||
result[i++] = screen->rect;
|
||||
result[i++] = screen->brect;
|
||||
|
||||
*num = i;
|
||||
return result;
|
||||
}
|
||||
|
@ -300,40 +324,43 @@ rects_of_view(View *v, uint *num, Frame *ignore) {
|
|||
/* XXX: This will need cleanup */
|
||||
uchar *
|
||||
view_index(View *v) {
|
||||
uint a_i, buf_i, n;
|
||||
int len;
|
||||
Frame *f;
|
||||
Area *a;
|
||||
char *buf;
|
||||
uint i, n;
|
||||
int len;
|
||||
|
||||
len = sizeof(buffer);
|
||||
buf_i = 0;
|
||||
for((a = v->area), (a_i = 0); a && len > 0; (a=a->next), (a_i++)) {
|
||||
buf = buffer;
|
||||
for((a=v->area), (i=0); a && len > 0; (a=a->next), i++) {
|
||||
if(a->floating)
|
||||
n = snprintf(&buffer[buf_i], len, "# ~ %d %d\n",
|
||||
a->rect.width, a->rect.height);
|
||||
n = snprintf(buf, len, "# ~ %d %d\n",
|
||||
Dx(a->rect), Dy(a->rect));
|
||||
else
|
||||
n = snprintf(&buffer[buf_i], len, "# %d %d %d\n",
|
||||
a_i, a->rect.x, a->rect.width);
|
||||
buf_i += n;
|
||||
n = snprintf(buf, len, "# %d %d %d\n",
|
||||
i, a->rect.min.x, Dx(a->rect));
|
||||
|
||||
buf += n;
|
||||
len -= n;
|
||||
for(f=a->frame; f && len > 0; f=f->anext) {
|
||||
XRectangle *r = &f->rect;
|
||||
Rectangle *r = &f->rect;
|
||||
if(a->floating)
|
||||
n = snprintf(&buffer[buf_i], len, "~ 0x%x %d %d %d %d %s\n",
|
||||
(uint)f->client->win,
|
||||
r->x, r->y, r->width, r->height,
|
||||
n = snprintf(buf, len, "~ 0x%x %d %d %d %d %s\n",
|
||||
(uint)f->client->win.w,
|
||||
r->min.x, r->min.y, Dx(*r), Dy(*r),
|
||||
f->client->props);
|
||||
else
|
||||
n = snprintf(&buffer[buf_i], len, "%d 0x%x %d %d %s\n",
|
||||
a_i, (uint)f->client->win, r->y,
|
||||
r->height, f->client->props);
|
||||
n = snprintf(buf, len, "%d 0x%x %d %d %s\n",
|
||||
i, (uint)f->client->win.w,
|
||||
r->min.y, Dy(*r),
|
||||
f->client->props);
|
||||
if(len - n < 0)
|
||||
return (uchar*)buffer;
|
||||
buf_i += n;
|
||||
buf += n;
|
||||
len -= n;
|
||||
}
|
||||
}
|
||||
return (uchar *)buffer;
|
||||
return (uchar*)buffer;
|
||||
}
|
||||
|
||||
Client *
|
||||
|
@ -345,12 +372,15 @@ client_of_message(View *v, char *message, uint *next) {
|
|||
*next = 4;
|
||||
return view_selclient(v);
|
||||
}
|
||||
|
||||
sscanf(message, "0x%lx %n", &id, next);
|
||||
if(!id)
|
||||
sscanf(message, "%lu %n", &id, next);
|
||||
if(!id)
|
||||
return nil;
|
||||
for(c=client; c && c->win!=id; c=c->next);
|
||||
|
||||
for(c=client; c; c=c->next)
|
||||
if(c->win.w == id) break;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -367,10 +397,11 @@ area_of_message(View *v, char *message, uint *next) {
|
|||
*next = 2;
|
||||
return v->area;
|
||||
}
|
||||
|
||||
if(1 != sscanf(message, "%u %n", &i, next) || i == 0)
|
||||
return nil;
|
||||
for(a=v->area; i && a; a=a->next)
|
||||
i--;
|
||||
for(a=v->area; a; a=a->next)
|
||||
if(i-- == 0) break;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -463,7 +494,7 @@ newcolw_of_view(View *v, int num) {
|
|||
n = tokenize(toks, 16, buf, '+');
|
||||
if(n > num)
|
||||
if(sscanf(toks[num], "%u", &n) == 1)
|
||||
return screen->rect.width * ((double)n / 100);
|
||||
return Dx(screen->rect) * ((double)n / 100);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
18
rc/wmiirc.sh
18
rc/wmiirc.sh
|
@ -93,11 +93,13 @@ eventstuff() {
|
|||
esac
|
||||
menulast=${do:-"$menulast"}
|
||||
esac
|
||||
!
|
||||
cat <<!
|
||||
# Key Bindings
|
||||
Key $MODKEY-Control-t
|
||||
case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
|
||||
case \$(wmiir read /keys | wc -l | tr -d ' \t\n') in
|
||||
0|1)
|
||||
echo -n $Keys | tr ' ' '\012' | wmiir write /keys
|
||||
echo -n \$Keys | tr ' ' '\012' | wmiir write /keys
|
||||
wmiir xwrite /ctl grabmod $MODKEY;;
|
||||
*)
|
||||
wmiir xwrite /keys $MODKEY-Control-t
|
||||
|
@ -120,11 +122,11 @@ eventstuff() {
|
|||
Key $MODKEY-m
|
||||
wmiir xwrite /tag/sel/ctl colmode sel max
|
||||
Key $MODKEY-a
|
||||
Action $(actionlist | $WMII_MENU) &
|
||||
Action \$(actionlist | \$WMII_MENU) &
|
||||
Key $MODKEY-p
|
||||
sh -c "$($WMII_MENU <$progsfile)" &
|
||||
sh -c "\$(\$WMII_MENU <\$progsfile)" &
|
||||
Key $MODKEY-t
|
||||
wmiir xwrite /ctl "view $(tagsmenu)" &
|
||||
wmiir xwrite /ctl "view \$(tagsmenu)" &
|
||||
Key $MODKEY-Return
|
||||
$WMII_TERM &
|
||||
Key $MODKEY-Shift-$LEFT
|
||||
|
@ -140,7 +142,7 @@ eventstuff() {
|
|||
Key $MODKEY-Shift-c
|
||||
wmiir xwrite /client/sel/ctl kill
|
||||
Key $MODKEY-Shift-t
|
||||
wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" "$(tagsmenu)" &
|
||||
wmiir xwrite "/client/\$(wmiir read /client/sel/ctl)/tags" "\$(tagsmenu)" &
|
||||
!
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
cat <<!
|
||||
|
@ -163,7 +165,9 @@ EOF
|
|||
|
||||
# Feed events to `wmiiloop' for processing
|
||||
IFS=''
|
||||
eval $(eventstuff | sed "s/\\\$MODKEY/$MODKEY/g;s/^[ ]//" | wmiiloop)
|
||||
regex=''
|
||||
for i in MODKEY LEFT RIGHT UP DOWN; do regex="$regex""s|\\\$$i|`eval echo '$'$i`|g;"; done
|
||||
eval $(eventstuff | sed "$regex""s/^[ ]//" | wmiiloop)
|
||||
unset IFS
|
||||
|
||||
# Functions
|
||||
|
|
Loading…
Reference in New Issue