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:
Emmanuel Lepage Vallee 2016-01-09 04:25:46 -05:00
parent 7c0425fdfd
commit 6e85a46093
9 changed files with 34 additions and 36 deletions

View File

@ -94,7 +94,9 @@ local function setup_drawable(data)
end)
data:connect_signal("item::removed",function(_,item,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)
end
internal.layout:emit_signal("widget::updated")
end)
data:connect_signal("item::appended",function(_,item)

View File

@ -210,6 +210,13 @@ local function new_item(data,args)
-- Listen to signals
item:connect_signal("state::changed",function()
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)
-- Add support for long hover and press

View File

@ -85,7 +85,7 @@ local function create_item(item,data,args)
bg.fit = function(box, context, w,h)
-- args.y = data.height-h-data.margins.top --TODO dead code?
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
return wibox.widget.background.fit(box,context, w,h)
end

View File

@ -10,7 +10,8 @@ local module = {
BOTTOM = 2,
RIGHT = 2,
LEFT = 4
}
},
need_full_repaint = true
}
local function create_path(cr,x,height,padding)

View File

@ -15,7 +15,8 @@ local module = {
BOTTOM = 2,
RIGHT = 20,
LEFT = 3
}
},
need_full_repaint = true
}
local hcode = {"#7777ff","#ff7777","#77ff77","#77ffff","#ffff77"}

View File

@ -12,7 +12,8 @@ local module = {
BOTTOM = 0,
RIGHT = 0,
LEFT = 0
}
},
need_full_repaint = true
}
local function prefix_draw(self, context, cr, width, height)

View File

@ -12,7 +12,8 @@ local module = {
BOTTOM = 0,
RIGHT = 0,
LEFT = 0
}
},
need_full_repaint = true
}
local function prefix_draw(self, context, cr, width, height)

View File

@ -133,9 +133,9 @@ function module:setup_item(data,item,args)
end
--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
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
end
@ -144,8 +144,15 @@ local function new(data)
base = require( "radical.base" )
end
local l = wibox.layout.fixed.horizontal()
l.fit = function(self,context,w,h,force_values) --TODO use the context instead of extra argument
local result,r2 = wibox.layout.fixed:get_preferred_size(self,context, force_values and w, force_values and h)
l._fit = l.fit
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
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
@ -155,6 +162,7 @@ local function new(data)
data:emit_signal("layout_size",w,h)
return w,h
end
l.fit = new_fit
l.add = function(l,item)
return wibox.layout.fixed.add(l,item.widget)
end

View File

@ -52,38 +52,16 @@ function module:setup_key_hooks(data)
end
--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
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
end
return w, item.height or h
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)
local text_w = item._internal.text_w
@ -113,8 +91,7 @@ function module:setup_item(data,item,args)
end
--Create the background
local item_layout = item.layout or data.item_layout or horizontal_item_layout
item.widget = item_layout(item,data,args)--wibox.widget.background()
cache_pixmap(item)
item.widget = item_layout(item,data,args)
--Event handling
if data.select_on == base.event.HOVER then