better use of the space in smart placement
This commit is contained in:
parent
31b5b709f6
commit
c3aeedfa24
24
client.c
24
client.c
|
@ -218,11 +218,12 @@ client_focus(Client *c, int screen, Bool from_mouse)
|
||||||
* \return new geometry
|
* \return new geometry
|
||||||
*/
|
*/
|
||||||
static Area
|
static Area
|
||||||
client_get_smart_geometry(Area geometry, int screen)
|
client_get_smart_geometry(Area geometry, int border, int screen)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Area newgeometry = { 0, 0, 0, 0, NULL };
|
Area newgeometry = { 0, 0, 0, 0, NULL };
|
||||||
Area *screen_geometry, *arealist = NULL, *r;
|
Area *screen_geometry, *arealist = NULL, *r;
|
||||||
|
Bool found = False;
|
||||||
|
|
||||||
screen_geometry = p_new(Area, 1);
|
screen_geometry = p_new(Area, 1);
|
||||||
|
|
||||||
|
@ -249,14 +250,31 @@ client_get_smart_geometry(Area geometry, int screen)
|
||||||
for(r = arealist; r; r = r->next)
|
for(r = arealist; r; r = r->next)
|
||||||
if(r->width >= geometry.width && r->height >= geometry.height
|
if(r->width >= geometry.width && r->height >= geometry.height
|
||||||
&& r->width * r->height > newgeometry.width * newgeometry.height)
|
&& r->width * r->height > newgeometry.width * newgeometry.height)
|
||||||
|
{
|
||||||
|
found = True;
|
||||||
newgeometry = *r;
|
newgeometry = *r;
|
||||||
|
}
|
||||||
|
|
||||||
area_list_wipe(&arealist);
|
/* we did not found a space with enough space for our size:
|
||||||
|
* just take the biggest available and go in */
|
||||||
|
if(!found)
|
||||||
|
for(r = arealist; r; r = r->next)
|
||||||
|
if(r->width * r->height > newgeometry.width * newgeometry.height)
|
||||||
|
newgeometry = *r;
|
||||||
|
|
||||||
/* restore height and width */
|
/* restore height and width */
|
||||||
newgeometry.width = geometry.width;
|
newgeometry.width = geometry.width;
|
||||||
newgeometry.height = geometry.height;
|
newgeometry.height = geometry.height;
|
||||||
|
|
||||||
|
/* fix offscreen */
|
||||||
|
if(AREA_RIGHT(newgeometry) > AREA_RIGHT(*screen_geometry))
|
||||||
|
newgeometry.x = screen_geometry->x + screen_geometry->width - newgeometry.width - 2 * border;
|
||||||
|
|
||||||
|
if(AREA_BOTTOM(newgeometry) > AREA_BOTTOM(*screen_geometry))
|
||||||
|
newgeometry.y = screen_geometry->y + screen_geometry->height - newgeometry.height - 2 * border;
|
||||||
|
|
||||||
|
area_list_wipe(&arealist);
|
||||||
|
|
||||||
return newgeometry;
|
return newgeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +373,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
client_setfloating(c, rettrans || c->isfixed);
|
client_setfloating(c, rettrans || c->isfixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->f_geometry = client_get_smart_geometry(c->f_geometry, c->screen);
|
c->f_geometry = client_get_smart_geometry(c->f_geometry, c->border, c->screen);
|
||||||
|
|
||||||
XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue