diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index 36863576..927b2c5c 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -79,16 +79,36 @@ local titlebar = { -- @param surface -- @see gears.surface ---- minimize_button_normal +--- minimize_button_normal. -- @beautiful beautiful.titlebar_minimize_button_normal -- @param surface -- @see gears.surface +--- minimize_button_normal_hover. +-- @beautiful beautiful.titlebar_minimize_button_normal_hover +-- @param surface +-- @see gears.surface + +--- minimize_button_normal_click. +-- @beautiful beautiful.titlebar_minimize_button_normal_click +-- @param surface +-- @see gears.surface + --- close_button_normal. -- @beautiful beautiful.titlebar_close_button_normal -- @param surface -- @see gears.surface +--- close_button_normal_hover. +-- @beautiful beautiful.titlebar_close_button_normal_hover +-- @param surface +-- @see gears.surface + +--- close_button_normal_click. +-- @beautiful beautiful.titlebar_close_button_normal_click +-- @param surface +-- @see gears.surface + --- ontop_button_normal. -- @beautiful beautiful.titlebar_ontop_button_normal -- @param surface @@ -114,11 +134,31 @@ local titlebar = { -- @param surface -- @see gears.surface +--- minimize_button_focus_hover. +-- @beautiful beautiful.titlebar_minimize_button_focus_hover +-- @param surface +-- @see gears.surface + +--- minimize_button_focus_click. +-- @beautiful beautiful.titlebar_minimize_button_focus_click +-- @param surface +-- @see gears.surface + --- close_button_focus. -- @beautiful beautiful.titlebar_close_button_focus -- @param surface -- @see gears.surface +--- close_button_focus_hover. +-- @beautiful beautiful.titlebar_close_button_focus_hover +-- @param surface +-- @see gears.surface + +--- close_button_focus_click. +-- @beautiful beautiful.titlebar_close_button_focus_click +-- @param surface +-- @see gears.surface + --- ontop_button_focus. -- @beautiful beautiful.titlebar_ontop_button_focus -- @param surface @@ -134,81 +174,241 @@ local titlebar = { -- @param surface -- @see gears.surface +--- floating_button_normal_active_hover. +-- @beautiful beautiful.titlebar_floating_button_normal_active_hover +-- @param surface +-- @see gears.surface + +--- floating_button_normal_active_click. +-- @beautiful beautiful.titlebar_floating_button_normal_active_click +-- @param surface +-- @see gears.surface + --- maximized_button_normal_active. -- @beautiful beautiful.titlebar_maximized_button_normal_active -- @param surface -- @see gears.surface +--- maximized_button_normal_active_hover. +-- @beautiful beautiful.titlebar_maximized_button_normal_active_hover +-- @param surface +-- @see gears.surface + +--- maximized_button_normal_active_click. +-- @beautiful beautiful.titlebar_maximized_button_normal_active_click +-- @param surface +-- @see gears.surface + --- ontop_button_normal_active. -- @beautiful beautiful.titlebar_ontop_button_normal_active -- @param surface -- @see gears.surface +--- ontop_button_normal_active_hover. +-- @beautiful beautiful.titlebar_ontop_button_normal_active_hover +-- @param surface +-- @see gears.surface + +--- ontop_button_normal_active_click. +-- @beautiful beautiful.titlebar_ontop_button_normal_active_click +-- @param surface +-- @see gears.surface + --- sticky_button_normal_active. -- @beautiful beautiful.titlebar_sticky_button_normal_active -- @param surface -- @see gears.surface +--- sticky_button_normal_active_hover. +-- @beautiful beautiful.titlebar_sticky_button_normal_active_hover +-- @param surface +-- @see gears.surface + +--- sticky_button_normal_active_click. +-- @beautiful beautiful.titlebar_sticky_button_normal_active_click +-- @param surface +-- @see gears.surface + --- floating_button_focus_active. -- @beautiful beautiful.titlebar_floating_button_focus_active -- @param surface -- @see gears.surface +--- floating_button_focus_active_hover. +-- @beautiful beautiful.titlebar_floating_button_focus_active_hover +-- @param surface +-- @see gears.surface + +--- floating_button_focus_active_click. +-- @beautiful beautiful.titlebar_floating_button_focus_active_click +-- @param surface +-- @see gears.surface + --- maximized_button_focus_active. -- @beautiful beautiful.titlebar_maximized_button_focus_active -- @param surface -- @see gears.surface +--- maximized_button_focus_active_hover. +-- @beautiful beautiful.titlebar_maximized_button_focus_active_hover +-- @param surface +-- @see gears.surface + +--- maximized_button_focus_active_click. +-- @beautiful beautiful.titlebar_maximized_button_focus_active_click +-- @param surface +-- @see gears.surface + --- ontop_button_focus_active. -- @beautiful beautiful.titlebar_ontop_button_focus_active -- @param surface -- @see gears.surface +--- ontop_button_focus_active_hover. +-- @beautiful beautiful.titlebar_ontop_button_focus_active_hover +-- @param surface +-- @see gears.surface + +--- ontop_button_focus_active_click. +-- @beautiful beautiful.titlebar_ontop_button_focus_active_click +-- @param surface +-- @see gears.surface + --- sticky_button_focus_active. -- @beautiful beautiful.titlebar_sticky_button_focus_active -- @param surface -- @see gears.surface +--- sticky_button_focus_active_hover. +-- @beautiful beautiful.titlebar_sticky_button_focus_active_hover +-- @param surface +-- @see gears.surface + +--- sticky_button_focus_active_click. +-- @beautiful beautiful.titlebar_sticky_button_focus_active_click +-- @param surface +-- @see gears.surface + --- floating_button_normal_inactive. -- @beautiful beautiful.titlebar_floating_button_normal_inactive -- @param surface -- @see gears.surface +--- floating_button_normal_inactive_hover. +-- @beautiful beautiful.titlebar_floating_button_normal_inactive_hover +-- @param surface +-- @see gears.surface + +--- floating_button_normal_inactive_click. +-- @beautiful beautiful.titlebar_floating_button_normal_inactive_click +-- @param surface +-- @see gears.surface + --- maximized_button_normal_inactive. -- @beautiful beautiful.titlebar_maximized_button_normal_inactive -- @param surface -- @see gears.surface +--- maximized_button_normal_inactive_hover. +-- @beautiful beautiful.titlebar_maximized_button_normal_inactive_hover +-- @param surface +-- @see gears.surface + +--- maximized_button_normal_inactive_click. +-- @beautiful beautiful.titlebar_maximized_button_normal_inactive_click +-- @param surface +-- @see gears.surface + --- ontop_button_normal_inactive. -- @beautiful beautiful.titlebar_ontop_button_normal_inactive -- @param surface -- @see gears.surface +--- ontop_button_normal_inactive_hover. +-- @beautiful beautiful.titlebar_ontop_button_normal_inactive_hover +-- @param surface +-- @see gears.surface + +--- ontop_button_normal_inactive_click. +-- @beautiful beautiful.titlebar_ontop_button_normal_inactive_click +-- @param surface +-- @see gears.surface + --- sticky_button_normal_inactive. -- @beautiful beautiful.titlebar_sticky_button_normal_inactive -- @param surface -- @see gears.surface +--- sticky_button_normal_inactive_hover. +-- @beautiful beautiful.titlebar_sticky_button_normal_inactive_hover +-- @param surface +-- @see gears.surface + +--- sticky_button_normal_inactive_click. +-- @beautiful beautiful.titlebar_sticky_button_normal_inactive_click +-- @param surface +-- @see gears.surface + --- floating_button_focus_inactive. -- @beautiful beautiful.titlebar_floating_button_focus_inactive -- @param surface -- @see gears.surface +--- floating_button_focus_inactive_hover. +-- @beautiful beautiful.titlebar_floating_button_focus_inactive_hover +-- @param surface +-- @see gears.surface + +--- floating_button_focus_inactive_click. +-- @beautiful beautiful.titlebar_floating_button_focus_inactive_click +-- @param surface +-- @see gears.surface + --- maximized_button_focus_inactive. -- @beautiful beautiful.titlebar_maximized_button_focus_inactive -- @param surface -- @see gears.surface +--- maximized_button_focus_inactive_hover. +-- @beautiful beautiful.titlebar_maximized_button_focus_inactive_hover +-- @param surface +-- @see gears.surface + +--- maximized_button_focus_inactive_click. +-- @beautiful beautiful.titlebar_maximized_button_focus_inactive_click +-- @param surface +-- @see gears.surface + --- ontop_button_focus_inactive. -- @beautiful beautiful.titlebar_ontop_button_focus_inactive -- @param surface -- @see gears.surface +--- ontop_button_focus_inactive_hover. +-- @beautiful beautiful.titlebar_ontop_button_focus_inactive_hover +-- @param surface +-- @see gears.surface + +--- ontop_button_focus_inactive_click. +-- @beautiful beautiful.titlebar_ontop_button_focus_inactive_click +-- @param surface +-- @see gears.surface + --- sticky_button_focus_inactive. -- @beautiful beautiful.titlebar_sticky_button_focus_inactive -- @param surface -- @see gears.surface +--- sticky_button_focus_inactive_hover. +-- @beautiful beautiful.titlebar_sticky_button_focus_inactive_hover +-- @param surface +-- @see gears.surface + +--- sticky_button_focus_inactive_click. +-- @beautiful beautiful.titlebar_sticky_button_focus_inactive_click +-- @param surface +-- @see gears.surface + --- Set a declarative widget hierarchy description. -- See [The declarative layout system](../documentation/03-declarative-layout.md.html) -- @param args An array containing the widgets disposition @@ -421,10 +621,14 @@ function titlebar.widget.button(c, name, selector, action) if img ~= "" then prefix = prefix .. "_" end + if ret.state ~= "" then + img = img .. "_" + end -- First try with a prefix based on the client's focus state, -- then try again without that prefix if nothing was found, -- and finally, try a fallback for compatibility with Awesome 3.5 themes - local theme = beautiful["titlebar_" .. name .. "_button_" .. prefix .. img] + local theme = beautiful["titlebar_" .. name .. "_button_" .. prefix .. img .. ret.state] + or beautiful["titlebar_" .. name .. "_button_" .. prefix .. img] or beautiful["titlebar_" .. name .. "_button_" .. img] or beautiful["titlebar_" .. name .. "_button_" .. prefix .. "_inactive"] if theme then @@ -433,10 +637,35 @@ function titlebar.widget.button(c, name, selector, action) end ret:set_image(img) end + ret.state = "" if action then - ret:buttons(abutton({ }, 1, nil, function() action(c, selector(c)) end)) + ret:buttons(abutton({ }, 1, nil, function() + ret.state = "" + update() + action(c, selector(c)) + end)) + else + ret:connect_signal("button::release", function(mod, x, y, b) + if b == 1 then + ret.state = "" + update() + end + end) end - + ret:connect_signal("mouse::enter", function() + ret.state = "hover" + update() + end) + ret:connect_signal("mouse::leave", function() + ret.state = "" + update() + end) + ret:connect_signal("button::press", function(mod, x, y, b) + if b == 1 then + ret.state = "click" + update() + end + end) ret.update = update update()