root_to_region(Window root)
{
struct swm_region *r;
- int i;
+ Window rr, cr;
+ int i, x, y, wx, wy;
+ unsigned int mask;
for (i = 0; i < ScreenCount(display); i++)
if (screens[i].root == root)
cur_focus && cur_focus->ws->r && cur_focus->s == &screens[i])
r = cur_focus->ws->r;
else {
- Window rr, cr;
- int x, y, wx, wy;
- unsigned int mask;
-
if (XQueryPointer(display, screens[i].root,
&rr, &cr, &x, &y, &wx, &wy, &mask) == False) {
r = TAILQ_FIRST(&screens[i].rl);
} else {
TAILQ_FOREACH(r, &screens[i].rl, entry) {
if (x > X(r) && x < X(r) + WIDTH(r) &&
- y > Y(r) && y < Y(r) + HEIGHT(r)) {
+ y > Y(r) && y < Y(r) + HEIGHT(r))
break;
- }
}
if (r == NULL)
struct ws_win *
find_window(Window id)
{
- struct ws_win *win;
- int i, j;
+ struct ws_win *win;
+ int i, j;
for (i = 0; i < ScreenCount(display); i++)
for (j = 0; j < SWM_WS_MAX; j++)
return;
other_r = new_ws->r;
+ fprintf(stderr, "switchws: other_r %p\n", other_r);
if (!other_r) {
- /* if the other region is hidden, switch windows */
+ /* if the other workspace is hidden, switch windows */
/* map new window first to prevent ugly blinking */
TAILQ_FOREACH(win, &new_ws->winlist, entry)
void
cycle_layout(struct swm_region *r, union arg *args)
{
- struct workspace *ws = r->ws;
+ struct workspace *ws = r->ws;
DNPRINTF(SWM_D_EVENT, "cycle_layout: workspace: %d\n", ws->idx);
void
stack(void) {
- struct swm_geometry g;
- struct swm_region *r;
- int i, j;
+ struct swm_geometry g;
+ struct swm_region *r;
+ int i, j;
DNPRINTF(SWM_D_STACK, "stack\n");
void
visibilitynotify(XEvent *e)
{
- int i;
- struct swm_region *r;
- DNPRINTF(SWM_D_EVENT, "visibilitynotify: window: %lu\n", e->xvisibility.window);
+ int i;
+ struct swm_region *r;
+
+ DNPRINTF(SWM_D_EVENT, "visibilitynotify: window: %lu\n",
+ e->xvisibility.window);
if (e->xvisibility.state == VisibilityUnobscured)
for (i = 0; i < ScreenCount(display); i++)
TAILQ_FOREACH(r, &screens[i].rl, entry)
new_region(struct swm_screen *s, struct workspace *ws,
int x, int y, int w, int h)
{
- struct swm_region *r;
+ struct swm_region *r;
DNPRINTF(SWM_D_MISC, "new region on screen %d: %dx%d (%d, %d)\n",
s->idx, x, y, w, h);
void
setup_screens(void)
{
- int i;
-
+#ifdef SWM_XRR_HAS_CRTC
+ XRRCrtcInfo *ci;
+ XRRScreenResources *sr;
+ int c;
+#endif /* SWM_XRR_HAS_CRTC */
+ Window d1, d2, *wins = NULL;
+ XWindowAttributes wa;
+ struct swm_region *r;
+ unsigned int num;
+ int errorbase, major, minor;
+ int ncrtc, w = 0;
+ int i, j, k;
+ struct workspace *ws;
if ((screens = calloc(ScreenCount(display),
sizeof(struct swm_screen))) == NULL)
/* map physical screens */
for (i = 0; i < ScreenCount(display); i++) {
-#ifdef SWM_XRR_HAS_CRTC
- XRRCrtcInfo *crtc_info;
- XRRScreenResources *res;
- int c;
-#endif /* SWM_XRR_HAS_CRTC */
- Window d1, d2, *wins = NULL;
- XWindowAttributes wa;
- struct swm_region *r;
- int errorbase, major, minor;
- int j, ncrtc, w = 0;
- unsigned int num;
-
+ DNPRINTF(SWM_D_WS, "setup_screens: init screen %d\n", i);
screens[i].idx = i;
TAILQ_INIT(&screens[i].rl);
screens[i].root = RootWindow(display, i);
/* init all workspaces */
for (j = 0; j < SWM_WS_MAX; j++) {
- int k;
- struct workspace *ws = &screens[i].ws[j];
-
+ ws = &screens[i].ws[j];
ws->idx = j;
ws->restack = 1;
ws->focus = NULL;
continue;
}
-
#ifdef SWM_XRR_HAS_CRTC
- res = XRRGetScreenResources (display, screens[i].root);
- if (res == NULL) {
+ sr = XRRGetScreenResources(display, screens[i].root);
+ if (sr == NULL) {
ncrtc = 0;
new_region(&screens[i], &screens[i].ws[w],
0, 0, DisplayWidth(display, i),
DisplayHeight(display, i));
} else
- ncrtc = res->ncrtc;
+ ncrtc = sr->ncrtc;
for (c = 0; c < ncrtc; c++) {
- crtc_info = XRRGetCrtcInfo(display, res, res->crtcs[c]);
- if (crtc_info != NULL && crtc_info->mode == None)
+ ci = XRRGetCrtcInfo(display, sr, sr->crtcs[c]);
+ if (ci->noutput == 0)
+ continue;
+
+ if (ci != NULL && ci->mode == None)
new_region(&screens[i], &screens[i].ws[w],
0, 0, DisplayWidth(display, i),
DisplayHeight(display, i));
else
new_region(&screens[i], &screens[i].ws[w],
- crtc_info->x, crtc_info->y,
- crtc_info->width, crtc_info->height);
+ ci->x, ci->y, ci->width, ci->height);
w++;
}
+ XRRFreeCrtcInfo(ci);
+ XRRFreeScreenResources(sr);
#else
new_region(&screens[i], &screens[i].ws[w],
0, 0, DisplayWidth(display, i),
setup_screens();
- //ws[0].focus = TAILQ_FIRST(&ws[0].winlist);
+ /* ws[0].focus = TAILQ_FIRST(&ws[0].winlist); */
grabkeys();
stack();