From cf0a4b42b4025372ce8dab813129a7012b92468f Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 3 May 2016 00:32:58 -0400 Subject: [PATCH] mouse: Add `current_widgets` --- lib/awful/mouse/init.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/awful/mouse/init.lua b/lib/awful/mouse/init.lua index 3e01a24e..7875d494 100644 --- a/lib/awful/mouse/init.lua +++ b/lib/awful/mouse/init.lua @@ -304,6 +304,35 @@ end function mouse.object.set_current_wibox() end +--- Get the widgets currently under the mouse cursor. +-- +-- @property current_widgets +-- @tparam nil|table list The widget list +-- @treturn table The list of widgets.The first element is the biggest +-- container while the last is the topmost widget. The table contains *x*, *y*, +-- *width*, *height* and *widget*. +-- @treturn table The list of geometries. +-- @see wibox.find_widgets + +function mouse.object.get_current_widgets() + local w = mouse.object.get_current_wibox() + if w then + local geo, coords = w:geometry(), capi.mouse:coords() + + local list = w:find_widgets(coords.x - geo.x, coords.y - geo.y) + + local ret = {} + + for k, v in ipairs(list) do + ret[k] = v.widget + end + + return ret, list + end +end + +function mouse.object.set_current_widgets() end + --- True if the left mouse button is pressed. -- @property is_left_mouse_button_pressed -- @param boolean