commit 5db99548345a5367626dce99b1b8b41a7ffdcd8f
parent 884269f5a131b46974331c61adc9103eb0e0df80
Author: Kris Maglione <bsdaemon@wmii.de>
Date: Thu, 29 Jun 2006 13:35:57 -0400
Merge, it seems
Diffstat:
9 files changed, 108 insertions(+), 120 deletions(-)
diff --git a/TODO.wmii-4 b/TODO.wmii-4
@@ -1,14 +1,16 @@
-- fs2.c refactorings
-- implement /lbar/ and /rbar/ (first label of /rbar/ should take up the rest available space)
-- make frames view-specific, do not destroy them during send_to_area's within a view (allows faster checks for client_of_view etc).
-- idea for column mode: add collapsing to each Frame, add revert Xrectangle, remove column modes, add max flag to each Frame (maximizes to area until next navigation action within this area)
-- do better relaxation (remove /def/border and calculate borders dynamically)
-- re-introduce mouse based resizals (titlebar and border)
-- liblitz: window abstraction (creation, events), can be reused in menu and bar
- and frames
-- tagbars and grab-boxes (like in acme)
-- screen dimension rescaling if screen resolution changes (even with Xrandr)
-- Xinerama support
-- partial EWMH support
-- libixp: idea from PoP: implement a va_args method similiar to printf for
- marshalling 9P messages, might reduce LOC drastically
+- Make frames view-specific, do not destroy them during send_to_area's within a view (allows faster checks for client_of_view etc).
+- Add collapsing to each Frame, add revert Xrectangle, remove column modes, add max flag to each Frame (maximizes to area until next navigation action within this area)
+- Editable tag bars
+- Grab boxes
+- Enable border based resizals (think about removal of /def/grabmode then)
+- New events file system interface
+- "Sticky" floating windows (scratchpad layer)
+- Do better relaxation (remove /def/border and calculate borders dynamically)
+- Resizable managed area
+- Proper managed mode resizing and movement (ie., col based based rather than arbitrary)
+- Xinerama support(?)
+- Screen dimension rescaling if screen resolution changes (even with Xrandr)
+- Partial EWMH support
+- Workaround for apps that miss resize events
+- wmiisystray
+- Plumbing for tag bar
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -777,7 +777,7 @@ apply_tags(Client *c, const char *tags)
update_client_views(c, toks);
XChangeProperty(blz.display, c->win, tags_atom, XA_STRING, 8,
- PropModeReplace, c->tags, strlen(c->tags));
+ PropModeReplace, (unsigned char *)c->tags, strlen(c->tags));
}
static void
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -79,7 +79,7 @@ handle_buttonrelease(XEvent *e)
}
else if((f = frame_of_win(ev->window))) {
if(blitz_brelease_input(&f->tagbar, ev->x, ev->y))
- map_frame(f, &f->tagbar.rect);
+ draw_frame(f);
write_event("ClientClick %d %d\n", idx_of_client(f->client), ev->button);
}
}
@@ -92,7 +92,7 @@ handle_motionnotify(XEvent *e)
if((f = frame_of_win(ev->window))) {
if(blitz_bmotion_input(&f->tagbar, ev->x, ev->y))
- map_frame(f, &f->tagbar.rect);
+ draw_frame(f);
}
}
@@ -105,7 +105,7 @@ handle_buttonpress(XEvent *e)
if((f = frame_of_win(ev->window))) {
ev->state &= valid_mask;
if(blitz_bpress_input(&f->tagbar, ev->x, ev->y))
- map_frame(f, &f->tagbar.rect);
+ draw_frame(f);
if((ev->state & def.mod) == def.mod) {
focus(f->client, True);
switch(ev->button) {
diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c
@@ -43,6 +43,8 @@ create_frame(Client *c, View *v)
f->tagbar.gc = c->gc;
f->tagbar.font = &def.font;
f->tagbar.color = def.normcolor;
+ f->tagbar.text = c->tags;
+ f->tagbar.size = sizeof(c->tags);
return f;
}
@@ -87,19 +89,10 @@ update_frame_widget_colors(Frame *f)
}
void
-map_frame(Frame *f, XRectangle *r)
-{
- XCopyArea(blz.display, pmap, f->client->framewin, f->client->gc,
- r->x, r->y, r->width, r->height, r->x, r->y);
- XSync(blz.display, False);
-}
-
-void
draw_frame(Frame *f)
{
Frame *p;
unsigned int fidx, size, w;
- XRectangle r = f->rect;
for(fidx=0, p=f->area->frame; p && p != f; p=p->anext, fidx++);
for(size=fidx; p; p=p->anext, size++);
@@ -123,9 +116,7 @@ draw_frame(Frame *f)
/* tag bar */
f->tagbar.rect = f->posbar.rect;
f->tagbar.rect.x = 0;
- f->tagbar.rect.width = def.testtags ?
- f->tagbar.rect.height + blitz_textwidth(&def.font, def.testtags) :
- f->tagbar.rect.height + blitz_textwidth(&def.font, f->client->tags);
+ f->tagbar.rect.width = f->tagbar.rect.height + blitz_textwidth(&def.font, f->tagbar.text);
if(f->tagbar.rect.width > f->rect.width / 3)
f->tagbar.rect.width = f->rect.width / 3;
@@ -135,12 +126,12 @@ draw_frame(Frame *f)
f->titlebar.rect.width = f->rect.width - (f->tagbar.rect.width + f->posbar.rect.width);
blitz_draw_tile(&f->tile);
- f->tagbar.text = def.testtags ? def.testtags : f->client->tags;
blitz_draw_input(&f->tagbar);
blitz_draw_label(&f->titlebar, f->client->name);
blitz_draw_label(&f->posbar, buffer);
- r.x = r.y = 0;
- map_frame(f, &r);
+ XCopyArea(blz.display, pmap, f->client->framewin, f->client->gc,
+ 0, 0, f->rect.width, f->rect.height, 0, 0);
+ XSync(blz.display, False);
}
void
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -288,11 +288,6 @@ message_root(char *message)
def.mod = mod;
if(view)
restack_view(sel);
- }else if(!strncmp(message, "testtags ", 9)) {
- message += 9;
- free(def.testtags);
- def.testtags = strlen(message) ? strdup(message) : nil;
- draw_frames();
}else
return Ebadcmd;
@@ -310,8 +305,6 @@ read_root_ctl()
i += snprintf(&buffer[i], (BUFFER_SIZE - i), "font %s\n", def.font.fontstr);
i += snprintf(&buffer[i], (BUFFER_SIZE - i), "grabmod %s\n", def.grabmod);
i += snprintf(&buffer[i], (BUFFER_SIZE - i), "border %d\n", def.border);
- if(def.testtags)
- i += snprintf(&buffer[i], (BUFFER_SIZE - i), "testtags %s\n", def.testtags);
return buffer;
}
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -156,7 +156,6 @@ typedef struct {
unsigned int border;
unsigned int snap;
char *keys;
- char *testtags;
unsigned int keyssz;
Rules tagrules;
Rules colrules;
@@ -265,7 +264,6 @@ void insert_frame(Frame *pos, Frame *f, Bool before);
void draw_frame(Frame *f);
void draw_frames();
void update_frame_widget_colors(Frame *f);
-void map_frame(Frame *f, XRectangle *r);
/* fs.c */
void fs_attach(P9Req *r);
diff --git a/liblitz/blitz.h b/liblitz/blitz.h
@@ -47,8 +47,6 @@ struct BlitzFont {
XFontSet set;
int ascent;
int descent;
- int rbearing;
- int lbearing;
char *fontstr;
};
@@ -90,6 +88,7 @@ void blitz_drawbg(Display *dpy, Drawable drawable, GC gc,
/* font.c */
unsigned int blitz_textwidth(BlitzFont *font, char *text);
+unsigned int blitz_textwidth_l(BlitzFont *font, char *text, unsigned int len);
void blitz_loadfont(Blitz *blitz, BlitzFont *font);
/* input.c */
diff --git a/liblitz/font.c b/liblitz/font.c
@@ -12,14 +12,20 @@
#include "blitz.h"
unsigned int
-blitz_textwidth(BlitzFont *font, char *text)
+blitz_textwidth_l(BlitzFont *font, char *text, unsigned int len)
{
if(font->set) {
XRectangle r;
- XmbTextExtents(font->set, text, strlen(text), nil, &r);
+ XmbTextExtents(font->set, text, len, nil, &r);
return r.width;
}
- return XTextWidth(font->xfont, text, strlen(text));
+ return XTextWidth(font->xfont, text, len);
+}
+
+unsigned int
+blitz_textwidth(BlitzFont *font, char *text)
+{
+ return blitz_textwidth_l(font, text, strlen(text));
}
void
@@ -56,10 +62,6 @@ blitz_loadfont(Blitz *blitz, BlitzFont *font)
font->ascent = (*xfonts)->ascent;
if(font->descent < (*xfonts)->descent)
font->descent = (*xfonts)->descent;
- if(font->rbearing < (*xfonts)->max_bounds.rbearing)
- font->rbearing = (*xfonts)->max_bounds.rbearing;
- if(font->lbearing < (*xfonts)->min_bounds.lbearing)
- font->lbearing = (*xfonts)->min_bounds.lbearing;
xfonts++;
}
}
@@ -78,7 +80,5 @@ blitz_loadfont(Blitz *blitz, BlitzFont *font)
}
font->ascent = font->xfont->ascent;
font->descent = font->xfont->descent;
- font->rbearing = font->xfont->max_bounds.rbearing;
- font->lbearing = font->xfont->min_bounds.lbearing;
}
}
diff --git a/liblitz/input.c b/liblitz/input.c
@@ -32,84 +32,101 @@ xchangegc(BlitzInput *i, BlitzColor *c, Bool invert)
static void
xdrawtextpart(BlitzInput *i, char *start, char *end,
- int *xoff, int yoff, unsigned int boxw)
+ unsigned int *xoff, unsigned int yoff)
{
- char *p, buf[2];
-
- buf[1] = 0;
- for(p = start; p && *p && p != end; p++) {
- *buf = *p;
- if(i->font->set)
- XmbDrawImageString(i->blitz->display, i->drawable, i->font->set, i->gc,
- *xoff, yoff, buf, 1);
- else
- XDrawImageString(i->blitz->display, i->drawable, i->gc, *xoff, yoff,
- buf, 1);
- *xoff += boxw;
- }
-}
+ char c;
+ if(!start)
+ return;
+ if(end) {
+ c = *end;
+ *end = 0;
+ }
+ if(i->font->set)
+ XmbDrawImageString(i->blitz->display, i->drawable, i->font->set, i->gc,
+ *xoff, yoff, start, strlen(start));
+ else
+ XDrawImageString(i->blitz->display, i->drawable, i->gc, *xoff, yoff,
+ start, strlen(start));
-void
-xget_fontmetric(BlitzInput *i, int *x, int *y, unsigned int *w, unsigned int *h)
-{
- *w = i->font->rbearing - i->font->lbearing;
- *h = i->font->ascent + i->font->descent;
- /* XXX: This is a temporary hack */
- *x = i->rect.x + (i->rect.height - *h) / 2 + i->font->rbearing;
- *y = i->rect.y + (i->rect.height - *h) / 2 + i->font->ascent;
+ *xoff += blitz_textwidth(i->font, start);
+ if(end)
+ *end = c;
}
+
void
blitz_draw_input(BlitzInput *i)
{
- int xoff, yoff;
- unsigned int boxw, boxh, nbox;
+ unsigned int xoff, yoff;
+ char *start, *end;
if (!i)
return;
blitz_drawbg(i->blitz->display, i->drawable, i->gc, i->rect, i->color, True);
- xget_fontmetric(i, &xoff, &yoff, &boxw, &boxh);
- nbox = i->rect.width / boxw;
+
+ yoff = i->rect.y + (i->rect.height - (i->font->ascent + i->font->descent))
+ / 2 + i->font->ascent;
+ xoff = i->rect.x + i->rect.height / 2;
+
+ start = end = nil;
+ if(i->curstart && i->curend && i->curstart < i->curend) {
+ start = i->curstart;
+ end = i->curend;
+ }
+ else {
+ start = i->curend;
+ end = i->curstart;
+ }
+ if(end)
+ end++;
/* draw normal text */
xchangegc(i, &i->color, False);
- xdrawtextpart(i, i->text, i->curstart, &xoff, yoff, boxw);
+ xdrawtextpart(i, i->text, start, &xoff, yoff);
/* draw sel text */
xchangegc(i, &i->color, True);
- xdrawtextpart(i, i->curstart, i->curend, &xoff, yoff, boxw);
+ xdrawtextpart(i, start, end, &xoff, yoff);
/* draw remaining normal text */
xchangegc(i, &i->color, False);
- xdrawtextpart(i, i->curend, nil, &xoff, yoff, boxw);
+ xdrawtextpart(i, end, nil, &xoff, yoff);
+}
+
+Bool
+blitz_ispointinrect(int x, int y, XRectangle * r)
+{
+ return (x >= r->x) && (x <= r->x + r->width)
+ && (y >= r->y) && (y <= r->y + r->height);
}
static char *
-charof(BlitzInput *i, int x, int y)
+xcharof(BlitzInput *i, int x, char *start, unsigned int len)
{
- int xoff, yoff;
- unsigned int boxw, boxh, nbox, cbox, l;
+ unsigned int piv, tw;
- if(!i->text || (y < i->rect.y) || (y > i->rect.y + i->rect.height))
- return nil;
- xget_fontmetric(i, &xoff, &yoff, &boxw, &boxh);
- nbox = i->rect.width / boxw;
- cbox = (x - i->rect.x) / boxw;
+ if(!(piv = len / 2))
+ return start; /* found */
- if(cbox > nbox)
- return nil;
+ tw = blitz_textwidth_l(i->font, start, piv);
- if((l = strlen(i->text)) > cbox)
- return i->text + cbox;
+ if(x < tw)
+ return xcharof(i, x, start, piv);
else
- return i->text + l;
+ return xcharof(i, x - tw, start + piv, strlen(start + piv));
}
-Bool
-blitz_ispointinrect(int x, int y, XRectangle * r)
+static char *
+charof(BlitzInput *i, int x, int y)
{
- return (x >= r->x) && (x <= r->x + r->width)
- && (y >= r->y) && (y <= r->y + r->height);
+ if(!i->text || !blitz_ispointinrect(x, y, &i->rect))
+ return nil;
+
+ /* normalize x */
+ if((x -= (i->rect.x + i->rect.height / 2)) < 0)
+ return nil;
+
+ return xcharof(i, x, i->text, strlen(i->text));
}
Bool
@@ -117,16 +134,12 @@ blitz_bpress_input(BlitzInput *i, int x, int y)
{
char *ostart, *oend;
- if(!blitz_ispointinrect(x, y, &i->rect))
+ if(!(i->drag = blitz_ispointinrect(x, y, &i->rect)))
return False;
ostart = i->curstart;
oend = i->curend;
i->curstart = i->curend = charof(i, x, y);
- i->drag = True;
- if((i->curstart == ostart) && (i->curend == oend))
- return False;
- blitz_draw_input(i);
- return True;
+ return (i->curstart == ostart) && (i->curend == oend);
}
Bool
@@ -134,15 +147,13 @@ blitz_brelease_input(BlitzInput *i, int x, int y)
{
char *oend;
- if(!blitz_ispointinrect(x, y, &i->rect))
+ if(!(i->drag = blitz_ispointinrect(x, y, &i->rect)) ||
+ !i->curstart)
return False;
oend = i->curend;
i->curend = charof(i, x, y);
i->drag = False;
- if(i->curend == oend)
- return False;
- blitz_draw_input(i);
- return True;
+ return i->curend == oend;
}
Bool
@@ -150,17 +161,11 @@ blitz_bmotion_input(BlitzInput *i, int x, int y)
{
char *oend;
- if(!i->drag || !blitz_ispointinrect(x, y, &i->rect))
+ if(!i->drag || !(i->drag = blitz_ispointinrect(x, y, &i->rect))
+ || !i->curstart)
return False;
oend = i->curend;
i->curend = charof(i, x, y);
- if(i->curend == oend)
- return False;
- if(i->curstart > i->curend) {
- char *tmp = i->curend;
- i->curend = i->curstart;
- i->curstart = tmp;
- }
- return True;
+ return i->curend == oend;
}