placement: fix smart
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
3513e43f0f
commit
236ccc165c
|
@ -19,9 +19,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* asprintf */
|
|
||||||
#define _GNU_SOURCE
|
|
||||||
|
|
||||||
#include <cairo-xcb.h>
|
#include <cairo-xcb.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1179,7 +1176,7 @@ area_array_remove(area_array_t *areas, area_t elem)
|
||||||
{
|
{
|
||||||
.x = r.x,
|
.x = r.x,
|
||||||
.y = r.y,
|
.y = r.y,
|
||||||
.width = AREA_LEFT(inter) - r.x,
|
.width = AREA_LEFT(inter) - AREA_LEFT(r),
|
||||||
.height = r.height,
|
.height = r.height,
|
||||||
};
|
};
|
||||||
area_array_append(areas, extra);
|
area_array_append(areas, extra);
|
||||||
|
@ -1192,7 +1189,7 @@ area_array_remove(area_array_t *areas, area_t elem)
|
||||||
.x = r.x,
|
.x = r.x,
|
||||||
.y = r.y,
|
.y = r.y,
|
||||||
.width = r.width,
|
.width = r.width,
|
||||||
.height = AREA_TOP(inter) - r.y,
|
.height = AREA_TOP(inter) - AREA_LEFT(r),
|
||||||
};
|
};
|
||||||
area_array_append(areas, extra);
|
area_array_append(areas, extra);
|
||||||
}
|
}
|
||||||
|
|
13
placement.c
13
placement.c
|
@ -73,6 +73,7 @@ placement_smart(client_t *c)
|
||||||
area_array_t areas;
|
area_array_t areas;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
layout_t *layout;
|
layout_t *layout;
|
||||||
|
int i;
|
||||||
|
|
||||||
area_array_init(&areas);
|
area_array_init(&areas);
|
||||||
screen_geometry = screen_area_get(c->screen,
|
screen_geometry = screen_area_get(c->screen,
|
||||||
|
@ -83,7 +84,7 @@ placement_smart(client_t *c)
|
||||||
area_array_append(&areas, screen_geometry);
|
area_array_append(&areas, screen_geometry);
|
||||||
|
|
||||||
for(client = globalconf.clients; client; client = client->next)
|
for(client = globalconf.clients; client; client = client->next)
|
||||||
if((client->isfloating || layout == layout_floating)
|
if(client != c && (client->isfloating || layout == layout_floating)
|
||||||
&& client_isvisible(client, c->screen))
|
&& client_isvisible(client, c->screen))
|
||||||
{
|
{
|
||||||
newgeometry = client->f_geometry;
|
newgeometry = client->f_geometry;
|
||||||
|
@ -98,7 +99,7 @@ placement_smart(client_t *c)
|
||||||
newgeometry.width = 0;
|
newgeometry.width = 0;
|
||||||
newgeometry.height = 0;
|
newgeometry.height = 0;
|
||||||
|
|
||||||
for(int i = 0; i < areas.len; i++)
|
for(i = areas.len - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
area_t *r = &areas.tab[i];
|
area_t *r = &areas.tab[i];
|
||||||
|
|
||||||
|
@ -113,14 +114,12 @@ placement_smart(client_t *c)
|
||||||
/* we did not found a space with enough space for our size:
|
/* we did not found a space with enough space for our size:
|
||||||
* just take the biggest available and go in */
|
* just take the biggest available and go in */
|
||||||
if(!found)
|
if(!found)
|
||||||
{
|
for(i = 0; i < areas.len; i++)
|
||||||
for(int i = 0; i < areas.len; i++)
|
|
||||||
{
|
{
|
||||||
area_t *r = &areas.tab[i];
|
area_t *r = &areas.tab[i];
|
||||||
if(r->width * r->height > newgeometry.width * newgeometry.height)
|
if(r->width * r->height > newgeometry.width * newgeometry.height)
|
||||||
newgeometry = *r;
|
newgeometry = *r;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* restore height and width */
|
/* restore height and width */
|
||||||
newgeometry.width = c->f_geometry.width;
|
newgeometry.width = c->f_geometry.width;
|
||||||
|
@ -134,6 +133,10 @@ placement_smart(client_t *c)
|
||||||
return newgeometry;
|
return newgeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Compute placement for a window centered under the mouse.
|
||||||
|
* \param c The client.
|
||||||
|
* \return The proposed geometry.
|
||||||
|
*/
|
||||||
area_t
|
area_t
|
||||||
placement_under_mouse(client_t *c)
|
placement_under_mouse(client_t *c)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue