Fix several possible segfault

This commit is contained in:
Martin Duquesnoy 2011-09-21 19:16:41 +02:00
parent c2d75ff9c8
commit 30fdd1a69d
5 changed files with 17 additions and 14 deletions

View File

@ -167,8 +167,6 @@ client_swap(struct client *c1, struct client *c2)
static void
client_grabbuttons(struct client *c, bool focused)
{
wmfs_numlockmask();
XUngrabButton(W->dpy, AnyButton, AnyModifier, c->win);
if(focused)
@ -204,7 +202,7 @@ client_draw_bord(struct client *c)
/* Selected client's border */
if(W->client)
draw_rect(c->tag->frame, c->tag->sel->geo, THEME_DEFAULT->client_s.bg);
draw_rect(W->client->tag->frame, W->client->tag->sel->geo, THEME_DEFAULT->client_s.bg);
}
@ -225,6 +223,8 @@ client_focus(struct client *c)
XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime);
}
else
XSetInputFocus(W->dpy, W->root, RevertToPointerRoot, CurrentTime);
}
/** Get a client name
@ -330,6 +330,8 @@ client_new(Window w, XWindowAttributes *wa)
WIN_STATE(w, Map);
ewmh_set_wm_state(w, NormalState);
client_get_name(c);
client_focus(c);
client_configure(c);
return c;
@ -419,7 +421,6 @@ client_remove(struct client *c)
ewmh_set_wm_state(c->win, WithdrawnState);
XUngrabButton(W->dpy, AnyButton, AnyModifier, c->win);
XUngrabServer(W->dpy);
XSync(W->dpy, False);
XSetErrorHandler(wmfs_error_handler);

View File

@ -73,6 +73,7 @@ layout_split_check_row_dir(struct client *c, struct client *g, Position p)
{
s += (LDIR(p) ? cc->geo.h : cc->geo.w);
if(s == cs)
return true;
if(s > cs)
@ -97,7 +98,7 @@ layout_split_arrange_closed(struct client *ghost)
{
struct client *c, *cc;
struct geo g;
bool b;
bool b = false;
Position p;
/* Search for single parent for easy resize

View File

@ -92,8 +92,6 @@ screen_update_sel(void)
if(INAREA(x, y, s->geo))
break;
client_focus(s->seltag->sel);
return (W->screen = s);
}
#endif /* HAVE_XINERAMA */

View File

@ -94,7 +94,10 @@ tag_client(struct tag *t, struct client *c)
SLIST_REMOVE(&c->tag->clients, c, client, tnext);
if(c->tag->sel == c)
{
c->tag->sel = NULL;
client_focus(client_next(c));
}
}
/*

View File

@ -37,13 +37,13 @@ wmfs_error_handler(Display *d, XErrorEvent *event)
return 0;
XGetErrorText(d, event->error_code, mess, 128);
warnx("%s(%d) opcodes %d/%d\n resource #%lx\n",
mess,
event->error_code,
event->request_code,
event->minor_code,
event->resourceid);
if(XGetErrorText(d, event->error_code, mess, 128))
warnx("%s(%d) opcodes %d/%d\n resource #%lx\n",
mess,
event->error_code,
event->request_code,
event->minor_code,
event->resourceid);
return 1;
}