2016-05-08 08:10:35 +02:00
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
--- Wibox module for awful.
|
|
|
|
|
-- This module allows you to easily create wibox and attach them to the edge of
|
|
|
|
|
-- a screen.
|
|
|
|
|
--
|
|
|
|
|
-- @author Emmanuel Lepage Vallee <elv1313@gmail.com>
|
|
|
|
|
-- @copyright 2016 Emmanuel Lepage Vallee
|
2016-05-15 09:50:39 +02:00
|
|
|
|
-- @classmod awful.wibar
|
2016-05-08 08:10:35 +02:00
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
|
local capi =
|
|
|
|
|
{
|
|
|
|
|
screen = screen,
|
|
|
|
|
client = client
|
|
|
|
|
}
|
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
|
local tostring = tostring
|
|
|
|
|
local ipairs = ipairs
|
|
|
|
|
local error = error
|
|
|
|
|
local wibox = require("wibox")
|
|
|
|
|
local beautiful = require("beautiful")
|
|
|
|
|
local util = require("awful.util")
|
|
|
|
|
local placement = require("awful.placement")
|
|
|
|
|
|
|
|
|
|
local function get_screen(s)
|
|
|
|
|
return s and capi.screen[s]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local awfulwibar = { mt = {} }
|
|
|
|
|
|
|
|
|
|
--- Array of table with wiboxes inside.
|
|
|
|
|
-- It's an array so it is ordered.
|
|
|
|
|
local wiboxes = setmetatable({}, {__mode = "v"})
|
|
|
|
|
|
2017-02-26 21:56:09 +01:00
|
|
|
|
--- If the wibar needs to be stretched to fill the screen.
|
|
|
|
|
-- @property stretch
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @tparam boolean stretch
|
|
|
|
|
|
|
|
|
|
--- The wibar's width.
|
|
|
|
|
-- @property width
|
|
|
|
|
-- @tparam integer width
|
|
|
|
|
|
|
|
|
|
--- The wibar's height.
|
|
|
|
|
-- @property height
|
|
|
|
|
-- @tparam integer height
|
|
|
|
|
|
|
|
|
|
--- If the wibar needs to be stretched to fill the screen.
|
|
|
|
|
-- @beautiful beautiful.stretch
|
|
|
|
|
-- @tparam boolean stretch
|
2017-02-26 21:56:09 +01:00
|
|
|
|
|
|
|
|
|
--- The wibar border width.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.border_width
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam integer border_width
|
|
|
|
|
|
|
|
|
|
--- The wibar border color.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.border_color
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam string border_color
|
|
|
|
|
|
|
|
|
|
--- If the wibar is to be on top of other windows.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.ontop
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam boolean ontop
|
|
|
|
|
|
|
|
|
|
--- The wibar's mouse cursor.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.cursor
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam string cursor
|
|
|
|
|
|
|
|
|
|
--- The wibar opacity, between 0 and 1.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.opacity
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam number opacity
|
|
|
|
|
|
|
|
|
|
--- The window type (desktop, normal, dock, …).
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.type
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam string type
|
|
|
|
|
|
|
|
|
|
--- The wibar's width.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.width
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam integer width
|
|
|
|
|
|
|
|
|
|
--- The wibar's height.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.height
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam integer height
|
|
|
|
|
|
|
|
|
|
--- The wibar's background color.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.bg
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam color bg
|
|
|
|
|
|
|
|
|
|
--- The wibar's background image.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.bgimage
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam surface bgimage
|
|
|
|
|
|
|
|
|
|
--- The wibar's foreground (text) color.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.fg
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam color fg
|
|
|
|
|
|
|
|
|
|
--- The wibar's shape.
|
2017-02-27 22:10:45 +01:00
|
|
|
|
-- @beautiful beautiful.shape
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam gears.shape shape
|
|
|
|
|
|
2016-05-08 08:10:35 +02:00
|
|
|
|
-- Compute the margin on one side
|
|
|
|
|
local function get_margin(w, position, auto_stop)
|
|
|
|
|
local h_or_w = (position == "top" or position == "bottom") and "height" or "width"
|
|
|
|
|
local ret = 0
|
|
|
|
|
|
|
|
|
|
for _, v in ipairs(wiboxes) do
|
|
|
|
|
-- Ignore the wibars placed after this one
|
|
|
|
|
if auto_stop and v == w then break end
|
|
|
|
|
|
|
|
|
|
if v.position == position and v.screen == w.screen and v.visible then
|
|
|
|
|
ret = ret + v[h_or_w]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- `honor_workarea` cannot be used as it does modify the workarea itself.
|
|
|
|
|
-- a manual padding has to be generated.
|
|
|
|
|
local function get_margins(w)
|
|
|
|
|
local position = w.position
|
|
|
|
|
assert(position)
|
|
|
|
|
|
|
|
|
|
local margins = {left=0, right=0, top=0, bottom=0}
|
|
|
|
|
|
|
|
|
|
margins[position] = get_margin(w, position, true)
|
|
|
|
|
|
|
|
|
|
-- Avoid overlapping wibars
|
|
|
|
|
if position == "left" or position == "right" then
|
|
|
|
|
margins.top = get_margin(w, "top" )
|
|
|
|
|
margins.bottom = get_margin(w, "bottom")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return margins
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Create the placement function
|
|
|
|
|
local function gen_placement(position, stretch)
|
|
|
|
|
local maximize = (position == "right" or position == "left") and
|
|
|
|
|
"maximize_vertically" or "maximize_horizontally"
|
|
|
|
|
|
|
|
|
|
return placement[position] + (stretch and placement[maximize] or nil)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Attach the placement function.
|
|
|
|
|
local function attach(wb, align)
|
|
|
|
|
gen_placement(align, wb._stretch)(wb, {
|
|
|
|
|
attach = true,
|
|
|
|
|
update_workarea = true,
|
|
|
|
|
margins = get_margins(wb)
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Re-attach all wibars on a given wibar screen
|
|
|
|
|
local function reattach(wb)
|
|
|
|
|
local s = wb.screen
|
|
|
|
|
for _, w in ipairs(wiboxes) do
|
|
|
|
|
if w ~= wb and w.screen == s then
|
|
|
|
|
if w.detach_callback then
|
|
|
|
|
w.detach_callback()
|
|
|
|
|
w.detach_callback = nil
|
|
|
|
|
end
|
|
|
|
|
attach(w, w.position)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- The wibox position.
|
|
|
|
|
-- @property position
|
|
|
|
|
-- @param string Either "left", right", "top" or "bottom"
|
|
|
|
|
|
|
|
|
|
local function get_position(wb)
|
|
|
|
|
return wb._position or "top"
|
|
|
|
|
end
|
|
|
|
|
|
2017-02-13 22:08:30 +01:00
|
|
|
|
local function set_position(wb, position, skip_reattach)
|
2016-05-08 08:10:35 +02:00
|
|
|
|
-- Detach first to avoid any uneeded callbacks
|
|
|
|
|
if wb.detach_callback then
|
|
|
|
|
wb.detach_callback()
|
|
|
|
|
|
|
|
|
|
-- Avoid disconnecting twice, this produces a lot of warnings
|
|
|
|
|
wb.detach_callback = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Move the wibar to the end of the list to avoid messing up the others in
|
|
|
|
|
-- case there is stacked wibars on one side.
|
|
|
|
|
if wb._position then
|
|
|
|
|
for k, w in ipairs(wiboxes) do
|
|
|
|
|
if w == wb then
|
|
|
|
|
table.remove(wiboxes, k)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.insert(wiboxes, wb)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- In case the position changed, it may be necessary to reset the size
|
|
|
|
|
if (wb._position == "left" or wb._position == "right")
|
|
|
|
|
and (position == "top" or position == "bottom") then
|
|
|
|
|
wb.height = math.ceil(beautiful.get_font_height(wb.font) * 1.5)
|
|
|
|
|
elseif (wb._position == "top" or wb._position == "bottom")
|
|
|
|
|
and (position == "left" or position == "right") then
|
|
|
|
|
wb.width = math.ceil(beautiful.get_font_height(wb.font) * 1.5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Set the new position
|
|
|
|
|
wb._position = position
|
|
|
|
|
|
|
|
|
|
-- Attach to the new position
|
|
|
|
|
attach(wb, position)
|
2017-02-13 22:08:30 +01:00
|
|
|
|
|
|
|
|
|
-- A way to skip reattach is required when first adding a wibar as it's not
|
|
|
|
|
-- in the `wiboxes` table yet and can't be added until it's attached.
|
|
|
|
|
if not skip_reattach then
|
|
|
|
|
-- Changing the position will also cause the other margins to be invalidated.
|
|
|
|
|
-- For example, adding a wibar to the top will change the margins of any left
|
|
|
|
|
-- or right wibars. To solve, this, they need to be re-attached.
|
|
|
|
|
reattach(wb)
|
|
|
|
|
end
|
2016-05-08 08:10:35 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Stretch the wibar.
|
|
|
|
|
--
|
|
|
|
|
-- @property stretch
|
|
|
|
|
-- @param[opt=true] boolean
|
|
|
|
|
|
|
|
|
|
local function get_stretch(w)
|
|
|
|
|
return w._stretch
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function set_stretch(w, value)
|
|
|
|
|
w._stretch = value
|
|
|
|
|
|
|
|
|
|
attach(w, w.position)
|
|
|
|
|
end
|
|
|
|
|
|
2016-05-15 09:50:39 +02:00
|
|
|
|
--- Remove a wibar.
|
|
|
|
|
-- @function remove
|
|
|
|
|
local function remove(self)
|
|
|
|
|
self.visible = false
|
|
|
|
|
|
|
|
|
|
if self.detach_callback then
|
|
|
|
|
self.detach_callback()
|
|
|
|
|
self.detach_callback = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for k, w in ipairs(wiboxes) do
|
|
|
|
|
if w == self then
|
|
|
|
|
table.remove(wiboxes, k)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self._screen = nil
|
|
|
|
|
end
|
|
|
|
|
|
2016-05-08 08:10:35 +02:00
|
|
|
|
--- Get a wibox position if it has been set, or return top.
|
|
|
|
|
-- @param wb The wibox
|
|
|
|
|
-- @deprecated awful.wibar.get_position
|
|
|
|
|
-- @return The wibox position.
|
|
|
|
|
function awfulwibar.get_position(wb)
|
|
|
|
|
util.deprecate("Use wb:get_position() instead of awful.wibar.get_position")
|
|
|
|
|
return get_position(wb)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Put a wibox on a screen at this position.
|
|
|
|
|
-- @param wb The wibox to attach.
|
|
|
|
|
-- @param position The position: top, bottom left or right.
|
|
|
|
|
-- @param screen This argument is deprecated, use wb.screen directly.
|
|
|
|
|
-- @deprecated awful.wibar.set_position
|
|
|
|
|
function awfulwibar.set_position(wb, position, screen) --luacheck: no unused args
|
|
|
|
|
util.deprecate("Use wb:set_position(position) instead of awful.wibar.set_position")
|
|
|
|
|
|
|
|
|
|
set_position(wb, position)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Attach a wibox to a screen.
|
2016-05-19 06:49:44 +02:00
|
|
|
|
--
|
|
|
|
|
-- This function has been moved to the `awful.placement` module. Calling this
|
|
|
|
|
-- no longer does anything.
|
|
|
|
|
--
|
2016-05-08 08:10:35 +02:00
|
|
|
|
-- @param wb The wibox to attach.
|
|
|
|
|
-- @param position The position of the wibox: top, bottom, left or right.
|
|
|
|
|
-- @param screen The screen to attach to
|
2016-05-19 06:49:44 +02:00
|
|
|
|
-- @see awful.placement
|
2016-05-08 08:10:35 +02:00
|
|
|
|
-- @deprecated awful.wibar.attach
|
|
|
|
|
function awfulwibar.attach(wb, position, screen) --luacheck: no unused args
|
|
|
|
|
util.deprecate("awful.wibar.attach is deprecated, use the 'attach' property"..
|
|
|
|
|
" of awful.placement. This method doesn't do anything anymore"
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Align a wibox.
|
|
|
|
|
--
|
|
|
|
|
-- Supported alignment are:
|
|
|
|
|
--
|
|
|
|
|
-- * top_left
|
|
|
|
|
-- * top_right
|
|
|
|
|
-- * bottom_left
|
|
|
|
|
-- * bottom_right
|
|
|
|
|
-- * left
|
|
|
|
|
-- * right
|
|
|
|
|
-- * top
|
|
|
|
|
-- * bottom
|
|
|
|
|
-- * centered
|
|
|
|
|
-- * center_vertical
|
|
|
|
|
-- * center_horizontal
|
|
|
|
|
--
|
|
|
|
|
-- @param wb The wibox.
|
|
|
|
|
-- @param align The alignment
|
|
|
|
|
-- @param screen This argument is deprecated. It is not used. Use wb.screen
|
|
|
|
|
-- directly.
|
|
|
|
|
-- @deprecated awful.wibar.align
|
|
|
|
|
-- @see awful.placement.align
|
|
|
|
|
function awfulwibar.align(wb, align, screen) --luacheck: no unused args
|
|
|
|
|
if align == "center" then
|
|
|
|
|
util.deprecate("awful.wibar.align(wb, 'center' is deprecated, use 'centered'")
|
|
|
|
|
align = "centered"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if screen then
|
|
|
|
|
util.deprecate("awful.wibar.align 'screen' argument is deprecated")
|
|
|
|
|
end
|
|
|
|
|
|
2016-05-19 06:49:44 +02:00
|
|
|
|
if placement[align] then
|
|
|
|
|
return placement[align](wb)
|
|
|
|
|
end
|
2016-05-08 08:10:35 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Stretch a wibox so it takes all screen width or height.
|
|
|
|
|
--
|
|
|
|
|
-- **This function has been removed.**
|
|
|
|
|
--
|
|
|
|
|
-- @deprecated awful.wibox.stretch
|
|
|
|
|
-- @see awful.placement
|
2016-12-09 18:03:03 +01:00
|
|
|
|
-- @see awful.wibar.stretch
|
2016-05-08 08:10:35 +02:00
|
|
|
|
|
|
|
|
|
--- Create a new wibox and attach it to a screen edge.
|
|
|
|
|
-- You can add also position key with value top, bottom, left or right.
|
|
|
|
|
-- You can also use width or height in % and set align to center, right or left.
|
|
|
|
|
-- You can also set the screen key with a screen number to attach the wibox.
|
2016-05-19 06:40:40 +02:00
|
|
|
|
-- If not specified, the primary screen is assumed.
|
|
|
|
|
-- @see wibox
|
|
|
|
|
-- @tparam[opt=nil] table arg
|
|
|
|
|
-- @tparam string arg.position The position.
|
|
|
|
|
-- @tparam string arg.stretch If the wibar need to be stretched to fill the screen.
|
|
|
|
|
-- @tparam integer arg.border_width Border width.
|
|
|
|
|
-- @tparam string arg.border_color Border color.
|
|
|
|
|
-- @tparam boolean arg.ontop On top of other windows.
|
|
|
|
|
-- @tparam string arg.cursor The mouse cursor.
|
|
|
|
|
-- @tparam boolean arg.visible Visibility.
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam number arg.opacity The wibar's opacity, between 0 and 1.
|
2016-05-19 06:40:40 +02:00
|
|
|
|
-- @tparam string arg.type The window type (desktop, normal, dock, …).
|
|
|
|
|
-- @tparam integer arg.x The x coordinates.
|
|
|
|
|
-- @tparam integer arg.y The y coordinates.
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam integer arg.width The wibar's width.
|
|
|
|
|
-- @tparam integer arg.height The wibar's height.
|
2016-05-19 06:40:40 +02:00
|
|
|
|
-- @tparam screen arg.screen The wibox screen.
|
|
|
|
|
-- @tparam wibox.widget arg.widget The widget that the wibox displays.
|
|
|
|
|
-- @param arg.shape_bounding The wibox’s bounding shape as a (native) cairo surface.
|
|
|
|
|
-- @param arg.shape_clip The wibox’s clip shape as a (native) cairo surface.
|
2017-01-26 11:15:28 +01:00
|
|
|
|
-- @param arg.shape_input The wibox’s input shape as a (native) cairo surface.
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam color arg.bg The wibar's background.
|
2016-05-19 06:40:40 +02:00
|
|
|
|
-- @tparam surface arg.bgimage The background image of the drawable.
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- @tparam color arg.fg The wibar's foreground (text) color.
|
2016-05-19 06:40:40 +02:00
|
|
|
|
-- @return The new wibar
|
|
|
|
|
-- @function awful.wibar
|
2016-05-08 08:10:35 +02:00
|
|
|
|
function awfulwibar.new(arg)
|
|
|
|
|
arg = arg or {}
|
|
|
|
|
local position = arg.position or "top"
|
|
|
|
|
local has_to_stretch = true
|
|
|
|
|
local screen = get_screen(arg.screen or 1)
|
|
|
|
|
|
|
|
|
|
arg.type = arg.type or "dock"
|
|
|
|
|
|
|
|
|
|
if position ~= "top" and position ~="bottom"
|
|
|
|
|
and position ~= "left" and position ~= "right" then
|
|
|
|
|
error("Invalid position in awful.wibar(), you may only use"
|
|
|
|
|
.. " 'top', 'bottom', 'left' and 'right'")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Set default size
|
|
|
|
|
if position == "left" or position == "right" then
|
|
|
|
|
arg.width = arg.width or math.ceil(beautiful.get_font_height(arg.font) * 1.5)
|
|
|
|
|
if arg.height then
|
|
|
|
|
has_to_stretch = false
|
|
|
|
|
if arg.screen then
|
|
|
|
|
local hp = tostring(arg.height):match("(%d+)%%")
|
|
|
|
|
if hp then
|
|
|
|
|
arg.height = math.ceil(screen.geometry.height * hp / 100)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
arg.height = arg.height or math.ceil(beautiful.get_font_height(arg.font) * 1.5)
|
|
|
|
|
if arg.width then
|
|
|
|
|
has_to_stretch = false
|
|
|
|
|
if arg.screen then
|
|
|
|
|
local wp = tostring(arg.width):match("(%d+)%%")
|
|
|
|
|
if wp then
|
|
|
|
|
arg.width = math.ceil(screen.geometry.width * wp / 100)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2016-05-19 06:05:47 +02:00
|
|
|
|
arg.screen = nil
|
|
|
|
|
|
2017-02-26 21:56:09 +01:00
|
|
|
|
-- The C code scans the table directly, so metatable magic cannot be used.
|
|
|
|
|
for _, prop in ipairs {
|
2017-02-27 22:10:45 +01:00
|
|
|
|
"border_width", "border_color", "font", "opacity", "ontop", "cursor",
|
2017-02-26 21:56:09 +01:00
|
|
|
|
"height", "width", "bgimage", "bg", "fg", "type", "stretch", "shape"
|
|
|
|
|
} do
|
|
|
|
|
if (arg[prop] == nil) and beautiful["wibar_"..prop] ~= nil then
|
|
|
|
|
arg[prop] = beautiful["wibar_"..prop]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2016-05-08 08:10:35 +02:00
|
|
|
|
local w = wibox(arg)
|
|
|
|
|
|
|
|
|
|
w.screen = screen
|
2016-05-15 09:50:39 +02:00
|
|
|
|
w._screen = screen --HACK When a screen is removed, then getbycoords wont work
|
2016-05-08 08:10:35 +02:00
|
|
|
|
w._stretch = arg.stretch == nil and has_to_stretch or arg.stretch
|
|
|
|
|
|
|
|
|
|
w.get_position = get_position
|
|
|
|
|
w.set_position = set_position
|
|
|
|
|
|
|
|
|
|
w.get_stretch = get_stretch
|
|
|
|
|
w.set_stretch = set_stretch
|
2016-05-15 09:50:39 +02:00
|
|
|
|
w.remove = remove
|
2016-05-08 08:10:35 +02:00
|
|
|
|
|
2016-05-19 00:21:22 +02:00
|
|
|
|
if arg.visible == nil then w.visible = true end
|
2016-05-08 08:10:35 +02:00
|
|
|
|
|
2017-02-13 22:08:30 +01:00
|
|
|
|
-- `w` needs to be inserted in `wiboxes` before reattach or its own offset
|
|
|
|
|
-- will not be taken into account by the "older" wibars when `reattach` is
|
|
|
|
|
-- called. `skip_reattach` is required.
|
|
|
|
|
w:set_position(position, true)
|
2016-05-08 08:10:35 +02:00
|
|
|
|
|
|
|
|
|
table.insert(wiboxes, w)
|
|
|
|
|
|
2017-02-13 22:08:30 +01:00
|
|
|
|
-- Force all the wibars to be moved
|
|
|
|
|
reattach(w)
|
|
|
|
|
|
2016-05-08 08:10:35 +02:00
|
|
|
|
w:connect_signal("property::visible", function() reattach(w) end)
|
|
|
|
|
|
|
|
|
|
return w
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
capi.screen.connect_signal("removed", function(s)
|
2017-02-02 22:42:20 +01:00
|
|
|
|
local wibars = {}
|
2016-05-08 08:10:35 +02:00
|
|
|
|
for _, wibar in ipairs(wiboxes) do
|
2016-05-15 09:50:39 +02:00
|
|
|
|
if wibar._screen == s then
|
2017-02-02 22:42:20 +01:00
|
|
|
|
table.insert(wibars, wibar)
|
2016-05-08 08:10:35 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2017-02-02 22:42:20 +01:00
|
|
|
|
for _, wibar in ipairs(wibars) do
|
|
|
|
|
wibar:remove()
|
|
|
|
|
end
|
2016-05-08 08:10:35 +02:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
function awfulwibar.mt:__call(...)
|
|
|
|
|
return awfulwibar.new(...)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--@DOC_wibox_COMMON@
|
|
|
|
|
|
|
|
|
|
return setmetatable(awfulwibar, awfulwibar.mt)
|
|
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|