titlebar: remove/add now handle border
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f0fe2e03c6
commit
b2bb33b9d8
6
mouse.c
6
mouse.c
|
@ -140,8 +140,6 @@ mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
&globalconf.screens[c->screen].padding);
|
&globalconf.screens[c->screen].padding);
|
||||||
|
|
||||||
geometry = titlebar_geometry_add(c->titlebar, c->border, geometry);
|
geometry = titlebar_geometry_add(c->titlebar, c->border, geometry);
|
||||||
geometry.width += 2 * c->border;
|
|
||||||
geometry.height += 2 * c->border;
|
|
||||||
|
|
||||||
geometry =
|
geometry =
|
||||||
mouse_snapclienttogeometry_inside(geometry, screen_geometry, snap);
|
mouse_snapclienttogeometry_inside(geometry, screen_geometry, snap);
|
||||||
|
@ -153,8 +151,6 @@ mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
if(snapper != c && client_isvisible(snapper, c->screen))
|
if(snapper != c && client_isvisible(snapper, c->screen))
|
||||||
{
|
{
|
||||||
snapper_geometry = snapper->geometry;
|
snapper_geometry = snapper->geometry;
|
||||||
snapper_geometry.width += 2 * snapper->border;
|
|
||||||
snapper_geometry.height += 2 * snapper->border;
|
|
||||||
snapper_geometry = titlebar_geometry_add(snapper->titlebar, snapper->border, snapper_geometry);
|
snapper_geometry = titlebar_geometry_add(snapper->titlebar, snapper->border, snapper_geometry);
|
||||||
geometry =
|
geometry =
|
||||||
mouse_snapclienttogeometry_outside(geometry,
|
mouse_snapclienttogeometry_outside(geometry,
|
||||||
|
@ -162,8 +158,6 @@ mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
snap);
|
snap);
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry.width -= 2 * c->border;
|
|
||||||
geometry.height -= 2 * c->border;
|
|
||||||
return titlebar_geometry_remove(c->titlebar, c->border, geometry);
|
return titlebar_geometry_remove(c->titlebar, c->border, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
placement.c
12
placement.c
|
@ -35,7 +35,7 @@ const name_func_link_t FloatingPlacementList[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
static area_t
|
static area_t
|
||||||
placement_fix_offscreen(area_t geometry, int screen, int border)
|
placement_fix_offscreen(area_t geometry, int screen)
|
||||||
{
|
{
|
||||||
area_t screen_geometry;
|
area_t screen_geometry;
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ placement_fix_offscreen(area_t geometry, int screen, int border)
|
||||||
|
|
||||||
/* fix offscreen */
|
/* fix offscreen */
|
||||||
if(AREA_RIGHT(geometry) > AREA_RIGHT(screen_geometry))
|
if(AREA_RIGHT(geometry) > AREA_RIGHT(screen_geometry))
|
||||||
geometry.x = screen_geometry.x + screen_geometry.width - (geometry.width + 2 * border);
|
geometry.x = screen_geometry.x + screen_geometry.width - geometry.width;
|
||||||
else if(AREA_LEFT(geometry) < AREA_LEFT(screen_geometry))
|
else if(AREA_LEFT(geometry) < AREA_LEFT(screen_geometry))
|
||||||
geometry.x = screen_geometry.x;
|
geometry.x = screen_geometry.x;
|
||||||
|
|
||||||
if(AREA_BOTTOM(geometry) > AREA_BOTTOM(screen_geometry))
|
if(AREA_BOTTOM(geometry) > AREA_BOTTOM(screen_geometry))
|
||||||
geometry.y = screen_geometry.y + screen_geometry.height - (geometry.height + 2 * border);
|
geometry.y = screen_geometry.y + screen_geometry.height - geometry.height;
|
||||||
else if(AREA_TOP(geometry) < AREA_TOP(screen_geometry))
|
else if(AREA_TOP(geometry) < AREA_TOP(screen_geometry))
|
||||||
geometry.y = screen_geometry.y;
|
geometry.y = screen_geometry.y;
|
||||||
|
|
||||||
|
@ -85,8 +85,6 @@ placement_smart(client_t *c)
|
||||||
&& client_isvisible(client, c->screen))
|
&& client_isvisible(client, c->screen))
|
||||||
{
|
{
|
||||||
newgeometry = client->f_geometry;
|
newgeometry = client->f_geometry;
|
||||||
newgeometry.width += 2 * client->border;
|
|
||||||
newgeometry.height += 2 * client->border;
|
|
||||||
newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry);
|
newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry);
|
||||||
area_array_remove(&areas, newgeometry);
|
area_array_remove(&areas, newgeometry);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +121,7 @@ placement_smart(client_t *c)
|
||||||
newgeometry.height = c->f_geometry.height;
|
newgeometry.height = c->f_geometry.height;
|
||||||
|
|
||||||
newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry);
|
newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry);
|
||||||
newgeometry = placement_fix_offscreen(newgeometry, c->screen, c->border);
|
newgeometry = placement_fix_offscreen(newgeometry, c->screen);
|
||||||
newgeometry = titlebar_geometry_remove(c->titlebar, c->border, newgeometry);
|
newgeometry = titlebar_geometry_remove(c->titlebar, c->border, newgeometry);
|
||||||
|
|
||||||
area_array_wipe(&areas);
|
area_array_wipe(&areas);
|
||||||
|
@ -153,7 +151,7 @@ placement_under_mouse(client_t *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
finalgeometry = titlebar_geometry_add(c->titlebar, c->border, finalgeometry);
|
finalgeometry = titlebar_geometry_add(c->titlebar, c->border, finalgeometry);
|
||||||
finalgeometry = placement_fix_offscreen(finalgeometry, c->screen, c->border);
|
finalgeometry = placement_fix_offscreen(finalgeometry, c->screen);
|
||||||
finalgeometry = titlebar_geometry_remove(c->titlebar, c->border, finalgeometry);
|
finalgeometry = titlebar_geometry_remove(c->titlebar, c->border, finalgeometry);
|
||||||
|
|
||||||
return finalgeometry;
|
return finalgeometry;
|
||||||
|
|
22
titlebar.h
22
titlebar.h
|
@ -33,7 +33,7 @@ void titlebar_refresh(void);
|
||||||
|
|
||||||
int luaA_titlebar_userdata_new(lua_State *, titlebar_t *);
|
int luaA_titlebar_userdata_new(lua_State *, titlebar_t *);
|
||||||
|
|
||||||
/** Add the titlebar geometry to a geometry.
|
/** Add the titlebar geometry and border to a geometry.
|
||||||
* \param t The titlebar
|
* \param t The titlebar
|
||||||
* \param border The client border size.
|
* \param border The client border size.
|
||||||
* \param geometry The geometry
|
* \param geometry The geometry
|
||||||
|
@ -48,25 +48,34 @@ titlebar_geometry_add(titlebar_t *t, int border, area_t geometry)
|
||||||
case Top:
|
case Top:
|
||||||
geometry.y -= t->sw->geometry.height + 2 * t->border.width - border;
|
geometry.y -= t->sw->geometry.height + 2 * t->border.width - border;
|
||||||
geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
|
geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
|
||||||
|
geometry.width += 2 * border;
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
|
geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
|
||||||
|
geometry.width += 2 * border;
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
geometry.x -= t->sw->geometry.width + 2 * t->border.width - border;
|
geometry.x -= t->sw->geometry.width + 2 * t->border.width - border;
|
||||||
geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
|
geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
|
||||||
|
geometry.height += 2 * border;
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
|
geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
|
||||||
|
geometry.height += 2 * border;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
geometry.width += 2 * border;
|
||||||
|
geometry.height += 2 * border;
|
||||||
|
}
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove the titlebar geometry to a geometry.
|
/** Remove the titlebar geometry and border width to a geometry.
|
||||||
* \param t The titlebar.
|
* \param t The titlebar.
|
||||||
* \param border The client border size.
|
* \param border The client border size.
|
||||||
* \param geometry The geometry.
|
* \param geometry The geometry.
|
||||||
|
@ -81,20 +90,29 @@ titlebar_geometry_remove(titlebar_t *t, int border, area_t geometry)
|
||||||
case Top:
|
case Top:
|
||||||
geometry.y += t->sw->geometry.height + 2 * t->border.width - border;
|
geometry.y += t->sw->geometry.height + 2 * t->border.width - border;
|
||||||
geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
|
geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
|
||||||
|
geometry.width -= 2 * border;
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
|
geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
|
||||||
|
geometry.width -= 2 * border;
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
geometry.x += t->sw->geometry.width + 2 * t->border.width - border;
|
geometry.x += t->sw->geometry.width + 2 * t->border.width - border;
|
||||||
geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
|
geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
|
||||||
|
geometry.height -= 2 * border;
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
|
geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
|
||||||
|
geometry.height -= 2 * border;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
geometry.width -= 2 * border;
|
||||||
|
geometry.height -= 2 * border;
|
||||||
|
}
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue