Fix grab keys after keybind conf

This commit is contained in:
Martin Duquesnoy 2011-09-18 14:11:53 +02:00
parent 4321dc3aa8
commit cfb64b94f3
8 changed files with 65 additions and 70 deletions

View File

@ -33,18 +33,19 @@ CLIENT_RESIZE_DIR(Bottom)
void void
client_configure(struct client *c) client_configure(struct client *c)
{ {
XConfigureEvent ev; XConfigureEvent ev =
{
ev.type = ConfigureNotify; .type = ConfigureNotify,
ev.event = c->win; .event = c->win,
ev.window = c->win; .window = c->win,
ev.x = c->geo.x; .x = c->geo.x,
ev.y = c->geo.y; .y = c->geo.y,
ev.width = c->geo.w; .width = c->geo.w,
ev.height = c->geo.h; .height = c->geo.h,
ev.above = None; .above = None,
ev.border_width = 0; .border_width = 0,
ev.override_redirect = 0; .override_redirect = 0
};
XSendEvent(W->dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev); XSendEvent(W->dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev);
XSync(W->dpy, False); XSync(W->dpy, False);
@ -109,24 +110,6 @@ client_next_with_pos(struct client *bc, Position p)
return c; return c;
} }
/** Map a client
* \param c struct client pointer
*/
void
client_map(struct client *c)
{
XMapWindow(W->dpy, c->win);
}
/** Unmap a client
* \param c struct client pointer
*/
void
client_unmap(struct client *c)
{
XUnmapWindow(W->dpy, c->win);
}
static void static void
client_grabbuttons(struct client *c, bool focused) client_grabbuttons(struct client *c, bool focused)
{ {
@ -176,9 +159,9 @@ client_focus(struct client *c)
XSetWindowBorder(W->dpy, c->win, THEME_DEFAULT->client_s.bg); XSetWindowBorder(W->dpy, c->win, THEME_DEFAULT->client_s.bg);
client_grabbuttons(c, true);
XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime);
client_grabbuttons(c, true);
} }
} }
@ -209,9 +192,9 @@ client_get_name(struct client *c)
void void
client_close(struct client *c) client_close(struct client *c)
{ {
XEvent ev; bool canbedel;
Atom *atom = NULL;
int proto; int proto;
Atom *atom = NULL;
/* Event will call client_remove */ /* Event will call client_remove */
if(XGetWMProtocols(W->dpy, c->win, &atom, &proto) && atom) if(XGetWMProtocols(W->dpy, c->win, &atom, &proto) && atom)
@ -219,29 +202,39 @@ client_close(struct client *c)
while(proto--) while(proto--)
if(atom[proto] == ATOM("WM_DELETE_WINDOW")) if(atom[proto] == ATOM("WM_DELETE_WINDOW"))
{ {
ev.type = ClientMessage; canbedel = true;
ev.xclient.window = c->win;
ev.xclient.message_type = ATOM("WM_PROTOCOLS");
ev.xclient.format = 32;
ev.xclient.data.l[0] = ATOM("WM_DELETE_WINDOW");
ev.xclient.data.l[1] = CurrentTime;
ev.xclient.data.l[2] = 0;
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
XSendEvent(W->dpy, c->win, False, NoEventMask, &ev);
XFree(atom); XFree(atom);
break;
return;
} }
XKillClient(W->dpy, c->win); if(canbedel)
{
XEvent ev =
{
.type = ClientMessage,
.xclient.window = c->win,
.xclient.message_type = ATOM("WM_PROTOCOLS"),
.xclient.format = 32,
.xclient.data.l[0] = ATOM("WM_DELETE_WINDOW"),
.xclient.data.l[1] = CurrentTime
};
XSendEvent(W->dpy, c->win, False, NoEventMask, &ev);
}
else
XKillClient(W->dpy, c->win);
} }
else else
XKillClient(W->dpy, c->win); XKillClient(W->dpy, c->win);
} }
void
uicb_client_close(Uicb cmd)
{
if(W->client)
client_close(W->client);
}
struct client* struct client*
client_new(Window w, XWindowAttributes *wa) client_new(Window w, XWindowAttributes *wa)
{ {
@ -264,8 +257,7 @@ client_new(Window w, XWindowAttributes *wa)
tag_client(W->screen->seltag, c); tag_client(W->screen->seltag, c);
/* X window attributes */ /* X window attributes */
XSelectInput(W->dpy, w, EnterWindowMask | FocusChangeMask XSelectInput(W->dpy, w, EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PropertyChangeMask);
| PropertyChangeMask | StructureNotifyMask);
XSetWindowBorder(W->dpy, w, THEME_DEFAULT->client_n.bg); XSetWindowBorder(W->dpy, w, THEME_DEFAULT->client_n.bg);
XSetWindowBorderWidth(W->dpy, w, THEME_DEFAULT->client_border_width); XSetWindowBorderWidth(W->dpy, w, THEME_DEFAULT->client_border_width);
client_grabbuttons(c, false); client_grabbuttons(c, false);
@ -274,8 +266,8 @@ client_new(Window w, XWindowAttributes *wa)
SLIST_INSERT_HEAD(&W->h.client, c, next); SLIST_INSERT_HEAD(&W->h.client, c, next);
/* Map */ /* Map */
WIN_STATE(c->win, Map); WIN_STATE(w, Map);
ewmh_set_wm_state(c->win, NormalState); ewmh_set_wm_state(w, NormalState);
client_configure(c); client_configure(c);
@ -312,9 +304,9 @@ client_fac_resize(struct client *c, Position p, int fac)
/* Check futur size/pos */ /* Check futur size/pos */
if(!client_fac_geo(c, p, fac) if(!client_fac_geo(c, p, fac)
|| !client_fac_geo(gc, RPOS(p), -fac) || !client_fac_geo(gc, RPOS(p), -fac)
|| !client_fac_check_row(c, p, fac) || !client_fac_check_row(c, p, fac)
|| !client_fac_check_row(gc, RPOS(p), -fac)) || !client_fac_check_row(gc, RPOS(p), -fac))
return; return;

View File

@ -15,6 +15,7 @@ struct client *client_next_with_pos(struct client *bc, Position p);
void client_focus(struct client *c); void client_focus(struct client *c);
void client_get_name(struct client *c); void client_get_name(struct client *c);
void client_close(struct client *c); void client_close(struct client *c);
void uicb_client_close(Uicb cmd);
struct client *client_new(Window w, XWindowAttributes *wa); struct client *client_new(Window w, XWindowAttributes *wa);
void client_moveresize(struct client *c, struct geo g); void client_moveresize(struct client *c, struct geo g);
void client_maximize(struct client *c); void client_maximize(struct client *c);

View File

@ -16,7 +16,7 @@
static void static void
config_theme(void) config_theme(void)
{ {
struct theme *t, *p; struct theme *t, *p = NULL;
size_t i, n; size_t i, n;
struct conf_sec *sec, **ks; struct conf_sec *sec, **ks;
@ -191,6 +191,8 @@ config_keybind(void)
SLIST_INSERT_HEAD(&W->h.keybind, k, next); SLIST_INSERT_HEAD(&W->h.keybind, k, next);
} }
wmfs_grab_keys();
free(ks); free(ks);
} }

