Skip to content

Class DrawableList ​

The drawables drawn against one window, output, cursor or the desktop. A list holds any kind of Drawable.

Implements: List<Drawable>

What each list's drawables are placed against:

  • window.drawables: the window's box as drawn, animations included.
  • output.drawables: the whole output. Each drawable's layer places it among windows and layer surfaces.
  • wm.drawables: global coordinates, the ones windows have. Drawn on every output they overlap.
  • cursor.drawables: the pointer's hotspot. Drawn on every output they reach, in front of everything including the cursor image.

wm.drawables and cursor lists have no right or bottom edge, so their drawables are placed with left, top, width and height only.

  • A window's list goes when the window does, after its close animation. An output's list goes with the output.
  • A reload empties every list for the new config to fill. If the new config fails to load, the old lists come back.

Properties ​

window.drawables = drawables: Drawable[] | DrawableList | nildrawables ​

Replaces the list's contents with drawables, in that order. Works the same on an output's, a cursor's and wm.drawables.

  • nil empties the list.

Errors for a drawable listed twice, an item that isn't a Drawable, a drawable using right or bottom in wm.drawables or a cursor's list, and an output that is gone. Nothing changes.

lua
local shadow = Drawable.rect({ left = -8, right = -8, top = -8, bottom = -8, z = -2, radius = 14, fill = "#00000040" })
local outline = Drawable.rect({ left = -1, right = -1, top = -1, bottom = -1, z = -1, radius = 8, border_width = 1, border_color = "#ffffff30" })
local before = window.drawables:all()
window.drawables = { shadow, outline }
window.drawables = before

Methods ​

drawables:add(drawable: Drawable) -> niladd ​

Adds drawable at the end of the list, in front of the others with the same z. It can be in other lists at the same time.

Errors when it is already in this list, when the list's output is gone, and for a drawable using right or bottom added to wm.drawables or a cursor's list.

lua
local snap_preview = Drawable.rect({
	left = 0, top = 0, width = 0, height = 0, z = 50, visible = false,
	fill = "#88c0d040", border_width = 2, border_color = "#88c0d0", radius = 8,
})
wm.drawables:add(snap_preview)

drawables:remove(drawable: Drawable) -> booleanremove ​

Takes drawable out of this list.

  • false when it wasn't in the list.

drawables:clear() -> nilclear ​

Empties the list. The drawables themselves don't change and can be added again.