client: Turn `rc.lua` logic into a new `request::border` signal.

The default `rc.lua` was using the focus/unfocus signals to set
the border color along with `awful.rules`. This logic block was
no longer aligned with the rest of `rc.lua` since it was
the only place where `beautiful` variables where only used by
`rc.lua`.

On top of this, the new request handler also has extra contexts
for the urgent and floating/maximixed use cases. So it can be used
by themes to implement much smarter borders than just focus based
ones. They were previously limited by the fact most of the
(un-monkey-patchable) logic was in `rc.lua`.

Note that this commit also shuffle the awful.rules order between
the titlebar and the border and changes the tests accordignly.
After some consideration, I came to the conclusion the previous
behavior was bogus and the fact that the placement tests required
to know about the titlebar height is simply a proof of that. The
change was required in this commit because since the border is no
longer in the default rules, a new buggy edge case surfaced.
This commit is contained in:
Emmanuel Lepage Vallee 2019-11-10 20:47:43 -05:00 committed by Emmanuel Lepage-Vallee
parent c10bdc3cfe
commit 04c757322c
29 changed files with 810 additions and 110 deletions

View File

@ -441,9 +441,7 @@ awful.rules.rules = {
-- @DOC_GLOBAL_RULE@ -- @DOC_GLOBAL_RULE@
-- All clients will match this rule. -- All clients will match this rule.
{ rule = { }, { rule = { },
properties = { border_width = beautiful.border_width, properties = { focus = awful.client.focus.filter,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true, raise = true,
screen = awful.screen.preferred, screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen placement = awful.placement.no_overlap+awful.placement.no_offscreen
@ -540,8 +538,3 @@ end)
client.connect_signal("mouse::enter", function(c) client.connect_signal("mouse::enter", function(c)
c:activate { context = "mouse_enter", raise = false } c:activate { context = "mouse_enter", raise = false }
end) end)
-- @DOC_BORDER@
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)

View File

@ -221,11 +221,6 @@ sections.DOC_CSD_TITLEBARS = [[
See `client.requests_no_titlebar` for more details. See `client.requests_no_titlebar` for more details.
]] ]]
sections.DOC_BORDER = [[
 
]]
-- Ask ldoc to generate links -- Ask ldoc to generate links
local function add_links(line) local function add_links(line)

View File

@ -62,6 +62,14 @@ This document was last updated at commit v4.3-197-g9085ed631.
objects. If you used these low level APIs to add keys and buttons dynamically, objects. If you used these low level APIs to add keys and buttons dynamically,
please migrate your code to the corresponding `:append_` and `:remove_` please migrate your code to the corresponding `:append_` and `:remove_`
client methods. client methods.
* `beautiful.border_width` and `beautiful.border_color` are now honored even
when the part related to borders is removed from `rc.lua`. Set them
appropriately in your theme or disconnect the default `request::border`
handler.
* The order by which the client rules compute the geometry have changed
slightly. The border is now applied before the titlebar offset. This should
not affect most users unless you had mitigated the bug it fixes by adding
the titlebar offset in your rules.
<a name="v43"></a> <a name="v43"></a>
# Awesome window manager framework version 4.3 changes # Awesome window manager framework version 4.3 changes

View File

@ -0,0 +1,492 @@
*/
/**
* The fallback border color when the client is floating.
*
* @beautiful beautiful.border_color_floating
* @param color
* @see request::border
* @see beautiful.border_color_floating_active
* @see beautiful.border_color_floating_normal
* @see beautiful.border_color_floating_urgent
* @see beautiful.border_color_floating_new
*/
/**
* The fallback border color when the client is mazimized.
*
* @beautiful beautiful.border_color_mazimized
* @param color
* @see request::border
* @see beautiful.border_color_maximized_active
* @see beautiful.border_color_maximized_normal
* @see beautiful.border_color_maximized_urgent
* @see beautiful.border_color_maximized_new
*/
/**
* The border color when the client is active.
*
* @beautiful beautiful.border_color_active
* @param color
* @see request::border
*/
/**
* The border color when the client is not active.
*
* @beautiful beautiful.border_color_normal
* @param color
* @see request::border
*/
/**
* The border color when the client has the urgent property set.
*
* @beautiful beautiful.border_color_urgent
* @param color
* @see request::border
*/
/**
* The border color when the client is not active and new.
*
* @beautiful beautiful.border_color_new
* @param color
* @see request::border
*/
/**
* The border color when the (floating) client is active.
*
* @beautiful beautiful.border_color_floating_active
* @param color
* @see request::border
*/
/**
* The border color when the (floating) client is not active.
*
* @beautiful beautiful.border_color_floating_normal
* @param color
* @see request::border
*/
/**
* The border color when the (floating) client has the urgent property set.
*
* @beautiful beautiful.border_color_floating_urgent
* @param color
* @see request::border
*/
/**
* The border color when the (floating) client is not active and new.
*
* @beautiful beautiful.border_color_floating_new
* @param color
* @see request::border
*/
/**
* The border color when the (maximized) client is active.
*
* @beautiful beautiful.border_color_maximized_active
* @param color
* @see request::border
*/
/**
* The border color when the (maximized) client is not active.
*
* @beautiful beautiful.border_color_maximized_normal
* @param color
* @see request::border
*/
/**
* The border color when the (maximized) client has the urgent property set.
*
* @beautiful beautiful.border_color_maximized_urgent
* @param color
* @see request::border
*/
/**
* The border color when the (maximized) client is not active and new.
*
* @beautiful beautiful.border_color_maximized_new
* @param color
* @see request::border
*/
/**
* The border color when the (fullscreen) client is active.
*
* @beautiful beautiful.border_color_fullscreen_active
* @param color
* @see request::border
*/
/**
* The border color when the (fullscreen) client is not active.
*
* @beautiful beautiful.border_color_fullscreen_normal
* @param color
* @see request::border
*/
/**
* The border color when the (fullscreen) client has the urgent property set.
*
* @beautiful beautiful.border_color_fullscreen_urgent
* @param color
* @see request::border
*/
/**
* The border color when the (fullscreen) client is not active and new.
*
* @beautiful beautiful.border_color_fullscreen_new
* @param color
* @see request::border
*/
/**
* The fallback border width when nothing else is set.
*
* @beautiful beautiful.border_width
* @param integer
* @see request::border
* @see beautiful.border_width_floating
* @see beautiful.border_width_mazimized
* @see beautiful.border_width_floating_active
* @see beautiful.border_width_floating_normal
* @see beautiful.border_width_floating_urgent
* @see beautiful.border_width_floating_new
* @see beautiful.border_width_maximized_active
* @see beautiful.border_width_maximized_normal
* @see beautiful.border_width_maximized_urgent
* @see beautiful.border_width_maximized_new
*/
/**
* The fallback border width when the client is floating.
*
* @beautiful beautiful.border_width_floating
* @param integer
* @see request::border
* @see beautiful.border_width_floating_active
* @see beautiful.border_width_floating_normal
* @see beautiful.border_width_floating_urgent
* @see beautiful.border_width_floating_new
*/
/**
* The fallback border width when the client is mazimized.
*
* @beautiful beautiful.border_width_mazimized
* @param integer
* @see request::border
* @see beautiful.border_width_maximized_active
* @see beautiful.border_width_maximized_normal
* @see beautiful.border_width_maximized_urgent
* @see beautiful.border_width_maximized_new
*/
/**
* The client border width for the normal clients.
*
* @beautiful beautiful.border_width_normal
* @param integer
* @see request::border
*/
/**
* The client border width for the active client.
*
* @beautiful beautiful.border_width_active
* @param integer
* @see request::border
*/
/**
* The client border width for the urgent clients.
*
* @beautiful beautiful.border_width_urgent
* @param integer
* @see request::border
*/
/**
* The client border width for the new clients.
*
* @beautiful beautiful.border_width_new
* @param integer
* @see request::border
*/
/**
* The client border width for the normal floating clients.
*
* @beautiful beautiful.border_width_floating_normal
* @param integer
* @see request::border
*/
/**
* The client border width for the active floating client.
*
* @beautiful beautiful.border_width_floating_active
* @param integer
* @see request::border
*/
/**
* The client border width for the urgent floating clients.
*
* @beautiful beautiful.border_width_floating_urgent
* @param integer
* @see request::border
*/
/**
* The client border width for the new floating clients.
*
* @beautiful beautiful.border_width_floating_new
* @param integer
* @see request::border
*/
/**
* The client border width for the normal maximized clients.
*
* @beautiful beautiful.border_width_maximized_normal
* @param integer
* @see request::border
*/
/**
* The client border width for the active maximized client.
*
* @beautiful beautiful.border_width_maximized_active
* @param integer
* @see request::border
*/
/**
* The client border width for the urgent maximized clients.
*
* @beautiful beautiful.border_width_maximized_urgent
* @param integer
* @see request::border
*/
/**
* The client border width for the new maximized clients.
*
* @beautiful beautiful.border_width_maximized_new
* @param integer
* @see request::border
*/
/**
* The client border width for the normal fullscreen clients.
*
* @beautiful beautiful.border_width_fullscreen_normal
* @param integer
* @see request::border
*/
/**
* The client border width for the active fullscreen client.
*
* @beautiful beautiful.border_width_fullscreen_active
* @param integer
* @see request::border
*/
/**
* The client border width for the urgent fullscreen clients.
*
* @beautiful beautiful.border_width_fullscreen_urgent
* @param integer
* @see request::border
*/
/**
* The client border width for the new fullscreen clients.
*
* @beautiful beautiful.border_width_fullscreen_new
* @param integer
* @see request::border
*/
/**
* The client opacity for the normal clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_normal
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the active client.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_active
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the urgent clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_urgent
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the new clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_new
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the normal floating clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_floating_normal
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the active floating client.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_floating_active
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the urgent floating clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_floating_urgent
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the new floating clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_floating_new
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the normal maximized clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_maximized_normal
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the active maximized client.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_maximized_active
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the urgent maximized clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_maximized_urgent
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the new maximized clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_maximized_new
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the normal fullscreen clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_fullscreen_normal
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the active fullscreen client.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_fullscreen_active
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the urgent fullscreen clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_fullscreen_urgent
* @param[opt=1] number
* @see request::border
*/
/**
* The client opacity for the new fullscreen clients.
*
* A number between 0 and 1.
*
* @beautiful beautiful.opacity_fullscreen_new
* @param[opt=1] number
* @see request::border
*/
/**
* The marked clients border color.
* Note that only solid colors are supported.
* @beautiful beautiful.border_marked
* @param color
*/
/*

View File

@ -688,6 +688,12 @@ function client.object.set_floating(c, s)
c:geometry(client.property.get(c, "floating_geometry")) c:geometry(client.property.get(c, "floating_geometry"))
end end
c.screen = scr c.screen = scr
if s then
c:emit_signal("request::border", "floating", {})
else
c:emit_signal("request::border", (c.active and "" or "in").."active", {})
end
end end
end end
@ -834,6 +840,17 @@ local function update_implicitly_floating(c)
if cur ~= new then if cur ~= new then
client.property.set(c, "_implicitly_floating", new) client.property.set(c, "_implicitly_floating", new)
c:emit_signal("property::floating") c:emit_signal("property::floating")
-- Don't send the border signals as they would be sent twice (with this
-- one having the wrong context). There is some `property::` signal
-- sent before `request::manage`.
if client.property.get(c, "_border_init") then
if cur then
c:emit_signal("request::border", "floating", {})
else
c:emit_signal("request::border", (c.active and "" or "in").."active", {})
end
end
end end
end end
@ -1389,6 +1406,19 @@ function client.object.set_shape(self, shape)
set_shape(self) set_shape(self)
end end
-- Proxy those properties to decorate their accessors with an extra flag to
-- define when they are set by the user. This allows to "manage" the value of
-- those properties internally until they are manually overridden.
for _, prop in ipairs { "border_width", "border_color", "opacity" } do
client.object["get_"..prop] = function(self)
return self["_"..prop]
end
client.object["set_"..prop] = function(self, value)
self._private["_user_"..prop] = true
self["_"..prop] = value
end
end
--- Activate (focus) a client. --- Activate (focus) a client.
-- --
-- This method is the correct way to focus a client. While -- This method is the correct way to focus a client. While
@ -1531,7 +1561,9 @@ function client.object.set_active(c, value)
end end
end end
-- Register standards signals capi.client.connect_signal("property::active", function(c)
c:emit_signal("request::border", (c.active and "" or "in").."active", {})
end)
--- The last geometry when client was floating. --- The last geometry when client was floating.
-- @signal property::floating_geometry -- @signal property::floating_geometry
@ -1547,6 +1579,21 @@ end
--- The client unmarked signal. --- The client unmarked signal.
-- @deprecatedsignal unmarked -- @deprecatedsignal unmarked
--- Emited when the border client might need to be update.
--
-- The context are:
--
-- * **added**: When a new client is created.
-- * **active**: When client gains the focus (or stop being urgent/floating
-- but is active).
-- * **inactive**: When client loses the focus (or stop being urgent/floating
-- and is not active.
-- * **urgent**: When a client becomes urgent.
-- * **floating**: When the floating or maximization state changes.
--
-- @signal request::border
-- @see awful.ewmh.update_border
-- Add clients during startup to focus history. -- Add clients during startup to focus history.
-- This used to happen through ewmh.activate, but that only handles visible -- This used to happen through ewmh.activate, but that only handles visible
-- clients now. -- clients now.
@ -1561,6 +1608,9 @@ capi.client.connect_signal("request::manage", function (c)
if awesome.startup then if awesome.startup then
client.focus.history.add(c) client.focus.history.add(c)
end end
client.property.set(c, "_border_init", true)
c:emit_signal("request::border", "added", {})
end) end)
capi.client.connect_signal("request::unmanage", client.focus.history.delete) capi.client.connect_signal("request::unmanage", client.focus.history.delete)

View File

@ -63,9 +63,24 @@ end
-- @client c The client object. -- @client c The client object.
-- @param prop The property which is updated. -- @param prop The property which is updated.
function urgent.add(c, prop) function urgent.add(c, prop)
if type(c) == "client" and prop == "urgent" and c.urgent then assert(
c.urgent ~= nil,
"`awful.client.urgent.add()` takes a client as first parameter"
)
if prop == "urgent" and c.urgent then
table.insert(data, c) table.insert(data, c)
end end
if c.urgent then
c:emit_signal("request::border", "urgent", {})
else
c:emit_signal(
"request::border",
(c.active and "" or "in").."active",
{}
)
end
end end
--- Remove client from urgent stack. --- Remove client from urgent stack.

View File

@ -17,6 +17,7 @@ local asuit = require("awful.layout.suit")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local alayout = require("awful.layout") local alayout = require("awful.layout")
local atag = require("awful.tag") local atag = require("awful.tag")
local gdebug = require("gears.debug")
local ewmh = { local ewmh = {
generic_activate_filters = {}, generic_activate_filters = {},
@ -453,6 +454,158 @@ ewmh.add_activate_filter(function(c)
end end
end, "mouse_enter") end, "mouse_enter")
--- The default client `request::border` handler.
--
-- To replace this handler with your own, use:
--
-- client.disconnect_signal("request::border", awful.ewmh.update_border)
--
-- The default implementation chooses from dozens beautiful theme variables
-- depending if the client is tiled, floating, maximized and then from its state
-- (urgent, new, active, normal)
--
-- @signalhandler awful.ewmh.update_border
-- @usebeautiful beautiful.border_color_active
-- @usebeautiful beautiful.border_color_normal
-- @usebeautiful beautiful.border_color_new
-- @usebeautiful beautiful.border_color_urgent
-- @usebeautiful beautiful.border_color_floating
-- @usebeautiful beautiful.border_color_floating_active
-- @usebeautiful beautiful.border_color_floating_normal
-- @usebeautiful beautiful.border_color_floating_new
-- @usebeautiful beautiful.border_color_floating_urgent
-- @usebeautiful beautiful.border_color_maximized
-- @usebeautiful beautiful.border_color_maximized_active
-- @usebeautiful beautiful.border_color_maximized_normal
-- @usebeautiful beautiful.border_color_maximized_new
-- @usebeautiful beautiful.border_color_maximized_urgent
-- @usebeautiful beautiful.border_color_fullscreen
-- @usebeautiful beautiful.border_color_fullscreen_active
-- @usebeautiful beautiful.border_color_fullscreen_normal
-- @usebeautiful beautiful.border_color_fullscreen_new
-- @usebeautiful beautiful.border_color_fullscreen_urgent
-- @usebeautiful beautiful.border_width_active
-- @usebeautiful beautiful.border_width_normal
-- @usebeautiful beautiful.border_width_new
-- @usebeautiful beautiful.border_width_urgent
-- @usebeautiful beautiful.border_width_floating
-- @usebeautiful beautiful.border_width_floating_active
-- @usebeautiful beautiful.border_width_floating_normal
-- @usebeautiful beautiful.border_width_floating_new
-- @usebeautiful beautiful.border_width_floating_urgent
-- @usebeautiful beautiful.border_width_maximized
-- @usebeautiful beautiful.border_width_maximized_active
-- @usebeautiful beautiful.border_width_maximized_normal
-- @usebeautiful beautiful.border_width_maximized_new
-- @usebeautiful beautiful.border_width_maximized_urgent
-- @usebeautiful beautiful.border_width_fullscreen
-- @usebeautiful beautiful.border_width_fullscreen_active
-- @usebeautiful beautiful.border_width_fullscreen_normal
-- @usebeautiful beautiful.border_width_fullscreen_new
-- @usebeautiful beautiful.border_width_fullscreen_urgent
-- @usebeautiful beautiful.opacity_floating
-- @usebeautiful beautiful.opacity_floating_active
-- @usebeautiful beautiful.opacity_floating_normal
-- @usebeautiful beautiful.opacity_floating_new
-- @usebeautiful beautiful.opacity_floating_urgent
-- @usebeautiful beautiful.opacity_maximized
-- @usebeautiful beautiful.opacity_maximized_active
-- @usebeautiful beautiful.opacity_maximized_normal
-- @usebeautiful beautiful.opacity_maximized_new
-- @usebeautiful beautiful.opacity_maximized_urgent
-- @usebeautiful beautiful.opacity_fullscreen
-- @usebeautiful beautiful.opacity_fullscreen_active
-- @usebeautiful beautiful.opacity_fullscreen_normal
-- @usebeautiful beautiful.opacity_fullscreen_new
-- @usebeautiful beautiful.opacity_fullscreen_urgent
-- @usebeautiful beautiful.opacity_active
-- @usebeautiful beautiful.opacity_normal
-- @usebeautiful beautiful.opacity_new
-- @usebeautiful beautiful.opacity_urgent
function ewmh.update_border(c, context)
local suffix, fallback = "", ""
-- Add the sub-namespace.
if c.fullscreen then
suffix, fallback = "_fullscreen", "_fullscreen"
elseif c.maximized then
suffix, fallback = "_maximized", "_maximized"
elseif c.floating then
suffix, fallback = "_floating", "_floating"
end
-- Add the state suffix.
if c.urgent then
suffix = suffix .. "_urgent"
elseif c.active then
suffix = suffix .. "_active"
elseif context == "added" then
suffix = suffix .. "_new"
else
suffix = suffix .. "_normal"
end
if not c._private._user_border_width then
c._border_width = beautiful["border_width"..suffix]
or beautiful["border_width"..fallback]
or beautiful.border_width
end
if not c._private._user_border_color then
-- First, check marked clients. This is a concept that should probably
-- never have been added to the core. The documentation claims it works,
-- even if it has been broken for 90% of AwesomeWM releases ever since
-- it was added.
if c.marked and beautiful.border_marked then
c._border_color = beautiful.border_marked
return
end
local tv = beautiful["border_color"..suffix]
if fallback ~= "" and not tv then
tv = beautiful["border_color"..fallback]
end
-- The old theme variable did not have "color" in its name.
if (not tv) and beautiful.border_normal and (not c.active) then
gdebug.deprecate(
"Use `beautiful.border_color_normal` instead of `beautiful.border_normal`",
{deprecated_in=5}
)
tv = beautiful.border_normal
elseif (not tv) and beautiful.border_focus then
gdebug.deprecate(
"Use `beautiful.border_color_active` instead of `beautiful.border_focus`",
{deprecated_in=5}
)
tv = beautiful.border_focus
end
if not tv then
tv = beautiful.border_color
end
if tv then
c._border_color = tv
end
end
if not c._private._user_opacity then
local tv = beautiful["opacity"..suffix]
if fallback ~= "" and not tv then
tv = beautiful["opacity"..fallback]
end
if tv then
c._opacity = tv
end
end
end
client.connect_signal("request::border", ewmh.update_border)
client.connect_signal("request::activate", ewmh.activate) client.connect_signal("request::activate", ewmh.activate)
client.connect_signal("request::tag", ewmh.tag) client.connect_signal("request::tag", ewmh.tag)
client.connect_signal("request::urgent", ewmh.urgent) client.connect_signal("request::urgent", ewmh.urgent)

View File

@ -119,8 +119,8 @@ local function load_theme(a, b)
local fallback = beautiful.get() local fallback = beautiful.get()
if a.reset then b = fallback end if a.reset then b = fallback end
if a == "reset" then a = fallback end if a == "reset" then a = fallback end
ret.border = a.border_color or b.menu_border_color or b.border_normal or ret.border = a.border_color or b.menu_border_color or b.border_color_normal or
fallback.menu_border_color or fallback.border_normal fallback.menu_border_color or fallback.border_color_normal
ret.border_width= a.border_width or b.menu_border_width or b.border_width or ret.border_width= a.border_width or b.menu_border_width or b.border_width or
fallback.menu_border_width or fallback.border_width or dpi(0) fallback.menu_border_width or fallback.border_width or dpi(0)
ret.fg_focus = a.fg_focus or b.menu_fg_focus or b.fg_focus or ret.fg_focus = a.fg_focus or b.menu_fg_focus or b.fg_focus or

View File

@ -708,7 +708,7 @@ local function get_relative_regions(geo, mode, is_absolute)
-- Detect various types of geometry table and (try) to get rid of the -- Detect various types of geometry table and (try) to get rid of the
-- differences so the code below don't have to care anymore. -- differences so the code below don't have to care anymore.
if geo.drawin then if geo.drawin then
bw, dgeo = geo.drawin.border_width, geo.drawin:geometry() bw, dgeo = geo.drawin._border_width, geo.drawin:geometry()
elseif geo.drawable and geo.drawable.get_wibox then elseif geo.drawable and geo.drawable.get_wibox then
bw = geo.drawable.get_wibox().border_width bw = geo.drawable.get_wibox().border_width
dgeo = geo.drawable.get_wibox():geometry() dgeo = geo.drawable.get_wibox():geometry()

View File

@ -538,6 +538,12 @@ crules._execute = function(_, c, props, callbacks)
props.keys = props.keys or keys props.keys = props.keys or keys
props.buttons = props.buttons or btns props.buttons = props.buttons or btns
-- Border width will also cause geometry related properties to fail
if props.border_width then
c.border_width = type(props.border_width) == "function" and
props.border_width(c, props) or props.border_width
end
-- This has to be done first, as it will impact geometry related props. -- This has to be done first, as it will impact geometry related props.
if props.titlebars_enabled and (type(props.titlebars_enabled) ~= "function" if props.titlebars_enabled and (type(props.titlebars_enabled) ~= "function"
or props.titlebars_enabled(c,props)) then or props.titlebars_enabled(c,props)) then
@ -545,12 +551,6 @@ crules._execute = function(_, c, props, callbacks)
c._request_titlebars_called = true c._request_titlebars_called = true
end end
-- Border width will also cause geometry related properties to fail
if props.border_width then
c.border_width = type(props.border_width) == "function" and
props.border_width(c, props) or props.border_width
end
-- Size hints will be re-applied when setting width/height unless it is -- Size hints will be re-applied when setting width/height unless it is
-- disabled first -- disabled first
if props.size_hints_honor ~= nil then if props.size_hints_honor ~= nil then

View File

@ -694,7 +694,7 @@ function tooltip.new(args)
or beautiful.bg_focus or "#ffcb60" or beautiful.bg_focus or "#ffcb60"
local border_width = args.border_width or beautiful.tooltip_border_width or 0 local border_width = args.border_width or beautiful.tooltip_border_width or 0
local border_color = args.border_color or beautiful.tooltip_border_color local border_color = args.border_color or beautiful.tooltip_border_color
or beautiful.border_normal or "#ffcb60" or beautiful.border_color_normal or "#ffcb60"
-- Set wibox default properties -- Set wibox default properties
self.wibox_properties = { self.wibox_properties = {

View File

@ -131,7 +131,7 @@ local function parse_cell_options(cell, args)
elseif prop == 'border_width' then elseif prop == 'border_width' then
default = beautiful.border_width or 0 default = beautiful.border_width or 0
elseif prop == 'border_color' then elseif prop == 'border_color' then
default = beautiful.border_normal or beautiful.fg_normal default = beautiful.border_color_normal or beautiful.fg_normal
end end
-- Get default -- Get default

View File

@ -132,23 +132,12 @@ local active_font
-- @beautiful beautiful.useless_gap -- @beautiful beautiful.useless_gap
-- @param[opt=0] number -- @param[opt=0] number
--- The client border width. --- The fallback border width.
-- @beautiful beautiful.border_width -- @beautiful beautiful.border_width
-- @param number -- @param number
--- The default clients border color. --- The fallback border color.
-- Note that only solid colors are supported. -- @beautiful beautiful.border_color
-- @beautiful beautiful.border_normal
-- @param color
--- The focused client border color.
-- Note that only solid colors are supported.
-- @beautiful beautiful.border_focus
-- @param color
--- The marked clients border color.
-- Note that only solid colors are supported.
-- @beautiful beautiful.border_marked
-- @param color -- @param color
--- The wallpaper path. --- The wallpaper path.

View File

@ -630,7 +630,7 @@ end
-- @string[opt=`beautiful.notification_fg` or `beautiful.fg_focus` or `'#ffffff'`] args.fg Foreground color. -- @string[opt=`beautiful.notification_fg` or `beautiful.fg_focus` or `'#ffffff'`] args.fg Foreground color.
-- @string[opt=`beautiful.notification_fg` or `beautiful.bg_focus` or `'#535d6c'`] args.bg Background color. -- @string[opt=`beautiful.notification_fg` or `beautiful.bg_focus` or `'#535d6c'`] args.bg Background color.
-- @int[opt=`beautiful.notification_border_width` or 1] args.border_width Border width. -- @int[opt=`beautiful.notification_border_width` or 1] args.border_width Border width.
-- @string[opt=`beautiful.notification_border_color` or `beautiful.border_focus` or `'#535d6c'`] args.border_color Border color. -- @string[opt=`beautiful.notification_border_color` or `beautiful.border_color_active` or `'#535d6c'`] args.border_color Border color.
-- @tparam[opt=`beautiful.notification_shape`] gears.shape args.shape Widget shape. -- @tparam[opt=`beautiful.notification_shape`] gears.shape args.shape Widget shape.
-- @tparam[opt=`beautiful.notification_opacity`] gears.opacity args.opacity Widget opacity. -- @tparam[opt=`beautiful.notification_opacity`] gears.opacity args.opacity Widget opacity.
-- @tparam[opt=`beautiful.notification_margin`] gears.margin args.margin Widget margin. -- @tparam[opt=`beautiful.notification_margin`] gears.margin args.margin Widget margin.

View File

@ -777,7 +777,7 @@ end
-- @string[opt=`beautiful.notification_fg` or `beautiful.bg_focus` or `'#535d6c'`] args.bg Background color. -- @string[opt=`beautiful.notification_fg` or `beautiful.bg_focus` or `'#535d6c'`] args.bg Background color.
-- @int[opt=`beautiful.notification_border_width` or 1] args.border_width Border width. -- @int[opt=`beautiful.notification_border_width` or 1] args.border_width Border width.
-- @string[opt=`beautiful.notification_border_color` or -- @string[opt=`beautiful.notification_border_color` or
-- `beautiful.border_focus` or `'#535d6c'`] args.border_color Border color. -- `beautiful.border_color_active` or `'#535d6c'`] args.border_color Border color.
-- @tparam[opt=`beautiful.notification_shape`] gears.shape args.shape Widget shape. -- @tparam[opt=`beautiful.notification_shape`] gears.shape args.shape Widget shape.
-- @tparam[opt=`beautiful.notification_opacity`] gears.opacity args.opacity Widget opacity. -- @tparam[opt=`beautiful.notification_opacity`] gears.opacity args.opacity Widget opacity.
-- @tparam[opt=`beautiful.notification_margin`] gears.margin args.margin Widget margin. -- @tparam[opt=`beautiful.notification_margin`] gears.margin args.margin Widget margin.

View File

@ -221,7 +221,20 @@ function wibox:get_children_by_id(name)
return {} return {}
end end
for _, k in pairs{ "struts", "geometry", "get_xproperty", "set_xproperty" } do -- Proxy those properties to decorate their accessors with an extra flag to
-- define when they are set by the user. This allows to "manage" the value of
-- those properties internally until they are manually overridden.
for _, prop in ipairs { "border_width", "border_color", "opacity" } do
wibox["get_"..prop] = function(self)
return self["_"..prop]
end
wibox["set_"..prop] = function(self, value)
self._private["_user_"..prop] = true
self["_"..prop] = value
end
end
for _, k in ipairs{ "struts", "geometry", "get_xproperty", "set_xproperty" } do
wibox[k] = function(self, ...) wibox[k] = function(self, ...)
return self.drawin[k](self.drawin, ...) return self.drawin[k](self.drawin, ...)
end end
@ -362,6 +375,14 @@ local function new(args)
ret.shape = args.shape ret.shape = args.shape
end end
if args.border_width then
ret.border_width = args.border_width
end
if args.border_color then
ret.border_color = args.border_color
end
if args.input_passthrough then if args.input_passthrough then
ret.input_passthrough = args.input_passthrough ret.input_passthrough = args.input_passthrough
end end

View File

@ -568,20 +568,19 @@
* The client border width. * The client border width.
* @property border_width * @property border_width
* @param integer * @param integer
* @propemits false false
* @see request::border
*/ */
/** /**
* The client border color. * The client border color.
* *
* **Signal:**
*
* * *property::border\_color*
*
* @see gears.color
*
* @property border_color * @property border_color
* @param pattern Any string, gradients and patterns will be converted to a * @param color Any string, gradients and patterns will be converted to a
* cairo pattern. * cairo pattern.
* @propemits false false
* @see request::border
* @see gears.color
*/ */
/** /**
@ -593,6 +592,8 @@
* *
* @property urgent * @property urgent
* @param boolean * @param boolean
* @propemits false false
* @see request::border
*/ */
/** /**
@ -619,6 +620,8 @@
* *
* @property opacity * @property opacity
* @param number Between 0 (transparent) to 1 (opaque) * @param number Between 0 (transparent) to 1 (opaque)
* @propemits false false
* @see request::border
*/ */
/** /**
@ -673,6 +676,8 @@
* *
* @property maximized * @property maximized
* @param boolean * @param boolean
* @propemits false false
* @see request::border
*/ */
/** /**
@ -976,27 +981,6 @@
* @see client.geometry * @see client.geometry
*/ */
/**
* The border color when the client is focused.
*
* @beautiful beautiful.border_focus
* @param string
*/
/**
* The border color when the client is not focused.
*
* @beautiful beautiful.border_normal
* @param string
*/
/**
* The client border width.
*
* @beautiful beautiful.border_width
* @param integer
*/
/** Return client struts (reserved space at the edge of the screen). /** Return client struts (reserved space at the edge of the screen).
* *
* @param struts A table with new strut values, or none. * @param struts A table with new strut values, or none.
@ -4095,4 +4079,6 @@ client_class_setup(lua_State *L)
/* @DOC_cobject_COMMON@ */ /* @DOC_cobject_COMMON@ */
/* @DOC_client_theme_COMMON@ */
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -530,15 +530,15 @@ window_class_setup(lua_State *L)
NULL, NULL,
(lua_class_propfunc_t) luaA_window_get_window, (lua_class_propfunc_t) luaA_window_get_window,
NULL); NULL);
luaA_class_add_property(&window_class, "opacity", luaA_class_add_property(&window_class, "_opacity",
(lua_class_propfunc_t) luaA_window_set_opacity, (lua_class_propfunc_t) luaA_window_set_opacity,
(lua_class_propfunc_t) luaA_window_get_opacity, (lua_class_propfunc_t) luaA_window_get_opacity,
(lua_class_propfunc_t) luaA_window_set_opacity); (lua_class_propfunc_t) luaA_window_set_opacity);
luaA_class_add_property(&window_class, "border_color", luaA_class_add_property(&window_class, "_border_color",
(lua_class_propfunc_t) luaA_window_set_border_color, (lua_class_propfunc_t) luaA_window_set_border_color,
(lua_class_propfunc_t) luaA_window_get_border_color, (lua_class_propfunc_t) luaA_window_get_border_color,
(lua_class_propfunc_t) luaA_window_set_border_color); (lua_class_propfunc_t) luaA_window_set_border_color);
luaA_class_add_property(&window_class, "border_width", luaA_class_add_property(&window_class, "_border_width",
(lua_class_propfunc_t) luaA_window_set_border_width, (lua_class_propfunc_t) luaA_window_set_border_width,
(lua_class_propfunc_t) luaA_window_get_border_width, (lua_class_propfunc_t) luaA_window_get_border_width,
(lua_class_propfunc_t) luaA_window_set_border_width); (lua_class_propfunc_t) luaA_window_set_border_width);

