format with stylua

This commit is contained in:
BZ 2021-11-28 17:18:41 +01:00
parent 6e1482e635
commit a6f1df134e
1 changed files with 867 additions and 852 deletions

View File

@ -202,12 +202,12 @@ function module.menu_client(custom_menu, c)
if custom_menu and len(custom_menu) > 0 then
local function generate_menu_entry(e)
if e and type(e) == 'table' and e.text then
if e and type(e) == "table" and e.text then
local text = ""
if type(e.text) == 'string' then
if type(e.text) == "string" then
text = e.text
end
if type(e.text) == 'function' then
if type(e.text) == "function" then
text = e.text(c)
end
return {
@ -297,9 +297,12 @@ local add_hot_corner = function(args)
for _, btn in ipairs(defs) do
if actions[btn.name] then
local signal = signal_name(position, btn.name)
table.insert(buttons, awful.button({}, btn.button, function()
table.insert(
buttons,
awful.button({}, btn.button, function()
awesome.emit_signal(signal)
end))
end)
)
if must_connect_signal then
awesome.connect_signal(signal, glib_context(actions[btn.name]))
end
@ -391,7 +394,8 @@ local function new(config)
local align_vertical = cfg.align_vertical or "center" -- "top" | "center" | "bottom"
local buttons = cfg.buttons or { "floating", "minimize", "maximize", "close" }
local button_left_click = cfg.button_left_click or function(c)
local button_left_click = cfg.button_left_click
or function(c)
if c.maximized then
c.maximized = false
end
@ -401,11 +405,13 @@ local function new(config)
local button_double_click = cfg.button_double_click or function(c)
c.maximized = not c.maximized
end
local button_middle_click = cfg.middle_click or function(c)
local button_middle_click = cfg.middle_click
or function(c)
c:emit_signal("request::activate", "mouse_click", { raise = true })
awful.mouse.client.resize(c)
end
local button_right_click = cfg.right_click or function(c)
local button_right_click = cfg.right_click
or function(c)
if c.client_menu then
c.client_menu:hide()
end
@ -582,8 +588,10 @@ local function new(config)
local dy = math.max(math.abs(m_y - y) - (c.height / 2), 0)
local distance = math.sqrt(dx * dx + dy * dy)
if (not snapping_max_distance or (distance <= snapping_max_distance)) and
(not closest_distance or distance < closest_distance) then
if
(not snapping_max_distance or (distance <= snapping_max_distance))
and (not closest_distance or distance < closest_distance)
then
closest_distance = distance
closest_c = c
end
@ -602,7 +610,7 @@ local function new(config)
local c = mouse_closest_client()
if c then
if snapping_center_mouse then
mouse.coords {x = c.x + c.width / 2, y = c.y + c.height / 2}
mouse.coords({ x = c.x + c.width / 2, y = c.y + c.height / 2 })
end
left_click_function(c)
end
@ -652,8 +660,7 @@ local function new(config)
local smart_border_titlebars = function(c)
local button_widgets = {}
local border_bg = wibox.widget.base.make_widget_declarative(
{
local border_bg = wibox.widget.base.make_widget_declarative({
{ widget = wibox.container.margin },
id = "border_bg",
bg = color_normal,
@ -680,8 +687,7 @@ local function new(config)
local border_expander, border_expander_center
if layout == "fixed" then
border_expander_center = wibox.widget.base.make_widget_declarative(
{
border_expander_center = wibox.widget.base.make_widget_declarative({
fill_vertical = true,
fill_horizontal = true,
content_fill_vertical = true,
@ -689,8 +695,7 @@ local function new(config)
border_bg,
widget = wibox.container.place,
})
border_expander = wibox.widget.base.make_widget_declarative(
{
border_expander = wibox.widget.base.make_widget_declarative({
{ layout = wibox.layout.fixed.horizontal },
border_bg,
{ layout = wibox.layout.fixed.horizontal },
@ -713,16 +718,18 @@ local function new(config)
if _button_positions[pos] then
-- border with buttons
local button_layout = wibox.widget.base.make_widget_declarative(
{id = "button_layout", spacing_widget = spacing_widget, layout = btn_layout})
local button_layout = wibox.widget.base.make_widget_declarative({
id = "button_layout",
spacing_widget = spacing_widget,
layout = btn_layout,
})
local titlebar_widget
if layout == "fixed" then
if ori(pos) == "v" then
local expander = align_vertical == "center" and border_expander_center or border_expander
titlebar_widget = wibox.widget.base.make_widget_declarative(
{
titlebar_widget = wibox.widget.base.make_widget_declarative({
align_vertical == "top" and button_layout or expander,
align_vertical == "center" and button_layout or expander,
align_vertical == "bottom" and button_layout or expander,
@ -731,8 +738,7 @@ local function new(config)
})
else
local expander = align_horizontal == "center" and border_expander_center or border_expander
titlebar_widget = wibox.widget.base.make_widget_declarative(
{
titlebar_widget = wibox.widget.base.make_widget_declarative({
align_horizontal == "left" and button_layout or expander,
align_horizontal == "center" and button_layout or expander,
align_horizontal == "right" and button_layout or expander,
@ -743,19 +749,22 @@ local function new(config)
end
if layout == "ratio" then
titlebar_widget = wibox.widget.base.make_widget_declarative(
{button_layout, id = "titlebar_widget", bg = color_normal, widget = wibox.container.background})
titlebar_widget = wibox.widget.base.make_widget_declarative({
button_layout,
id = "titlebar_widget",
bg = color_normal,
widget = wibox.container.background,
})
end
tb:setup{
tb:setup({
titlebar_widget,
bg = "#00000000",
shape = rounded_corner and rounded_corner_shape(rounded_corner, pos) or nil,
widget = wibox.container.background(),
}
})
local ratio_button_layout = wibox.widget.base.make_widget_declarative(
{
local ratio_button_layout = wibox.widget.base.make_widget_declarative({
homogeneous = layout == "ratio" and true or false,
expand = true,
layout = ori(pos) == "h" and wibox.layout.grid.horizontal or wibox.layout.grid.vertical,
@ -776,8 +785,7 @@ local function new(config)
b.action = cfg["button_" .. btn .. "_function"] or nil
end
local button_widget = wibox.widget.base.make_widget_declarative(
{
local button_widget = wibox.widget.base.make_widget_declarative({
{ widget = wibox.container.margin },
id = b.name,
forced_width = ori(pos) == "h" and b.button_size or nil,
@ -787,13 +795,13 @@ local function new(config)
})
if show_button_tooltips then
awful.tooltip {
awful.tooltip({
objects = { button_widget },
align = "top_left",
timer_function = function()
return b.name
end,
}
})
end
button_widget:connect_signal("mouse::enter", function()
@ -852,15 +860,22 @@ local function new(config)
table.insert(ratio_children, border_bg)
button_layout:set_children(ratio_children)
if (ori(pos) == "h" and align_horizontal == "left") or (ori(pos) == "v" and align_vertical == "top") then
if
(ori(pos) == "h" and align_horizontal == "left")
or (ori(pos) == "v" and align_vertical == "top")
then
button_layout:ajust_ratio(2, 0, button_ratio, 1.0 - button_ratio)
end
if (ori(pos) == "h" and align_horizontal == "right") or
(ori(pos) == "v" and align_vertical == "bottom") then
if
(ori(pos) == "h" and align_horizontal == "right")
or (ori(pos) == "v" and align_vertical == "bottom")
then
button_layout:ajust_ratio(2, 1.0 - button_ratio, button_ratio, 0)
end
if (ori(pos) == "h" and align_horizontal == "center") or
(ori(pos) == "v" and align_vertical == "center") then
if
(ori(pos) == "h" and align_horizontal == "center")
or (ori(pos) == "v" and align_vertical == "center")
then
local side_ratio = (1.0 - button_ratio) / 2
button_layout:ajust_ratio(2, side_ratio, button_ratio, side_ratio)
end
@ -870,23 +885,23 @@ local function new(config)
button_layout:set_children(list_of_buttons)
end
else
tb:setup{
tb:setup({
border_bg,
bg = "#00000000",
shape = rounded_corner and rounded_corner_shape(rounded_corner, pos) or nil,
widget = wibox.container.background,
}
})
end
end
-- show client title tooltip on border hover
if show_title_tooltip then
awful.tooltip {
awful.tooltip({
objects = { border_bg },
timer_function = function()
return c.name
end,
}
})
end
local update_border = function()