Fix more issues for 3.6. The arrow_prefix now work using a new hack
The "hack" force the full redraw of the menu. This is what 3.5 did anyway, but of course is not correct. The new layout system allow widgets to have a larger fit and it should cascade by itself. This is not yet used by radical. This commit also fix some mistake made during the initial port. My whole config now load mostly correctly. Some 3.5 era bugs even fixed themselves! It is still slower for some reasons and have many errors left, but it "look" ok.
This commit is contained in:
parent
7c0425fdfd
commit
6e85a46093
2
bar.lua
2
bar.lua
|
@ -94,7 +94,9 @@ local function setup_drawable(data)
|
||||||
end)
|
end)
|
||||||
data:connect_signal("item::removed",function(_,item,old_idx)
|
data:connect_signal("item::removed",function(_,item,old_idx)
|
||||||
table.remove(internal.layout.widgets,old_idx)
|
table.remove(internal.layout.widgets,old_idx)
|
||||||
|
if internal.layout._emit_updated then
|
||||||
item.widget:disconnect_signal("widget::updated", internal.layout._emit_updated)
|
item.widget:disconnect_signal("widget::updated", internal.layout._emit_updated)
|
||||||
|
end
|
||||||
internal.layout:emit_signal("widget::updated")
|
internal.layout:emit_signal("widget::updated")
|
||||||
end)
|
end)
|
||||||
data:connect_signal("item::appended",function(_,item)
|
data:connect_signal("item::appended",function(_,item)
|
||||||
|
|
|
@ -210,6 +210,13 @@ local function new_item(data,args)
|
||||||
-- Listen to signals
|
-- Listen to signals
|
||||||
item:connect_signal("state::changed",function()
|
item:connect_signal("state::changed",function()
|
||||||
item:style()
|
item:style()
|
||||||
|
|
||||||
|
-- Some item.style need full widget repaint
|
||||||
|
if item.style.need_full_repaint then
|
||||||
|
--TODO HACK HACK HACK for the repaint, this is really, really stupid
|
||||||
|
data._internal.layout:emit_signal("widget::redraw_needed")
|
||||||
|
--TODO END HACK
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Add support for long hover and press
|
-- Add support for long hover and press
|
||||||
|
|
|
@ -85,7 +85,7 @@ local function create_item(item,data,args)
|
||||||
bg.fit = function(box, context, w,h)
|
bg.fit = function(box, context, w,h)
|
||||||
-- args.y = data.height-h-data.margins.top --TODO dead code?
|
-- args.y = data.height-h-data.margins.top --TODO dead code?
|
||||||
if data._internal.layout.item_fit then
|
if data._internal.layout.item_fit then
|
||||||
return data._internal.layout.item_fit(data,item,box,contextw,h)
|
return data._internal.layout.item_fit(data,item,box,context, w, h)
|
||||||
else
|
else
|
||||||
return wibox.widget.background.fit(box,context, w,h)
|
return wibox.widget.background.fit(box,context, w,h)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,8 @@ local module = {
|
||||||
BOTTOM = 2,
|
BOTTOM = 2,
|
||||||
RIGHT = 2,
|
RIGHT = 2,
|
||||||
LEFT = 4
|
LEFT = 4
|
||||||
}
|
},
|
||||||
|
need_full_repaint = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local function create_path(cr,x,height,padding)
|
local function create_path(cr,x,height,padding)
|
||||||
|
|
|
@ -15,7 +15,8 @@ local module = {
|
||||||
BOTTOM = 2,
|
BOTTOM = 2,
|
||||||
RIGHT = 20,
|
RIGHT = 20,
|
||||||
LEFT = 3
|
LEFT = 3
|
||||||
}
|
},
|
||||||
|
need_full_repaint = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local hcode = {"#7777ff","#ff7777","#77ff77","#77ffff","#ffff77"}
|
local hcode = {"#7777ff","#ff7777","#77ff77","#77ffff","#ffff77"}
|
||||||
|
|
|
@ -12,7 +12,8 @@ local module = {
|
||||||
BOTTOM = 0,
|
BOTTOM = 0,
|
||||||
RIGHT = 0,
|
RIGHT = 0,
|
||||||
LEFT = 0
|
LEFT = 0
|
||||||
}
|
},
|
||||||
|
need_full_repaint = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local function prefix_draw(self, context, cr, width, height)
|
local function prefix_draw(self, context, cr, width, height)
|
||||||
|
|
|
@ -12,7 +12,8 @@ local module = {
|
||||||
BOTTOM = 0,
|
BOTTOM = 0,
|
||||||
RIGHT = 0,
|
RIGHT = 0,
|
||||||
LEFT = 0
|
LEFT = 0
|
||||||
}
|
},
|
||||||
|
need_full_repaint = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local function prefix_draw(self, context, cr, width, height)
|
local function prefix_draw(self, context, cr, width, height)
|
||||||
|
|
|
@ -133,9 +133,9 @@ function module:setup_item(data,item,args)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Get preferred item geometry
|
--Get preferred item geometry
|
||||||
local function item_fit(data,item,...)
|
local function item_fit(data,item,self, content, width, height)
|
||||||
if not data.visible then return 1,1 end
|
if not data.visible then return 1,1 end
|
||||||
local w, h = item._private_data._fit(...)
|
local w, h = item._private_data._fit(self,content,width,height) --TODO port to new context API
|
||||||
return data.item_width or 70, item._private_data.height or h
|
return data.item_width or 70, item._private_data.height or h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,8 +144,15 @@ local function new(data)
|
||||||
base = require( "radical.base" )
|
base = require( "radical.base" )
|
||||||
end
|
end
|
||||||
local l = wibox.layout.fixed.horizontal()
|
local l = wibox.layout.fixed.horizontal()
|
||||||
l.fit = function(self,context,w,h,force_values) --TODO use the context instead of extra argument
|
l._fit = l.fit
|
||||||
local result,r2 = wibox.layout.fixed:get_preferred_size(self,context, force_values and w, force_values and h)
|
local new_fit
|
||||||
|
new_fit = function(self,context,w,h,force_values) --TODO use the context instead of extra argument
|
||||||
|
|
||||||
|
-- Get the original fit, the function need to be replaced to avoir a stack overflow
|
||||||
|
l.fit = l._fit
|
||||||
|
local result,r2 = self:get_preferred_size(context, force_values and w, force_values and h)
|
||||||
|
l.fit = new_fit
|
||||||
|
|
||||||
local w,h
|
local w,h
|
||||||
if data.auto_resize and data._internal.largest_item_h then
|
if data.auto_resize and data._internal.largest_item_h then
|
||||||
w,h = data.rowcount*(data.item_width or data.default_width),data._internal.largest_item_h_v > data.item_height and data._internal.largest_item_h_v or data.item_height
|
w,h = data.rowcount*(data.item_width or data.default_width),data._internal.largest_item_h_v > data.item_height and data._internal.largest_item_h_v or data.item_height
|
||||||
|
@ -155,6 +162,7 @@ local function new(data)
|
||||||
data:emit_signal("layout_size",w,h)
|
data:emit_signal("layout_size",w,h)
|
||||||
return w,h
|
return w,h
|
||||||
end
|
end
|
||||||
|
l.fit = new_fit
|
||||||
l.add = function(l,item)
|
l.add = function(l,item)
|
||||||
return wibox.layout.fixed.add(l,item.widget)
|
return wibox.layout.fixed.add(l,item.widget)
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,38 +52,16 @@ function module:setup_key_hooks(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Get preferred item geometry
|
--Get preferred item geometry
|
||||||
local function item_fit(data,item,self,width,height)
|
local function item_fit(data,item,self,context, width,height)
|
||||||
local w, h = 0,0--item._internal.cache_w or 1,item._internal.cache_h or 1
|
local w, h = 0,0--item._internal.cache_w or 1,item._internal.cache_h or 1
|
||||||
if data.visible then
|
if data.visible then
|
||||||
w, h = item._private_data._fit({},self,{},width,height)
|
w, h = item._private_data._fit({},self,context,width,height)
|
||||||
item._internal.pix_cache = {} --Clear the pimap cache
|
item._internal.pix_cache = {} --Clear the pimap cache
|
||||||
end
|
end
|
||||||
|
|
||||||
return w, item.height or h
|
return w, item.height or h
|
||||||
end
|
end
|
||||||
|
|
||||||
-- As of July 2013, LGI is too slow to redraw big menus at ok speed
|
|
||||||
-- This do a pixmap cache to allow pre-rendering
|
|
||||||
local function cache_pixmap(item)
|
|
||||||
item._internal.pix_cache = {}
|
|
||||||
item.widget._draw = item.widget.draw
|
|
||||||
item.widget.draw = function(self, context, cr, width, height)
|
|
||||||
if not w.visible or item._hidden then return end
|
|
||||||
if item._internal.pix_cache[10*width+7*height+(item.selected and 8888 or 999)] then
|
|
||||||
cr:set_source_surface(item._internal.pix_cache[10*width+7*height+(item.selected and 8888 or 999)])
|
|
||||||
cr:paint()
|
|
||||||
else
|
|
||||||
local img5 = cairo.ImageSurface.create(cairo.Format.ARGB32, width, height)
|
|
||||||
local cr5 = cairo.Context(img5)
|
|
||||||
item.widget._draw(self, context, cr5, width, height)
|
|
||||||
cr:set_source_surface(img5)
|
|
||||||
cr:paint()
|
|
||||||
item._internal.pix_cache[10*width+7*height+(item.selected and 8888 or 999)] = img5
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function module:setup_text(item,data,text_w)
|
function module:setup_text(item,data,text_w)
|
||||||
local text_w = item._internal.text_w
|
local text_w = item._internal.text_w
|
||||||
|
|
||||||
|
@ -113,8 +91,7 @@ function module:setup_item(data,item,args)
|
||||||
end
|
end
|
||||||
--Create the background
|
--Create the background
|
||||||
local item_layout = item.layout or data.item_layout or horizontal_item_layout
|
local item_layout = item.layout or data.item_layout or horizontal_item_layout
|
||||||
item.widget = item_layout(item,data,args)--wibox.widget.background()
|
item.widget = item_layout(item,data,args)
|
||||||
cache_pixmap(item)
|
|
||||||
|
|
||||||
--Event handling
|
--Event handling
|
||||||
if data.select_on == base.event.HOVER then
|
if data.select_on == base.event.HOVER then
|
||||||
|
|
Loading…
Reference in New Issue