all: Fix segfault (remove titlebar border again)

This commit is contained in:
Martin Duquesnoy 2008-10-27 18:21:55 +01:00
parent 4bd8a487e9
commit add0f0187b
8 changed files with 41 additions and 32 deletions

View File

@ -125,21 +125,16 @@ client_focus(Client *c)
{ {
grabbuttons(sel, False); grabbuttons(sel, False);
XSetWindowBorder(dpy, sel->win, conf.client.bordernormal); XSetWindowBorder(dpy, sel->win, conf.client.bordernormal);
if(conf.titlebar.exist)
XSetWindowBorder(dpy, sel->tbar->win, conf.client.bordernormal);
} }
if(c) if(c)
grabbuttons(c, True); grabbuttons(c, True);
sel = c; selbytag[seltag] = sel = c;
selbytag[seltag] = sel;
if(c) if(c)
{ {
XSetWindowBorder(dpy, c->win, conf.client.borderfocus); XSetWindowBorder(dpy, c->win, conf.client.borderfocus);
if(conf.titlebar.exist)
XSetWindowBorder(dpy, sel->tbar->win, conf.client.borderfocus);
if(conf.raisefocus) if(conf.raisefocus)
client_raise(c); client_raise(c);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
@ -219,13 +214,14 @@ client_map(Client *c)
if(!c) if(!c)
return; return;
XMapWindow(dpy, c->win);
if(conf.titlebar.exist) if(conf.titlebar.exist)
{ {
XMapWindow(dpy, c->tbar->win); XMapWindow(dpy, c->tbar->win);
bar_refresh(c->tbar); bar_refresh(c->tbar);
} }
XMapWindow(dpy, c->win);
return; return;
} }
@ -265,14 +261,12 @@ client_manage(Window w, XWindowAttributes *wa)
c->tag = t->tag; c->tag = t->tag;
if(!c->free) if(!c->free)
c->free = (rettrans == Success) || c->hint; c->free = (rettrans == Success) || c->hint;
else
client_raise(c);
efree(t); efree(t);
client_attach(c); client_attach(c);
XMoveResizeWindow(dpy, c->win, c->geo.x, c->geo.y, c->geo.width, c->geo.height); XMoveResizeWindow(dpy, c->win, c->geo.x, c->geo.y, c->geo.width, c->geo.height);
client_map(c); client_map(c);
client_raise(c);
setwinstate(c->win, NormalState); setwinstate(c->win, NormalState);
client_focus(c); client_focus(c);
arrange(); arrange();
@ -430,13 +424,12 @@ client_raise(Client *c)
if(!c || c->tile || c->max) if(!c || c->tile || c->max)
return; return;
XRaiseWindow(dpy, c->win);
if(conf.titlebar.exist) if(conf.titlebar.exist)
{ {
XRaiseWindow(dpy, c->tbar->win); XRaiseWindow(dpy, c->tbar->win);
titlebar_update(c); titlebar_update(c);
} }
XRaiseWindow(dpy, c->win);
return; return;
} }
@ -463,19 +456,23 @@ client_unhide(Client *c)
void void
client_unmanage(Client *c) client_unmanage(Client *c)
{ {
int i;
Client *cc;
XGrabServer(dpy); XGrabServer(dpy);
XSetErrorHandler(errorhandlerdummy); XSetErrorHandler(errorhandlerdummy);
if(sel == c) if(sel == c)
client_focus(NULL); client_focus(NULL);
for(i = 0, cc = clients; cc; cc = cc->next, ++i)
if(selbytag[i] == c)
selbytag[i] = NULL;
client_detach(c); client_detach(c);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setwinstate(c->win, WithdrawnState); setwinstate(c->win, WithdrawnState);
XSync(dpy, False); XSync(dpy, False);
XUngrabServer(dpy); XUngrabServer(dpy);
if(conf.titlebar.exist) if(conf.titlebar.exist)
bar_delete(c->tbar); titlebar_delete(c);
efree(c); efree(c);
XSetErrorHandler(errorhandler); XSetErrorHandler(errorhandler);
arrange(); arrange();

View File

@ -92,10 +92,10 @@ draw_taglist(Drawable dr)
void void
draw_layout(void) draw_layout(void)
{ {
draw_text(bar->dr, taglen[conf.ntag] + BPAD/2, fonth, draw_text(bar->dr, taglen[conf.ntag] + 1, fonth,
conf.colors.layout_fg, conf.colors.layout_fg,
conf.colors.layout_bg, conf.colors.layout_bg,
BPAD, tags[seltag].layout.symbol); 2, tags[seltag].layout.symbol);
return; return;
} }

View File

@ -396,10 +396,7 @@ unmapnotify(XEvent ev)
Client *c; Client *c;
if((c = client_get(ev.xunmap.window))) if((c = client_get(ev.xunmap.window)))
if(ev.xunmap.send_event client_unmanage(c);
&& ev.xunmap.event == RootWindow(ev.xany.display, screen)
&& getwinstate(c->win) == NormalState)
client_unmanage(c);
return; return;
} }

