mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
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.
This commit is contained in:
10
calmwm.h
10
calmwm.h
@@ -218,6 +218,13 @@ struct autogroupwin {
|
|||||||
};
|
};
|
||||||
TAILQ_HEAD(autogroupwin_q, 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 {
|
struct screen_ctx {
|
||||||
TAILQ_ENTRY(screen_ctx) entry;
|
TAILQ_ENTRY(screen_ctx) entry;
|
||||||
int which;
|
int which;
|
||||||
@@ -229,11 +236,10 @@ struct screen_ctx {
|
|||||||
struct geom work; /* workable area, gap-applied */
|
struct geom work; /* workable area, gap-applied */
|
||||||
struct gap gap;
|
struct gap gap;
|
||||||
struct cycle_entry_q mruq;
|
struct cycle_entry_q mruq;
|
||||||
|
struct region_ctx_q regionq;
|
||||||
XftColor xftcolor[CWM_COLOR_NITEMS];
|
XftColor xftcolor[CWM_COLOR_NITEMS];
|
||||||
XftDraw *xftdraw;
|
XftDraw *xftdraw;
|
||||||
XftFont *xftfont;
|
XftFont *xftfont;
|
||||||
int xinerama_no;
|
|
||||||
XineramaScreenInfo *xinerama;
|
|
||||||
#define CALMWM_NGROUPS 10
|
#define CALMWM_NGROUPS 10
|
||||||
struct group_ctx groups[CALMWM_NGROUPS];
|
struct group_ctx groups[CALMWM_NGROUPS];
|
||||||
struct group_ctx_q groupq;
|
struct group_ctx_q groupq;
|
||||||
|
|||||||
46
screen.c
46
screen.c
@@ -41,6 +41,7 @@ screen_init(int which)
|
|||||||
sc = xcalloc(1, sizeof(*sc));
|
sc = xcalloc(1, sizeof(*sc));
|
||||||
|
|
||||||
TAILQ_INIT(&sc->mruq);
|
TAILQ_INIT(&sc->mruq);
|
||||||
|
TAILQ_INIT(&sc->regionq);
|
||||||
|
|
||||||
sc->which = which;
|
sc->which = which;
|
||||||
sc->rootwin = RootWindow(X_Dpy, sc->which);
|
sc->rootwin = RootWindow(X_Dpy, sc->which);
|
||||||
@@ -116,23 +117,13 @@ screen_updatestackingorder(struct screen_ctx *sc)
|
|||||||
struct geom
|
struct geom
|
||||||
screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags)
|
screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags)
|
||||||
{
|
{
|
||||||
XineramaScreenInfo *info;
|
struct region_ctx *region;
|
||||||
struct geom geom;
|
struct geom geom = sc->work;
|
||||||
int i;
|
|
||||||
|
|
||||||
geom = sc->work;
|
TAILQ_FOREACH(region, &sc->regionq, entry) {
|
||||||
|
if (x >= region->area.x && x < region->area.x+region->area.w &&
|
||||||
if (sc->xinerama == NULL)
|
y >= region->area.y && y < region->area.y+region->area.h) {
|
||||||
return (geom);
|
geom = region->area;
|
||||||
|
|
||||||
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;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +140,8 @@ void
|
|||||||
screen_update_geometry(struct screen_ctx *sc)
|
screen_update_geometry(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
XineramaScreenInfo *info = NULL;
|
XineramaScreenInfo *info = NULL;
|
||||||
int info_no = 0;
|
struct region_ctx *region;
|
||||||
|
int info_no = 0, i;
|
||||||
|
|
||||||
sc->view.x = 0;
|
sc->view.x = 0;
|
||||||
sc->view.y = 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. */
|
/* RandR event may have a CTRC added or removed. */
|
||||||
if (XineramaIsActive(X_Dpy))
|
if (XineramaIsActive(X_Dpy))
|
||||||
info = XineramaQueryScreens(X_Dpy, &info_no);
|
info = XineramaQueryScreens(X_Dpy, &info_no);
|
||||||
if (sc->xinerama != NULL)
|
|
||||||
XFree(sc->xinerama);
|
while ((region = TAILQ_FIRST(&sc->regionq)) != NULL) {
|
||||||
sc->xinerama = info;
|
TAILQ_REMOVE(&sc->regionq, region, entry);
|
||||||
sc->xinerama_no = info_no;
|
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_desktop_geometry(sc);
|
||||||
xu_ewmh_net_workarea(sc);
|
xu_ewmh_net_workarea(sc);
|
||||||
|
|||||||
Reference in New Issue
Block a user