mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Move redundant bits from screen_init (while dealing with existing
clients) directly into client_init, performing the X roundtrip only once. With the previous change in maprequest, this moves decision making into one place for creating new clients.
This commit is contained in:
parent
ad76995af7
commit
ad96c16838
2
calmwm.h
2
calmwm.h
@ -383,7 +383,7 @@ void client_map(struct client_ctx *);
|
|||||||
void client_maximize(struct client_ctx *);
|
void client_maximize(struct client_ctx *);
|
||||||
void client_msg(struct client_ctx *, Atom, Time);
|
void client_msg(struct client_ctx *, Atom, Time);
|
||||||
void client_move(struct client_ctx *);
|
void client_move(struct client_ctx *);
|
||||||
struct client_ctx *client_init(Window, struct screen_ctx *, int);
|
struct client_ctx *client_init(Window, struct screen_ctx *);
|
||||||
void client_ptrsave(struct client_ctx *);
|
void client_ptrsave(struct client_ctx *);
|
||||||
void client_ptrwarp(struct client_ctx *);
|
void client_ptrwarp(struct client_ctx *);
|
||||||
void client_raise(struct client_ctx *);
|
void client_raise(struct client_ctx *);
|
||||||
|
12
client.c
12
client.c
@ -55,18 +55,26 @@ client_find(Window win)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct client_ctx *
|
struct client_ctx *
|
||||||
client_init(Window win, struct screen_ctx *sc, int mapped)
|
client_init(Window win, struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
struct client_ctx *cc;
|
struct client_ctx *cc;
|
||||||
XWindowAttributes wattr;
|
XWindowAttributes wattr;
|
||||||
long state;
|
long state;
|
||||||
|
int mapped;
|
||||||
|
|
||||||
if (win == None)
|
if (win == None)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if (!XGetWindowAttributes(X_Dpy, win, &wattr))
|
if (!XGetWindowAttributes(X_Dpy, win, &wattr))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if (sc == NULL)
|
|
||||||
|
if (sc == NULL) {
|
||||||
sc = screen_fromroot(wattr.root);
|
sc = screen_fromroot(wattr.root);
|
||||||
|
mapped = 1;
|
||||||
|
} else {
|
||||||
|
if (wattr.override_redirect || wattr.map_state != IsViewable)
|
||||||
|
return (NULL);
|
||||||
|
mapped = wattr.map_state != IsUnmapped;
|
||||||
|
}
|
||||||
|
|
||||||
cc = xcalloc(1, sizeof(*cc));
|
cc = xcalloc(1, sizeof(*cc));
|
||||||
|
|
||||||
|
16
screen.c
16
screen.c
@ -35,7 +35,6 @@ screen_init(int which)
|
|||||||
{
|
{
|
||||||
struct screen_ctx *sc;
|
struct screen_ctx *sc;
|
||||||
Window *wins, w0, w1;
|
Window *wins, w0, w1;
|
||||||
XWindowAttributes winattr;
|
|
||||||
XSetWindowAttributes rootattr;
|
XSetWindowAttributes rootattr;
|
||||||
unsigned int nwins, i;
|
unsigned int nwins, i;
|
||||||
|
|
||||||
@ -62,17 +61,12 @@ screen_init(int which)
|
|||||||
CWEventMask|CWCursor, &rootattr);
|
CWEventMask|CWCursor, &rootattr);
|
||||||
|
|
||||||
/* Deal with existing clients. */
|
/* Deal with existing clients. */
|
||||||
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++)
|
||||||
XGetWindowAttributes(X_Dpy, wins[i], &winattr);
|
(void)client_init(wins[i], sc);
|
||||||
if (winattr.override_redirect ||
|
|
||||||
winattr.map_state != IsViewable)
|
|
||||||
continue;
|
|
||||||
(void)client_init(wins[i], sc, winattr.map_state != IsUnmapped);
|
|
||||||
}
|
|
||||||
if (wins)
|
|
||||||
XFree(wins);
|
|
||||||
|
|
||||||
|
XFree(wins);
|
||||||
|
}
|
||||||
screen_updatestackingorder(sc);
|
screen_updatestackingorder(sc);
|
||||||
|
|
||||||
if (HasRandr)
|
if (HasRandr)
|
||||||
|
@ -80,7 +80,7 @@ xev_handle_maprequest(XEvent *ee)
|
|||||||
client_ptrsave(old_cc);
|
client_ptrsave(old_cc);
|
||||||
|
|
||||||
if ((cc = client_find(e->window)) == NULL)
|
if ((cc = client_find(e->window)) == NULL)
|
||||||
cc = client_init(e->window, NULL, 1);
|
cc = client_init(e->window, NULL);
|
||||||
|
|
||||||
if ((cc != NULL) && ((cc->flags & CLIENT_IGNORE) == 0))
|
if ((cc != NULL) && ((cc->flags & CLIENT_IGNORE) == 0))
|
||||||
client_ptrwarp(cc);
|
client_ptrwarp(cc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user