local config = require "awesome-wm-nice.config" local shapes = require "awesome-wm-nice.shapes" local wibox = require "wibox" local wlayout_manual = require "wibox.layout.manual" local shade = {} -- Legacy global variables local bottom_edge_height = 3 -- Adds a window shade to the given client function shade.add_window_shade(c, src_top, src_bottom) local geo = c:geometry() local w = wibox() w.width = geo.width w.background = "transparent" w.x = geo.x w.y = geo.y w.height = config.titlebar_height + bottom_edge_height w.ontop = true w.visible = false w.shape = shapes.rounded_rect { tl = config.titlebar_radius, tr = config.titlebar_radius, bl = 4, br = 4, } -- Need to use a manual layout because layout fixed seems to introduce a thin gap src_top.point = { x = 0, y = 0 } src_top.forced_width = geo.width src_bottom.point = { x = 0, y = config.titlebar_height } w.widget = { src_top, src_bottom, layout = wlayout_manual } -- Clean up resources when a client is killed c:connect_signal("request::unmanage", function() if c._nice_window_shade then c._nice_window_shade.visible = false c._nice_window_shade = nil end -- Clean up collectgarbage "collect" end) c._nice_window_shade_up = false c._nice_window_shade = w end -- Shows the window contents function shade.shade_roll_down(c) if not c._nice_window_shade_up then return end c:geometry { x = c._nice_window_shade.x, y = c._nice_window_shade.y } c:activate() c._nice_window_shade.visible = false c._nice_window_shade_up = false end -- Hides the window contents function shade.shade_roll_up(c) if c._nice_window_shade_up then return end local w = c._nice_window_shade local geo = c:geometry() w.x = geo.x w.y = geo.y w.width = geo.width c.minimized = true w.visible = true w.ontop = true c._nice_window_shade_up = true end -- Toggles the window shade state function shade.shade_toggle(c) c.minimized = not c.minimized c._nice_window_shade.visible = c.minimized end return shade