From 582f1a9481901d3f3a82a9b10366e25fff19d0ec Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Mon, 30 Mar 2009 07:30:32 +0200 Subject: [PATCH] Screen/Infobar: Fix position with multi-head, add spgeo[] (screen pure geometry). --- src/event.c | 2 +- src/infobar.c | 42 +++++++++++++++--------------------------- src/layout.c | 1 + src/screen.c | 25 ++++++++++++++++++++++++- src/wmfs.c | 1 + src/wmfs.h | 1 + 6 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/event.c b/src/event.c index 3ad05c7..afb07d4 100644 --- a/src/event.c +++ b/src/event.c @@ -114,7 +114,7 @@ buttonpress(XButtonEvent *ev) { if(conf.layout_system && (ev->button == Button1 || ev->button == Button3)) /* True -> menu */ { - y = infobar[selscreen].layout_button->geo.y + INFOBARH; + y = (sgeo[selscreen].y - (BORDH + TBARH)) + infobar[selscreen].layout_button->geo.y; x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH); if(infobar[selscreen].geo.y != sgeo[selscreen].y - (INFOBARH + TBARH)) diff --git a/src/infobar.c b/src/infobar.c index 27bf598..f783959 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -50,18 +50,18 @@ infobar_init(void) switch(tags[sc][seltag[sc]].barpos) { case IB_Hide: - sgeo[sc].y = TBARH; - sgeo[selscreen].height += INFOBARH; - infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2; + sgeo[sc].y = spgeo[sc].y + TBARH; + sgeo[sc].height += INFOBARH; + infobar[sc].geo.y = -(infobar[sc].geo.height) * 2; break; case IB_Bottom: - sgeo[selscreen].y = TBARH; - infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH; + sgeo[sc].y = TBARH; + infobar[sc].geo.y = spgeo[sc].y + sgeo[sc].height + TBARH; break; default: case IB_Top: - sgeo[sc].y = INFOBARH + TBARH; - infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH); + sgeo[sc].y = spgeo[sc].y + INFOBARH + TBARH; + infobar[sc].geo.y = spgeo[sc].y; break; } @@ -191,38 +191,26 @@ infobar_destroy(void) void infobar_set_position(int pos) { - int th; - screen_get_sel(); - if(XineramaIsActive(dpy)) - { - int n = 0; - XineramaScreenInfo *xsi = XineramaQueryScreens(dpy, &n); - - th = xsi[selscreen].height; - XFree(xsi); - } - else - th = MAXH; switch(pos) { case IB_Hide: - sgeo[selscreen].y = TBARH; - sgeo[selscreen].height = th - TBARH; + sgeo[selscreen].y = spgeo[selscreen].y + TBARH; + sgeo[selscreen].height = spgeo[selscreen].height - TBARH; infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2; break; case IB_Bottom: - sgeo[selscreen].y = TBARH; - sgeo[selscreen].height = th - INFOBARH - TBARH; - infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH; + sgeo[selscreen].y = spgeo[selscreen].y + TBARH; + sgeo[selscreen].height = spgeo[selscreen].height - INFOBARH - TBARH; + infobar[selscreen].geo.y = spgeo[selscreen].y + sgeo[selscreen].height + TBARH; break; default: case IB_Top: - sgeo[selscreen].y = INFOBARH + TBARH; - sgeo[selscreen].height = th - INFOBARH - TBARH; - infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH); + sgeo[selscreen].y = spgeo[selscreen].y + INFOBARH + TBARH; + sgeo[selscreen].height = spgeo[selscreen].height - INFOBARH - TBARH; + infobar[selscreen].geo.y = spgeo[selscreen].y; break; } diff --git a/src/layout.c b/src/layout.c index ae4b09c..6c77164 100644 --- a/src/layout.c +++ b/src/layout.c @@ -397,6 +397,7 @@ multi_tile(int screen, Position type) /** Mirror layout function * \param screen Screen to execute this function + * \param horizont To specify the mirror mode (vertical/horizontal) */ void mirror(int screen, Bool horizontal) diff --git a/src/screen.c b/src/screen.c index 6711b60..e0f8421 100644 --- a/src/screen.c +++ b/src/screen.c @@ -70,6 +70,7 @@ screen_get_geo(int s) XineramaScreenInfo *xsi; xsi = XineramaQueryScreens(dpy, &n); + geo.x = xsi[s].x_org + BORDH; if(barpos == IB_Hide || barpos == IB_Bottom) geo.y = TBARH; @@ -168,13 +169,35 @@ screen_get_sel(void) void screen_init_geo(void) { - int i; + int i, n; + XineramaScreenInfo *xsi; sgeo = emalloc(screen_count(), sizeof(XRectangle)); + spgeo = emalloc(screen_count(), sizeof(XRectangle)); for(i = 0; i < screen_count(); ++i) sgeo[i] = screen_get_geo(i); + if(XineramaIsActive(dpy)) + { + xsi = XineramaQueryScreens(dpy, &n); + for(i = 0; i < n; ++i) + { + spgeo[i].x = xsi[i].x_org; + spgeo[i].y = xsi[i].y_org; + spgeo[i].width = xsi[i].width; + spgeo[i].height = xsi[i].height; + } + XFree(xsi); + } + else + { + spgeo[0].x = 0; + spgeo[0].y = 0; + spgeo[0].width = MAXW; + spgeo[0].height = MAXH; + } + ewmh_set_desktop_geometry(); ewmh_set_workarea(); diff --git a/src/wmfs.c b/src/wmfs.c index d827532..ce9c520 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -106,6 +106,7 @@ quit(void) infobar_destroy(); IFREE(sgeo); + IFREE(spgeo); IFREE(infobar); IFREE(keys); IFREE(func_list); diff --git a/src/wmfs.h b/src/wmfs.h index a5f9c64..ce26a96 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -311,6 +311,7 @@ Key *keys; Bool exiting; char statustext[1024]; XRectangle *sgeo; +XRectangle *spgeo; Cursor cursor[CurLast]; /* Fonts */