View File

@ -70,7 +70,7 @@ function client.gen_fake(args)
ret.type = "normal" ret.type = "normal"
ret.valid = true ret.valid = true
ret.size_hints = {} ret.size_hints = {}
ret.border_width = 1 ret._border_width = 1
ret.icon_sizes = {{16,16}} ret.icon_sizes = {{16,16}}
ret.name = "Example Client" ret.name = "Example Client"
ret._private._struts = { top = 0, right = 0, left = 0, bottom = 0 } ret._private._struts = { top = 0, right = 0, left = 0, bottom = 0 }

View File

@ -15,7 +15,7 @@ local function new_drawin(_, args)
ret.y=0 ret.y=0
ret.width=1 ret.width=1
ret.height=1 ret.height=1
ret.border_width=0 ret._border_width=0
ret.ontop = false ret.ontop = false
ret.below = false ret.below = false
ret.above = false ret.above = false

View File

@ -1,6 +1,4 @@
local awful = require("awful") local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local test_client = require("_client") local test_client = require("_client")
local runner = require("_runner") local runner = require("_runner")
@ -14,8 +12,9 @@ end
local tests = {} local tests = {}
local tb_height = gears.math.round(beautiful.get_font_height() * 1.5) -- Set it to something different than the default to make sure it doesn't change
local border_width = beautiful.border_width -- due to some request::border.
local border_width = 3
local class = "test-awful-placement" local class = "test-awful-placement"
local rule = { local rule = {
@ -24,6 +23,7 @@ local rule = {
}, },
properties = { properties = {
floating = true, floating = true,
border_width = border_width,
placement = awful.placement.no_overlap + awful.placement.no_offscreen placement = awful.placement.no_overlap + awful.placement.no_offscreen
} }
} }
@ -40,7 +40,7 @@ end
local function default_test(c, geometry) local function default_test(c, geometry)
check_geometry(c, geometry.expected_x, geometry.expected_y, check_geometry(c, geometry.expected_x, geometry.expected_y,
geometry.expected_width or geometry.width, geometry.expected_width or geometry.width,
geometry.expected_height or (geometry.height + tb_height)) geometry.expected_height or (geometry.height))
return true return true
end end
@ -242,7 +242,7 @@ for _, tag_num in ipairs{1, 2, 3} do
width = wa.width - 50, width = wa.width - 50,
height = 100, height = 100,
expected_x = wa.x, expected_x = wa.x,
expected_y = wa.y + tb_height + 2*border_width + 100 expected_y = wa.y + 2*border_width + 100
} }
end end
} }
@ -258,7 +258,7 @@ for _, tag_num in ipairs{1, 2, 3} do
width = wa.width - 10, width = wa.width - 10,
height = wa.height - 50, height = wa.height - 50,
expected_x = wa.x, expected_x = wa.x,
expected_y = wa.y + 50 - 2*border_width - tb_height expected_y = (wa.y + wa.height) - (wa.height - 50 + 2*border_width)
} }
end end
} }
@ -270,7 +270,7 @@ for _, tag_num in ipairs{1, 2, 3} do
return { return {
width = wa.width - 10, width = wa.width - 10,
height = wa.height - 50, height = wa.height - 50,
expected_x = wa.x + 10 - 2*border_width, expected_x = (wa.x + wa.width) - (wa.width - 10 + 2*border_width),
expected_y = wa.y expected_y = wa.y
} }
end end
@ -283,8 +283,8 @@ for _, tag_num in ipairs{1, 2, 3} do
return { return {
width = wa.width - 10, width = wa.width - 10,
height = wa.height - 50, height = wa.height - 50,
expected_x = wa.x + 10 - 2*border_width, expected_x = (wa.x + wa.width ) - (wa.width - 10 + 2*border_width),
expected_y = wa.y + 50 - 2*border_width - tb_height expected_y = (wa.y + wa.height) - (wa.height - 50 + 2*border_width)
} }
end end
} }

