2008-11-14 16:16:09 +01:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 13:02:39 +02:00
|
|
|
--- Mouse module for awful
|
|
|
|
--
|
2008-11-14 16:16:09 +01:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008 Julien Danjou
|
2016-04-25 04:09:14 +02:00
|
|
|
-- @module mouse
|
2008-11-14 16:16:09 +01:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
2019-10-20 07:52:38 +02:00
|
|
|
local floating = require("awful.layout.suit.floating")
|
2016-04-21 07:51:34 +02:00
|
|
|
local aplace = require("awful.placement")
|
2017-03-15 06:08:40 +01:00
|
|
|
local gdebug = require("gears.debug")
|
2008-12-03 23:03:44 +01:00
|
|
|
local type = type
|
2008-11-14 16:16:09 +01:00
|
|
|
local ipairs = ipairs
|
|
|
|
local capi =
|
|
|
|
{
|
2009-04-03 17:15:14 +02:00
|
|
|
root = root,
|
2008-11-14 16:16:09 +01:00
|
|
|
mouse = mouse,
|
|
|
|
screen = screen,
|
|
|
|
client = client,
|
|
|
|
mousegrabber = mousegrabber,
|
|
|
|
}
|
|
|
|
|
2016-04-21 10:03:20 +02:00
|
|
|
local mouse = {
|
2016-04-22 07:59:02 +02:00
|
|
|
snap = require("awful.mouse.snap"),
|
2019-10-20 08:09:51 +02:00
|
|
|
client = require("awful.mouse.client"),
|
|
|
|
resize = require("awful.mouse.resize"),
|
2016-04-28 05:20:00 +02:00
|
|
|
drag_to_tag = require("awful.mouse.drag_to_tag")
|
2016-04-21 10:03:20 +02:00
|
|
|
}
|
2008-11-14 16:16:09 +01:00
|
|
|
|
2016-04-25 03:00:38 +02:00
|
|
|
mouse.object = {}
|
2012-06-14 01:33:27 +02:00
|
|
|
mouse.wibox = {}
|
2008-11-14 16:16:09 +01:00
|
|
|
|
2020-03-22 08:32:45 +01:00
|
|
|
--- The default distance before snapping clients together.
|
2020-08-10 08:34:28 +02:00
|
|
|
--
|
|
|
|
-- @DOC_screen_client_snap_EXAMPLE@
|
|
|
|
--
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @tfield integer awful.mouse.snap.default_distance
|
2016-04-22 08:16:59 +02:00
|
|
|
-- @tparam[opt=8] integer default_distance
|
|
|
|
-- @see awful.mouse.snap
|
|
|
|
|
2020-03-22 08:32:45 +01:00
|
|
|
--- The default distance before activating screen edge snap.
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @tfield integer awful.mouse.snap.aerosnap_distance
|
2021-06-16 21:42:30 +02:00
|
|
|
-- @tparam[opt=16] integer aerosnap_distance
|
2020-03-22 08:32:45 +01:00
|
|
|
-- @see awful.mouse.snap
|
|
|
|
|
2016-04-28 03:16:20 +02:00
|
|
|
--- Enable screen edges snapping.
|
2020-08-10 08:34:28 +02:00
|
|
|
--
|
|
|
|
--@DOC_awful_placement_aero_snap_EXAMPLE@
|
|
|
|
--
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @tfield[opt=true] boolean awful.mouse.snap.edge_enabled
|
2021-06-16 21:42:30 +02:00
|
|
|
-- @tparam boolean edge_enabled
|
2016-04-28 03:16:20 +02:00
|
|
|
|
|
|
|
--- Enable client to client snapping.
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @tfield[opt=true] boolean awful.mouse.snap.client_enabled
|
2021-06-16 21:42:30 +02:00
|
|
|
-- @tparam boolean client_enabled
|
2016-04-28 03:16:20 +02:00
|
|
|
|
|
|
|
--- Enable changing tag when a client is dragged to the edge of the screen.
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @tfield[opt=false] boolean awful.mouse.drag_to_tag.enabled
|
2021-06-16 21:42:30 +02:00
|
|
|
-- @tparam boolean enabled
|
2016-04-28 03:16:20 +02:00
|
|
|
|
2016-04-23 08:14:01 +02:00
|
|
|
--- The snap outline background color.
|
|
|
|
-- @beautiful beautiful.snap_bg
|
|
|
|
-- @tparam color|string|gradient|pattern color
|
|
|
|
|
|
|
|
--- The snap outline width.
|
|
|
|
-- @beautiful beautiful.snap_border_width
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @tparam integer snap_border_width
|
2016-04-23 08:14:01 +02:00
|
|
|
|
2016-04-28 03:16:20 +02:00
|
|
|
--- The snap outline shape.
|
2016-04-23 08:14:01 +02:00
|
|
|
-- @beautiful beautiful.snap_shape
|
|
|
|
-- @tparam function shape A `gears.shape` compatible function
|
|
|
|
|
2020-03-22 08:32:45 +01:00
|
|
|
--- The gap between snapped clients.
|
2018-04-22 08:02:52 +02:00
|
|
|
-- @beautiful beautiful.snapper_gap
|
2020-03-22 08:32:45 +01:00
|
|
|
-- @tparam[opt=0] number snapper_gap
|
2018-04-22 08:02:52 +02:00
|
|
|
|
2021-12-14 01:21:44 +01:00
|
|
|
--- The resize cursor name.
|
|
|
|
-- @beautiful beautiful.cursor_mouse_resize
|
2021-12-17 22:46:08 +01:00
|
|
|
-- @tparam[opt="cross"] string cursor
|
2021-12-14 01:21:44 +01:00
|
|
|
|
|
|
|
--- The move cursor name.
|
|
|
|
-- @beautiful beautiful.cursor_mouse_move
|
2021-12-17 22:46:08 +01:00
|
|
|
-- @tparam[opt="fleur"] string cursor
|
2021-12-14 01:21:44 +01:00
|
|
|
|
2009-02-15 20:12:45 +01:00
|
|
|
--- Get the client object under the pointer.
|
2016-04-25 04:09:14 +02:00
|
|
|
-- @deprecated awful.mouse.client_under_pointer
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @treturn client|nil The client object under the pointer, if one can be found.
|
2016-04-25 04:33:44 +02:00
|
|
|
-- @see current_client
|
2012-06-14 01:33:27 +02:00
|
|
|
function mouse.client_under_pointer()
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use mouse.current_client instead of awful.mouse.client_under_pointer()", {deprecated_in=4})
|
2008-12-03 23:03:44 +01:00
|
|
|
|
2016-04-25 04:33:44 +02:00
|
|
|
return mouse.object.get_current_client()
|
2008-12-03 23:03:44 +01:00
|
|
|
end
|
|
|
|
|
2016-04-30 07:47:41 +02:00
|
|
|
-- Older layouts implement their own mousegrabber.
|
|
|
|
-- @tparam client c The client
|
|
|
|
-- @tparam table args Additional arguments
|
|
|
|
-- @treturn boolean This return false when the resize need to be aborted
|
|
|
|
mouse.resize.add_enter_callback(function(c, args) --luacheck: no unused args
|
|
|
|
if c.floating then return end
|
|
|
|
|
|
|
|
local l = c.screen.selected_tag and c.screen.selected_tag.layout or nil
|
2019-10-20 07:52:38 +02:00
|
|
|
if l == floating then return end
|
2016-04-30 07:47:41 +02:00
|
|
|
|
2019-10-20 07:52:38 +02:00
|
|
|
if l.mouse_resize_handler then
|
2016-04-30 07:47:41 +02:00
|
|
|
capi.mousegrabber.stop()
|
|
|
|
|
|
|
|
local geo, corner = aplace.closest_corner(capi.mouse, {parent=c})
|
|
|
|
|
|
|
|
l.mouse_resize_handler(c, corner, geo.x, geo.y)
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end, "mouse.resize")
|
|
|
|
|
2016-04-25 04:33:44 +02:00
|
|
|
--- Get the client currently under the mouse cursor.
|
|
|
|
-- @property current_client
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] client|nil current_client
|
|
|
|
-- @propertytype nil When the mouse cursor is not over a client.
|
2016-04-25 04:33:44 +02:00
|
|
|
|
|
|
|
function mouse.object.get_current_client()
|
|
|
|
local obj = capi.mouse.object_under_pointer()
|
|
|
|
if type(obj) == "client" then
|
|
|
|
return obj
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the wibox currently under the mouse cursor.
|
|
|
|
-- @property current_wibox
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] wibox|nil current_wibox
|
|
|
|
-- @propertytype nil When the mouse cursor is not over a wibox.
|
2016-04-25 04:33:44 +02:00
|
|
|
|
|
|
|
function mouse.object.get_current_wibox()
|
|
|
|
local obj = capi.mouse.object_under_pointer()
|
2016-05-03 06:01:55 +02:00
|
|
|
if type(obj) == "drawin" and obj.get_wibox then
|
|
|
|
return obj:get_wibox()
|
2016-04-25 04:33:44 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-03 06:32:58 +02:00
|
|
|
--- Get the widgets currently under the mouse cursor.
|
|
|
|
--
|
|
|
|
-- @property current_widgets
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] nil|table current_widgets
|
|
|
|
-- @tablerowtype table The list of `wibox.widget`s. The first element is the biggest
|
|
|
|
-- container while the last is the topmost widget.
|
|
|
|
-- @propertytype nil When the mouse cursor is not over any widget.
|
2016-05-03 06:32:58 +02:00
|
|
|
|
|
|
|
function mouse.object.get_current_widgets()
|
|
|
|
local w = mouse.object.get_current_wibox()
|
|
|
|
if w then
|
|
|
|
local geo, coords = w:geometry(), capi.mouse:coords()
|
2020-02-16 01:27:33 +01:00
|
|
|
local bw = w.border_width
|
2016-05-03 06:32:58 +02:00
|
|
|
|
2020-02-16 01:27:33 +01:00
|
|
|
local list = w:find_widgets(coords.x - geo.x - bw, coords.y - geo.y - bw)
|
2016-05-03 06:32:58 +02:00
|
|
|
|
|
|
|
local ret = {}
|
|
|
|
|
|
|
|
for k, v in ipairs(list) do
|
|
|
|
ret[k] = v.widget
|
|
|
|
end
|
|
|
|
|
|
|
|
return ret, list
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-03 07:21:39 +02:00
|
|
|
--- Get the topmost widget currently under the mouse cursor.
|
|
|
|
-- @property current_widget
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] widget|nil current_widget
|
|
|
|
-- @propertytype nil When the mouse cursor is not over a widget.
|
2016-05-29 04:08:47 +02:00
|
|
|
-- @see current_widget_geometry
|
2016-05-03 07:21:39 +02:00
|
|
|
|
|
|
|
function mouse.object.get_current_widget()
|
|
|
|
local wdgs, geos = mouse.object.get_current_widgets()
|
|
|
|
|
|
|
|
if wdgs then
|
|
|
|
return wdgs[#wdgs], geos[#geos]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-29 04:08:47 +02:00
|
|
|
--- Get the current widget geometry.
|
|
|
|
-- @property current_widget_geometry
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] table|nil current_widget_geometry
|
|
|
|
-- @tparam number current_widget_geometry.x
|
|
|
|
-- @tparam number current_widget_geometry.y
|
|
|
|
-- @tparam number current_widget_geometry.width
|
|
|
|
-- @tparam number current_widget_geometry.height
|
|
|
|
-- @propertytype nil When there is no current widgets.
|
|
|
|
-- @propertytype table
|
2016-05-29 04:08:47 +02:00
|
|
|
-- @see current_widget
|
|
|
|
|
|
|
|
function mouse.object.get_current_widget_geometry()
|
|
|
|
local _, ret = mouse.object.get_current_widget()
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the current widget geometries.
|
|
|
|
-- @property current_widget_geometries
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] table|nil current_widget_geometries A list of geometry tables.
|
|
|
|
-- @propertytype nil When there is no widgets.
|
|
|
|
-- @propertytype table A list of geometry tables.
|
|
|
|
-- @tablerowkey x integer
|
|
|
|
-- @tablerowkey y integer
|
|
|
|
-- @tablerowkey width integer
|
|
|
|
-- @tablerowkey height integer
|
2016-05-29 04:08:47 +02:00
|
|
|
-- @see current_widgets
|
|
|
|
|
|
|
|
function mouse.object.get_current_widget_geometries()
|
|
|
|
local _, ret = mouse.object.get_current_widgets()
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2019-10-20 08:09:51 +02:00
|
|
|
--- Move the wibox under the cursor.
|
|
|
|
-- @staticfct awful.mouse.wibox.move
|
2020-01-26 01:24:00 +01:00
|
|
|
-- @tparam wibox w The wibox to move, or none to use that under the pointer
|
2022-07-05 10:37:14 +02:00
|
|
|
-- @noreturn
|
2020-01-26 01:24:00 +01:00
|
|
|
-- @request wibox geometry mouse.move granted Requests to move the wibox.
|
2019-10-20 08:09:51 +02:00
|
|
|
function mouse.wibox.move(w)
|
|
|
|
w = w or mouse.current_wibox
|
|
|
|
if not w then return end
|
|
|
|
|
|
|
|
if not w
|
|
|
|
or w.type == "desktop"
|
|
|
|
or w.type == "splash"
|
|
|
|
or w.type == "dock" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Compute the offset
|
|
|
|
local coords = capi.mouse.coords()
|
|
|
|
local geo = aplace.centered(capi.mouse,{parent=w, pretend=true})
|
|
|
|
|
|
|
|
local offset = {
|
|
|
|
x = geo.x - coords.x,
|
|
|
|
y = geo.y - coords.y,
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse.resize(w, "mouse.move", {
|
|
|
|
placement = aplace.under_mouse,
|
|
|
|
offset = offset
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2016-04-25 04:51:36 +02:00
|
|
|
--- True if the left mouse button is pressed.
|
|
|
|
-- @property is_left_mouse_button_pressed
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=false] boolean is_left_mouse_button_pressed
|
2016-04-25 04:51:36 +02:00
|
|
|
|
|
|
|
--- True if the right mouse button is pressed.
|
|
|
|
-- @property is_right_mouse_button_pressed
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=false] boolean is_right_mouse_button_pressed
|
2016-04-25 04:51:36 +02:00
|
|
|
|
|
|
|
--- True if the middle mouse button is pressed.
|
|
|
|
-- @property is_middle_mouse_button_pressed
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=false] boolean is_middle_mouse_button_pressed
|
2016-04-25 04:51:36 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
--- Add an `awful.button` based mousebinding to the global set.
|
|
|
|
--
|
|
|
|
-- A **global** mousebinding is one which is always present, even when there is
|
|
|
|
-- no focused client. If your intent is too add a mousebinding which acts on
|
|
|
|
-- the focused client do **not** use this.
|
|
|
|
--
|
|
|
|
-- @staticfct awful.mouse.append_global_mousebinding
|
|
|
|
-- @tparam awful.button button The button object.
|
2022-07-05 10:37:14 +02:00
|
|
|
-- @noreturn
|
2018-12-29 02:47:06 +01:00
|
|
|
-- @see awful.button
|
|
|
|
|
|
|
|
function mouse.append_global_mousebinding(button)
|
|
|
|
capi.root._append_button(button)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Add multiple `awful.button` based mousebindings to the global set.
|
|
|
|
--
|
|
|
|
-- A **global** mousebinding is one which is always present, even when there is
|
|
|
|
-- no focused client. If your intent is too add a mousebinding which acts on
|
|
|
|
-- the focused client do **not** use this
|
|
|
|
--
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @staticfct awful.mouse.append_global_mousebindings
|
2018-12-29 02:47:06 +01:00
|
|
|
-- @tparam table buttons A table of `awful.button` objects. Optionally, it can have
|
|
|
|
-- a `group` entry. If set, the `group` property will be set on all `awful.buttons`
|
|
|
|
-- objects.
|
2022-07-05 10:37:14 +02:00
|
|
|
-- @noreturn
|
2018-12-29 02:47:06 +01:00
|
|
|
-- @see awful.button
|
|
|
|
|
|
|
|
function mouse.append_global_mousebindings(buttons)
|
|
|
|
local g = buttons.group
|
|
|
|
buttons.group = nil
|
|
|
|
|
|
|
|
-- Avoid the boilerplate. If the user is adding multiple buttons at once, then
|
|
|
|
-- they are probably related.
|
|
|
|
if g then
|
|
|
|
for _, k in ipairs(buttons) do
|
|
|
|
k.group = g
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
capi.root._append_buttons(buttons)
|
|
|
|
buttons.group = g
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Remove a mousebinding from the global set.
|
|
|
|
--
|
|
|
|
-- @staticfct awful.mouse.remove_global_mousebinding
|
|
|
|
-- @tparam awful.button button The button object.
|
2022-07-05 10:37:14 +02:00
|
|
|
-- @noreturn
|
2018-12-29 02:47:06 +01:00
|
|
|
-- @see awful.button
|
|
|
|
|
|
|
|
function mouse.remove_global_mousebinding(button)
|
|
|
|
capi.root._remove_button(button)
|
|
|
|
end
|
|
|
|
|
2019-10-16 08:13:45 +02:00
|
|
|
local default_buttons = {}
|
|
|
|
|
|
|
|
--- Add an `awful.button` to the default client buttons.
|
|
|
|
--
|
|
|
|
-- @staticfct awful.mouse.append_client_mousebinding
|
|
|
|
-- @tparam awful.button button The button.
|
2022-07-05 10:37:14 +02:00
|
|
|
-- @noreturn
|
2019-10-16 08:13:45 +02:00
|
|
|
-- @emits client_mousebinding::added
|
|
|
|
-- @emitstparam client_mousebinding::added awful.button button The button.
|
|
|
|
-- @see awful.button
|
|
|
|
-- @see awful.keyboard.append_client_keybinding
|
|
|
|
|
|
|
|
function mouse.append_client_mousebinding(button)
|
|
|
|
table.insert(default_buttons, button)
|
2019-10-16 08:27:00 +02:00
|
|
|
|
|
|
|
for _, c in ipairs(capi.client.get(nil, false)) do
|
|
|
|
c:append_mousebinding(button)
|
|
|
|
end
|
|
|
|
|
2019-10-16 08:13:45 +02:00
|
|
|
capi.client.emit_signal("client_mousebinding::added", button)
|
|
|
|
end
|
|
|
|
|
2019-10-16 08:27:00 +02:00
|
|
|
--- Add a `awful.button`s to the default client buttons.
|
|
|
|
--
|
|
|
|
-- @staticfct awful.mouse.append_client_mousebindings
|
|
|
|
-- @tparam table buttons A table containing `awful.button` objects.
|
2022-07-05 10:37:14 +02:00
|
|
|
-- @noreturn
|
2019-10-16 08:27:00 +02:00
|
|
|
-- @see awful.button
|
|
|
|
-- @see awful.keyboard.append_client_keybinding
|
|
|
|
-- @see awful.mouse.append_client_mousebinding
|
|
|
|
-- @see awful.keyboard.append_client_keybindings
|
|
|
|
|
|
|
|
function mouse.append_client_mousebindings(buttons)
|
|
|
|
for _, button in ipairs(buttons) do
|
|
|
|
mouse.append_client_mousebinding(button)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-16 08:47:16 +02:00
|
|
|
--- Remove a mousebinding from the default client buttons.
|
|
|
|
--
|
|
|
|
-- @staticfct awful.mouse.remove_client_mousebinding
|
|
|
|
-- @tparam awful.button button The button.
|
|
|
|
-- @treturn boolean True if the button was removed and false if it wasn't found.
|
|
|
|
-- @see awful.keyboard.append_client_keybinding
|
|
|
|
|
|
|
|
function mouse.remove_client_mousebinding(button)
|
|
|
|
for k, v in ipairs(default_buttons) do
|
|
|
|
if button == v then
|
|
|
|
table.remove(default_buttons, k)
|
|
|
|
|
|
|
|
for _, c in ipairs(capi.client.get(nil, false)) do
|
|
|
|
c:remove_mousebinding(button)
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2021-05-31 08:55:07 +02:00
|
|
|
for k, b in ipairs {"left", "middle", "right"} do
|
2016-04-25 04:51:36 +02:00
|
|
|
mouse.object["is_".. b .."_mouse_button_pressed"] = function()
|
2021-05-31 08:55:07 +02:00
|
|
|
return capi.mouse.coords().buttons[k]
|
2016-04-25 04:51:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-04-03 17:15:14 +02:00
|
|
|
-- Set the cursor at startup
|
|
|
|
capi.root.cursor("left_ptr")
|
|
|
|
|
2016-04-25 03:00:38 +02:00
|
|
|
-- Implement the custom property handler
|
|
|
|
local props = {}
|
|
|
|
|
|
|
|
capi.mouse.set_newindex_miss_handler(function(_,key,value)
|
|
|
|
if mouse.object["set_"..key] then
|
|
|
|
mouse.object["set_"..key](value)
|
2016-06-04 15:51:58 +02:00
|
|
|
elseif not mouse.object["get_"..key] then
|
2016-04-25 03:00:38 +02:00
|
|
|
props[key] = value
|
2016-06-04 15:51:58 +02:00
|
|
|
else
|
|
|
|
-- If there is a getter, but no setter, then the property is read-only
|
|
|
|
error("Cannot set '" .. tostring(key) .. " because it is read-only")
|
2016-04-25 03:00:38 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
capi.mouse.set_index_miss_handler(function(_,key)
|
|
|
|
if mouse.object["get_"..key] then
|
|
|
|
return mouse.object["get_"..key]()
|
2021-05-31 08:55:07 +02:00
|
|
|
elseif mouse.object[key] and key:sub(1, 3) == "is_" then
|
|
|
|
return mouse.object[key]()
|
|
|
|
elseif mouse.object[key] then
|
|
|
|
return mouse.object[key]
|
2016-04-25 03:00:38 +02:00
|
|
|
else
|
|
|
|
return props[key]
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2016-04-25 04:21:35 +02:00
|
|
|
--- Get or set the mouse coords.
|
|
|
|
--
|
|
|
|
--@DOC_awful_mouse_coords_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @tparam[opt=nil] table coords_table None or a table with x and y keys as mouse
|
|
|
|
-- coordinates.
|
|
|
|
-- @tparam[opt=nil] integer coords_table.x The mouse horizontal position
|
|
|
|
-- @tparam[opt=nil] integer coords_table.y The mouse vertical position
|
|
|
|
-- @tparam[opt=false] boolean silent Disable mouse::enter or mouse::leave events that
|
|
|
|
-- could be triggered by the pointer when moving.
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @treturn table The coords. It contains the `x`, `y` and `buttons` keys.
|
|
|
|
-- `buttons` contains the button number as key and a boolean as value (if it is
|
|
|
|
-- pressed).
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct mouse.coords
|
2021-12-14 01:21:44 +01:00
|
|
|
-- @see is_left_mouse_button_pressed
|
|
|
|
-- @see is_right_mouse_button_pressed
|
|
|
|
-- @see is_middle_mouse_button_pressed
|
2016-04-25 04:21:35 +02:00
|
|
|
|
2019-10-16 08:49:05 +02:00
|
|
|
capi.client.connect_signal("scanning", function()
|
|
|
|
capi.client.emit_signal("request::default_mousebindings", "startup")
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Private function to be used by `ruled.client`.
|
|
|
|
function mouse._get_client_mousebindings()
|
|
|
|
return default_buttons
|
|
|
|
end
|
|
|
|
|
2019-10-20 08:09:51 +02:00
|
|
|
mouse.resize_handler = mouse.resize._resize_handler
|
|
|
|
|
2012-06-14 01:33:27 +02:00
|
|
|
return mouse
|
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|