Make async menu faster
This may cause some visual artefacts, but is about 5 time faster than the old way.
This commit is contained in:
parent
14c420ac49
commit
f746a8b347
|
@ -3,6 +3,7 @@ local beautiful = require( "beautiful" )
|
||||||
local color = require( "gears.color" )
|
local color = require( "gears.color" )
|
||||||
local cairo = require( "lgi" ).cairo
|
local cairo = require( "lgi" ).cairo
|
||||||
local base = require( "radical.base" )
|
local base = require( "radical.base" )
|
||||||
|
local glib = require("lgi").GLib
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
margins = {
|
margins = {
|
||||||
|
@ -51,7 +52,7 @@ local function do_gen_menu_top(data, width, height, radius,padding,args)
|
||||||
return img
|
return img
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_direction(data,direction)
|
local function _set_direction(data,direction)
|
||||||
local geometry = (direction == "left" or direction == "right") and {width = data.wibox.height, height = data.wibox.width} or {height = data.wibox.height, width = data.wibox.width}
|
local geometry = (direction == "left" or direction == "right") and {width = data.wibox.height, height = data.wibox.width} or {height = data.wibox.height, width = data.wibox.width}
|
||||||
local top_clip_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,data.border_width,{bg=beautiful.fg_normal or "#0000ff",fg=data.bg or "#00ffff"})
|
local top_clip_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,data.border_width,{bg=beautiful.fg_normal or "#0000ff",fg=data.bg or "#00ffff"})
|
||||||
local top_bounding_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,0,{bg="#00000000",fg="#ffffffff"})
|
local top_bounding_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,0,{bg="#00000000",fg="#ffffffff"})
|
||||||
|
@ -70,6 +71,15 @@ local function set_direction(data,direction)
|
||||||
end
|
end
|
||||||
data.wibox.shape_bounding = top_bounding_surface._native
|
data.wibox.shape_bounding = top_bounding_surface._native
|
||||||
data.wibox:set_bg(cairo.Pattern.create_for_surface(top_clip_surface))
|
data.wibox:set_bg(cairo.Pattern.create_for_surface(top_clip_surface))
|
||||||
|
data._internal._need_direction_reload = false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Try to avoid useless repaint, this function is heavy
|
||||||
|
local function set_direction(data,direction)
|
||||||
|
if not data._internal._need_direction_reload then
|
||||||
|
glib.idle_add(glib.PRIORITY_HIGH_IDLE, function() _set_direction(data,direction) end)
|
||||||
|
data._internal._need_direction_reload = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw(data,args)
|
local function draw(data,args)
|
||||||
|
|
|
@ -20,7 +20,8 @@ local function draw(self, w, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fit(box, w, h)
|
local function fit(box, w, h)
|
||||||
return box.direction == module.VERTICAL and 5 or w,box.direction == module.VERTICAL and h or 5
|
local direction = box.direction or w > h and module.HORIZONTAL or module.VERTICAL
|
||||||
|
return direction == module.VERTICAL and 5 or w,direction == module.VERTICAL and h or 5
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new(menu,direction)
|
local function new(menu,direction)
|
||||||
|
|
Loading…
Reference in New Issue