Skip to content

Class WindowBox ​

Where and how a window is drawn and stacked, read from window.box.

position, size, opacity and corner_radius read back as an Animated, even when given a plain value.

lua
local going_to = window.box.position:target()
window.box.position = Anim.spring(going_to + Point(0, 40))

Properties ​

box.position: Point | Animatedposition ​

The window's top-left corner in global coordinates.

  • Default: 0,0 for a new window.
  • A hidden window keeps its position. Assigning one while hidden sets where it comes back.
lua
window.box.position = Anim.spring(Point(200, 120), { stiffness = 300 })

box.size: Size | Animated | nilsize ​

The size the window is drawn at. The window's content is scaled to fill it.

  • nil (the default): the size the app drew, the same as window.size.
  • The app is not told about this size. Pair it with window:request_size for a smooth resize:
lua
local size = { width = 640, height = 480 }
window.box.size = Anim.spring(size)
window:request_size(size)

box.opacity: number | Animatedopacity ​

How opaque the window and its drawables are, from 0 to 1.

  • Default: 1.
  • At 0 the window still takes input. Set visible to false to remove it.
lua
window.box.opacity = Anim.tween(0.85, 200)

box.corner_radius: number | Animated | (number | Animated)[] | nilcorner_radius ​

Rounds the window's corners, in logical pixels, like CSS border-radius.

  • One value rounds every corner. A table of four is top-left, top-right, bottom-right, bottom-left.
  • Default: nil, square corners. 0 is the same.
  • Each corner is at most half the shorter side.
  • Reads back as one Animated when all four are the same, otherwise a table of four.
  • Clicks on a cut-away corner go to whatever is under it.
  • Popups and drawables keep square corners. A border drawable matches with radius = corner radius + border width.

Errors for a table that doesn't have four values, and for a negative radius.

lua
window.box.corner_radius = { 0, 0, 6, 6 }

box.visible: booleanvisible ​

Whether the window is on screen. It can't be animated, so fade opacity first for a smooth exit.

  • Default: true.
  • A hidden window takes no input and can't have keyboard focus. Seats focused on it lose focus.
  • It stays in wm.windows, after the visible ones.
  • Taskbars see it as minimized.
lua
window.box.visible = false

box.z: integerz ​

The window's stacking level. A higher z is drawn in front and gets pointer input first.

  • Default: 0.
  • Windows with the same z keep the order they were raised in.
  • z only orders windows among themselves. Overlay layers are always in front. Top layers are in front of every window that isn't fullscreen.
lua
window.box.z = 1

box.input: booleaninput ​

Whether the window takes pointer input. False makes it click-through: clicks reach whatever is under it.

  • Default: true.
  • A hidden window takes no input whatever this says.
lua
window.box.input = false

Methods ​

box:raise() -> nilraise ​

Puts the window in front of every other window with the same z. It does not change z or focus.

lua
window.box:raise()