focus: Allow empty screens to be selected
This commit is contained in:
parent
7155d6c48c
commit
38d8824668
|
@ -103,3 +103,7 @@ assigned to shortcuts.
|
|||
|
||||
The `collision.highlight_cursor(timeout)` method will highlight the current mouse
|
||||
cursor position.
|
||||
|
||||
# Notes
|
||||
|
||||
Using the focus arrows to select empty screens only work in Awesome 3.5.7+
|
46
focus.lua
46
focus.lua
|
@ -54,15 +54,20 @@ local function init()
|
|||
wiboxes["center"].shape_bounding = img._native
|
||||
end
|
||||
|
||||
local function emulate_client(screen)
|
||||
return {is_screen = true, screen=screen, geometry=function() return capi.screen[screen].workarea end}
|
||||
end
|
||||
|
||||
local function display_wiboxes(cltbl,geomtbl,float,swap,c)
|
||||
if not wiboxes then
|
||||
init()
|
||||
end
|
||||
local fc = capi.client.focus or emulate_client(capi.mouse.screen)
|
||||
for k,v in ipairs({"left","right","up","down","center"}) do
|
||||
local next_clients = (float and swap) and c or cltbl[util.get_rectangle_in_direction(v , geomtbl, capi.client.focus:geometry())]
|
||||
local next_clients = (float and swap) and c or cltbl[util.get_rectangle_in_direction(v , geomtbl, fc:geometry())]
|
||||
if next_clients or k==5 then
|
||||
local same, center = capi.client.focus == next_clients,k==5
|
||||
local geo = center and capi.client.focus:geometry() or next_clients:geometry()
|
||||
local same, center = fc == next_clients,k==5
|
||||
local geo = center and fc:geometry() or next_clients:geometry()
|
||||
wiboxes[v].visible = true
|
||||
wiboxes[v].x = (swap and float and (not center)) and (geo.x + (k>2 and (geo.width/2) or 0) + (k==2 and geo.width or 0) - 75/2) or (geo.x + geo.width/2 - 75/2)
|
||||
wiboxes[v].y = (swap and float and (not center)) and (geo.y + (k<=2 and geo.height/2 or 0) + (k==4 and geo.height or 0) - 75/2) or (geo.y + geo.height/2 - 75/2)
|
||||
|
@ -91,25 +96,51 @@ local function floating_clients()
|
|||
end
|
||||
|
||||
local function bydirection(dir, c, swap,max)
|
||||
if c then
|
||||
local float = client.floating.get(c) or alayout.get(c.screen) == alayout.suit.floating
|
||||
if not c then
|
||||
c = emulate_client(capi.mouse.screen)
|
||||
end
|
||||
|
||||
local float = nil
|
||||
|
||||
if c.is_screen then
|
||||
float = false
|
||||
else
|
||||
float = (client.floating.get(c) or alayout.get(c.screen) == alayout.suit.floating)
|
||||
end
|
||||
|
||||
-- Move the client if floating, swaping wont work anyway
|
||||
if swap and float then
|
||||
c:geometry((max and float_move_max or float_move)(dir,c))
|
||||
display_wiboxes(nil,nil,float,swap,c)
|
||||
else
|
||||
-- Get all clients rectangle
|
||||
local cltbl,geomtbl = max and floating_clients() or client.tiled(),{}
|
||||
local cltbl,geomtbl,scrs = max and floating_clients() or client.tiled(),{},{}
|
||||
for i,cl in ipairs(cltbl) do
|
||||
geomtbl[i] = cl:geometry()
|
||||
scrs[cl.screen or 1] = true
|
||||
end
|
||||
|
||||
-- Add rectangles for empty screens too
|
||||
for i = 1, capi.screen.count() do
|
||||
if not scrs[i] then
|
||||
geomtbl[#geomtbl+1] = capi.screen[i].workarea
|
||||
cltbl[#geomtbl] = emulate_client(i)
|
||||
end
|
||||
end
|
||||
|
||||
local target = util.get_rectangle_in_direction(dir, geomtbl, c:geometry())
|
||||
if swap ~= true then
|
||||
-- If we found a client to focus, then do it.
|
||||
if target then
|
||||
capi.client.focus = cltbl[((not cltbl[target] and #cltbl == 1) and 1 or target)]
|
||||
local cl = cltbl[target]
|
||||
if cl and cl.is_screen then
|
||||
capi.client.focus = nil --TODO Fix upstream fix
|
||||
capi.mouse.screen = capi.screen[cl.screen]
|
||||
else
|
||||
capi.client.focus = cltbl[((not cl and #cltbl == 1) and 1 or target)]
|
||||
capi.client.focus:raise()
|
||||
end
|
||||
end
|
||||
else
|
||||
if target then
|
||||
-- We found a client to swap
|
||||
|
@ -146,7 +177,6 @@ local function bydirection(dir, c, swap,max)
|
|||
end
|
||||
display_wiboxes(cltbl,geomtbl,float,swap,c)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function module.global_bydirection(dir, c,swap,max)
|
||||
|
|
|
@ -171,7 +171,6 @@ function module.mouse_resize(c,corner)
|
|||
if c.apply_size_hints then
|
||||
local w,h = c:apply_size_hints(new.width,new.height)
|
||||
new.x,new.y,new.width,new.height = new.x - (w-new.width),new.y - (h-new.height),w,h
|
||||
print("AAA",w,h,new.width,new.height,new.x)
|
||||
end
|
||||
|
||||
c:geometry(new)
|
||||
|
@ -180,13 +179,6 @@ function module.mouse_resize(c,corner)
|
|||
end,"fleur")
|
||||
end
|
||||
|
||||
-- awful.mouse.client._resize = awful.mouse.client.resize
|
||||
-- awful.mouse.client.resize = function(c,...)
|
||||
-- module.display(c)
|
||||
-- auto_hide = true
|
||||
-- awful.mouse.client._resize(c,...)
|
||||
-- module.hide()
|
||||
-- end
|
||||
|
||||
return module
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
|
|
Loading…
Reference in New Issue