screen: Add sgeo for don't have to exec screen_get_geo at all times...

This commit is contained in:
Martin Duquesnoy 2008-12-06 15:56:11 +01:00
parent 6a24974b7b
commit 588cdea544
8 changed files with 42 additions and 21 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -45,6 +45,7 @@ init(void)
init_key();
init_root();
init_atom();
screen_init_geo();
infobar_init();
grabkeys();

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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];