Diplay tag layout content when doing ctrl+alt+arrow
This commit is contained in:
parent
b843d3b2a7
commit
4a18826d04
10
focus.lua
10
focus.lua
|
@ -166,10 +166,20 @@ function module.display(mod,key,event,direction,is_swap,is_max)
|
||||||
for i,cl in ipairs(cltbl) do
|
for i,cl in ipairs(cltbl) do
|
||||||
geomtbl[i] = cl:geometry()
|
geomtbl[i] = cl:geometry()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Sometime, there is no focussed clients
|
||||||
|
if not c then
|
||||||
|
c = geomtbl[1] or cltbl[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If there is still no accessible clients, there is nothing to display
|
||||||
|
if not c then return end
|
||||||
|
|
||||||
display_wiboxes(cltbl,geomtbl,client.floating.get(c) or alayout.get(c.screen) == alayout.suit.floating,is_swap,c)
|
display_wiboxes(cltbl,geomtbl,client.floating.get(c) or alayout.get(c.screen) == alayout.suit.floating,is_swap,c)
|
||||||
end
|
end
|
||||||
|
|
||||||
function module._quit()
|
function module._quit()
|
||||||
|
if not wiboxes then return end
|
||||||
for k,v in ipairs({"left","right","up","down","center"}) do
|
for k,v in ipairs({"left","right","up","down","center"}) do
|
||||||
wiboxes[v].visible = false
|
wiboxes[v].visible = false
|
||||||
end
|
end
|
||||||
|
|
11
init.lua
11
init.lua
|
@ -6,6 +6,7 @@ local module = {
|
||||||
_focus = require( "collision.focus" ),
|
_focus = require( "collision.focus" ),
|
||||||
_resize = require( "collision.resize"),
|
_resize = require( "collision.resize"),
|
||||||
_max = require( "collision.max" ),
|
_max = require( "collision.max" ),
|
||||||
|
_screen = require( "collision.screen"),
|
||||||
}
|
}
|
||||||
|
|
||||||
local current_mode = "focus"
|
local current_mode = "focus"
|
||||||
|
@ -16,6 +17,7 @@ local event_callback = {
|
||||||
resize = module._resize.resize ,
|
resize = module._resize.resize ,
|
||||||
max = module._max.change_focus ,
|
max = module._max.change_focus ,
|
||||||
tag = module._max.change_tag ,
|
tag = module._max.change_tag ,
|
||||||
|
screen = module._screen.reload ,
|
||||||
}
|
}
|
||||||
|
|
||||||
local start_callback = {
|
local start_callback = {
|
||||||
|
@ -24,6 +26,7 @@ local start_callback = {
|
||||||
resize = module._resize.display ,
|
resize = module._resize.display ,
|
||||||
max = module._max.display_clients,
|
max = module._max.display_clients,
|
||||||
tag = module._max.display_tags ,
|
tag = module._max.display_tags ,
|
||||||
|
screen = module._screen.display ,
|
||||||
}
|
}
|
||||||
|
|
||||||
local exit_callback = {
|
local exit_callback = {
|
||||||
|
@ -32,6 +35,7 @@ local exit_callback = {
|
||||||
resize = module._resize.hide ,
|
resize = module._resize.hide ,
|
||||||
max = module._max.hide ,
|
max = module._max.hide ,
|
||||||
tag = module._max.hide ,
|
tag = module._max.hide ,
|
||||||
|
screen = module._screen.hide ,
|
||||||
}
|
}
|
||||||
|
|
||||||
local keys = {--Normal Xephyr G510 alt G510
|
local keys = {--Normal Xephyr G510 alt G510
|
||||||
|
@ -112,6 +116,12 @@ function module.tag(direction,c,max)
|
||||||
start_loop(false,max)
|
start_loop(false,max)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function module.screen(direction)
|
||||||
|
current_mode = "screen"
|
||||||
|
module._screen.display()
|
||||||
|
start_loop(false,max)
|
||||||
|
end
|
||||||
|
|
||||||
local function new(k)
|
local function new(k)
|
||||||
-- Replace the keys array. The new one has to have a valid mapping
|
-- Replace the keys array. The new one has to have a valid mapping
|
||||||
keys = k or keys
|
keys = k or keys
|
||||||
|
@ -124,6 +134,7 @@ local function new(k)
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Shift" }, key_nane, function () module.move (k ) end)
|
aw[#aw+1] = awful.key({ "Mod4", "Shift" }, key_nane, function () module.move (k ) end)
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Shift", "Control" }, key_nane, function () module.move (k,nil,true) end)
|
aw[#aw+1] = awful.key({ "Mod4", "Shift", "Control" }, key_nane, function () module.move (k,nil,true) end)
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Control" }, key_nane, function () module.focus (k,nil,true) end)
|
aw[#aw+1] = awful.key({ "Mod4", "Control" }, key_nane, function () module.focus (k,nil,true) end)
|
||||||
|
aw[#aw+1] = awful.key({ "Mod4", "Mod1" , "Control" }, key_nane, function () module.screen(k ) end)
|
||||||
if k == "left" or k =="right" then -- Conflict with my text editor, so I say no
|
if k == "left" or k =="right" then -- Conflict with my text editor, so I say no
|
||||||
aw[#aw+1] = awful.key({ "Mod1", "Control" }, key_nane, function () module.tag (k,nil,true) end)
|
aw[#aw+1] = awful.key({ "Mod1", "Control" }, key_nane, function () module.tag (k,nil,true) end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
-- This helper module help retro-generate the clients layout from awful
|
||||||
|
-- this is a giant hack and doesn't even always work and require upstream
|
||||||
|
-- patches
|
||||||
|
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local ipairs,math = ipairs,math
|
||||||
|
local awful = require("awful")
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
local color = require( "gears.color")
|
||||||
|
local util = require( "collision.util" )
|
||||||
|
local capi = { screen = screen, client=client }
|
||||||
|
|
||||||
|
local module = {}
|
||||||
|
local margin = 2
|
||||||
|
local radius = 4
|
||||||
|
|
||||||
|
-- Emulate a client using meta table magic
|
||||||
|
local function gen_cls(c,results)
|
||||||
|
local ret = setmetatable({},{__index = function(t,i)
|
||||||
|
local ret2 = c[i]
|
||||||
|
if type(ret2) == "function" then
|
||||||
|
if i == "geometry" then
|
||||||
|
return function(self,...)
|
||||||
|
if #{...} > 0 then
|
||||||
|
local geom = ({...})[1]
|
||||||
|
-- Make a copy as the original will be changed
|
||||||
|
results[c] = awful.util.table.join(({...})[1],{})
|
||||||
|
return geom
|
||||||
|
end
|
||||||
|
return c:geometry()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return function(self,...) return ret2(c,...) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ret2
|
||||||
|
end})
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.get_geometry(tag)
|
||||||
|
local cls,results = {},setmetatable({},{__mode="k"})
|
||||||
|
local s = awful.tag.getscreen(tag)
|
||||||
|
local focus,focus_wrap = capi.client.focus,nil
|
||||||
|
for k,v in ipairs (tag:clients()) do
|
||||||
|
cls[#cls+1] = gen_cls(v,results)
|
||||||
|
if v == focus then
|
||||||
|
focus_wrap = cls[#cls]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- The magnifier layout require a focussed client
|
||||||
|
-- there wont be any as that layout is not selected
|
||||||
|
-- take one at random or (TODO) use stack data
|
||||||
|
if not focus_wrap then
|
||||||
|
focus_wrap = cls[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
local param = {
|
||||||
|
tag = tag,
|
||||||
|
screen = 1,
|
||||||
|
clients = cls,
|
||||||
|
focus = focus_wrap,
|
||||||
|
workarea = capi.screen[s or 1].workarea
|
||||||
|
}
|
||||||
|
|
||||||
|
local l = awful.tag.getproperty(tag,"layout")
|
||||||
|
l.arrange(param)
|
||||||
|
|
||||||
|
return results
|
||||||
|
end
|
||||||
|
|
||||||
|
local function draw_round_rect(cr,x,y,w,h)
|
||||||
|
cr:save()
|
||||||
|
cr:translate(x,y)
|
||||||
|
cr:new_path()
|
||||||
|
-- cr:move_to(0,radius+1)
|
||||||
|
-- cr:line_to(0,radius)
|
||||||
|
cr:arc(radius,radius,radius,math.pi,3*(math.pi/2))
|
||||||
|
cr:move_to(radius,0)
|
||||||
|
cr:line_to(w-2*radius,0)
|
||||||
|
cr:arc(w-radius,radius,radius,3*(math.pi/2),math.pi*2)
|
||||||
|
cr:move_to(w,radius)
|
||||||
|
cr:line_to(w,h-radius)
|
||||||
|
cr:arc(w-radius,h-radius,radius,math.pi*2,math.pi/2)
|
||||||
|
cr:move_to(w-radius,h)
|
||||||
|
cr:line_to(radius,h)
|
||||||
|
cr:arc(radius,h-radius,radius,math.pi/2,math.pi)
|
||||||
|
cr:move_to(0,h-radius)
|
||||||
|
cr:line_to(0,radius)
|
||||||
|
cr:move_to(0,radius)
|
||||||
|
cr:close_path()
|
||||||
|
cr:stroke_preserve()
|
||||||
|
-- cr:set_source_rgba(1,0,0,1)
|
||||||
|
-- cr:fill() --BUG
|
||||||
|
cr:restore()
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.draw(tag,cr,width,height)
|
||||||
|
local worked = false
|
||||||
|
local l = module.get_geometry(tag)
|
||||||
|
local s = awful.tag.getscreen(tag)
|
||||||
|
local scr_geo = capi.screen[s or 1].workarea
|
||||||
|
local ratio = height/scr_geo.height
|
||||||
|
local w_stretch = width/(scr_geo.width*ratio)
|
||||||
|
local r,g,b = util.get_rgb()
|
||||||
|
cr:set_source_rgba(r,g,b,0.7)
|
||||||
|
cr:set_line_width(3)
|
||||||
|
for c,geom in pairs(l) do
|
||||||
|
draw_round_rect(cr,geom.x*ratio*w_stretch+margin,geom.y*ratio+margin,geom.width*ratio*w_stretch-margin*2,geom.height*ratio-margin*2)
|
||||||
|
worked = true
|
||||||
|
end
|
||||||
|
--TODO floating clients
|
||||||
|
return worked
|
||||||
|
end
|
||||||
|
|
||||||
|
return module
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
77
max.lua
77
max.lua
|
@ -1,16 +1,19 @@
|
||||||
local capi = {screen=screen,client=client}
|
local capi = {screen=screen,client=client}
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local cairo = require( "lgi" ).cairo
|
local cairo = require( "lgi" ).cairo
|
||||||
local color = require( "gears.color" )
|
local color = require( "gears.color" )
|
||||||
local beautiful = require( "beautiful" )
|
local beautiful = require( "beautiful" )
|
||||||
local surface = require( "gears.surface" )
|
local surface = require( "gears.surface" )
|
||||||
|
local layout = require( "collision.layout" )
|
||||||
|
local util = require( "collision.util" )
|
||||||
local pango = require("lgi").Pango
|
local pango = require("lgi").Pango
|
||||||
local pangocairo = require("lgi").PangoCairo
|
local pangocairo = require("lgi").PangoCairo
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
local w = nil
|
local w = nil
|
||||||
local rad = 10
|
local rad = 10
|
||||||
|
local border = 3
|
||||||
|
|
||||||
local function init()
|
local function init()
|
||||||
w = wibox{}
|
w = wibox{}
|
||||||
|
@ -18,16 +21,6 @@ local function init()
|
||||||
w.visible = true
|
w.visible = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local rr,rg,rb
|
|
||||||
local function get_rgb()
|
|
||||||
if not rr then
|
|
||||||
local pat = color(beautiful.fg_normal)
|
|
||||||
local s,r,g,b,a = pat:get_rgba()
|
|
||||||
rr,rg,rb = r,g,b
|
|
||||||
end
|
|
||||||
return rr,rg,rb
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_round_rect(width,height,bg)
|
local function get_round_rect(width,height,bg)
|
||||||
local img2 = cairo.ImageSurface(cairo.Format.ARGB32, width,height)
|
local img2 = cairo.ImageSurface(cairo.Format.ARGB32, width,height)
|
||||||
local cr2 = cairo.Context(img2)
|
local cr2 = cairo.Context(img2)
|
||||||
|
@ -55,7 +48,7 @@ local function create_arrow(cr,x,y,width, height,direction)
|
||||||
cr:rotate(math.pi)
|
cr:rotate(math.pi)
|
||||||
end
|
end
|
||||||
cr:move_to(x,y)
|
cr:move_to(x,y)
|
||||||
local r,g,b = get_rgb()
|
local r,g,b = util.get_rgb()
|
||||||
cr:set_source_rgba(r,g,b,0.15)
|
cr:set_source_rgba(r,g,b,0.15)
|
||||||
cr:set_antialias(1)
|
cr:set_antialias(1)
|
||||||
cr:rectangle(2*margin,2*(height/7),width/3,3*(height/7))
|
cr:rectangle(2*margin,2*(height/7),width/3,3*(height/7))
|
||||||
|
@ -70,7 +63,7 @@ local function create_arrow(cr,x,y,width, height,direction)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pango_l = nil
|
local pango_l = nil
|
||||||
local function draw_shape(s,collection,current_idx,icon_f,y)
|
local function draw_shape(s,collection,current_idx,icon_f,y,text_height)
|
||||||
local geo = capi.screen[s].geometry
|
local geo = capi.screen[s].geometry
|
||||||
local wa =capi.screen[s].workarea
|
local wa =capi.screen[s].workarea
|
||||||
|
|
||||||
|
@ -120,11 +113,11 @@ local function draw_shape(s,collection,current_idx,icon_f,y)
|
||||||
cr3:set_source(k==current_idx and focus or nornal)
|
cr3:set_source(k==current_idx and focus or nornal)
|
||||||
cr3:rectangle(dx,0,width,height)
|
cr3:rectangle(dx,0,width,height)
|
||||||
cr3:fill()
|
cr3:fill()
|
||||||
cr3:set_source_surface(img4,dx+3,3)
|
cr3:set_source_surface(img4,dx+border,border)
|
||||||
cr3:paint()
|
cr3:paint()
|
||||||
|
|
||||||
-- Print the icon
|
-- Print the icon
|
||||||
local icon = icon_f(v,width-20,height-20-50)
|
local icon = icon_f(v,width-20,height-20-text_height)
|
||||||
if icon then
|
if icon then
|
||||||
cr3:save()
|
cr3:save()
|
||||||
cr3:translate(dx+10,10)
|
cr3:translate(dx+10,10)
|
||||||
|
@ -134,18 +127,18 @@ local function draw_shape(s,collection,current_idx,icon_f,y)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Print a pretty line
|
-- Print a pretty line
|
||||||
local r,g,b = get_rgb()
|
local r,g,b = util.get_rgb()
|
||||||
cr3:set_source_rgba(r,g,b,0.7)
|
cr3:set_source_rgba(r,g,b,0.7)
|
||||||
cr3:set_line_width(1)
|
cr3:set_line_width(1)
|
||||||
cr3:move_to(dx+margin,height - 47)
|
cr3:move_to(dx+margin,height - text_height-border)
|
||||||
cr3:line_to(dx+margin+width-2*margin,height - 47)
|
cr3:line_to(dx+margin+width-2*margin,height - text_height-border)
|
||||||
cr3:stroke()
|
cr3:stroke()
|
||||||
|
|
||||||
-- Pring the text
|
-- Pring the text
|
||||||
pango_l.text = v.name
|
pango_l.text = v.name
|
||||||
pango_l.width = pango.units_from_double(width-16)
|
pango_l.width = pango.units_from_double(width-16)
|
||||||
pango_l.height = pango.units_from_double(height-40)
|
pango_l.height = pango.units_from_double(height-text_height-10)
|
||||||
cr3:move_to(dx+8,height-40)
|
cr3:move_to(dx+8,height-text_height-0)
|
||||||
cr3:show_layout(pango_l)
|
cr3:show_layout(pango_l)
|
||||||
|
|
||||||
-- Draw an arrow
|
-- Draw an arrow
|
||||||
|
@ -230,7 +223,7 @@ function module.display_clients(s,direction)
|
||||||
end
|
end
|
||||||
local clients = awful.client.tiled(s)
|
local clients = awful.client.tiled(s)
|
||||||
local fk = awful.util.table.hasitem(clients,capi.client.focus)
|
local fk = awful.util.table.hasitem(clients,capi.client.focus)
|
||||||
draw_shape(s,clients,fk,client_icon)
|
draw_shape(s,clients,fk,client_icon,nil,50)
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.change_focus(mod,key,event,direction,is_swap,is_max)
|
function module.change_focus(mod,key,event,direction,is_swap,is_max)
|
||||||
|
@ -240,7 +233,7 @@ function module.change_focus(mod,key,event,direction,is_swap,is_max)
|
||||||
c:raise()
|
c:raise()
|
||||||
local clients = awful.client.tiled(s)
|
local clients = awful.client.tiled(s)
|
||||||
local fk = awful.util.table.hasitem(clients,c)
|
local fk = awful.util.table.hasitem(clients,c)
|
||||||
draw_shape(s,clients,fk,client_icon)
|
draw_shape(s,clients,fk,client_icon,nil,50)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -249,14 +242,28 @@ local function tag_icon(t,width,height)
|
||||||
local img = cairo.ImageSurface(cairo.Format.ARGB32, width, height)
|
local img = cairo.ImageSurface(cairo.Format.ARGB32, width, height)
|
||||||
local cr = cairo.Context(img)
|
local cr = cairo.Context(img)
|
||||||
|
|
||||||
local icon = surface(awful.tag.geticon(t))
|
local has_layout = layout.draw(t,cr,width,height)
|
||||||
local w,h = icon:get_width(),icon:get_height()
|
|
||||||
local aspect,aspect_h = width / w,(height) / h
|
-- Create a monochrome representation of the icon
|
||||||
if aspect > aspect_h then aspect = aspect_h end
|
local icon_orig = surface(awful.tag.geticon(t))
|
||||||
cr:translate((width-w*aspect)/2,(height-h*aspect)/2)
|
if icon_orig then
|
||||||
cr:scale(aspect, aspect)
|
local icon = cairo.ImageSurface(cairo.Format.ARGB32, icon_orig:get_width(), icon_orig:get_height())
|
||||||
cr:set_source_surface(icon)
|
local cr2 = cairo.Context(icon)
|
||||||
cr:paint()
|
cr2:set_source_surface(icon_orig)
|
||||||
|
cr2:paint()
|
||||||
|
|
||||||
|
cr2:set_source(color(beautiful.fg_normal))
|
||||||
|
cr2:set_operator(cairo.Operator.IN)
|
||||||
|
cr2:paint()
|
||||||
|
|
||||||
|
local w,h = icon:get_width(),icon:get_height()
|
||||||
|
local aspect,aspect_h = width / w,(height) / h
|
||||||
|
if aspect > aspect_h then aspect = aspect_h end
|
||||||
|
cr:translate((width-w*aspect)/2,(height-h*aspect)/2)
|
||||||
|
cr:scale(aspect, aspect)
|
||||||
|
cr:set_source_surface(icon)
|
||||||
|
cr:paint_with_alpha(has_layout and 0.75 or 1)
|
||||||
|
end
|
||||||
return img
|
return img
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -271,7 +278,7 @@ function module.display_tags(s,direction)
|
||||||
end
|
end
|
||||||
local tags = awful.tag.gettags(s)
|
local tags = awful.tag.gettags(s)
|
||||||
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
||||||
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15)
|
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15,20)
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.change_tag(mod,key,event,direction,is_swap,is_max)
|
function module.change_tag(mod,key,event,direction,is_swap,is_max)
|
||||||
|
@ -279,7 +286,7 @@ function module.change_tag(mod,key,event,direction,is_swap,is_max)
|
||||||
awful.tag[direction == "left" and "viewprev" or "viewnext"](s)
|
awful.tag[direction == "left" and "viewprev" or "viewnext"](s)
|
||||||
local tags = awful.tag.gettags(s)
|
local tags = awful.tag.gettags(s)
|
||||||
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
||||||
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15)
|
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15,20)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
local capi = {screen=screen,client=client}
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local awful = require("awful")
|
||||||
|
local cairo = require( "lgi" ).cairo
|
||||||
|
local color = require( "gears.color" )
|
||||||
|
local beautiful = require( "beautiful" )
|
||||||
|
local surface = require( "gears.surface" )
|
||||||
|
local pango = require("lgi").Pango
|
||||||
|
local pangocairo = require("lgi").PangoCairo
|
||||||
|
local module = {}
|
||||||
|
|
||||||
|
function module.display()
|
||||||
|
print("DISPLAT")
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.hide()
|
||||||
|
print("HIDE")
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.reload()
|
||||||
|
print("RELOAD")
|
||||||
|
end
|
||||||
|
|
||||||
|
return module
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
|
@ -0,0 +1,18 @@
|
||||||
|
local color = require( "gears.color" )
|
||||||
|
local beautiful = require( "beautiful" )
|
||||||
|
|
||||||
|
local module = {}
|
||||||
|
|
||||||
|
|
||||||
|
local rr,rg,rb
|
||||||
|
function module.get_rgb()
|
||||||
|
if not rr then
|
||||||
|
local pat = color(beautiful.fg_normal)
|
||||||
|
local s,r,g,b,a = pat:get_rgba()
|
||||||
|
rr,rg,rb = r,g,b
|
||||||
|
end
|
||||||
|
return rr,rg,rb
|
||||||
|
end
|
||||||
|
|
||||||
|
return module
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
Loading…
Reference in New Issue