View File

@ -31,6 +31,7 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
{ "tag_prev", uicb_tag_prev }, { "tag_prev", uicb_tag_prev },
/* Client */ /* Client */
{ "client_close", uicb_client_close },
{ "client_resize_right", uicb_client_resize_Right }, { "client_resize_right", uicb_client_resize_Right },
{ "client_resize_left", uicb_client_resize_Left }, { "client_resize_left", uicb_client_resize_Left },
{ "client_resize_top", uicb_client_resize_Top }, { "client_resize_top", uicb_client_resize_Top },

View File

@ -33,7 +33,7 @@ static void
infobar_elem_tag_init(struct element *e) infobar_elem_tag_init(struct element *e)
{ {
struct tag *t; struct tag *t;
struct barwin *b, *prev; struct barwin *b, *prev = NULL;
struct geo g = { 0, 0, 0, 0 }; struct geo g = { 0, 0, 0, 0 };
int s, j; int s, j;

View File

@ -92,6 +92,7 @@ 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); SLIST_REMOVE(&c->tag->clients, c, client, tnext);
/* TODO: Focus next client */ /* TODO: Focus next client */
if(c->tag->sel == c) if(c->tag->sel == c)
c->tag->sel = NULL; c->tag->sel = NULL;
@ -99,7 +100,6 @@ tag_client(struct tag *t, struct client *c)
/* /*
* Case of client removing: umap frame if empty * Case of client removing: umap frame if empty
* TODO: arrange layout
*/ */
if(!t) if(!t)
{ {
@ -107,7 +107,6 @@ tag_client(struct tag *t, struct client *c)
if(SLIST_EMPTY(&c->tag->clients)) if(SLIST_EMPTY(&c->tag->clients))
WIN_STATE(c->tag->frame, Unmap); WIN_STATE(c->tag->frame, Unmap);
return; return;
} }

View File

@ -121,6 +121,11 @@ wmfs_xinit(void)
W->xdepth = DefaultDepth(W->dpy, W->xscreen); W->xdepth = DefaultDepth(W->dpy, W->xscreen);
W->gc = DefaultGC(W->dpy, W->xscreen); W->gc = DefaultGC(W->dpy, W->xscreen);
/*
* Keys
*/
wmfs_numlockmask();
/* /*
* Root window/cursor * Root window/cursor
*/ */
@ -132,11 +137,6 @@ wmfs_xinit(void)
*/ */
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
/*
* Keys
*/
wmfs_numlockmask();
/* /*
* Barwin linked list * Barwin linked list
*/ */
@ -151,7 +151,7 @@ wmfs_grab_keys(void)
KeyCode c; KeyCode c;
struct keybind *k; struct keybind *k;
/*wmfs_numlockmask();*/ wmfs_numlockmask();
XUngrabKey(W->dpy, AnyKey, AnyModifier, W->root); XUngrabKey(W->dpy, AnyKey, AnyModifier, W->root);

View File

@ -115,13 +115,13 @@
# Resize selected tiled client with direction # Resize selected tiled client with direction
[key] mod = {"Super"} key = "h" func = "client_resize_left" cmd = "20" [/key] [key] mod = {"Super"} key = "h" func = "client_resize_left" cmd = "20" [/key]
[key] mod = {"Super"} key = "l" func = "client_resize_right" cmd = "20" [/key] [key] mod = {"Super"} key = "l" func = "client_resize_left" cmd = "-20" [/key]
[key] mod = {"Super"} key = "k" func = "client_resize_top" cmd = "20" [/key] [key] mod = {"Super"} key = "k" func = "client_resize_top" cmd = "20" [/key]
[key] mod = {"Super"} key = "j" func = "client_resize_bottom" cmd = "20" [/key] [key] mod = {"Super"} key = "j" func = "client_resize_top" cmd = "-20" [/key]
[key] mod = {"Super", "Control"} key = "h" func = "client_resize_right" cmd = "-20" [/key] [key] mod = {"Super", "Control"} key = "h" func = "client_resize_right" cmd = "-20" [/key]
[key] mod = {"Super", "Control"} key = "l" func = "client_resize_left" cmd = "-20" [/key] [key] mod = {"Super", "Control"} key = "l" func = "client_resize_right" cmd = "20" [/key]
[key] mod = {"Super", "Control"} key = "k" func = "client_resize_bottom" cmd = "-20" [/key] [key] mod = {"Super", "Control"} key = "k" func = "client_resize_bottom" cmd = "-20" [/key]
[key] mod = {"Super", "Control"} key = "j" func = "client_resize_top" cmd = "-20" [/key] [key] mod = {"Super", "Control"} key = "j" func = "client_resize_bottom" cmd = "20" [/key]
[/keys] [/keys]