
local beautiful = require("beautiful")
local awful = require("awful")
local shapes = require("extras.nice.shapes")

function update_titlebars(c, init)
    init = init or false

    -- Rounded Corners
    if not c.fullscreen and not c.maximized then
        c.shape = shapes.rounded_rect {
            tl = beautiful.corner_radius,
            tr = beautiful.corner_radius,
            bl = beautiful.corner_radius,
            br = beautiful.corner_radius
        }
    else
        c.shape = nil
    end
end

function toggle_window_buffers(s)
    if not s.top then
        s.left = awful.wibar({
            screen = s,
            position = "left",
            opacity = 0.0,
            input_passthrough = true,
        })

        s.right = awful.wibar({
            screen = s,
            position = "right",
            opacity = 0.0,
            input_passthrough = true,
        })

        s.top = awful.wibar({
            screen = s,
            position = "top",
            opacity = 0.0,
            input_passthrough = true,
        })

        s.bottom = awful.wibar({
            screen = s,
            position = "bottom",
            opacity = 0.0,
            input_passthrough = true,
        })
    end

    -- Three states: off, small borders, large borders
    s.buffer_state = s.buffer_state or "off"

    if s.buffer_state == "off" then
        s.buffer_state = "small"
        s.left.visible = true
        s.right.visible = true
        s.top.visible = true
        s.bottom.visible = true
        s.left.width = 50
        s.right.width = 50
        s.top.height = 50
        s.bottom.height = 50
    elseif s.buffer_state == "small" then
        s.buffer_state = "large"
        s.left.visible = true
        s.right.visible = true
        s.top.visible = true
        s.bottom.visible = true
        s.left.width = 200
        s.right.width = 200
        s.top.height = 50
        s.bottom.height = 350
    elseif s.buffer_state == "large" then
        s.buffer_state = "off"
        s.left.visible = false
        s.right.visible = false
        s.top.visible = false
        s.bottom.visible = false
    end

end

