diff options
author | okan | 2014-02-03 21:07:47 +0000 |
---|---|---|
committer | okan | 2014-02-03 21:07:47 +0000 |
commit | a0551f88bbfd3d91402c779824dabeb7969849a2 (patch) | |
tree | e7b8926a0fd8661e6ffa058d109c70e50eba0c2a /screen.c | |
parent | 2d0a84ba83633a3ef2de56baa1c9289869dafde1 (diff) | |
download | cwm-a0551f88bbfd3d91402c779824dabeb7969849a2.tar.gz |
Introduce a region queue and replace screen's XineramaScreenInfo; we
still use Xinerama to populate the regions per screen, but will switch
at a more appropriate time.
Diffstat (limited to '')
-rw-r--r-- | screen.c | 50 |
1 files changed, 27 insertions, 23 deletions
@@ -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.59 2014/02/03 20:29:05 okan Exp $ + * $OpenBSD: screen.c,v 1.60 2014/02/03 21:07:47 okan Exp $ */ #include <sys/param.h> @@ -41,6 +41,7 @@ screen_init(int which) sc = xcalloc(1, sizeof(*sc)); TAILQ_INIT(&sc->mruq); + TAILQ_INIT(&sc->regionq); sc->which = which; sc->rootwin = RootWindow(X_Dpy, sc->which); @@ -116,23 +117,13 @@ screen_updatestackingorder(struct screen_ctx *sc) struct geom screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags) { - XineramaScreenInfo *info; - struct geom geom; - int i; - - geom = sc->work; - - if (sc->xinerama == NULL) - return (geom); - - for (i = 0; i < sc->xinerama_no; i++) { - info = &sc->xinerama[i]; - if (x >= info->x_org && x < info->x_org + info->width && - y >= info->y_org && y < info->y_org + info->height) { - geom.x = info->x_org; - geom.y = info->y_org; - geom.w = info->width; - geom.h = info->height; + struct region_ctx *region; + struct geom geom = sc->work; + + TAILQ_FOREACH(region, &sc->regionq, entry) { + if (x >= region->area.x && x < region->area.x+region->area.w && + y >= region->area.y && y < region->area.y+region->area.h) { + geom = region->area; break; } } @@ -149,7 +140,8 @@ void screen_update_geometry(struct screen_ctx *sc) { XineramaScreenInfo *info = NULL; - int info_no = 0; + struct region_ctx *region; + int info_no = 0, i; sc->view.x = 0; sc->view.y = 0; @@ -164,10 +156,22 @@ screen_update_geometry(struct screen_ctx *sc) /* RandR event may have a CTRC added or removed. */ if (XineramaIsActive(X_Dpy)) info = XineramaQueryScreens(X_Dpy, &info_no); - if (sc->xinerama != NULL) - XFree(sc->xinerama); - sc->xinerama = info; - sc->xinerama_no = info_no; + + while ((region = TAILQ_FIRST(&sc->regionq)) != NULL) { + TAILQ_REMOVE(&sc->regionq, region, entry); + free(region); + } + for (i = 0; i < info_no; i++) { + region = xmalloc(sizeof(*region)); + region->num = i; + region->area.x = info[i].x_org; + region->area.y = info[i].y_org; + region->area.w = info[i].width; + region->area.h = info[i].height; + TAILQ_INSERT_TAIL(&sc->regionq, region, entry); + } + if (info) + XFree(info); xu_ewmh_net_desktop_geometry(sc); xu_ewmh_net_workarea(sc); |