Add support for "geometry" argument for mouse events and awful.button

This commit is contained in:
Emmanuel Lepage Vallee 2013-03-22 00:52:02 -04:00 committed by Uli Schlachter
parent e0a163cba0
commit d5a3669e96
2 changed files with 10 additions and 14 deletions

View File

@ -58,7 +58,7 @@ end
function drawable:widget_at(widget, x, y, width, height)
local t = {
widget = widget,
x = x, y = y,
x = x, y = y,drawable = self,
width = width, height = height
}
table.insert(self._widget_geometries, t)
@ -140,7 +140,7 @@ end
local function emit_difference(name, list, skip)
local function in_table(table, val)
for k, v in pairs(table) do
if v == val then
if v.widget == val.widget then
return true
end
end
@ -149,7 +149,7 @@ local function emit_difference(name, list, skip)
for k, v in pairs(list) do
if not in_table(skip, v) then
v:emit_signal(name)
v.widget:emit_signal(name,v)
end
end
end
@ -166,17 +166,13 @@ local function handle_motion(_drawable, x, y)
-- Build a plain list of all widgets on that point
local widgets_list = _drawable:find_widgets(x, y)
local widgets = {}
for k, v in pairs(widgets_list) do
widgets[#widgets + 1] = v.widget
end
-- First, "leave" all widgets that were left
emit_difference("mouse::leave", _drawable._widgets_under_mouse, widgets)
emit_difference("mouse::leave", _drawable._widgets_under_mouse, widgets_list)
-- Then enter some widgets
emit_difference("mouse::enter", widgets, _drawable._widgets_under_mouse)
emit_difference("mouse::enter", widgets_list, _drawable._widgets_under_mouse)
_drawable._widgets_under_mouse = widgets
_drawable._widgets_under_mouse = widgets_list
end
local function setup_signals(_drawable)
@ -243,13 +239,13 @@ function drawable.new(d, widget_arg)
ret._widgets_under_mouse = {}
local function button_signal(name)
d:connect_signal(name, function(d, x, y, ...)
d:connect_signal(name, function(d, x, y, button, modifiers)
local widgets = ret:find_widgets(x, y)
for k, v in pairs(widgets) do
-- Calculate x/y inside of the widget
local lx = x - v.x
local ly = y - v.y
v.widget:emit_signal(name, lx, ly, ...)
v.widget:emit_signal(name, lx, ly, button, modifiers,v)
end
end)
end

View File

@ -23,7 +23,7 @@ function base:buttons(_buttons)
end
--- Handle a button event on a widget. This is used internally.
function base.handle_button(event, widget, x, y, button, modifiers)
function base.handle_button(event, widget, x, y, button, modifiers, geometry)
local function is_any(mod)
return #mod == 1 and mod[1] == "Any"
end
@ -55,7 +55,7 @@ function base.handle_button(event, widget, x, y, button, modifiers)
-- Emit the signals
for k, v in pairs(matches) do
v:emit_signal(event)
v:emit_signal(event,geometry)
end
end