focus handling is up to the Layout now

This commit is contained in:
Anselm R. Garbe 2006-01-18 15:42:44 +02:00
parent faa69a3a5f
commit 576075e75f
7 changed files with 42 additions and 34 deletions

View File

@ -25,22 +25,6 @@ alloc_client(Window w)
return c;
}
void
focus_client(Client * c)
{
Client *old = sel_client();
if(old)
ungrab_client(old, AnyModifier, AnyButton);
grab_client(c, Mod1Mask, Button1);
grab_client(c, Mod1Mask, Button3);
c->frame->sel = c;
XRaiseWindow(dpy, c->win);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XSync(dpy, False);
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
}
void
set_client_state(Client * c, int state)
{
@ -57,13 +41,12 @@ map_client(Client * c)
{
XMapRaised(dpy, c->win);
set_client_state(c, NormalState);
/* grab_client(c, AnyModifier, AnyButton); */
}
void
unmap_client(Client * c)
{
ungrab_client(c, AnyModifier, AnyButton);
ungrab_client(c, AnyModifier, AnyButton);
XUnmapWindow(dpy, c->win);
set_client_state(c, WithdrawnState);
}
@ -78,15 +61,13 @@ reparent_client(Client * c, Window w, int x, int y)
void
grab_client(Client * c, unsigned long mod, unsigned int button)
{
XGrabButton(dpy, button, mod, c->win, True,
XGrabButton(dpy, button, mod, c->win, False,
ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
if((mod != AnyModifier) && num_lock_mask) {
XGrabButton(dpy, button, mod | num_lock_mask, c->win, True,
ButtonPressMask, GrabModeSync, GrabModeAsync, None,
None);
XGrabButton(dpy, button, mod | num_lock_mask, c->win, False,
ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
XGrabButton(dpy, button, mod | num_lock_mask | LockMask, c->win,
True, ButtonPressMask, GrabModeSync, GrabModeAsync,
None, None);
True, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
}
}

View File

@ -66,7 +66,8 @@ handle_buttonpress(XEvent * e)
Layout *l = sel_layout();
if(l != c->frame->layout)
focus_layout(c->frame->layout);
focus_client(c);
l = c->frame->layout;
l->def->focus(l, c, False);
ev->state &= valid_mask;
if(ev->state & Mod1Mask) {
Align align;

View File

@ -275,7 +275,7 @@ attach_client_to_frame(Frame * f, Client * client)
client->next = nil;
c->next = client;
}
f->sel = client;
/*f->sel = client;*/
f->nclients++;
client->frame = f;
resize_frame(f, &f->rect, 0);

View File

@ -417,19 +417,31 @@ static void
focus_col(Layout *l, Client *c, Bool raise)
{
Acme *acme = l->aux;
Client *old = sel_col(l);
Cell *cell = c->frame->aux;
Client *old = sel_client();
c->frame->sel = c;
acme->sel = cell->col;
cell->col->sel = cell;
l->file[L_SEL_FRAME]->content = c->frame->file[F_PREFIX]->content;
if(raise)
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
c->rect.width / 2, c->rect.height / 2);
focus_client(c);
if(old && old != c)
if(old && (old != c)) {
ungrab_client(old, AnyModifier, AnyButton);
grab_client(old, AnyModifier, AnyButton);
draw_frame(old->frame);
}
ungrab_client(c, AnyModifier, AnyButton);
grab_client(c, Mod1Mask, Button1);
grab_client(c, Mod1Mask, Button3);
XRaiseWindow(dpy, c->win);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
draw_frame(c->frame);
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
XSync(dpy, False);
}
static Frame *

View File

@ -186,19 +186,30 @@ static void
focus_float(Layout *l, Client *c, Bool raise)
{
Float *fl = l->aux;
Client *old = fl->sel->sel;
Client *old = sel_client();
c->frame->sel = c;
fl->sel = c->frame;
l->file[L_SEL_FRAME]->content = c->frame->file[F_PREFIX]->content;
if(raise) {
XRaiseWindow(dpy, c->frame->win);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
c->rect.width / 2, c->rect.height / 2);
}
focus_client(c);
if(old && old != c)
draw_frame(old->frame);
if(old && (old != c)) {
grab_client(old, AnyModifier, AnyButton);
draw_frame(old->frame);
}
ungrab_client(c, AnyModifier, AnyButton);
grab_client(c, Mod1Mask, Button1);
grab_client(c, Mod1Mask, Button3);
XRaiseWindow(dpy, c->win);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
draw_frame(c->frame);
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
XSync(dpy, False);
}
static Frame *

View File

@ -222,7 +222,6 @@ void ungrab_client(Client * c, unsigned long mod, unsigned int button);
void unmap_client(Client * c);
void map_client(Client * c);
void reparent_client(Client * c, Window w, int x, int y);
void focus_client(Client * c);
void attach_client(Client * c);
void detach_client(Client * c, Bool unmap);
Client *sel_client();

View File

@ -1,4 +1,8 @@
#!9PREFIX/bin/rc
# quit wmii
wmiir write /bar/ctl quit
wmiir write /menu/ctl quit
wmiir write /keys/ctl quit
wmiir write /wm/ctl quit
wmiir write /ctl quit