diff options
author | David Delassus <david.jose.delassus@gmail.com> | 2012-05-04 19:37:51 +0200 |
---|---|---|
committer | David Delassus <david.jose.delassus@gmail.com> | 2012-05-04 19:37:51 +0200 |
commit | 643d2a6b265a9da288b562d0c64233cd2621a880 (patch) | |
tree | 219cca35983f3b6558828e0ce6d0a737cabc0b40 | |
parent | 8b49878f50f5612cbca139ea898fa7110f93abf5 (diff) | |
download | wmfs-643d2a6b265a9da288b562d0c64233cd2621a880.zip wmfs-643d2a6b265a9da288b562d0c64233cd2621a880.tar.gz wmfs-643d2a6b265a9da288b562d0c64233cd2621a880.tar.bz2 |
Manage _NET_WM_STATE_STICKY
-rw-r--r-- | src/client.c | 23 | ||||
-rw-r--r-- | src/client.h | 1 | ||||
-rw-r--r-- | src/ewmh.c | 32 | ||||
-rw-r--r-- | src/ewmh.h | 1 | ||||
-rw-r--r-- | src/layout.c | 2 | ||||
-rw-r--r-- | src/wmfs.h | 1 |
6 files changed, 58 insertions, 2 deletions
diff --git a/src/client.c b/src/client.c index 39c9bc6..1ae6e72 100644 --- a/src/client.c +++ b/src/client.c @@ -972,12 +972,14 @@ client_new(Window w, XWindowAttributes *wa, bool scan) client_apply_rule(c); } + ewmh_manage_state_sticky(c); + /* * Conf option set per client, for possibility * to config only one client */ c->border = c->theme->client_border_width; - if(!(c->tbarw = c->theme->client_titlebar_width)) + if(!(c->tbarw = c->theme->client_titlebar_width) || (c->flags & CLIENT_STICKY)) c->tbarw = c->border; c->ncol = c->theme->client_n; @@ -1200,6 +1202,25 @@ client_moveresize(struct client *c, struct geo *g) } void +client_place_at_mouse(struct client *c) +{ + int x, y; + + Window w; + int d, u; + + XQueryPointer(W->dpy, W->root, &w, &w, &x, &y, &d, &d, (uint *)&u); + + if(x < c->screen->ugeo.x) + x = 0; + if(y < c->screen->ugeo.y) + y = 0; + + c->geo.x = ((x + c->geo.w) > c->screen->ugeo.w ? c->screen->ugeo.w - c->geo.w : x); + c->geo.y = ((y + c->geo.h) > c->screen->ugeo.h ? c->screen->ugeo.h - c->geo.h : y); +} + +void client_maximize(struct client *c) { c->geo.x = c->geo.y = 0; diff --git a/src/client.h b/src/client.h index 3783f80..0535aae 100644 --- a/src/client.h +++ b/src/client.h @@ -44,6 +44,7 @@ void client_geo_hints(struct geo *g, int *s); void client_get_sizeh(struct client *c); bool client_winsize(struct client *c, struct geo *geo); void client_moveresize(struct client *c, struct geo *g); +void client_place_at_mouse(struct client *c); void client_maximize(struct client *c); void client_fac_resize(struct client *c, enum position p, int fac); void client_fac_adjust(struct client *c); @@ -227,6 +227,38 @@ ewmh_manage_state(long data[], struct client *c) layout_fix_hole(c); } } + +} + +void +ewmh_manage_state_sticky(struct client *c) +{ + Atom *atom, rf; + int f; + unsigned long n, il, i; + unsigned char *data = NULL; + + if(XGetWindowProperty(W->dpy, c->win, W->net_atom[net_wm_state], 0L, 0x7FFFFFFFL, false, + XA_ATOM, &rf, &f, &n, &il, &data) == Success && n) + { + atom = (Atom*)data; + + for(i = 0; i < n; ++i) + { + /* manage _NET_WM_STATE_STICKY */ + if(atom[i] == W->net_atom[net_wm_state_sticky]) + { + c->flags |= CLIENT_STICKY; + c->flags |= CLIENT_FREE; + + client_place_at_mouse(c); + + break; + } + } + + XFree(data); + } } void @@ -124,6 +124,7 @@ void ewmh_get_client_list(void); long ewmh_get_xembed_state(Window win); void ewmh_update_wmfs_props(void); void ewmh_manage_state(long data[], struct client *c); +void ewmh_manage_state_sticky(struct client *c); void ewmh_manage_window_type(struct client *c); bool ewmh_manage_window_type_desktop(Window win); diff --git a/src/layout.c b/src/layout.c index b73cea6..3d92dae 100644 --- a/src/layout.c +++ b/src/layout.c @@ -631,7 +631,7 @@ layout_client(struct client *c) return; } - if(c->flags & CLIENT_FREE) + if(c->flags & (CLIENT_FREE | CLIENT_STICKY)) { layout_split_arrange_closed(c); c->flags ^= CLIENT_TILED; @@ -217,6 +217,7 @@ struct client #define CLIENT_TILED 0x2000 #define CLIENT_MOUSE 0x4000 #define CLIENT_IGNORE_TAG 0x8000 +#define CLIENT_STICKY 0x10000 Flags flags; Window win, frame, tmp; SLIST_ENTRY(client) next; /* Global list */ |