awful.wibox: update strut on wibox attachement
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
a7a1ead538
commit
d6fd7f1116
|
@ -11,7 +11,6 @@ local capi = { screen = screen, client = client }
|
|||
local tag = require("awful.tag")
|
||||
local util = require("awful.util")
|
||||
local suit = require("awful.layout.suit")
|
||||
local wibox = require("awful.wibox")
|
||||
local ascreen = require("awful.screen")
|
||||
local capi = {
|
||||
screen = screen,
|
||||
|
@ -64,7 +63,7 @@ end
|
|||
-- @param screen The screen to arrange.
|
||||
function arrange(screen)
|
||||
local p = {}
|
||||
p.workarea = wibox.get_workarea(screen)
|
||||
p.workarea = capi.screen[screen].workarea
|
||||
-- Handle padding
|
||||
local padding = ascreen.padding(screen)
|
||||
if padding then
|
||||
|
|
|
@ -25,7 +25,6 @@ local util = require("awful.util")
|
|||
local tags = require("awful.tag")
|
||||
local layout = require("awful.widget.layout")
|
||||
local awbeautiful = require("beautiful")
|
||||
local awibox = require("awful.wibox")
|
||||
local tonumber = tonumber
|
||||
|
||||
--- Menu module for awful
|
||||
|
@ -257,7 +256,7 @@ function clients(menu)
|
|||
end
|
||||
|
||||
local function set_coords(menu, screen_idx)
|
||||
local s_geometry = awibox.get_workarea(screen_idx)
|
||||
local s_geometry = capi.screen[screen_idx].workarea
|
||||
local screen_w = s_geometry.x + s_geometry.width
|
||||
local screen_h = s_geometry.y + s_geometry.height
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ function client.snap(c, snap, x, y, fixed_x, fixed_y)
|
|||
geom.y = y or geom.y
|
||||
|
||||
geom, edge = snap_inside(geom, capi.screen[c.screen].geometry, snap)
|
||||
geom = snap_inside(geom, awibox.get_workarea(c.screen), snap)
|
||||
geom = snap_inside(geom, capi.screen[c.screen].workarea, snap)
|
||||
|
||||
-- Allow certain windows to snap to the edge of the workarea.
|
||||
-- Only allow docking to workarea for consistency/to avoid problems.
|
||||
|
@ -240,7 +240,7 @@ function client.dragtotag.border(c)
|
|||
for _, v in ipairs(mouse.buttons) do
|
||||
if v then button_down = true end
|
||||
end
|
||||
local wa = awibox.get_workarea(c.screen)
|
||||
local wa = capi.screen[c.screen].workarea
|
||||
if mouse.x >= wa.x + wa.width then
|
||||
capi.mouse.coords({ x = wa.x + wa.width - 1 })
|
||||
elseif mouse.x <= wa.x then
|
||||
|
@ -287,7 +287,7 @@ function wibox.move(w)
|
|||
w.x = capi.mouse.coords().x + offset.x
|
||||
w.y = capi.mouse.coords().y + offset.y
|
||||
else
|
||||
local wa = awibox.get_workarea(capi.mouse.screen)
|
||||
local wa = capi.screen[capi.mouse.screen].workarea
|
||||
|
||||
if capi.mouse.coords()["y"] > wa.y + wa.height - 10 then
|
||||
awibox.set_position(w, "bottom", w.screen)
|
||||
|
@ -360,7 +360,7 @@ local function client_resize_magnifier(c, corner)
|
|||
local corner, x, y = client.corner(c, corner)
|
||||
capi.mouse.coords({ x = x, y = y })
|
||||
|
||||
local wa = awibox.get_workarea(c.screen)
|
||||
local wa = capi.screen[c.screen].workarea
|
||||
local center_x = wa.x + wa.width / 2
|
||||
local center_y = wa.y + wa.height / 2
|
||||
local maxdist_pow = (wa.width^2 + wa.height^2) / 4
|
||||
|
@ -383,7 +383,7 @@ local function client_resize_magnifier(c, corner)
|
|||
end
|
||||
|
||||
local function client_resize_tiled(c, lay)
|
||||
local wa = awibox.get_workarea(c.screen)
|
||||
local wa = capi.screen[c.screen].workarea
|
||||
local mwfact = tag.getmwfact()
|
||||
local cursor
|
||||
local g = c:geometry()
|
||||
|
|
|
@ -17,7 +17,6 @@ local capi =
|
|||
}
|
||||
local client = require("awful.client")
|
||||
local layout = require("awful.layout")
|
||||
local wibox = require("awful.wibox")
|
||||
|
||||
--- Placement module for awful
|
||||
module("awful.placement")
|
||||
|
@ -106,7 +105,7 @@ end
|
|||
function no_offscreen(c)
|
||||
local c = c or capi.client.focus
|
||||
local geometry = c:geometry()
|
||||
local screen_geometry = wibox.get_workarea(c.screen)
|
||||
local screen_geometry = capi.screen[c.screen].workarea
|
||||
|
||||
if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then
|
||||
geometry.x = screen_geometry.x + screen_geometry.width - geometry.width
|
||||
|
@ -128,7 +127,7 @@ end
|
|||
function no_overlap(c)
|
||||
local cls = client.visible(c.screen)
|
||||
local curlay = layout.get()
|
||||
local areas = { wibox.get_workarea(c.screen) }
|
||||
local areas = { capi.screen[c.screen].workarea }
|
||||
local geometry = c:geometry()
|
||||
for i, cl in pairs(cls) do
|
||||
if cl ~= c and (client.floating.get(cl) or curlay == layout.suit.floating) then
|
||||
|
|
|
@ -25,60 +25,6 @@ module("awful.wibox")
|
|||
-- It's an array so it is ordered.
|
||||
local wiboxes = {}
|
||||
|
||||
--- Get the workarea space without wiboxes geometry.
|
||||
-- @param s The screen number.
|
||||
-- @return The screen workarea.
|
||||
function get_workarea(s)
|
||||
local area = capi.screen[s].workarea
|
||||
for _, wprop in ipairs(wiboxes) do
|
||||
if wprop.wibox.visible and wprop.wibox.screen == s then
|
||||
if wprop.position == "top" then
|
||||
area.y = area.y + wprop.wibox.height + (2 * wprop.wibox.border_width)
|
||||
area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
elseif wprop.position == "bottom" then
|
||||
area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
elseif wprop.position == "left" then
|
||||
area.x = area.x + wprop.wibox.width + (2 * wprop.wibox.border_width)
|
||||
area.width = area.width - (wprop.wibox.width + (2 * wprop.wibox.border_width))
|
||||
elseif wprop.position == "right" then
|
||||
area.width = area.width - (wprop.wibox.width + (2 * wprop.wibox.border_width))
|
||||
end
|
||||
end
|
||||
end
|
||||
return area
|
||||
end
|
||||
|
||||
local function compute_area(wibox, position, s)
|
||||
local s = wibox.screen or s or 1
|
||||
local area = capi.screen[s].workarea
|
||||
local ignore = false
|
||||
for _, wprop in ipairs(wiboxes) do
|
||||
if wprop.wibox == wibox then
|
||||
ignore = true
|
||||
elseif wprop.wibox.visible and wprop.wibox.screen == s
|
||||
and not (ignore and wprop.position == position) then
|
||||
if (wprop.position == "right" or wprop.position == "left")
|
||||
and wprop.position == position then
|
||||
area.x = area.x + (wibox.width + (2 * wibox.border_width))
|
||||
elseif wprop.position == "top" then
|
||||
if position == "top" then
|
||||
area.y = area.y + (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
elseif position == "left" or position == "right" then
|
||||
area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
area.y = area.y + (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
end
|
||||
elseif wprop.position == "bottom" then
|
||||
if position == "bottom" then
|
||||
area.y = area.y - (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
elseif position == "left" or position == "right" then
|
||||
area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return area
|
||||
end
|
||||
|
||||
--- Get a wibox position if it has been set, or return top.
|
||||
-- @param wibox The wibox
|
||||
-- @return The wibox position.
|
||||
|
@ -91,13 +37,14 @@ function get_position(wibox)
|
|||
return "top"
|
||||
end
|
||||
|
||||
--- Attach a wibox to a screen at the position.
|
||||
--- Put a wibox on a screen at this position.
|
||||
-- @param wibox The wibox to attach.
|
||||
-- @param position The position: top, bottom left or right.
|
||||
-- @param screen If the wibox it not attached to a screen, specified on which
|
||||
-- screen the position should be set.
|
||||
function set_position(wibox, position, screen)
|
||||
local area = compute_area(wibox, position, screen)
|
||||
local screen = screen or wibox.screen or 1
|
||||
local area = capi.screen[screen].geometry
|
||||
|
||||
-- The "length" of a wibox is always chosen to be the optimal size
|
||||
-- (non-floating).
|
||||
|
@ -170,13 +117,8 @@ function attach(wibox, position)
|
|||
end
|
||||
end
|
||||
|
||||
if position ~= "top" and position ~= "bottom" and position ~= "right" and position ~= "left" then
|
||||
position = "floating"
|
||||
end
|
||||
|
||||
if not wibox_prop_table then
|
||||
table.insert(wiboxes,
|
||||
setmetatable({ wibox = wibox, position = position }, { __mode = 'v' }))
|
||||
table.insert(wiboxes, setmetatable({ wibox = wibox, position = position }, { __mode = 'v' }))
|
||||
else
|
||||
wibox_prop_table.position = position
|
||||
end
|
||||
|
@ -184,10 +126,6 @@ function attach(wibox, position)
|
|||
wibox:add_signal("property::width", wibox_update_strut)
|
||||
wibox:add_signal("property::height", wibox_update_strut)
|
||||
|
||||
if wibox.screen and wibox.visible then
|
||||
update_all_wiboxes_position()
|
||||
end
|
||||
|
||||
wibox:add_signal("property::screen", call_wibox_position_hook_on_prop_update)
|
||||
wibox:add_signal("property::visible", call_wibox_position_hook_on_prop_update)
|
||||
wibox:add_signal("property::border_width", call_wibox_position_hook_on_prop_update)
|
||||
|
@ -200,7 +138,8 @@ end
|
|||
-- screen where to align. Otherwise 1 is assumed.
|
||||
function align(wibox, align, screen)
|
||||
local position = get_position(wibox)
|
||||
local area = compute_area(wibox, position, screen)
|
||||
local screen = screen or wibox.screen or 1
|
||||
local area = capi.screen[screen].geometry
|
||||
|
||||
if position == "right" then
|
||||
if align == "right" then
|
||||
|
@ -239,15 +178,19 @@ end
|
|||
|
||||
--- Stretch a wibox so it takes all screen width or height.
|
||||
-- @param wibox The wibox.
|
||||
function stretch(wibox)
|
||||
local position = get_position(wibox)
|
||||
local area = compute_area(wibox, position)
|
||||
if position == "right" or position == "left" then
|
||||
wibox.height = area.height - (2 * wibox.border_width)
|
||||
align(wibox, "center")
|
||||
else
|
||||
wibox.width = area.width - (2 * wibox.border_width)
|
||||
align(wibox, "left")
|
||||
-- @param screen The screen to stretch on, or the wibox screen.
|
||||
function stretch(wibox, screen)
|
||||
local screen = screen or wibox.screen
|
||||
if screen then
|
||||
local position = get_position(wibox)
|
||||
local area = capi.screen[screen].workarea
|
||||
if position == "right" or position == "left" then
|
||||
wibox.height = area.height - (2 * wibox.border_width)
|
||||
align(wibox, "center")
|
||||
else
|
||||
wibox.width = area.width - (2 * wibox.border_width)
|
||||
align(wibox, "left")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -274,7 +217,7 @@ function new(arg)
|
|||
if arg.screen then
|
||||
local hp = arg.height:match("(%d+)%%")
|
||||
if hp then
|
||||
arg.height = capi.screen[arg.screen].workarea.height * hp / 100
|
||||
arg.height = capi.screen[arg.screen].geometry.height * hp / 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -285,7 +228,7 @@ function new(arg)
|
|||
if arg.screen then
|
||||
local wp = arg.width:match("(%d+)%%")
|
||||
if wp then
|
||||
arg.width = capi.screen[arg.screen].workarea.width * wp / 100
|
||||
arg.width = capi.screen[arg.screen].geometry.width * wp / 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,6 @@ local capi = { screen = screen,
|
|||
timer = timer }
|
||||
local button = require("awful.button")
|
||||
local util = require("awful.util")
|
||||
local wibox = require("awful.wibox")
|
||||
local bt = require("beautiful")
|
||||
local layout = require("awful.widget.layout")
|
||||
|
||||
|
@ -120,7 +119,7 @@ end
|
|||
-- @param width Popup width (optional)
|
||||
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
|
||||
local function get_offset(screen, position, idx, width, height)
|
||||
local ws = wibox.get_workarea(screen)
|
||||
local ws = capi.screen[screen].workarea
|
||||
local v = {}
|
||||
local idx = idx or #notifications[screen][position] + 1
|
||||
local width = width or notifications[screen][position][idx].width
|
||||
|
@ -368,7 +367,7 @@ function notify(args)
|
|||
end
|
||||
|
||||
-- crop to workarea size if too big
|
||||
local workarea = wibox.get_workarea(screen)
|
||||
local workarea = capi.screen[screen].workarea
|
||||
if width > workarea.width - 2 * (border_width or 0) - 2 * (config.padding or 0) then
|
||||
width = workarea.width - 2 * (border_width or 0) - 2 * (config.padding or 0)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue