mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Instead of using _NET_ACTIVE_WINDOW on restart, use the pointer location
to determine what client to set active. Reduces a round trip for every window.
This commit is contained in:
parent
0a7d8cc5c4
commit
6c20772841
3
calmwm.h
3
calmwm.h
@ -395,7 +395,7 @@ void client_get_sizehints(struct client_ctx *);
|
|||||||
void client_hide(struct client_ctx *);
|
void client_hide(struct client_ctx *);
|
||||||
void client_htile(struct client_ctx *);
|
void client_htile(struct client_ctx *);
|
||||||
int client_inbound(struct client_ctx *, int, int);
|
int client_inbound(struct client_ctx *, int, int);
|
||||||
struct client_ctx *client_init(Window, struct screen_ctx *, int);
|
struct client_ctx *client_init(Window, struct screen_ctx *);
|
||||||
void client_lower(struct client_ctx *);
|
void client_lower(struct client_ctx *);
|
||||||
void client_move(struct client_ctx *);
|
void client_move(struct client_ctx *);
|
||||||
void client_mtf(struct client_ctx *);
|
void client_mtf(struct client_ctx *);
|
||||||
@ -563,7 +563,6 @@ void xu_ewmh_net_workarea(struct screen_ctx *);
|
|||||||
void xu_ewmh_net_client_list(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_client_list_stacking(struct screen_ctx *);
|
||||||
void xu_ewmh_net_active_window(struct screen_ctx *, Window);
|
void xu_ewmh_net_active_window(struct screen_ctx *, Window);
|
||||||
Window xu_ewmh_get_net_active_window(struct screen_ctx *);
|
|
||||||
void xu_ewmh_net_number_of_desktops(struct screen_ctx *);
|
void xu_ewmh_net_number_of_desktops(struct screen_ctx *);
|
||||||
void xu_ewmh_net_showing_desktop(struct screen_ctx *);
|
void xu_ewmh_net_showing_desktop(struct screen_ctx *);
|
||||||
void xu_ewmh_net_virtual_roots(struct screen_ctx *);
|
void xu_ewmh_net_virtual_roots(struct screen_ctx *);
|
||||||
|
12
client.c
12
client.c
@ -37,14 +37,11 @@ static void client_mwm_hints(struct client_ctx *);
|
|||||||
static void client_wm_protocols(struct client_ctx *);
|
static void client_wm_protocols(struct client_ctx *);
|
||||||
|
|
||||||
struct client_ctx *
|
struct client_ctx *
|
||||||
client_init(Window win, struct screen_ctx *sc, int active)
|
client_init(Window win, struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
struct client_ctx *cc;
|
struct client_ctx *cc;
|
||||||
XWindowAttributes wattr;
|
XWindowAttributes wattr;
|
||||||
int mapped;
|
int mapped;
|
||||||
Window rwin, cwin;
|
|
||||||
int x, y, wx, wy;
|
|
||||||
unsigned int mask;
|
|
||||||
long state;
|
long state;
|
||||||
|
|
||||||
if (win == None)
|
if (win == None)
|
||||||
@ -108,10 +105,6 @@ client_init(Window win, struct screen_ctx *sc, int active)
|
|||||||
client_resize(cc, 0);
|
client_resize(cc, 0);
|
||||||
if (cc->initial_state)
|
if (cc->initial_state)
|
||||||
xu_set_wm_state(cc->win, cc->initial_state);
|
xu_set_wm_state(cc->win, cc->initial_state);
|
||||||
} else {
|
|
||||||
if ((active == 0) && (XQueryPointer(X_Dpy, cc->win, &rwin,
|
|
||||||
&cwin, &x, &y, &wx, &wy, &mask)) && (cwin != None))
|
|
||||||
active = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XSelectInput(X_Dpy, cc->win,
|
XSelectInput(X_Dpy, cc->win,
|
||||||
@ -152,9 +145,6 @@ out:
|
|||||||
XSync(X_Dpy, False);
|
XSync(X_Dpy, False);
|
||||||
XUngrabServer(X_Dpy);
|
XUngrabServer(X_Dpy);
|
||||||
|
|
||||||
if (active)
|
|
||||||
client_set_active(cc);
|
|
||||||
|
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
screen.c
27
screen.c
@ -33,13 +33,12 @@
|
|||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
static struct geom screen_apply_gap(struct screen_ctx *, struct geom);
|
static struct geom screen_apply_gap(struct screen_ctx *, struct geom);
|
||||||
static void screen_scan(struct screen_ctx *, Window);
|
static void screen_scan(struct screen_ctx *);
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_init(int which)
|
screen_init(int which)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc;
|
struct screen_ctx *sc;
|
||||||
Window active = None;
|
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
|
|
||||||
sc = xmalloc(sizeof(*sc));
|
sc = xmalloc(sizeof(*sc));
|
||||||
@ -67,7 +66,6 @@ screen_init(int which)
|
|||||||
xu_ewmh_net_number_of_desktops(sc);
|
xu_ewmh_net_number_of_desktops(sc);
|
||||||
xu_ewmh_net_showing_desktop(sc);
|
xu_ewmh_net_showing_desktop(sc);
|
||||||
xu_ewmh_net_virtual_roots(sc);
|
xu_ewmh_net_virtual_roots(sc);
|
||||||
active = xu_ewmh_get_net_active_window(sc);
|
|
||||||
|
|
||||||
attr.cursor = Conf.cursor[CF_NORMAL];
|
attr.cursor = Conf.cursor[CF_NORMAL];
|
||||||
attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
|
attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
|
||||||
@ -77,7 +75,7 @@ screen_init(int which)
|
|||||||
if (Conf.xrandr)
|
if (Conf.xrandr)
|
||||||
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
|
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
|
||||||
|
|
||||||
screen_scan(sc, active);
|
screen_scan(sc);
|
||||||
screen_updatestackingorder(sc);
|
screen_updatestackingorder(sc);
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&Screenq, sc, entry);
|
TAILQ_INSERT_TAIL(&Screenq, sc, entry);
|
||||||
@ -86,17 +84,26 @@ screen_init(int which)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
screen_scan(struct screen_ctx *sc, Window active)
|
screen_scan(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
Window *wins, w0, w1;
|
struct client_ctx *cc, *active = NULL;
|
||||||
unsigned int nwins, i;
|
Window *wins, w0, w1, rwin, cwin;
|
||||||
|
unsigned int nwins, i, mask;
|
||||||
|
int rx, ry, wx, wy;
|
||||||
|
|
||||||
|
XQueryPointer(X_Dpy, sc->rootwin, &rwin, &cwin,
|
||||||
|
&rx, &ry, &wx, &wy, &mask);
|
||||||
|
|
||||||
if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) {
|
if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) {
|
||||||
for (i = 0; i < nwins; i++)
|
for (i = 0; i < nwins; i++) {
|
||||||
(void)client_init(wins[i], sc, (active == wins[i]));
|
if ((cc = client_init(wins[i], sc)) != NULL)
|
||||||
|
if (cc->win == cwin)
|
||||||
|
active = cc;
|
||||||
|
}
|
||||||
XFree(wins);
|
XFree(wins);
|
||||||
}
|
}
|
||||||
|
if (active)
|
||||||
|
client_set_active(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct screen_ctx *
|
struct screen_ctx *
|
||||||
|
@ -87,7 +87,7 @@ xev_handle_maprequest(XEvent *ee)
|
|||||||
client_ptr_save(old_cc);
|
client_ptr_save(old_cc);
|
||||||
|
|
||||||
if ((cc = client_find(e->window)) == NULL)
|
if ((cc = client_find(e->window)) == NULL)
|
||||||
cc = client_init(e->window, NULL, 0);
|
cc = client_init(e->window, NULL);
|
||||||
|
|
||||||
if ((cc != NULL) && (!(cc->flags & CLIENT_IGNORE)))
|
if ((cc != NULL) && (!(cc->flags & CLIENT_IGNORE)))
|
||||||
client_ptr_warp(cc);
|
client_ptr_warp(cc);
|
||||||
|
16
xutil.c
16
xutil.c
@ -296,22 +296,6 @@ xu_ewmh_net_active_window(struct screen_ctx *sc, Window w)
|
|||||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
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_get_prop(sc->rootwin, ewmh[_NET_ACTIVE_WINDOW],
|
|
||||||
XA_WINDOW, 32, (unsigned char **)&p)) <= 0)
|
|
||||||
return None;
|
|
||||||
|
|
||||||
win = (Window)*p;
|
|
||||||
XFree(p);
|
|
||||||
|
|
||||||
return win;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xu_ewmh_net_number_of_desktops(struct screen_ctx *sc)
|
xu_ewmh_net_number_of_desktops(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user