[wmfs.c,.h] Fix bug/segfault (when you switched into the tags, and close a clients, you could close an hidden client, and make a segfault if you return on the hidden client tag.)

This commit is contained in:
Martin Duquesnoy 2008-09-17 16:30:42 +02:00
parent 315129a9aa
commit eb1e708346
4 changed files with 10 additions and 10 deletions

View File

@ -33,6 +33,7 @@ set(CMAKE_C_FLAGS ${CFLAGS})
set(LIBRARIES_TO_LINK set(LIBRARIES_TO_LINK
X11 X11
confuse) confuse)
target_link_libraries(wmfs ${LIBRARIES_TO_LINK}) target_link_libraries(wmfs ${LIBRARIES_TO_LINK})
# Messages # Messages

View File

@ -78,7 +78,7 @@ buttonpress(XEvent ev)
{ {
for(i = 0; i < conf.ntag + 1; ++i) for(i = 0; i < conf.ntag + 1; ++i)
{ {
if(ev.xbutton.x > taglen[i-1] if(ev.xbutton.x > taglen[i-1] - 3
&& ev.xbutton.x < taglen[i]) && ev.xbutton.x < taglen[i])
{ {
ITOA(s, i); ITOA(s, i);
@ -99,7 +99,7 @@ buttonpress(XEvent ev)
/* layout switch */ /* layout switch */
if(ev.xbutton.x >= taglen[conf.ntag] - 3 if(ev.xbutton.x >= taglen[conf.ntag] - 3
&& ev.xbutton.x < taglen[conf.ntag] + && ev.xbutton.x < taglen[conf.ntag] +
(strlen((getlayoutsym(layout[seltag])))*fonty+3)-3) (strlen((getlayoutsym(layout[seltag])))*fonty+3) - 3)
{ {
if(ev.xbutton.button == Button1 if(ev.xbutton.button == Button1
|| ev.xbutton.button == Button4) || ev.xbutton.button == Button4)

12
wmfs.c
View File

@ -43,7 +43,7 @@ arrange(void)
else else
hide(c); hide(c);
focus(selbytag[seltag]); focus(NULL);
layoutfunc[seltag](); layoutfunc[seltag]();
} }
@ -116,7 +116,6 @@ focus(Client *c)
grabbuttons(c, True); grabbuttons(c, True);
sel = c; sel = c;
selbytag[seltag] = c;
if(c) if(c)
{ {
@ -128,6 +127,8 @@ focus(Client *c)
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
updatetitle(c); updatetitle(c);
} }
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
return; return;
} }
@ -900,8 +901,6 @@ tag(char *cmd)
return; return;
seltag = tmp; seltag = tmp;
} }
if(selbytag[seltag])
focus(selbytag[seltag]);
arrange(); arrange();
return; return;
@ -1054,9 +1053,11 @@ unhide(Client *c)
void void
unmanage(Client *c) unmanage(Client *c)
{ {
if(ishide(c))
return;
XSetErrorHandler(errorhandlerdummy); XSetErrorHandler(errorhandlerdummy);
sel = (sel == c) ? c->next : NULL; sel = (sel == c) ? c->next : NULL;
selbytag[seltag] = (selbytag[seltag] == c) ? c->next : NULL;
if(conf.ttbarheight) if(conf.ttbarheight)
{ {
XUnmapWindow(dpy, c->tbar); XUnmapWindow(dpy, c->tbar);
@ -1139,7 +1140,6 @@ updatebar(void)
} }
/* if c is 0, you can execute this function for the first time /* if c is 0, you can execute this function for the first time
* else the button is just updated */ * else the button is just updated */
void void

3
wmfs.h
View File

@ -265,7 +265,7 @@ Window bar;
int screen; int screen;
int mw, mh; int mw, mh;
Conf conf; Conf conf;
Key keys[512]; Key keys[1024];
/* Atoms / Cursors */ /* Atoms / Cursors */
Atom wm_atom[WMLast]; Atom wm_atom[WMLast];
@ -286,7 +286,6 @@ int taglen[MAXTAG];
/* Important Client */ /* Important Client */
Client *clients; Client *clients;
Client *sel; Client *sel;
Client *selbytag[MAXTAG];
/* Layout/Tile Important variables */ /* Layout/Tile Important variables */
float mwfact[MAXTAG]; float mwfact[MAXTAG];