diff --git a/client.c b/client.c index 24a6ad77..839bc2b8 100644 --- a/client.c +++ b/client.c @@ -24,6 +24,7 @@ #include #include +#include "screen.h" #include "awesome.h" #include "layout.h" #include "tag.h" @@ -371,20 +372,18 @@ manage(Display * disp, DC *drawcontext, Window w, XWindowAttributes * wa, awesom } else { - int wax = get_windows_area_x(awesomeconf->statusbar); - int way = get_windows_area_y(awesomeconf->statusbar); - int waw = get_windows_area_width(disp, awesomeconf->statusbar); - int wah = get_windows_area_height(disp, awesomeconf->statusbar); + ScreenInfo *si = get_display_info(disp, awesomeconf->statusbar); - if(c->x + c->w + 2 * c->border > wax + waw) - c->x = c->rx = wax + waw - c->w - 2 * c->border; - if(c->y + c->h + 2 * c->border > way + wah) - c->y = c->ry = way + wah - c->h - 2 * c->border; - if(c->x < wax) - c->x = c->rx = wax; - if(c->y < way) - c->y = c->ry = way; + if(c->x + c->w + 2 * c->border > si->x_org + si->width) + c->x = c->rx = si->x_org + si->width - c->w - 2 * c->border; + if(c->y + c->h + 2 * c->border > si->y_org + si->height) + c->y = c->ry = si->y_org + si->height - c->h - 2 * c->border; + if(c->x < si->x_org) + c->x = c->rx = si->x_org; + if(c->y < si->y_org) + c->y = c->ry = si->y_org; c->border = awesomeconf->borderpx; + XFree(si); } wc.border_width = c->border; XConfigureWindow(disp, w, CWBorderWidth, &wc); diff --git a/screen.c b/screen.c index 6d9a6edd..6ce39d82 100644 --- a/screen.c +++ b/screen.c @@ -22,6 +22,12 @@ #include "util.h" #include "screen.h" +/** Get screens info + * \param disp Display ref + * \param statusbar statusbar + * \param screen_number int pointer filled with number of screens + * \return ScreenInfo struct array with all screens info + */ ScreenInfo * get_screen_info(Display *disp, Statusbar statusbar, int *screen_number) { @@ -52,3 +58,24 @@ get_screen_info(Display *disp, Statusbar statusbar, int *screen_number) return si; } + +/** Get display info + * \param disp Display ref + * \param statusbar statusbar + * \return ScreenInfo struct pointer with all display info + */ +ScreenInfo * +get_display_info(Display *disp, Statusbar statusbar) +{ + ScreenInfo *si; + + si = p_new(ScreenInfo, 1); + + si->x_org = 0; + si->y_org = statusbar.position == BarTop ? statusbar.height : 0; + si->width = DisplayWidth(disp, DefaultScreen(disp)); + si->height = DisplayHeight(disp, DefaultScreen(disp)) - + ((statusbar.position == BarTop || statusbar.position == BarBot) ? statusbar.height : 0); + + return si; +} diff --git a/screen.h b/screen.h index 1161abd7..5b1da930 100644 --- a/screen.h +++ b/screen.h @@ -30,5 +30,6 @@ typedef XineramaScreenInfo ScreenInfo; ScreenInfo * get_screen_info(Display *, Statusbar, int *); +ScreenInfo * get_display_info(Display *disp, Statusbar statusbar); #endif