diff --git a/src/bar.c b/src/bar.c index 34b8a84..5a0b63f 100644 --- a/src/bar.c +++ b/src/bar.c @@ -210,7 +210,7 @@ uicb_togglebarpos(uicb_t cmd) int i; conf.bartop = !conf.bartop; - sgeo.y = (conf.bartop) ? barheight : 0; + sgeo.y = (conf.bartop) ? barheight + conf.ttbarheight : conf.ttbarheight; if(conf.bartop) bary = 0; @@ -242,6 +242,7 @@ updatetitlebar(Client *c) draw_text(c->tbar->dr, 3, ((fonth - xftfont->descent) + ((conf.ttbarheight - fonth) / 2)), ((c == sel) ? conf.colors.ttbar_text_focus : conf.colors.ttbar_text_normal), conf.colors.bar, 0, c->title); + bar_refresh(c->tbar); } diff --git a/src/client.c b/src/client.c index a7a5915..2f57c6e 100644 --- a/src/client.c +++ b/src/client.c @@ -131,9 +131,9 @@ client_focus(Client *c) if(sel && sel != c) { grabbuttons(sel, False); - draw_border(sel->win, conf.colors.bordernormal); + XSetWindowBorder(dpy, sel->win, conf.colors.bordernormal); if(conf.ttbarheight) - draw_border(sel->tbar->win, conf.colors.bordernormal); + XSetWindowBorder(dpy, sel->tbar->win, conf.colors.bordernormal); } if(c) @@ -144,9 +144,9 @@ client_focus(Client *c) if(c) { - draw_border(c->win, conf.colors.borderfocus); + XSetWindowBorder(dpy, c->win, conf.colors.borderfocus); if(conf.ttbarheight) - draw_border(c->tbar->win, conf.colors.borderfocus); + XSetWindowBorder(dpy, c->tbar->win, conf.colors.borderfocus); if(conf.raisefocus) raiseclient(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); @@ -188,15 +188,15 @@ client_gettbar(Window w) void client_hide(Client *c) { - if(!c) - return; + //XMoveWindow(dpy, c->win, c->geo.x, c->geo.y + sgeo.height*2); + //if(conf.ttbarheight) + // bar_moveresize(c->tbar, c->geo.x, + // c->geo.y + sgeo.height*2, + //c->geo.width, c->geo.height); - XMoveWindow(dpy, c->win, c->geo.x, c->geo.y + sgeo.height*2); + XUnmapWindow(dpy, c->win); if(conf.ttbarheight) - bar_moveresize(c->tbar, - c->geo.x, - c->geo.y + sgeo.height*2, - c->geo.width, c->geo.height); + XUnmapWindow(dpy, c->tbar->win); setwinstate(c->win, IconicState); c->hide = True; @@ -266,6 +266,7 @@ client_manage(Window w, XWindowAttributes *wa) c->geo.width = wa->width; c->geo.height = wa->height - conf.ttbarheight; c->tag = seltag; + c->border = conf.borderheight; /* Create titlebar */ if(conf.ttbarheight) @@ -273,8 +274,9 @@ client_manage(Window w, XWindowAttributes *wa) c->geo.width, conf.ttbarheight, conf.borderheight, conf.colors.bar, True); + winc.border_width = c->border; XConfigureWindow(dpy, w, CWBorderWidth, &winc); - draw_border(w, conf.colors.bordernormal); + XSetWindowBorder(dpy, w, conf.colors.bordernormal); grabbuttons(c, False); XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask); @@ -311,8 +313,8 @@ client_moveresize(Client *c, XRectangle geo, bool r) /* minimum possible */ if (geo.width < 1) geo.width = 1; - if (geo.height < conf.ttbarheight + 1) - geo.height = conf.ttbarheight + 1; + if (geo.height < 1) + geo.height = 1; /* base */ geo.width -= c->basew; @@ -359,14 +361,11 @@ client_moveresize(Client *c, XRectangle geo, bool r) { c->geo = geo; - XMoveResizeWindow(dpy, - c->win, - geo.x, - geo.y + conf.ttbarheight, - geo.width, geo.height - conf.ttbarheight); + XMoveResizeWindow(dpy, c->win, geo.x, geo.y, + geo.width, geo.height); if(conf.ttbarheight) - bar_moveresize(c->tbar, geo.x, geo.y, geo.width, conf.ttbarheight); + bar_moveresize(c->tbar, geo.x, geo.y - conf.ttbarheight, geo.width, conf.ttbarheight); updatetitlebar(c); XSync(dpy, False); @@ -465,12 +464,16 @@ raiseclient(Client *c) void client_unhide(Client *c) { - if(!c) - return; - XMoveWindow(dpy, c->win, c->geo.x, c->geo.y + conf.ttbarheight); + //XMoveWindow(dpy, c->win, c->geo.x, c->geo.y); + //if(conf.ttbarheight) + // bar_moveresize(c->tbar, c->geo.x, + // c->geo.y - conf.ttbarheight, + // c->geo.width, conf.ttbarheight); + + XMapWindow(dpy, c->win); if(conf.ttbarheight) - bar_moveresize(c->tbar, c->geo.x, - c->geo.y, c->geo.width, conf.ttbarheight); + XMapWindow(dpy, c->tbar->win); + setwinstate(c->win, NormalState); c->hide = False; diff --git a/src/draw.c b/src/draw.c index 2170822..f034ca3 100644 --- a/src/draw.c +++ b/src/draw.c @@ -107,18 +107,6 @@ draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color) return; } -void -draw_border(Window win, int color) -{ - if(!win) - return; - - XSetWindowBorder(dpy, win, color); - XSetWindowBorderWidth(dpy, win, conf.borderheight); - - return; -} - ushort textw(const char *text) { diff --git a/src/event.c b/src/event.c index eb9c08d..3feec72 100644 --- a/src/event.c +++ b/src/event.c @@ -241,11 +241,8 @@ configurerequest(XEvent ev) ev.xconfigurerequest.value_mask, &wc); if((c = getclient(ev.xconfigurerequest.window))) if(wc.y < mw && wc.x < mh) - { - geo.y -= conf.ttbarheight; - geo.height += conf.ttbarheight; client_moveresize(c, geo, True); - } + return; } @@ -494,7 +491,8 @@ unmapnotify(XEvent ev) Client *c; if((c = getclient(ev.xunmap.window))) - if(!c->hide) + if(!c->hide && ev.xunmap.send_event + && getwinstate(c->win) == NormalState) client_unmanage(c); return; diff --git a/src/layout.c b/src/layout.c index 750e67d..fdfe513 100644 --- a/src/layout.c +++ b/src/layout.c @@ -131,7 +131,7 @@ maxlayout(void) geo.x = sgeo.x; geo.y = sgeo.y; geo.width = sgeo.width - (conf.borderheight * 2); - geo.height = sgeo.height - (conf.borderheight * 2); + geo.height = sgeo.height - (conf.borderheight * 2) - conf.ttbarheight; client_moveresize(c, geo, False); } @@ -255,10 +255,12 @@ tile(void) cgeo.height = tileheight - border; } + cgeo.height -= conf.ttbarheight; + client_moveresize(c, cgeo, tags[seltag].resizehint); if(n > nmaster && tileheight != sgeo.height) - cgeo.y = c->geo.y + c->geo.height + border; + cgeo.y = c->geo.y + c->geo.height + border + conf.ttbarheight; } return; @@ -296,7 +298,7 @@ uicb_togglemax(uicb_t cmd) geo.x = sgeo.x; geo.y = sgeo.y; geo.width = sgeo.width - (conf.borderheight * 2); - geo.height = sgeo.height - (conf.borderheight * 2); + geo.height = sgeo.height - (conf.borderheight * 2) - conf.ttbarheight; client_moveresize(sel, geo, False); raiseclient(sel); diff --git a/src/structs.h b/src/structs.h index 39022d4..becbc91 100644 --- a/src/structs.h +++ b/src/structs.h @@ -44,6 +44,7 @@ typedef const char* uicb_t; typedef unsigned int uint; typedef unsigned long ulong; typedef unsigned short ushort; +typedef unsigned char uchar; /* Enum */ enum { CurNormal, CurResize, CurMove, CurLast }; @@ -82,6 +83,8 @@ struct Client Window win; /* Titlebar */ BarWindow *tbar; + /* Border */ + int border; /* Client Layout Information */ Bool max, tile, free; Bool hint, hide, lmax; diff --git a/src/tag.c b/src/tag.c index 75c6757..0ca099a 100644 --- a/src/tag.c +++ b/src/tag.c @@ -91,6 +91,7 @@ uicb_tagtransfert(uicb_t cmd) sel->tag = n; selbytag[n] = sel; + selbytag[seltag] = NULL; arrange(); diff --git a/src/util.c b/src/util.c index 1e2b9a4..dd4b468 100644 --- a/src/util.c +++ b/src/util.c @@ -64,6 +64,30 @@ setwinstate(Window win, long state) return; } +long +getwinstate(Window win) +{ + int f; + long ret = -1; + ulong n, e; + uchar *p = NULL; + Atom at; + + if(XGetWindowProperty(dpy, win, XInternAtom(dpy, "WM_STATE", False), + 0L, 2L, False, XInternAtom(dpy, "WM_STATE", False), + &at, &f, &n, &e, (unsigned char **)&p) != Success) + { + return -1; + } + + if(n != 0) + ret = *p; + + free(p); + + return ret; +} + void uicb_spawn(uicb_t cmd) { diff --git a/src/wmfs.c b/src/wmfs.c index 269297f..b4b498e 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -177,9 +177,9 @@ init(void) /* INIT WORKABLE SPACE */ sgeo.x = 0; - sgeo.y = (conf.bartop) ? barheight : 0; + sgeo.y = (conf.bartop) ? barheight + conf.ttbarheight : conf.ttbarheight; sgeo.width = DisplayWidth(dpy, screen); - sgeo.height = DisplayHeight(dpy, screen) - barheight; + sgeo.height = DisplayHeight(dpy, screen) - (barheight + conf.ttbarheight); /* INIT STUFF */ diff --git a/src/wmfs.h b/src/wmfs.h index 0fe7e0a..14e314c 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -64,7 +64,7 @@ #define BPAD 2 /* bar.c */ -BarWindow* bar_create(int x, int y, uint w, uint h, int bord, uint color, Bool entermask); +BarWindow *bar_create(int x, int y, uint w, uint h, int bord, uint color, Bool entermask); void bar_delete(BarWindow *bw); void bar_moveresize(BarWindow *bw, int x, int y, uint w, uint h); void bar_refresh_color(BarWindow *bw); @@ -79,7 +79,6 @@ void draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str); void draw_taglist(Drawable dr); void draw_layout(void); void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color); -void draw_border(Window win, int color); ushort textw(const char *text); /* client.c */ @@ -89,7 +88,7 @@ void client_detach(Client *c); void client_switch(Bool c); void client_focus(Client *c); Client *getclient(Window w); -Client* client_gettbar(Window w); +Client *client_gettbar(Window w); void client_hide(Client *c); Bool ishide(Client *c); void mapclient(Client *c); @@ -128,6 +127,7 @@ void getevent(void); void *emalloc(uint element, uint size); ulong getcolor(char *color); void setwinstate(Window win, long state); +long getwinstate(Window win); void uicb_spawn(uicb_t); /* tag.c */ @@ -141,7 +141,7 @@ void arrange(void); void freelayout(void); void layoutswitch(Bool b); void maxlayout(void); -Client* nexttiled(Client *c); +Client *nexttiled(Client *c); void tile(void); void uicb_tile_switch(uicb_t); void uicb_togglemax(uicb_t);