From 1076b6eac3822b6fb51253e655831a8f472eaba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Thu, 25 May 2023 22:04:44 +0200 Subject: [PATCH] Move to screen instead of swapping to it --- awesome/keys.lua | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/awesome/keys.lua b/awesome/keys.lua index f88a792..426cb84 100644 --- a/awesome/keys.lua +++ b/awesome/keys.lua @@ -28,11 +28,37 @@ local keys = {} -- =================================================================== -- Movement Functions (Called by some keybinds) -- =================================================================== - +local function get_screen(s) + return s and screen[s] +end -- Move given client to given direction -local function move_client(c, direction) - awful.client.swap.global_bydirection(direction, c, nil) +local function move_client(sel, dir) + sel = sel or awful.client.focus + if sel then + -- move focus + awful.client.focus.global_bydirection(dir, sel) + local c = client.focus + + -- swapping inside a screen + if get_screen(sel.screen) == get_screen(c.screen) and sel ~= c then + c:swap(sel) + client.focus = sel + sel:raise() + + -- swapping to an empty screen + elseif sel == c then + sel:move_to_screen(awful.screen.focused()) + + -- swapping to a nonempty screen + elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel ~= c then + sel:move_to_screen(c.screen) + client.focus = sel + sel:raise() + end + + -- screen.focus(sel.screen) + end end