From 8a877bd4294716a82b627ef08e2b7ed23eeefc23 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 25 Jan 2020 20:10:24 -0500 Subject: [PATCH 1/6] tests: Mock `drawin` in the permission unit tests. --- spec/awful/permissions_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/awful/permissions_spec.lua b/spec/awful/permissions_spec.lua index fb58f3f9..ce13aabc 100644 --- a/spec/awful/permissions_spec.lua +++ b/spec/awful/permissions_spec.lua @@ -14,6 +14,13 @@ describe("awful.permissions.client_geometry_requests", function() _G.tag = { connect_signal = function() end, } + _G.awesome = { + connect_signal = function() end, + } + _G.drawin = { + set_index_miss_handler = function() end, + set_newindex_miss_handler = function() end + } local permissions = require("awful.permissions") From 5891783ba991baff7a54cee19e89755402da7059 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 25 Jan 2020 19:18:03 -0500 Subject: [PATCH 2/6] wibox: Do not overwrite `gears.object` methods. The next commit will all class level signals. The current design is used in widgets, but is a bad fit for wiboxes. They should behave more like client. In v5, setting methods on `wibox` directly will be deprecated. `wibox.object` is already supported. I don't think anyone really do that anyway and isn't documented. --- lib/wibox/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index 46f72d49..a5021d37 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -310,8 +310,9 @@ local function new(args) ret._drawable:_inform_visible(w.visible) end) + --TODO v5 deprecate this and use `wibox.object`. for k, v in pairs(wibox) do - if type(v) == "function" then + if (not rawget(ret, k)) and type(v) == "function" then ret[k] = v end end From 0c08bb430454b93f065e4a214ce9b686bab65bc5 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 25 Jan 2020 19:20:07 -0500 Subject: [PATCH 3/6] widget: Add class-level signal forwarding. Just like clients and other CAPI classes, it is now possible to connect to all instance signals. There was already a couple of `request::geometry`, but no way to forward them, so it was de-facto broken. --- lib/wibox/init.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index a5021d37..78285553 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -388,6 +388,9 @@ local function new(args) ret.input_passthrough = args.input_passthrough end + -- Make sure all signals bubble up + ret:_connect_everything(wibox.emit_signal) + return ret end @@ -409,6 +412,8 @@ object.properties(capi.drawin, { capi.drawin.object = wibox.object +object._setup_class_signals(wibox) + return setmetatable(wibox, wibox.mt) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 From 44301589c4d76c0c84d5f2896c0bf35d3e0a4248 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 25 Jan 2020 19:23:12 -0500 Subject: [PATCH 4/6] wibox: Connect the existing request::geometry signal to an handler. The signal has been implemented for years, but nothing was connected to it. --- lib/awful/permissions/init.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/awful/permissions/init.lua b/lib/awful/permissions/init.lua index 1a2fc3c0..c1baa0c5 100644 --- a/lib/awful/permissions/init.lua +++ b/lib/awful/permissions/init.lua @@ -18,6 +18,7 @@ local beautiful = require("beautiful") local alayout = require("awful.layout") local atag = require("awful.tag") local gdebug = require("gears.debug") +local wibox = require("wibox") local pcommon = require("awful.permissions._common") local permissions = { @@ -395,6 +396,20 @@ function permissions.geometry(c, context, hints) end end +--- Move and resize the wiboxes. +-- +-- This is the default geometry request handler. +-- +-- @signalhandler awful.permissions.wibox_geometry +-- @tparam wibox w The wibox. +-- @tparam string context The context +-- @tparam[opt={}] table hints The hints to pass to the handler +function permissions.wibox_geometry(w, context, hints) + if not pcommon.check(w, "wibox", "geometry", context) then return end + + w:geometry(hints) +end + --- Merge the 2 requests sent by clients wanting to be maximized. -- -- The X clients set 2 flags (atoms) when they want to be maximized. This caused @@ -712,6 +727,8 @@ client.connect_signal("property::hidden" , check_focus_delayed) client.connect_signal("property::minimized" , check_focus_delayed) client.connect_signal("property::sticky" , check_focus_delayed) +wibox.connect_signal("request::geometry" , permissions.wibox_geometry) + tag.connect_signal("property::selected", function (t) timer.delayed_call(check_focus_tag, t) end) From 973671b081cdf399f8d2eb4d89baa8aa9b436371 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 25 Jan 2020 19:24:00 -0500 Subject: [PATCH 5/6] doc: Document that awful.mouse.resize/move use the permission framework. --- lib/awful/mouse/init.lua | 3 ++- lib/awful/mouse/resize.lua | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/awful/mouse/init.lua b/lib/awful/mouse/init.lua index f4f526e9..9e1de712 100644 --- a/lib/awful/mouse/init.lua +++ b/lib/awful/mouse/init.lua @@ -177,7 +177,8 @@ end --- Move the wibox under the cursor. -- @staticfct awful.mouse.wibox.move ---@tparam wibox w The wibox to move, or none to use that under the pointer +-- @tparam wibox w The wibox to move, or none to use that under the pointer +-- @request wibox geometry mouse.move granted Requests to move the wibox. function mouse.wibox.move(w) w = w or mouse.current_wibox if not w then return end diff --git a/lib/awful/mouse/resize.lua b/lib/awful/mouse/resize.lua index 98981d33..ceb88350 100644 --- a/lib/awful/mouse/resize.lua +++ b/lib/awful/mouse/resize.lua @@ -103,6 +103,7 @@ end -- @tparam client client A client. -- @tparam[default=mouse.resize] string context The resizing context. -- @tparam[opt={}] table args A set of `awful.placement` arguments. +-- @request wibox geometry mouse.resize granted Requests to resize the wibox. local function handler(_, client, context, args) --luacheck: no unused_args args = args or {} context = context or "mouse.resize" From 68a6c978f544ae2cd7c93b3c3bc644629412184e Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 25 Jan 2020 19:27:18 -0500 Subject: [PATCH 6/6] doc: Document that wibox have class-level signals. --- lib/wibox/init.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index 78285553..d8e82ae1 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -399,6 +399,32 @@ end -- @param wibox -- @method draw +--- Connect a global signal on the wibox class. +-- +-- Functions connected to this signal source will be executed when any +-- wibox object emits the signal. +-- +-- It is also used for some generic wibox signals such as +-- `request::geometry`. +-- +-- @tparam string name The name of the signal +-- @tparam function func The function to attach +-- @staticfct wibox.connect_signal +-- @usage wibox.connect_signal("added", function(notif) +-- -- do something +-- end) + +--- Emit a wibox signal. +-- @tparam string name The signal name. +-- @param ... The signal callback arguments +-- @staticfct wibox.emit_signal + +--- Disconnect a signal from a source. +-- @tparam string name The name of the signal +-- @tparam function func The attached function +-- @staticfct wibox.disconnect_signal +-- @treturn boolean If the disconnection was successful + function wibox.mt:__call(...) return new(...) end