Re-implement XClientMessage handling so that we can feed screen_find and
client_find valid resources as needed, relieving the need for screen_find to ungracefully handle invalid root windows. Removes a long standing XXX. Should theoretically allow XClientMessage handling on more than one X screen. Alter callers of screen_find to handle failures.
This commit is contained in:
3
client.c
3
client.c
@@ -55,7 +55,8 @@ client_init(Window win, struct screen_ctx *sc)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (sc == NULL) {
|
if (sc == NULL) {
|
||||||
sc = screen_find(wattr.root);
|
if ((sc = screen_find(wattr.root)) == NULL)
|
||||||
|
return(NULL);
|
||||||
mapped = 1;
|
mapped = 1;
|
||||||
} else {
|
} else {
|
||||||
if (wattr.override_redirect || wattr.map_state != IsViewable)
|
if (wattr.override_redirect || wattr.map_state != IsViewable)
|
||||||
|
|||||||
4
screen.c
4
screen.c
@@ -100,8 +100,8 @@ screen_find(Window win)
|
|||||||
if (sc->rootwin == win)
|
if (sc->rootwin == win)
|
||||||
return(sc);
|
return(sc);
|
||||||
}
|
}
|
||||||
/* XXX FAIL HERE */
|
warnx("screen_find failure win 0x%lu\n", win);
|
||||||
return(TAILQ_FIRST(&Screenq));
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
50
xevents.c
50
xevents.c
@@ -240,7 +240,8 @@ xev_handle_buttonpress(XEvent *ee)
|
|||||||
if (e->window != e->root)
|
if (e->window != e->root)
|
||||||
return;
|
return;
|
||||||
cc = &fakecc;
|
cc = &fakecc;
|
||||||
cc->sc = screen_find(e->window);
|
if ((cc->sc = screen_find(e->window)) == NULL)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*mb->callback)(cc, &mb->argument);
|
(*mb->callback)(cc, &mb->argument);
|
||||||
@@ -290,7 +291,8 @@ xev_handle_keypress(XEvent *ee)
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
cc = &fakecc;
|
cc = &fakecc;
|
||||||
cc->sc = screen_find(e->window);
|
if ((cc->sc = screen_find(e->window)) == NULL)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*kb->callback)(cc, &kb->argument);
|
(*kb->callback)(cc, &kb->argument);
|
||||||
@@ -307,7 +309,8 @@ xev_handle_keyrelease(XEvent *ee)
|
|||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
sc = screen_find(e->root);
|
if ((sc = screen_find(e->root)) == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
|
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
|
||||||
for (i = 0; i < nitems(modkeys); i++) {
|
for (i = 0; i < nitems(modkeys); i++) {
|
||||||
@@ -325,42 +328,43 @@ xev_handle_clientmessage(XEvent *ee)
|
|||||||
struct client_ctx *cc, *old_cc;
|
struct client_ctx *cc, *old_cc;
|
||||||
struct screen_ctx *sc;
|
struct screen_ctx *sc;
|
||||||
|
|
||||||
sc = screen_find(e->window);
|
if (e->message_type == cwmh[WM_CHANGE_STATE]) {
|
||||||
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
if ((cc = client_find(e->window)) == NULL && e->window != sc->rootwin)
|
if (e->data.l[0] == IconicState)
|
||||||
return;
|
|
||||||
|
|
||||||
if (e->message_type == cwmh[WM_CHANGE_STATE] && e->format == 32 &&
|
|
||||||
e->data.l[0] == IconicState)
|
|
||||||
client_hide(cc);
|
client_hide(cc);
|
||||||
|
}
|
||||||
if (e->message_type == ewmh[_NET_CLOSE_WINDOW])
|
} else if (e->message_type == ewmh[_NET_CLOSE_WINDOW]) {
|
||||||
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
client_send_delete(cc);
|
client_send_delete(cc);
|
||||||
|
}
|
||||||
if (e->message_type == ewmh[_NET_ACTIVE_WINDOW] && e->format == 32) {
|
} else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) {
|
||||||
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
if ((old_cc = client_current()))
|
if ((old_cc = client_current()))
|
||||||
client_ptrsave(old_cc);
|
client_ptrsave(old_cc);
|
||||||
client_ptrwarp(cc);
|
client_ptrwarp(cc);
|
||||||
}
|
}
|
||||||
|
} else if (e->message_type == ewmh[_NET_WM_DESKTOP]) {
|
||||||
if (e->message_type == ewmh[_NET_WM_DESKTOP] && e->format == 32) {
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
/*
|
/*
|
||||||
* The EWMH spec states that if the cardinal returned is
|
* The EWMH spec states that if the cardinal returned
|
||||||
* 0xFFFFFFFF (-1) then the window should appear on all
|
* is 0xFFFFFFFF (-1) then the window should appear
|
||||||
* desktops, which in our case is assigned to group 0.
|
* on all desktops, in our case, group 0.
|
||||||
*/
|
*/
|
||||||
if (e->data.l[0] == (unsigned long)-1)
|
if (e->data.l[0] == (unsigned long)-1)
|
||||||
group_movetogroup(cc, 0);
|
group_movetogroup(cc, 0);
|
||||||
else
|
else
|
||||||
group_movetogroup(cc, e->data.l[0]);
|
group_movetogroup(cc, e->data.l[0]);
|
||||||
}
|
}
|
||||||
|
} else if (e->message_type == ewmh[_NET_WM_STATE]) {
|
||||||
if (e->message_type == ewmh[_NET_WM_STATE] && e->format == 32)
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
xu_ewmh_handle_net_wm_state_msg(cc,
|
xu_ewmh_handle_net_wm_state_msg(cc,
|
||||||
e->data.l[0], e->data.l[1], e->data.l[2]);
|
e->data.l[0], e->data.l[1], e->data.l[2]);
|
||||||
|
}
|
||||||
if (e->message_type == ewmh[_NET_CURRENT_DESKTOP] && e->format == 32)
|
} else if (e->message_type == ewmh[_NET_CURRENT_DESKTOP]) {
|
||||||
|
if ((sc = screen_find(e->window)) != NULL) {
|
||||||
group_only(sc, e->data.l[0]);
|
group_only(sc, e->data.l[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user