View File

@ -45,9 +45,10 @@ arrange(void)
tags[seltag].layout.func(); tags[seltag].layout.func();
if(selbytag[seltag] && selbytag[seltag]->win) if(selbytag[seltag] != NULL
&& selbytag[seltag]->tbar != NULL)
client_focus(selbytag[seltag]); client_focus(selbytag[seltag]);
else else
client_focus(NULL); client_focus(NULL);
updatebar(); updatebar();
@ -71,8 +72,8 @@ freelayout(void)
geo.y = c->ogeo.y; geo.y = c->ogeo.y;
geo.width = c->ogeo.width; geo.width = c->ogeo.width;
geo.height = c->ogeo.height; geo.height = c->ogeo.height;
client_moveresize(c, geo, True);
c->tile = c->lmax = False; c->tile = c->lmax = False;
client_moveresize(c, geo, True);
} }
} }
} }

View File

@ -89,7 +89,7 @@ struct Client
int border; int border;
/* Client Layout Information */ /* Client Layout Information */
Bool max, tile, free; Bool max, tile, free;
Bool hint, lmax; Bool hint, lmax, havetbar;
/* Struct in chains */ /* Struct in chains */
Client *next; Client *next;
Client *prev; Client *prev;

View File

@ -38,18 +38,31 @@ titlebar_create(Client *c)
int y; int y;
/* Set titlebar position : Top/Bottom */ /* Set titlebar position : Top/Bottom */
if(conf.titlebar.pos) switch(conf.titlebar.pos)
{
case Bottom:
y = c->geo.y + c->geo.height + conf.client.borderheight; y = c->geo.y + c->geo.height + conf.client.borderheight;
else break;
default:
case Top:
y = c->geo.y - (conf.titlebar.height + conf.client.borderheight); y = c->geo.y - (conf.titlebar.height + conf.client.borderheight);
break;
}
c->tbar = bar_create(c->geo.x, c->tbar = bar_create(c->geo.x, y, c->geo.width,
y,
c->geo.width,
conf.titlebar.height - conf.client.borderheight, conf.titlebar.height - conf.client.borderheight,
conf.client.borderheight, conf.client.borderheight,
conf.titlebar.bg, True); conf.titlebar.bg, True);
XSetWindowBorder(dpy, c->tbar->win, conf.client.bordernormal); XSetWindowBorder(dpy, c->tbar->win, conf.titlebar.bg);
return;
}
void
titlebar_delete(Client *c)
{
bar_delete(c->tbar);
c->tbar = NULL;
return; return;
} }

View File

@ -102,6 +102,7 @@ quit(void)
efree(keys); efree(keys);
efree(conf.titlebar.mouse); efree(conf.titlebar.mouse);
efree(conf.client.mouse); efree(conf.client.mouse);
efree(conf.root.mouse);
XSync(dpy, False); XSync(dpy, False);
return; return;

View File

@ -60,7 +60,6 @@
#define ITOA(p ,n) sprintf(p, "%i", n) #define ITOA(p ,n) sprintf(p, "%i", n)
#define debug(p) fprintf(stderr, "debug: %i\n", p) #define debug(p) fprintf(stderr, "debug: %i\n", p)
#define PAD 8 #define PAD 8
#define BPAD 2
/* bar.c */ /* 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);
@ -138,6 +137,7 @@ void uicb_tagtransfert(uicb_t);
/* titlebar.c */ /* titlebar.c */
void titlebar_create(Client *c); void titlebar_create(Client *c);
void titlebar_delete(Client *c);
Client* titlebar_get(Window w); Client* titlebar_get(Window w);
void titlebar_update_position(Client *c); void titlebar_update_position(Client *c);
void titlebar_update(Client *c); void titlebar_update(Client *c);