diff options
author | okan <okan> | 2014-02-03 21:07:47 +0000 |
---|---|---|
committer | okan <okan> | 2014-02-03 21:07:47 +0000 |
commit | 8653141b4b5d76bd7238003cf43034681c7724a4 (patch) | |
tree | badc1a0d327780d82348bdb498db6d3e958267e8 | |
parent | b923524a8e637141c0c832f6c8989ee600b67946 (diff) | |
parent | f793964c9ec586b9c4b4843c14bc83afaf275cb4 (diff) | |
download | cwm-8653141b4b5d76bd7238003cf43034681c7724a4.tar.gz cwm-8653141b4b5d76bd7238003cf43034681c7724a4.tar.xz cwm-8653141b4b5d76bd7238003cf43034681c7724a4.zip |
cvsimport
-rw-r--r-- | calmwm.h | 12 | ||||
-rw-r--r-- | client.c | 12 | ||||
-rw-r--r-- | screen.c | 86 | ||||
-rw-r--r-- | xevents.c | 2 |
4 files changed, 61 insertions, 51 deletions
diff --git a/calmwm.h b/calmwm.h index 4b7b98d..6026206 100644 --- a/calmwm.h +++ b/calmwm.h @@ -230,6 +230,13 @@ struct autogroupwin { }; TAILQ_HEAD(autogroupwin_q, autogroupwin); +struct region_ctx { + TAILQ_ENTRY(region_ctx) entry; + int num; + struct geom area; +}; +TAILQ_HEAD(region_ctx_q, region_ctx); + struct screen_ctx { TAILQ_ENTRY(screen_ctx) entry; int which; @@ -241,11 +248,10 @@ struct screen_ctx { struct geom work; /* workable area, gap-applied */ struct gap gap; struct cycle_entry_q mruq; + struct region_ctx_q regionq; XftColor xftcolor[CWM_COLOR_NITEMS]; XftDraw *xftdraw; XftFont *xftfont; - int xinerama_no; - XineramaScreenInfo *xinerama; #define CALMWM_NGROUPS 10 struct group_ctx groups[CALMWM_NGROUPS]; struct group_ctx_q groupq; @@ -395,7 +401,7 @@ void client_map(struct client_ctx *); void client_maximize(struct client_ctx *); void client_msg(struct client_ctx *, Atom, Time); 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_ptrwarp(struct client_ctx *); void client_raise(struct client_ctx *); diff --git a/client.c b/client.c index 5d8444b..5005d49 100644 --- a/client.c +++ b/client.c @@ -55,18 +55,26 @@ client_find(Window win) } 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; XWindowAttributes wattr; long state; + int mapped; if (win == None) return (NULL); if (!XGetWindowAttributes(X_Dpy, win, &wattr)) return (NULL); - if (sc == NULL) + + if (sc == NULL) { 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)); diff --git a/screen.c b/screen.c index 55e0430..22f7ef0 100644 --- a/screen.c +++ b/screen.c @@ -35,13 +35,13 @@ screen_init(int which) { struct screen_ctx *sc; Window *wins, w0, w1; - XWindowAttributes winattr; XSetWindowAttributes rootattr; unsigned int nwins, i; sc = xcalloc(1, sizeof(*sc)); TAILQ_INIT(&sc->mruq); + TAILQ_INIT(&sc->regionq); sc->which = which; sc->rootwin = RootWindow(X_Dpy, sc->which); @@ -62,17 +62,12 @@ screen_init(int which) CWEventMask|CWCursor, &rootattr); /* Deal with existing clients. */ - XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins); - for (i = 0; i < nwins; i++) { - XGetWindowAttributes(X_Dpy, wins[i], &winattr); - if (winattr.override_redirect || - winattr.map_state != IsViewable) - continue; - (void)client_init(wins[i], sc, winattr.map_state != IsUnmapped); - } - if (wins) - XFree(wins); + if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) { + for (i = 0; i < nwins; i++) + (void)client_init(wins[i], sc); + XFree(wins); + } screen_updatestackingorder(sc); if (HasRandr) @@ -103,19 +98,17 @@ screen_updatestackingorder(struct screen_ctx *sc) struct client_ctx *cc; unsigned int nwins, i, s; - if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) - return; - - for (s = 0, i = 0; i < nwins; i++) { - /* Skip hidden windows */ - if ((cc = client_find(wins[i])) == NULL || - cc->flags & CLIENT_HIDDEN) - continue; - - cc->stackingorder = s++; + if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) { + for (s = 0, i = 0; i < nwins; i++) { + /* Skip hidden windows */ + if ((cc = client_find(wins[i])) == NULL || + cc->flags & CLIENT_HIDDEN) + continue; + + cc->stackingorder = s++; + } + XFree(wins); } - - XFree(wins); } /* @@ -124,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; } } @@ -157,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; @@ -172,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); diff --git a/xevents.c b/xevents.c index 716d72b..027f52a 100644 --- a/xevents.c +++ b/xevents.c @@ -80,7 +80,7 @@ xev_handle_maprequest(XEvent *ee) client_ptrsave(old_cc); 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)) client_ptrwarp(cc); |