diff --git a/awesomerc.lua b/awesomerc.lua index 5f7e87c6..72c6d01e 100755 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -458,6 +458,11 @@ awful.rules.rules = { } }, properties = { floating = true }}, + -- Add titlebars to normal clients and dialogs + { rule_any = {type = { "normal", "dialog" } + }, properties = { titlebars_enabled = true } + }, + -- Set Firefox to always map on the tag named "2" on screen 1. -- { rule = { class = "Firefox" }, -- properties = { screen = 1, tag = "2" } }, @@ -481,48 +486,48 @@ client.connect_signal("manage", function (c) -- Prevent clients from being unreachable after screen count changes. awful.placement.no_offscreen(c) end +end) - local titlebars_enabled = true - if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then - -- buttons for the titlebar - local buttons = awful.util.table.join( - awful.button({ }, 1, function() - client.focus = c - c:raise() - awful.mouse.client.move(c) - end), - awful.button({ }, 3, function() - client.focus = c - c:raise() - awful.mouse.client.resize(c) - end) - ) +-- Add a titlebar if titlebars_enabled is set to true in the rules. +client.connect_signal("request::titlebars", function(c) + -- buttons for the titlebar + local buttons = awful.util.table.join( + awful.button({ }, 1, function() + client.focus = c + c:raise() + awful.mouse.client.move(c) + end), + awful.button({ }, 3, function() + client.focus = c + c:raise() + awful.mouse.client.resize(c) + end) + ) - awful.titlebar(c) : setup { - { -- Left - awful.titlebar.widget.iconwidget(c), - buttons = buttons, - layout = wibox.layout.fixed.horizontal + awful.titlebar(c) : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) }, - { -- Middle - { -- Title - align = "center", - widget = awful.titlebar.widget.titlewidget(c) - }, - buttons = buttons, - layout = wibox.layout.flex.horizontal - }, - { -- Right - awful.titlebar.widget.floatingbutton (c), - awful.titlebar.widget.maximizedbutton(c), - awful.titlebar.widget.stickybutton (c), - awful.titlebar.widget.ontopbutton (c), - awful.titlebar.widget.closebutton (c), - layout = wibox.layout.fixed.horizontal() - }, - layout = wibox.layout.align.horizontal - } - end + buttons = buttons, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } end) -- Enable sloppy focus diff --git a/lib/awful/client.lua b/lib/awful/client.lua index b6e0ef00..5af66f07 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -1122,6 +1122,12 @@ capi.client.add_signal("property::floating") capi.client.add_signal("property::dockable") +--- Emited when a client need to get a titlebar. +-- @signal request::titlebars +-- @tparam[opt=nil] string content The context (like "rules") +-- @tparam[opt=nil] table hints Some hints. +capi.client.add_signal("request::titlebars") + --- The client marked signal (deprecated). -- @signal .marked capi.client.add_signal("marked") diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index 8632d3a7..18168825 100644 --- a/lib/awful/rules.lua +++ b/lib/awful/rules.lua @@ -361,6 +361,10 @@ end -- @tab props Properties to apply. -- @tab[opt] callbacks Callbacks to apply. function rules.execute(c, props, callbacks) + -- This has to be done first, as it will impact geometry related props. + if props.titlebars_enabled then + c:emit_signal("request::titlebars", "rules", {properties=props}) + end -- Before requesting a tag, make sure the screen is right if props.screen then