From 76e3cc4799eabca43ecd4c86a0e254e603ddd8ad Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Sat, 12 Dec 2020 22:59:55 +0100 Subject: [PATCH 1/2] Use focus.filter in awful.client.focus.(global_)bydirection --- lib/awful/client/focus.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/awful/client/focus.lua b/lib/awful/client/focus.lua index 1b97674de..1deb9d7ed 100644 --- a/lib/awful/client/focus.lua +++ b/lib/awful/client/focus.lua @@ -174,7 +174,9 @@ function focus.bydirection(dir, c, stacked) local cltbl = client.visible(sel.screen, stacked) local geomtbl = {} for i,cl in ipairs(cltbl) do - geomtbl[i] = cl:geometry() + if focus.filter(cl) then + geomtbl[i] = cl:geometry() + end end local target = grect.get_in_direction(dir, geomtbl, sel:geometry()) @@ -211,7 +213,9 @@ function focus.global_bydirection(dir, c, stacked) local cltbl = client.visible(screen.focused(), stacked) local geomtbl = {} for i,cl in ipairs(cltbl) do - geomtbl[i] = cl:geometry() + if focus.filter(cl) then + geomtbl[i] = cl:geometry() + end end local target = grect.get_in_direction(dir, geomtbl, scr.geometry) From f45c8e8c691a92b7f5fdb41e2f9bec8eb3cd9441 Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Thu, 10 Feb 2022 17:31:23 +0100 Subject: [PATCH 2/2] Add test case for focus-bydirection --- tests/test-focus-bydirection.lua | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test-focus-bydirection.lua diff --git a/tests/test-focus-bydirection.lua b/tests/test-focus-bydirection.lua new file mode 100644 index 000000000..ad649b944 --- /dev/null +++ b/tests/test-focus-bydirection.lua @@ -0,0 +1,40 @@ +-- Test for https://github.com/awesomeWM/awesome/pull/3225 + +local runner = require("_runner") +local awful = require("awful") +local beautiful = require("beautiful") + +-- Ensure clients are placed next to each other +beautiful.column_count = 3 +awful.screen.focused().selected_tag.layout = awful.layout.suit.tile + + +local steps = { + function(count) + if count == 1 then + awful.spawn("xterm") + awful.spawn("xterm") + awful.spawn("xterm") + else + local cleft = client.get()[1] + local cright = client.get()[3] + client.get()[2].focusable = false + + -- Test with focus.bydirection + client.focus = cleft + awful.client.focus.bydirection("right") + assert(client.focus == cright) + + -- Test with focus.global_bydirection + client.focus = cleft + awful.client.focus.global_bydirection("right") + assert(client.focus == cright) + + return true + end + end, +} + +runner.run_steps(steps) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80