View File

@ -1,6 +1,5 @@
local awful = require("awful") local awful = require("awful")
local gears = require("gears") local gears = require("gears")
local beautiful = require("beautiful")
local test_client = require("_client") local test_client = require("_client")
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1) local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
@ -10,7 +9,6 @@ local message_printed = false
-- Magic table to store tests -- Magic table to store tests
local tests = {} local tests = {}
local tb_height = gears.math.round(beautiful.get_font_height() * 1.5)
-- local border_width = beautiful.border_width -- local border_width = beautiful.border_width
-- Detect "request::manage" race conditions -- Detect "request::manage" race conditions
@ -74,7 +72,7 @@ test_rule {
-- The size should not have changed -- The size should not have changed
local geo = get_client_by_class(class):geometry() local geo = get_client_by_class(class):geometry()
assert(geo.width == 100 and geo.height == 100+tb_height) assert(geo.width == 100 and geo.height == 100)
return true return true
end end

View File

@ -5,8 +5,8 @@ local runner = require("_runner")
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
beautiful.border_normal = "#0000ff" beautiful.border_color_normal = "#0000ff"
beautiful.border_focus = "#00ff00" beautiful.border_color_active = "#00ff00"
client.connect_signal("focus", function(c) client.connect_signal("focus", function(c)
c.border_color = "#ff0000" c.border_color = "#ff0000"

View File

@ -17,7 +17,7 @@ awful.rules.rules = {
y = 0, y = 0,
width = 100, width = 100,
height = 100, height = 100,
border_color = beautiful.border_normal border_color = beautiful.border_color_normal
} }
} }
} }
@ -103,7 +103,7 @@ local steps = {
function() function()
local c = client.get()[1] local c = client.get()[1]
assert(not pcall(function() c.border_width = -2000 end)) assert(not pcall(function() c._border_width = -2000 end))
assert(c.border_width==0) assert(c.border_width==0)
c.border_width = 125 c.border_width = 125

View File

@ -26,8 +26,8 @@ theme.fg_minimize = "#ffffff"
theme.useless_gap = dpi(0) theme.useless_gap = dpi(0)
theme.border_width = dpi(1) theme.border_width = dpi(1)
theme.border_normal = "#000000" theme.border_color_normal = "#000000"
theme.border_focus = "#535d6c" theme.border_color_active = "#535d6c"
theme.border_marked = "#91231c" theme.border_marked = "#91231c"
-- There are other variable sets -- There are other variable sets

View File

@ -120,9 +120,9 @@ theme.fg_minimize = mix(theme.wibar_fg, theme.wibar_bg, 0.9)
theme.bg_systray = theme.wibar_bg theme.bg_systray = theme.wibar_bg
theme.border_normal = theme.gtk.wm_border_unfocused_color theme.border_color_normal = theme.gtk.wm_border_unfocused_color
theme.border_focus = theme.gtk.wm_border_focused_color theme.border_color_active = theme.gtk.wm_border_focused_color
theme.border_marked = theme.gtk.success_color theme.border_color_marked = theme.gtk.success_color
theme.border_width = dpi(theme.gtk.button_border_width or 1) theme.border_width = dpi(theme.gtk.button_border_width or 1)
theme.border_radius = theme.gtk.button_border_radius theme.border_radius = theme.gtk.button_border_radius

View File

@ -27,9 +27,9 @@ theme.fg_minimize = "#2e3436"
theme.useless_gap = dpi(0) theme.useless_gap = dpi(0)
theme.border_width = dpi(2) theme.border_width = dpi(2)
theme.border_normal = "#dae3e0" theme.border_color_normal = "#dae3e0"
theme.border_focus = "#729fcf" theme.border_color_active = "#729fcf"
theme.border_marked = "#eeeeec" theme.border_color_marked = "#eeeeec"
-- IMAGES -- IMAGES
theme.layout_fairh = themes_path .. "sky/layouts/fairh.png" theme.layout_fairh = themes_path .. "sky/layouts/fairh.png"

View File

@ -29,9 +29,9 @@ theme.fg_minimize = theme.bg_normal
theme.useless_gap = dpi(3) theme.useless_gap = dpi(3)
theme.border_width = dpi(2) theme.border_width = dpi(2)
theme.border_normal = xrdb.color0 theme.border_color_normal = xrdb.color0
theme.border_focus = theme.bg_focus theme.border_color_active = theme.bg_focus
theme.border_marked = xrdb.color10 theme.border_color_marked = xrdb.color10
-- There are other variable sets -- There are other variable sets
-- overriding the default one when -- overriding the default one when

View File

@ -27,9 +27,9 @@ theme.bg_systray = theme.bg_normal
-- {{{ Borders -- {{{ Borders
theme.useless_gap = dpi(0) theme.useless_gap = dpi(0)
theme.border_width = dpi(2) theme.border_width = dpi(2)
theme.border_normal = "#3F3F3F" theme.border_color_normal = "#3F3F3F"
theme.border_focus = "#6F6F6F" theme.border_color_active = "#6F6F6F"
theme.border_marked = "#CC9393" theme.border_color_marked = "#CC9393"
-- }}} -- }}}
-- {{{ Titlebars -- {{{ Titlebars