diff options
author | David Delassus <david.jose.delassus@gmail.com> | 2012-05-05 06:43:59 -0700 |
---|---|---|
committer | David Delassus <david.jose.delassus@gmail.com> | 2012-05-05 06:43:59 -0700 |
commit | 59af6061471e84844b0b6c98d9b6e54cf68fda4c (patch) | |
tree | 52382118d065af0c1659b1544c374064d9b7a8eb | |
parent | 67c635f9be806b8dcbee841dbb54669e72112cef (diff) | |
parent | 151dc9f9f12464a3d01520752dacac84b6d24e0d (diff) | |
download | wmfs-59af6061471e84844b0b6c98d9b6e54cf68fda4c.zip wmfs-59af6061471e84844b0b6c98d9b6e54cf68fda4c.tar.gz wmfs-59af6061471e84844b0b6c98d9b6e54cf68fda4c.tar.bz2 |
Merge pull request #53 from linkdd/sticky-window
Fix manage of sticky windows (Closes #52)
-rw-r--r-- | src/client.c | 4 | ||||
-rw-r--r-- | src/event.c | 3 | ||||
-rw-r--r-- | src/ewmh.c | 55 | ||||
-rw-r--r-- | src/ewmh.h | 2 | ||||
-rw-r--r-- | src/layout.c | 2 | ||||
-rw-r--r-- | src/wmfs.h | 1 |
6 files changed, 54 insertions, 13 deletions
diff --git a/src/client.c b/src/client.c index 1ae6e72..f96869a 100644 --- a/src/client.c +++ b/src/client.c @@ -972,14 +972,12 @@ 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) || (c->flags & CLIENT_STICKY)) + if(!(c->tbarw = c->theme->client_titlebar_width)) c->tbarw = c->border; c->ncol = c->theme->client_n; diff --git a/src/event.c b/src/event.c index ace1ee8..9fb62fe 100644 --- a/src/event.c +++ b/src/event.c @@ -245,7 +245,8 @@ event_maprequest(XEvent *e) /* Which windows to manage */ if(!XGetWindowAttributes(EVDPY(e), ev->window, &at) || at.override_redirect - || ewmh_manage_window_type_desktop(ev->window)) + || ewmh_manage_window_type_desktop(ev->window) + || ewmh_manage_state_sticky(ev->window)) return; if(!client_gb_win(ev->window)) @@ -230,15 +230,16 @@ ewmh_manage_state(long data[], struct client *c) } -void -ewmh_manage_state_sticky(struct client *c) +bool +ewmh_manage_state_sticky(Window win) { Atom *atom, rf; int f; unsigned long n, il, i; unsigned char *data = NULL; + bool is_sticky = false; - if(XGetWindowProperty(W->dpy, c->win, W->net_atom[net_wm_state], 0L, 0x7FFFFFFFL, false, + if(XGetWindowProperty(W->dpy, win, W->net_atom[net_wm_state], 0L, 0x7FFFFFFFL, false, XA_ATOM, &rf, &f, &n, &il, &data) == Success && n) { atom = (Atom*)data; @@ -248,17 +249,59 @@ ewmh_manage_state_sticky(struct client *c) /* manage _NET_WM_STATE_STICKY */ if(atom[i] == W->net_atom[net_wm_state_sticky]) { - c->flags |= CLIENT_STICKY; - c->flags |= CLIENT_FREE; + XWindowAttributes at; + + XMapWindow(W->dpy, win); + XMapSubwindows(W->dpy, win); + + if(XGetWindowAttributes(W->dpy, win, &at)) + { + struct geo g; + + if(at.x < W->screen->ugeo.x) + g.x = W->screen->ugeo.x; + else if((at.x + at.width) > W->screen->ugeo.w) + g.x = W->screen->ugeo.w - at.width; + else + g.x = at.x; - client_place_at_mouse(c); + if(at.y < W->screen->ugeo.y) + g.y = W->screen->ugeo.y; + else if((at.y + at.height) > W->screen->ugeo.h) + g.y = W->screen->ugeo.h - at.height; + else + g.y = at.y; + XMoveWindow(W->dpy, win, g.x, g.y); + } + + if(W->client) + { + XUngrabButton(W->dpy, AnyButton, AnyModifier, W->client->win); + XGrabButton(W->dpy, AnyButton, AnyModifier, W->client->win, False, + ButtonMask, GrabModeAsync, GrabModeSync, None, None); + + client_frame_update(W->client, &W->client->ncol); + + W->client = NULL; + } + + + XRaiseWindow(W->dpy, win); + + XSetInputFocus(W->dpy, win, RevertToPointerRoot, CurrentTime); + XChangeProperty(W->dpy, W->root, W->net_atom[net_active_window], XA_WINDOW, 32, + PropModeReplace, (unsigned char *)&win, 1); + + is_sticky = true; break; } } XFree(data); } + + return is_sticky; } void @@ -124,7 +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); +bool ewmh_manage_state_sticky(Window win); 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 3d92dae..b73cea6 100644 --- a/src/layout.c +++ b/src/layout.c @@ -631,7 +631,7 @@ layout_client(struct client *c) return; } - if(c->flags & (CLIENT_FREE | CLIENT_STICKY)) + if(c->flags & CLIENT_FREE) { layout_split_arrange_closed(c); c->flags ^= CLIENT_TILED; @@ -217,7 +217,6 @@ 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 */ |