aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2016-09-16 14:32:02 +0000
committerokan2016-09-16 14:32:02 +0000
commit86e2c481f56ad0ea549838666d9fda03519fe1ef (patch)
tree6fb0d617fe57de9f58f1b7c0c1bec3ab3034bd04
parent10ebf1c3ea2b2d85a814934adc17e24cc6ea723a (diff)
downloadcwm-86e2c481f56ad0ea549838666d9fda03519fe1ef.tar.gz
During init, query screen for _NET_ACTIVE_WINDOW and set that client as
active; while we already look at what's under the pointer, use this information first, then look under the pointer (saving that round-trip). This restores the active state to a client after restart even if the pointer is not above it (and of course the pointer is not above another client).
-rw-r--r--calmwm.h5
-rw-r--r--client.c12
-rw-r--r--screen.c7
-rw-r--r--xevents.c4
-rw-r--r--xutil.c18
5 files changed, 32 insertions, 14 deletions
diff --git a/calmwm.h b/calmwm.h
index 3d4d4e1..8305ba6 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.311 2015/11/12 21:28:03 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.312 2016/09/16 14:32:02 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -398,7 +398,7 @@ void client_lower(struct client_ctx *);
void client_map(struct client_ctx *);
void client_msg(struct client_ctx *, Atom, Time);
void client_move(struct client_ctx *);
-struct client_ctx *client_init(Window, struct screen_ctx *);
+struct client_ctx *client_init(Window, struct screen_ctx *, int);
void client_ptrsave(struct client_ctx *);
void client_ptrwarp(struct client_ctx *);
void client_raise(struct client_ctx *);
@@ -564,6 +564,7 @@ void xu_ewmh_net_workarea(struct screen_ctx *);
void xu_ewmh_net_client_list(struct screen_ctx *);
void xu_ewmh_net_client_list_stacking(struct screen_ctx *);
void xu_ewmh_net_active_window(struct screen_ctx *, Window);
+Window xu_ewmh_get_net_active_window(struct screen_ctx *);
void xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *);
void xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *);
void xu_ewmh_net_showing_desktop(struct screen_ctx *);
diff --git a/client.c b/client.c
index 38b1471..b6d3b38 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: client.c,v 1.221 2016/09/14 21:00:24 okan Exp $
+ * $OpenBSD: client.c,v 1.222 2016/09/16 14:32:02 okan Exp $
*/
#include <sys/types.h>
@@ -43,13 +43,13 @@ static int client_inbound(struct client_ctx *, int, int);
struct client_ctx *curcc = NULL;
struct client_ctx *
-client_init(Window win, struct screen_ctx *sc)
+client_init(Window win, struct screen_ctx *sc, int active)
{
struct client_ctx *cc;
XWindowAttributes wattr;
int mapped;
Window rwin, cwin;
- int x, y, wx, wy, activate = 0;
+ int x, y, wx, wy;
unsigned int mask;
if (win == None)
@@ -105,9 +105,9 @@ client_init(Window win, struct screen_ctx *sc)
if ((cc->wmh) && (cc->wmh->flags & StateHint))
client_set_wm_state(cc, cc->wmh->initial_state);
} else {
- if ((XQueryPointer(X_Dpy, cc->win, &rwin, &cwin,
+ if ((active == 0) && (XQueryPointer(X_Dpy, cc->win, &rwin, &cwin,
&x, &y, &wx, &wy, &mask)) && (cwin != None))
- activate = 1;
+ active = 1;
}
XSelectInput(X_Dpy, cc->win, ColormapChangeMask | EnterWindowMask |
@@ -145,7 +145,7 @@ out:
XSync(X_Dpy, False);
XUngrabServer(X_Dpy);
- if (activate)
+ if (active)
client_setactive(cc);
return(cc);
diff --git a/screen.c b/screen.c
index e1f5fe8..9f3eb47 100644
--- a/screen.c
+++ b/screen.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: screen.c,v 1.79 2015/11/11 14:22:01 okan Exp $
+ * $OpenBSD: screen.c,v 1.80 2016/09/16 14:32:02 okan Exp $
*/
#include <sys/types.h>
@@ -35,7 +35,7 @@ void
screen_init(int which)
{
struct screen_ctx *sc;
- Window *wins, w0, w1;
+ Window *wins, w0, w1, active = None;
XSetWindowAttributes rootattr;
unsigned int nwins, i;
@@ -65,6 +65,7 @@ screen_init(int which)
xu_ewmh_net_wm_number_of_desktops(sc);
xu_ewmh_net_showing_desktop(sc);
xu_ewmh_net_virtual_roots(sc);
+ active = xu_ewmh_get_net_active_window(sc);
rootattr.cursor = Conf.cursor[CF_NORMAL];
rootattr.event_mask = SubstructureRedirectMask |
@@ -77,7 +78,7 @@ screen_init(int which)
/* Deal with existing clients. */
if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) {
for (i = 0; i < nwins; i++)
- (void)client_init(wins[i], sc);
+ (void)client_init(wins[i], sc, (active == wins[i]));
XFree(wins);
}
diff --git a/xevents.c b/xevents.c
index d82a3d2..cda021b 100644
--- a/xevents.c
+++ b/xevents.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xevents.c,v 1.121 2016/09/14 19:45:33 okan Exp $
+ * $OpenBSD: xevents.c,v 1.122 2016/09/16 14:32:02 okan Exp $
*/
/*
@@ -81,7 +81,7 @@ xev_handle_maprequest(XEvent *ee)
client_ptrsave(old_cc);
if ((cc = client_find(e->window)) == NULL)
- cc = client_init(e->window, NULL);
+ cc = client_init(e->window, NULL, 0);
if ((cc != NULL) && (!(cc->flags & CLIENT_IGNORE)))
client_ptrwarp(cc);
diff --git a/xutil.c b/xutil.c
index c8c74da..1a0c5d5 100644
--- a/xutil.c
+++ b/xutil.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xutil.c,v 1.103 2015/08/27 18:53:15 okan Exp $
+ * $OpenBSD: xutil.c,v 1.104 2016/09/16 14:32:02 okan Exp $
*/
#include <sys/types.h>
@@ -256,6 +256,22 @@ xu_ewmh_net_active_window(struct screen_ctx *sc, Window w)
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
}
+Window
+xu_ewmh_get_net_active_window(struct screen_ctx *sc)
+{
+ long *p;
+ Window win;
+
+ if ((xu_getprop(sc->rootwin, ewmh[_NET_ACTIVE_WINDOW],
+ XA_WINDOW, 32, (unsigned char **)&p)) <= 0)
+ return(None);
+
+ win = (Window)*p;
+ XFree(p);
+
+ return(win);
+}
+
void
xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *sc)
{