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
client_configure(struct client *c)
{
XConfigureEvent ev;
ev.type = ConfigureNotify;
ev.event = c->win;
ev.window = c->win;
ev.x = c->geo.x;
ev.y = c->geo.y;
ev.width = c->geo.w;
ev.height = c->geo.h;
ev.above = None;
ev.border_width = 0;
ev.override_redirect = 0;
XConfigureEvent ev =
{
.type = ConfigureNotify,
.event = c->win,
.window = c->win,
.x = c->geo.x,
.y = c->geo.y,
.width = c->geo.w,
.height = c->geo.h,
.above = None,
.border_width = 0,
.override_redirect = 0
};
XSendEvent(W->dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev);
XSync(W->dpy, False);
@ -109,24 +110,6 @@ client_next_with_pos(struct client *bc, Position p)
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
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);
client_grabbuttons(c, true);
XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime);
client_grabbuttons(c, true);
}
}
@ -209,9 +192,9 @@ client_get_name(struct client *c)
void
client_close(struct client *c)
{
XEvent ev;
Atom *atom = NULL;
bool canbedel;
int proto;
Atom *atom = NULL;
/* Event will call client_remove */
if(XGetWMProtocols(W->dpy, c->win, &atom, &proto) && atom)
@ -219,29 +202,39 @@ client_close(struct client *c)
while(proto--)
if(atom[proto] == ATOM("WM_DELETE_WINDOW"))
{
ev.type = ClientMessage;
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);
canbedel = true;
XFree(atom);
return;
break;
}
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
XKillClient(W->dpy, c->win);
}
void
uicb_client_close(Uicb cmd)
{
if(W->client)
client_close(W->client);
}
struct client*
client_new(Window w, XWindowAttributes *wa)
{
@ -264,8 +257,7 @@ client_new(Window w, XWindowAttributes *wa)
tag_client(W->screen->seltag, c);
/* X window attributes */
XSelectInput(W->dpy, w, EnterWindowMask | FocusChangeMask
| PropertyChangeMask | StructureNotifyMask);
XSelectInput(W->dpy, w, EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PropertyChangeMask);
XSetWindowBorder(W->dpy, w, THEME_DEFAULT->client_n.bg);
XSetWindowBorderWidth(W->dpy, w, THEME_DEFAULT->client_border_width);
client_grabbuttons(c, false);
@ -274,8 +266,8 @@ client_new(Window w, XWindowAttributes *wa)
SLIST_INSERT_HEAD(&W->h.client, c, next);
/* Map */
WIN_STATE(c->win, Map);
ewmh_set_wm_state(c->win, NormalState);
WIN_STATE(w, Map);
ewmh_set_wm_state(w, NormalState);
client_configure(c);

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_get_name(struct client *c);
void client_close(struct client *c);
void uicb_client_close(Uicb cmd);
struct client *client_new(Window w, XWindowAttributes *wa);
void client_moveresize(struct client *c, struct geo g);
void client_maximize(struct client *c);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -115,13 +115,13 @@
# Resize selected tiled client with direction
[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 = "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 = "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 = "j" func = "client_resize_top" cmd = "-20" [/key]
[key] mod = {"Super", "Control"} key = "j" func = "client_resize_bottom" cmd = "20" [/key]
[/keys]