X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=073ade9629a37f8b4f665c01a4c46300db0a68df;hb=45ac9837d3e0d8f21c567871ae2a94f9d192b480;hp=86c2afaac35005999cfa54d86e490e5af3d01638;hpb=99119d86977bc0f0d023f56d1dba269dcdff2706;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 86c2afa..073ade9 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -538,7 +538,9 @@ struct swm_region * 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) @@ -548,19 +550,14 @@ root_to_region(Window 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) @@ -573,8 +570,8 @@ root_to_region(Window root) 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++) @@ -662,8 +659,9 @@ switchws(struct swm_region *r, union arg *args) 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) @@ -783,7 +781,7 @@ focus(struct swm_region *r, union arg *args) 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); @@ -822,9 +820,9 @@ stack_reset(struct swm_region *r, union arg *args) 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"); @@ -1561,9 +1559,11 @@ unmapnotify(XEvent *e) 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) @@ -1643,7 +1643,7 @@ void 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); @@ -1665,8 +1665,19 @@ new_region(struct swm_screen *s, struct workspace *ws, 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) @@ -1674,18 +1685,7 @@ setup_screens(void) /* 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); @@ -1702,9 +1702,7 @@ setup_screens(void) /* 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; @@ -1741,29 +1739,32 @@ setup_screens(void) 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), @@ -1841,7 +1842,7 @@ main(int argc, char *argv[]) setup_screens(); - //ws[0].focus = TAILQ_FIRST(&ws[0].winlist); + /* ws[0].focus = TAILQ_FIRST(&ws[0].winlist); */ grabkeys(); stack();