summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-10-26 18:55:55 +0200
committerAnton Khirnov <anton@khirnov.net>2021-10-26 18:55:55 +0200
commit8867d417fce527dce7155fb18b26e2ab9a269c6c (patch)
treee226207bb6bfe8f77bfe54b3d3c614ab5de63119
parent871204a041cddf127149ef8e5fd1d5eb54784f51 (diff)
bindings: factor out shifting current client up/down
-rw-r--r--bindings.lua20
-rw-r--r--workspace.lua9
2 files changed, 11 insertions, 18 deletions
diff --git a/bindings.lua b/bindings.lua
index e1b68c8..999edd5 100644
--- a/bindings.lua
+++ b/bindings.lua
@@ -120,24 +120,8 @@ function M.create(workspace)
function () awful.layout.inc(-1, nil, workspace.layouts) end),
-- move to upper/lower page
- awful.key({ modkey, "Shift" }, "j",
- function ()
- if client.focus then
- local c = client.focus
- local s = c.screen
- workspace:client_move_relative(c, 1)
- timer.delayed_call(awful.screen.focus, s)
- end
- end),
- awful.key({ modkey, "Shift" }, "k",
- function ()
- if client.focus then
- local c = client.focus
- local s = c.screen
- workspace:client_move_relative(c, -1)
- timer.delayed_call(awful.screen.focus, s)
- end
- end),
+ awful.key({ modkey, "Shift" }, "j", function() workspace:shift_cur_client(1) end),
+ awful.key({ modkey, "Shift" }, "k", function() workspace:shift_cur_client(-1) end),
-- swap two screens
awful.key({ modkey, "Control" }, "q", function() workspace:swap_screens(1) end),
diff --git a/workspace.lua b/workspace.lua
index 654b118..db9973a 100644
--- a/workspace.lua
+++ b/workspace.lua
@@ -179,6 +179,15 @@ function Workspace:swap_screens(phys_idx)
end
end
+function Workspace:shift_cur_client(dir)
+ if client.focus then
+ local c = client.focus
+ local s = c.screen
+ self:client_move_relative(c, dir)
+ timer.delayed_call(awful.screen.focus, s)
+ end
+end
+
function Workspace:new(layouts)
local o = setmetatable({}, self)
self.__index = self