add get_display_info function to screen.c and use it for getting windows_area geom
This commit is contained in:
parent
c7735d4d1f
commit
59c870db3e
23
client.c
23
client.c
|
@ -24,6 +24,7 @@
|
|||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
|
||||
#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);
|
||||
|
|
27
screen.c
27
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue