From 1c882c3ced97399292656739896fdbb19f1a15f5 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 4 Oct 2016 20:15:55 +0000 Subject: When removing xrandr regions, ensure clients are within the bounds of the screen; adapted from an ancient diff from Sviatoslav Chagaev. Things in this area will likely change, but put this in so it works now and serves as a reminder. --- calmwm.h | 3 ++- screen.c | 25 ++++++++++++++++++++++++- xevents.c | 3 ++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/calmwm.h b/calmwm.h index d3b81b9..dd81e74 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.323 2016/10/04 15:52:32 okan Exp $ + * $OpenBSD: calmwm.h,v 1.324 2016/10/04 20:15:55 okan Exp $ */ #ifndef _CALMWM_H_ @@ -455,6 +455,7 @@ struct geom screen_area(struct screen_ctx *, int, int, int); void screen_init(int); void screen_update_geometry(struct screen_ctx *); void screen_updatestackingorder(struct screen_ctx *); +void screen_assert_clients_within(struct screen_ctx *); void kbfunc_client_cycle(struct client_ctx *, union arg *); void kbfunc_client_delete(struct client_ctx *, union arg *); diff --git a/screen.c b/screen.c index 660d9ff..6bf4165 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.81 2016/10/04 15:18:20 okan Exp $ + * $OpenBSD: screen.c,v 1.82 2016/10/04 20:15:55 okan Exp $ */ #include @@ -229,3 +229,26 @@ screen_apply_gap(struct screen_ctx *sc, struct geom geom) return(geom); } + +/* Bring back clients which are beyond the screen. */ +void +screen_assert_clients_within(struct screen_ctx *sc) +{ + struct client_ctx *cc; + int top, left, right, bottom; + + TAILQ_FOREACH(cc, &sc->clientq, entry) { + if (cc->sc != sc) + continue; + top = cc->geom.y; + left = cc->geom.x; + right = cc->geom.x + cc->geom.w + (cc->bwidth * 2) - 1; + bottom = cc->geom.y + cc->geom.h + (cc->bwidth * 2) - 1; + if ((top > sc->view.h || left > sc->view.w) || + (bottom < 0 || right < 0)) { + cc->geom.x = sc->gap.left; + cc->geom.y = sc->gap.top; + client_move(cc); + } + } +} diff --git a/xevents.c b/xevents.c index a59aee6..f2ecfe8 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.123 2016/10/03 13:41:30 okan Exp $ + * $OpenBSD: xevents.c,v 1.124 2016/10/04 20:15:55 okan Exp $ */ /* @@ -386,6 +386,7 @@ xev_handle_randr(XEvent *ee) if (sc->which == i) { XRRUpdateConfiguration(ee); screen_update_geometry(sc); + screen_assert_clients_within(sc); } } } -- cgit v1.2.3-2-gb3c3