Add select_screen method
This commit is contained in:
parent
65c2923d1a
commit
a79cc9161f
|
@ -51,7 +51,7 @@ while the `Control` key is used to max out the effect.
|
||||||
|
|
||||||
| Modifier 1 | Modifier 2 | Modifier 3 | 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` | | `Control` | Move the focus on the floating layer |
|
||||||
| `Mod4` | `Shift` | | Move a client in the tiled or 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 |
|
| `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
|
-- Swap clients across screen instead of adding them to the other tag
|
||||||
collision.settings.swap_across_screen = true
|
collision.settings.swap_across_screen = true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Other
|
||||||
|
|
||||||
|
The `collision.select_screen(idx)` function allow to select a screen and can be
|
||||||
|
assigned to shortcuts.
|
7
init.lua
7
init.lua
|
@ -10,6 +10,7 @@ local module = {
|
||||||
_max = require( "collision.max" ),
|
_max = require( "collision.max" ),
|
||||||
_screen = require( "collision.screen"),
|
_screen = require( "collision.screen"),
|
||||||
settings= col_utils.settings ,
|
settings= col_utils.settings ,
|
||||||
|
util = col_utils ,
|
||||||
}
|
}
|
||||||
|
|
||||||
local current_mode = "focus"
|
local current_mode = "focus"
|
||||||
|
@ -125,6 +126,12 @@ function module.screen(direction, move)
|
||||||
start_loop(false,max)
|
start_loop(false,max)
|
||||||
end
|
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)
|
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
|
||||||
|
|
10
resize.lua
10
resize.lua
|
@ -153,8 +153,14 @@ function module.resize(mod,key,event,direction,is_swap,is_max)
|
||||||
return true
|
return true
|
||||||
end
|
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
|
-- Resize from the top left corner
|
||||||
function module.mouse_resize(c,btn)
|
function module.mouse_resize(c,corner)
|
||||||
module.display(c)
|
module.display(c)
|
||||||
local geom,curX,curY = c:geometry(),capi.mouse.coords().x,capi.mouse.coords().y
|
local geom,curX,curY = c:geometry(),capi.mouse.coords().x,capi.mouse.coords().y
|
||||||
capi.mousegrabber.run(function(mouse)
|
capi.mousegrabber.run(function(mouse)
|
||||||
|
@ -162,7 +168,7 @@ function module.mouse_resize(c,btn)
|
||||||
module.hide()
|
module.hide()
|
||||||
return false
|
return false
|
||||||
elseif mouse.x ~= curX and mouse.y ~= curY then
|
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
|
end
|
||||||
return true
|
return true
|
||||||
end,"fleur")
|
end,"fleur")
|
||||||
|
|
38
screen.lua
38
screen.lua
|
@ -98,21 +98,7 @@ local function init_wiboxes(direction)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function next_screen(ss,dir,move)
|
local function select_screen(scr_index,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 geom = capi.screen[scr_index].geometry
|
local geom = capi.screen[scr_index].geometry
|
||||||
capi.mouse.coords({x=geom.x+geom.width/2,y=geom.y+geom.height/2+55})
|
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
|
return scr_index
|
||||||
end
|
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)
|
function module.display(_,dir,move)
|
||||||
if #wiboxes == 0 then
|
if #wiboxes == 0 then
|
||||||
init_wiboxes(dir)
|
init_wiboxes(dir)
|
||||||
|
@ -168,5 +172,9 @@ print("LA",mod and #mod)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function module.select_screen(idx)
|
||||||
|
select_screen(idx,false)
|
||||||
|
end
|
||||||
|
|
||||||
return module
|
return module
|
||||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
Loading…
Reference in New Issue