summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2016-09-16 14:32:03 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2016-09-16 14:32:03 +0000
commitab9a91599ced007e4aebd94a8eeb120a641453c2 (patch)
treeafff2902f770104a1195b8375fb7c51268566862
parent030169216e9b075261283ee3ba07182f30dbe8ca (diff)
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--app/cwm/calmwm.h5
-rw-r--r--app/cwm/client.c12
-rw-r--r--app/cwm/screen.c7
-rw-r--r--app/cwm/xevents.c4
-rw-r--r--app/cwm/xutil.c18
5 files changed, 32 insertions, 14 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 3d4d4e15d..8305ba69f 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/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/app/cwm/client.c b/app/cwm/client.c
index 38b1471f6..b6d3b383f 100644
--- a/app/cwm/client.c
+++ b/app/cwm/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/app/cwm/screen.c b/app/cwm/screen.c
index e1f5fe8c9..9f3eb47cb 100644
--- a/app/cwm/screen.c
+++ b/app/cwm/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/app/cwm/xevents.c b/app/cwm/xevents.c
index d82a3d2c7..cda021be5 100644
--- a/app/cwm/xevents.c
+++ b/app/cwm/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/app/cwm/xutil.c b/app/cwm/xutil.c
index c8c74da7b..1a0c5d588 100644
--- a/app/cwm/xutil.c
+++ b/app/cwm/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)
{