diff --git a/src/barwin.c b/src/barwin.c index 940b9d5..09a676c 100644 --- a/src/barwin.c +++ b/src/barwin.c @@ -44,8 +44,12 @@ */ BarWindow* barwin_create(Window parent, - int x, int y, uint w, uint h, - uint color, Bool entermask) + int x, + int y, + uint w, + uint h, + uint color, + Bool entermask) { XSetWindowAttributes at; BarWindow *bw; diff --git a/src/client.c b/src/client.c index e708e78..b749389 100644 --- a/src/client.c +++ b/src/client.c @@ -482,11 +482,10 @@ client_moveresize(Client *c, XRectangle geo, bool r) /* Set the client screen */ for(i = 0; i < screen_count(); ++i) - if(geo.x >= screen_get_geo(i).x - && geo.x < screen_get_geo(i).x + screen_get_geo(i).width - && geo.y >= screen_get_geo(i).y - INFOBARH - TBARH - && geo.y < screen_get_geo(i).y - INFOBARH - TBARH + screen_get_geo(i).height + INFOBARH) - + if(geo.x >= sgeo[i].x + && geo.x < sgeo[i].x + sgeo[i].width + && geo.y >= sgeo[i].y - INFOBARH - TBARH + && geo.y < sgeo[i].y - INFOBARH - TBARH + sgeo[i].height + INFOBARH) c->screen = i; frame_moveresize(c, geo); diff --git a/src/infobar.c b/src/infobar.c index b7c2e97..b7ceabf 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -47,12 +47,12 @@ infobar_init(void) j = 0; infobar[sc].geo.height = INFOBARH; infobar[sc].geo.y = (conf.bartop) - ? screen_get_geo(sc).y - INFOBARH - TBARH - : screen_get_geo(sc).height - INFOBARH; + ? sgeo[sc].y - INFOBARH - TBARH + : sgeo[sc].height - INFOBARH; /* Create infobar barwindow */ - infobar[sc].bar = barwin_create(root, screen_get_geo(sc).x - BORDH, infobar[sc].geo.y, - screen_get_geo(sc).width, infobar[sc].geo.height, conf.colors.bar, False); + infobar[sc].bar = barwin_create(root, sgeo[sc].x - BORDH, infobar[sc].geo.y, + sgeo[sc].width, infobar[sc].geo.height, conf.colors.bar, False); /* Create tags window */ for(i = 1; i < conf.ntag[sc] + 1; ++i) @@ -93,7 +93,7 @@ infobar_draw(int sc) /* DRAW status text */ draw_text(infobar[sc].bar->dr, - (screen_get_geo(sc).width - SHADH) - textw(statustext), + (sgeo[sc].width - SHADH) - textw(statustext), font->height, conf.colors.text, 0, statustext); @@ -186,7 +186,7 @@ infobar_destroy(void) void uicb_infobar_togglepos(uicb_t cmd) { - XRectangle sg = screen_get_geo(screen_get_sel()); + XRectangle sg = sgeo[screen_get_sel()]; conf.bartop = !conf.bartop; diff --git a/src/init.c b/src/init.c index a57b2c9..7d3046a 100644 --- a/src/init.c +++ b/src/init.c @@ -45,6 +45,7 @@ init(void) init_key(); init_root(); init_atom(); + screen_init_geo(); infobar_init(); grabkeys(); diff --git a/src/layout.c b/src/layout.c index 045e299..52e3f51 100644 --- a/src/layout.c +++ b/src/layout.c @@ -140,7 +140,7 @@ maxlayout(void) { Client *c; XRectangle geo; - XRectangle sg = screen_get_geo(screen_get_sel()); + XRectangle sg = sgeo[selscreen]; for(c = nexttiled(clients); c; c = nexttiled(c->next)) { @@ -170,7 +170,7 @@ maxlayout(void) Client* nexttiled(Client *c) { - for(; c && (c->max || c->free || c->screen != screen_get_sel() || ishide(c)); c = c->next); + for(; c && (c->max || c->free || c->screen != selscreen || ishide(c)); c = c->next); return c; } @@ -226,7 +226,7 @@ void grid(void) { Client *c; - XRectangle sg = screen_get_geo(screen_get_sel()); + XRectangle sg = sgeo[selscreen]; XRectangle cgeo = {sg.x, sg.y, 0, 0}; unsigned int i, n, cols, rows, cpcols = 0; unsigned int border = BORDH * 2; @@ -285,7 +285,7 @@ void multi_tile(Position type) { Client *c; - XRectangle sg = screen_get_geo(screen_get_sel()); + XRectangle sg = sgeo[selscreen]; XRectangle mastergeo = {sg.x, sg.y, 0, 0}; XRectangle cgeo = {sg.x, sg.y, 0, 0}; uint i , n, tilesize, mwfact, nmaster = tags[selscreen][seltag[selscreen]].nmaster; @@ -481,8 +481,6 @@ uicb_togglefree(uicb_t cmd) { CHECK(sel); - screen_get_sel(); - sel->free = !sel->free; sel->tile = False; sel->max = False; @@ -500,7 +498,7 @@ void uicb_togglemax(uicb_t cmd) { XRectangle geo; - XRectangle sg = screen_get_geo(screen_get_sel()); + XRectangle sg = sgeo[screen_get_sel()]; if(!sel || ishide(sel) || sel->hint) return; diff --git a/src/screen.c b/src/screen.c index bb1e419..b797e0f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -108,3 +108,20 @@ screen_get_sel(void) else return 0; } + +/** Init screen geo + */ +void +screen_init_geo(void) +{ + int i; + + sgeo = emalloc(screen_count(), sizeof(XRectangle)); + + for(i = 0; i < screen_count(); ++i) + sgeo[i] = screen_get_geo(i); + + return; +} + + diff --git a/src/wmfs.c b/src/wmfs.c index eaedae3..d87d79e 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -51,7 +51,6 @@ errorhandler(Display *d, XErrorEvent *event) * 42 = X_SetInputFocus * 28 = X_GrabButton */ - if((c = client_gb_win(event->resourceid))) if(event->error_code == BadWindow || (event->error_code == BadMatch && event->request_code == 42) @@ -104,6 +103,7 @@ quit(void) XFreeCursor(dpy, cursor[CurMove]); XFreeCursor(dpy, cursor[CurResize]); infobar_destroy(); + free(sgeo); free(infobar); free(seltag); free(keys); diff --git a/src/wmfs.h b/src/wmfs.h index 572ce4d..52a5ffd 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -184,6 +184,7 @@ void uicb_tagtransfert(uicb_t); int screen_count(void); XRectangle screen_get_geo(int s); int screen_get_sel(void); +void screen_init_geo(void); /* layout.c */ void arrange(void); @@ -237,6 +238,7 @@ Conf conf; Key *keys; Bool exiting; char statustext[1024]; +XRectangle *sgeo; /* Atoms / Cursors */ Atom wm_atom[WMLast];