Correctly forward menu item geometry

This commit is contained in:
Emmanuel Lepage Vallee 2014-07-27 23:49:14 -04:00
parent 16b87239c1
commit 52fdd8a1f2
7 changed files with 40 additions and 18 deletions

View File

@ -70,6 +70,7 @@ The current valid types are:
* **Embed:** Menus in menus. This can be used as subsections in large menus
* **Bar:** A compact horizontal wibox widget
* **Flexbar:** An extensible horizontal wibox widget
* **Dock:** OS X like dock with auto hiding and rectangular items
### Menu style
@ -285,14 +286,14 @@ Most item_layout also repackage the default widget signals. It usually does the
same as using the `buttonX` menu attributes, but is preferrable in some scenarios
like when a modifier is applied.
| Name | Description | Arguments |
| ----------------- | ----------------------------- | ------------------------ |
| button::press | A button press | menu,item,button_id,mods |
| button::release | A button release | menu,item,button_id,mods |
| mouse::enter | When the mouse enter | menu,item |
| mouse::leave | When the mouse leave | menu,item |
| long::hover | The mouse is hover 1.5 sec | menu,item |
| long::press | The mouse is pressed 1.5 sec | menu,item |
| Name | Description | Arguments |
| ----------------- | ----------------------------- | ---------------------------- |
| button::press | A button press | menu,item,button_id,mods,geo |
| button::release | A button release | menu,item,button_id,mods,geo |
| mouse::enter | When the mouse enter | menu,item |
| mouse::leave | When the mouse leave | menu,item |
| long::hover | The mouse is hover 1.5 sec | menu,item |
| long::press | The mouse is pressed 1.5 sec | menu,item |
`mods` is an array with the applied modifier as **key**. If the value is `nil`,
then the modifier is not present. Usual modifiers are `Control`, `Shift`, `mod1`

View File

@ -113,9 +113,9 @@ local function setup_buttons(data,item,args)
end
end
item:connect_signal("button::release",function(_m,_i,button_id,mods)
item:connect_signal("button::release",function(_m,_i,button_id,mods,geo)
if #mods == 0 and buttons[button_id] then
buttons[button_id](_m,_i,mods)
buttons[button_id](_m,_i,mods,geo)
end
end)
end

View File

@ -243,9 +243,9 @@ local function setup_buttons(data,item,args)
end
end
item:connect_signal("button::release",function(_m,_i,button_id,mods)
item:connect_signal("button::release",function(_m,_i,button_id,mods,geo)
if #mods == 0 and buttons[button_id] then
buttons[button_id](_m,_i,mods)
buttons[button_id](_m,_i,mods,geo)
end
end)
end

View File

@ -168,6 +168,7 @@ end
-- Create the auto hiding wibox
local function get_wibox(data, screen)
if data._internal.w then return data._internal.w end
data:emit_signal("dock::request")
local dir,rotation = get_direction(data)
local geo_src = data._internal._geom_vals or data
@ -225,6 +226,13 @@ local function create_placeholder(data)
if not data._internal._geom_vals then return end
local w,h,internal = data._internal._geom_vals.width,data._internal._geom_vals.height,data._internal
if h == 0 then
h = 1
end
if w == 0 then
w = 1
end
-- Resize the placeholder
internal.placeholder[hw_invert] = (hw_invert == "height") and h or w
align_wibox(internal.placeholder,dir,screen)
@ -283,6 +291,20 @@ local function setup_item(data,item,args)
local f = (data._internal.layout.setup_item) or (layout.vertical.setup_item)
f(data._internal.layout,data,item,args)
-- Buttons
local buttons = {}
for i=1,10 do
if args["button"..i] then
buttons[i] = args["button"..i]
end
end
item:connect_signal("button::release",function(_m,_i,button_id,mods,geo)
if #mods == 0 and buttons[button_id] then
buttons[button_id](_m,_i,mods,geo)
end
end)
-- Tooltip
item.widget:set_tooltip(item.tooltip)
end

View File

@ -77,9 +77,9 @@ local function setup_item(data,item,args)
end
end
item:connect_signal("button::release",function(_m,_i,button_id,mods)
item:connect_signal("button::release",function(_m,_i,button_id,mods,geo)
if #mods == 0 and buttons[button_id] then
buttons[button_id](_m,_i,mods)
buttons[button_id](_m,_i,mods,geo)
end
end)

View File

@ -124,14 +124,14 @@ function module.setup_event(data,item,widget)
data:emit_signal("button::press",item,id,mods_invert)
item:emit_signal("button::press",data,id,mods_invert)
end)
widget:connect_signal("button::release",function(_,__,___,id,mod)
widget:connect_signal("button::release",function(wdg,__,___,id,mod,geo)
local mods_invert = {}
for k,v in ipairs(mod) do
mods_invert[v] = i
end
item.state[4] = nil
data:emit_signal("button::release",item,id,mods_invert)
item:emit_signal("button::release",data,id,mods_invert)
data:emit_signal("button::release",item,id,mods_invert,geo)
item:emit_signal("button::release",data,id,mods_invert,geo)
end)
widget:connect_signal("mouse::enter",function(b,t)
data:emit_signal("mouse::enter",item)

View File

@ -255,7 +255,6 @@ local function new(data)
if not data.visible then return 1,1 end
local result,r2 = wibox.layout.fixed.fit(a1,99999,99999)
local w,h = compute_geo(data)
print("MIT",w,h)
data:emit_signal("layout_size",w,h)
return w,h
end