diff options
author | Peter Palfrader <peter@palfrader.org> | 2019-09-09 13:23:58 +0200 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2019-09-09 13:23:58 +0200 |
commit | d88c2581ab639d827a3bccadd1b76615db89c642 (patch) | |
tree | b359412a944bbab2523421649c5b0647f136b0d6 | |
parent | 8ee90e648fce6c39a16cddd5d78d0db1c98fc873 (diff) |
Try to fix the focus-under-mouse on tag change.
Just doing a delayed call did not always work, so run it with a delay of
0.05s again.
Also, the handler somehow gets triggered when a new client gets created
(e.g. opening a new terminal window), and then the thing under the mouse
would get focused instead of the new one. Try to deal with that by only
messing with the focus if the tag has changed since last time the
trigger ran.
-rw-r--r-- | config/awesome/rc.lua | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index ea1675c..c9152bb 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -700,20 +700,29 @@ client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_n -- -- from/inspired by https://stackoverflow.com/a/30684548 do_not_reset_focus = false +previous_tag = nil tag.connect_signal( "property::selected", function (t) local selected = tostring(t.selected) == "false" if selected then - if not do_not_reset_focus then - gears.timer.delayed_call( function() - local c = mouse.current_client - if not (c == nil) then - client.focus = c - end - end) + if not t == previous_tag and not do_not_reset_focus then + local focus_timer = gears.timer( + { timeout = 0.05, + autostart = true, + callback = function() + local c = mouse.current_client + if not (c == nil) then + client.focus = c + end + focus_timer:stop() + end + } + ) + focus_timer:start() end do_not_reset_focus = false + previous_tag = t end end ) |