Fix client_close & selected client management

This commit is contained in:
Martin Duquesnoy 2011-09-21 20:06:49 +02:00
parent 30fdd1a69d
commit 68aecac27c
4 changed files with 19 additions and 26 deletions

View File

@ -224,7 +224,10 @@ client_focus(struct client *c)
XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime);
} }
else else
{
W->client = W->screen->seltag->sel = NULL;
XSetInputFocus(W->dpy, W->root, RevertToPointerRoot, CurrentTime); XSetInputFocus(W->dpy, W->root, RevertToPointerRoot, CurrentTime);
}
} }
/** Get a client name /** Get a client name
@ -256,6 +259,7 @@ client_close(struct client *c)
{ {
bool canbedel; bool canbedel;
int proto; int proto;
XEvent ev;
Atom *atom = NULL; Atom *atom = NULL;
/* Event will call client_remove */ /* Event will call client_remove */
@ -271,18 +275,15 @@ client_close(struct client *c)
if(canbedel) if(canbedel)
{ {
XEvent ev = ev.type = ClientMessage;
{ ev.xclient.window = c->win;
.type = ClientMessage, ev.xclient.message_type = ATOM("WM_PROTOCOLS");
.xclient.window = c->win, ev.xclient.format = 32;
.xclient.message_type = ATOM("WM_PROTOCOLS"), ev.xclient.data.l[0] = ATOM("WM_DELETE_WINDOW");
.xclient.format = 32, ev.xclient.data.l[1] = CurrentTime;
.xclient.data.l[0] = ATOM("WM_DELETE_WINDOW"),
.xclient.data.l[1] = CurrentTime
};
XSendEvent(W->dpy, c->win, False, NoEventMask, &ev); XSendEvent(W->dpy, c->win, False, NoEventMask, &ev);
} }
else else
XKillClient(W->dpy, c->win); XKillClient(W->dpy, c->win);
} }
@ -408,12 +409,6 @@ client_remove(struct client *c)
XSetErrorHandler(wmfs_error_handler_dummy); XSetErrorHandler(wmfs_error_handler_dummy);
XReparentWindow(W->dpy, c->win, W->root, c->geo.x, c->geo.y); XReparentWindow(W->dpy, c->win, W->root, c->geo.x, c->geo.y);
if(W->client == c)
{
W->client = NULL;
XSetInputFocus(W->dpy, W->root, RevertToPointerRoot, CurrentTime);
}
/* Remove from global client list */ /* Remove from global client list */
SLIST_REMOVE(&W->h.client, c, client, next); SLIST_REMOVE(&W->h.client, c, client, next);
@ -426,6 +421,7 @@ client_remove(struct client *c)
XSetErrorHandler(wmfs_error_handler); XSetErrorHandler(wmfs_error_handler);
free(c); free(c);
c = NULL;
} }
void void

View File

@ -123,7 +123,7 @@ event_maprequest(XEvent *e)
return; return;
if(!client_gb_win(ev->window)) if(!client_gb_win(ev->window))
(struct client*)client_new(ev->window, &at); client_new(ev->window, &at);
} }
static void static void

View File

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

View File

@ -70,12 +70,12 @@ tag_screen(struct screen *s, struct tag *t)
WIN_STATE(t->frame, Map); WIN_STATE(t->frame, Map);
SLIST_FOREACH(c, &t->clients, tnext) SLIST_FOREACH(c, &t->clients, tnext)
ewmh_set_wm_state(c->win, NormalState); ewmh_set_wm_state(c->win, NormalState);
client_focus(t->sel);
} }
s->seltag = t; s->seltag = t;
client_focus(t->sel);
infobar_elem_screen_update(s, ElemTag); infobar_elem_screen_update(s, ElemTag);
} }
@ -91,13 +91,10 @@ tag_client(struct tag *t, struct client *c)
layout_split_arrange_closed(c); layout_split_arrange_closed(c);
SLIST_REMOVE(&c->tag->clients, c, client, tnext); if(c->tag->sel == c || W->client == c)
if(c->tag->sel == c)
{
c->tag->sel = NULL;
client_focus(client_next(c)); client_focus(client_next(c));
}
SLIST_REMOVE(&c->tag->clients, c, client, tnext);
} }
/* /*