mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
client, mouse: improve struts a bit
- struts are now additive - allow multiple docks at the edge of the screen, trigger is approaching workarea from inside Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
bf0329d8a3
commit
47efde17f5
2 changed files with 27 additions and 25 deletions
|
@ -72,14 +72,14 @@ end
|
||||||
local function snap_inside(g, sg, snap)
|
local function snap_inside(g, sg, snap)
|
||||||
local edgev = 'none'
|
local edgev = 'none'
|
||||||
local edgeh = 'none'
|
local edgeh = 'none'
|
||||||
if math.abs(g.x) < snap + sg.x and g.x > sg.x then
|
if math.abs(g.x) < snap + sg.x and g.x >= sg.x then
|
||||||
edgev = 'left'
|
edgev = 'left'
|
||||||
g.x = sg.x
|
g.x = sg.x
|
||||||
elseif math.abs((sg.x + sg.width) - (g.x + g.width)) < snap then
|
elseif math.abs((sg.x + sg.width) - (g.x + g.width)) < snap then
|
||||||
edgev = 'right'
|
edgev = 'right'
|
||||||
g.x = sg.x + sg.width - g.width
|
g.x = sg.x + sg.width - g.width
|
||||||
end
|
end
|
||||||
if math.abs(g.y) < snap + sg.y and g.y > sg.y then
|
if math.abs(g.y) < snap + sg.y and g.y >= sg.y then
|
||||||
edgeh = 'top'
|
edgeh = 'top'
|
||||||
g.y = sg.y
|
g.y = sg.y
|
||||||
elseif math.abs((sg.y + sg.height) - (g.y + g.height)) < snap then
|
elseif math.abs((sg.y + sg.height) - (g.y + g.height)) < snap then
|
||||||
|
@ -115,18 +115,19 @@ function client.snap(c, snap, x, y, fixed_x, fixed_y)
|
||||||
geom, edge = snap_inside(geom, capi.screen[c.screen].geometry, snap)
|
geom, edge = snap_inside(geom, capi.screen[c.screen].geometry, snap)
|
||||||
geom, edge2 = snap_inside(geom, capi.screen[c.screen].workarea, snap)
|
geom, edge2 = snap_inside(geom, capi.screen[c.screen].workarea, snap)
|
||||||
|
|
||||||
-- Allow certain windows to snap to the edge of the screen.
|
-- Allow certain windows to snap to the edge of the workarea.
|
||||||
|
-- Only allow docking to workarea for consistency/to avoid problems.
|
||||||
if c.type == "utility" or c.type == "toolbar" or c.type == "dock" then
|
if c.type == "utility" or c.type == "toolbar" or c.type == "dock" then
|
||||||
local struts = c:struts()
|
local struts = c:struts()
|
||||||
struts['left'] = 0
|
struts['left'] = 0
|
||||||
struts['right'] = 0
|
struts['right'] = 0
|
||||||
struts['top'] = 0
|
struts['top'] = 0
|
||||||
struts['bottom'] = 0
|
struts['bottom'] = 0
|
||||||
if edge ~= "none" and aclient.floating.get(c) then
|
if edge2 ~= "none" and aclient.floating.get(c) then
|
||||||
if edge == "left" or edge == "right" then
|
if edge2 == "left" or edge2 == "right" then
|
||||||
struts[edge] = cur_geom.width
|
struts[edge2] = cur_geom.width
|
||||||
elseif edge == "top" or edge == "bottom" then
|
elseif edge2 == "top" or edge2 == "bottom" then
|
||||||
struts[edge] = cur_geom.height
|
struts[edge2] = cur_geom.height
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
c:struts(struts)
|
c:struts(struts)
|
||||||
|
|
35
screen.c
35
screen.c
|
@ -176,6 +176,7 @@ screen_area_get(int screen, wibox_array_t *wiboxes,
|
||||||
area.height -= padding->top + padding->bottom;
|
area.height -= padding->top + padding->bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* struts are additive, to allow for multiple clients at the screen edge. */
|
||||||
if(strut)
|
if(strut)
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c;
|
||||||
|
@ -184,36 +185,36 @@ screen_area_get(int screen, wibox_array_t *wiboxes,
|
||||||
{
|
{
|
||||||
if(c->strut.top_start_x || c->strut.top_end_x)
|
if(c->strut.top_start_x || c->strut.top_end_x)
|
||||||
{
|
{
|
||||||
if(c->strut.top)
|
if (c->strut.top)
|
||||||
top = MAX(top, c->strut.top);
|
top += c->strut.top;
|
||||||
else
|
else
|
||||||
top = MAX(top, (c->geometry.y - area.y) + c->geometry.height);
|
top += c->geometry.height;
|
||||||
}
|
}
|
||||||
if(c->strut.bottom_start_x || c->strut.bottom_end_x)
|
if(c->strut.bottom_start_x || c->strut.bottom_end_x)
|
||||||
{
|
{
|
||||||
if(c->strut.bottom)
|
if (c->strut.bottom)
|
||||||
bottom = MAX(bottom, c->strut.bottom);
|
bottom += c->strut.bottom;
|
||||||
else
|
else
|
||||||
bottom = MAX(bottom, (area.y + area.height) - c->geometry.y);
|
bottom += c->geometry.height;
|
||||||
}
|
}
|
||||||
if(c->strut.left_start_y || c->strut.left_end_y)
|
if(c->strut.left_start_y || c->strut.left_end_y)
|
||||||
{
|
{
|
||||||
if(c->strut.left)
|
if (c->strut.left)
|
||||||
left = MAX(left, c->strut.left);
|
left += c->strut.left;
|
||||||
else
|
else
|
||||||
left = MAX(left, (c->geometry.x - area.x) + c->geometry.width);
|
left += c->geometry.width;
|
||||||
}
|
}
|
||||||
if(c->strut.right_start_y || c->strut.right_end_y)
|
if(c->strut.right_start_y || c->strut.right_end_y)
|
||||||
{
|
{
|
||||||
if(c->strut.right)
|
if (c->strut.right)
|
||||||
right = MAX(right, c->strut.right);
|
right += c->strut.right;
|
||||||
else
|
else
|
||||||
right = MAX(right, (area.x + area.width) - c->geometry.x);
|
right += c->geometry.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* swindow geometry includes borders. */
|
||||||
if(wiboxes)
|
if(wiboxes)
|
||||||
for(int i = 0; i < wiboxes->len; i++)
|
for(int i = 0; i < wiboxes->len; i++)
|
||||||
{
|
{
|
||||||
|
@ -222,16 +223,16 @@ screen_area_get(int screen, wibox_array_t *wiboxes,
|
||||||
switch(w->position)
|
switch(w->position)
|
||||||
{
|
{
|
||||||
case Top:
|
case Top:
|
||||||
top = MAX(top, (uint16_t) (w->sw.geometry.y - area.y) + w->sw.geometry.height + 2 * w->sw.border.width);
|
top += w->sw.geometry.height;
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
bottom = MAX(bottom, (uint16_t) (area.y + area.height) - w->sw.geometry.y);
|
bottom += w->sw.geometry.height;
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
left = MAX(left, (uint16_t) (w->sw.geometry.x - area.x) + w->sw.geometry.width + 2 * w->sw.border.width);
|
left += w->sw.geometry.width;
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
right = MAX(right, (uint16_t) (area.x + area.width) - w->sw.geometry.x);
|
right += w->sw.geometry.width;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue