Add select_screen method

This commit is contained in:
Emmanuel Lepage Vallee 2015-02-15 04:50:21 +00:00
parent 65c2923d1a
commit a79cc9161f
4 changed files with 44 additions and 18 deletions

View File

@ -51,7 +51,7 @@ while the `Control` key is used to max out the effect.
| Modifier 1 | Modifier 2 | Modifier 3 | Effect |
| :--------: | :----------: | :----------: | ----------------------------------------------------- |
| `Mod4` | | | Move the focus on the tiled layer |
| `Mod4` | | | Move the focus om the tiled layer |
| `Mod4` | | `Control` | Move the focus on the floating layer |
| `Mod4` | `Shift` | | Move a client in the tiled or floating layer |
| `Mod4` | `Shift` | `Control` | Move a floating client to the far side of that screen |
@ -95,3 +95,8 @@ be removed from rc.lua.
-- Swap clients across screen instead of adding them to the other tag
collision.settings.swap_across_screen = true
```
# Other
The `collision.select_screen(idx)` function allow to select a screen and can be
assigned to shortcuts.

View File

@ -10,6 +10,7 @@ local module = {
_max = require( "collision.max" ),
_screen = require( "collision.screen"),
settings= col_utils.settings ,
util = col_utils ,
}
local current_mode = "focus"
@ -125,6 +126,12 @@ function module.screen(direction, move)
start_loop(false,max)
end
function module.select_screen(idx)
if idx and idx > 0 and idx < capi.screen.count() then
module._screen.select_screen(idx)
end
end
local function new(k)
-- Replace the keys array. The new one has to have a valid mapping
keys = k or keys

View File

@ -153,8 +153,14 @@ function module.resize(mod,key,event,direction,is_swap,is_max)
return true
end
local corners = {
tl = function(geom,mouse,curX,curY) return {x=geom.x+(mouse.x-curX),y=geom.y+(mouse.y-curY),width=geom.width-(mouse.x-curX),height=geom.height-(mouse.y-curY)} end,
bl = function(geom,mouse,curX,curY) return {x=geom.x+(mouse.x-curX),y=geom.y ,width=geom.width-(mouse.x-curX),height=geom.height-(curY-mouse.y)} end,
br = function(geom,mouse,curX,curY) return {x=geom.x ,y=geom.y ,width=geom.width-(curX-mouse.x),height=geom.height-(curY-mouse.y)} end,
}
-- Resize from the top left corner
function module.mouse_resize(c,btn)
function module.mouse_resize(c,corner)
module.display(c)
local geom,curX,curY = c:geometry(),capi.mouse.coords().x,capi.mouse.coords().y
capi.mousegrabber.run(function(mouse)
@ -162,7 +168,7 @@ function module.mouse_resize(c,btn)
module.hide()
return false
elseif mouse.x ~= curX and mouse.y ~= curY then
c:geometry({x=geom.x+(mouse.x-curX),y=geom.y+(mouse.y-curY),width=geom.width-(mouse.x-curX),height=geom.height-(mouse.y-curY)})
c:geometry(corners[corner or "tl"](geom,mouse,curX,curY))
end
return true
end,"fleur")

View File

@ -98,21 +98,7 @@ local function init_wiboxes(direction)
return true
end
local function next_screen(ss,dir,move)
local scr_index = ss
for k,s in ipairs(screens) do
if ss == s then
scr_index = k
break
end
end
if dir == "left" then
scr_index = scr_index == 1 and #screens or scr_index - 1
elseif dir == "right" then
scr_index = scr_index == #screens and 1 or scr_index+1
end
local function select_screen(scr_index,move)
local geom = capi.screen[scr_index].geometry
capi.mouse.coords({x=geom.x+geom.width/2,y=geom.y+geom.height/2+55})
@ -130,6 +116,24 @@ local function next_screen(ss,dir,move)
return scr_index
end
local function next_screen(ss,dir,move)
local scr_index = ss
for k,s in ipairs(screens) do
if ss == s then
scr_index = k
break
end
end
if dir == "left" then
scr_index = scr_index == 1 and #screens or scr_index - 1
elseif dir == "right" then
scr_index = scr_index == #screens and 1 or scr_index+1
end
return select_screen(scr_index,move)
end
function module.display(_,dir,move)
if #wiboxes == 0 then
init_wiboxes(dir)
@ -168,5 +172,9 @@ print("LA",mod and #mod)
return true
end
function module.select_screen(idx)
select_screen(idx,false)
end
return module
-- kate: space-indent on; indent-width 2; replace-tabs on;