From 08ffc36589487037b1b276de001ccc26110de3b2 Mon Sep 17 00:00:00 2001 From: anakha Date: Thu, 3 Jun 2021 09:28:23 -0400 Subject: [PATCH] logic change --- init.lua | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/init.lua b/init.lua index ffb4a36..1f21998 100644 --- a/init.lua +++ b/init.lua @@ -1,40 +1,56 @@ --- [*] ------------------------------------------------------- dependencies -- ; +--------------------------------------------------------------> dependencies ; local gears = require('gears') --- [*] ------------------------------------------------------------ methods -- ; +-------------------------------------------------------------------> methods ; local mouser = function () - gears.timer.weak_start_new(0.1, function() + gears.timer.weak_start_new(0.05, function() local c = client.focus local cgeometry = c:geometry() mouse.coords({ x = cgeometry.x + cgeometry.width/2 , y = cgeometry.y + cgeometry.height/2 }) end) -end -- [+] relocate mouse after slightly waiting for focus to complete +end +--+ relocate mouse after slightly waiting for focus to +--> complete. you can adjust the timer if you are on a slow +--> cpu to give more time for the client to appear. --- [*] ------------------------------------------------------------- signal -- ; +---------------------------------------------------------------------> signal ; client.connect_signal("focus", function(c) - local current_client = mouse.current_client + local focused_client = c + --+ client the focus is going towards - if current_client and c ~= current_client then - mouser() - end -- [+] no need to relocate the mouse if already over the client + gears.timer.weak_start_new(0.05, function() + local current_client = mouse.current_client + + if not current_client then + mouser() return false + end + --+ nothing under the mouse, move directly + + if focused_client ~= current_client then + mouser() return false + end + --+ no need to relocate the mouse if already over + --> the client. + end) + --+ mouse.current_client would point to the previous + --> client without the callback. end) client.connect_signal("unmanage", function(c) - mouser() - --[[ - I think no client check behaviour is better when we - close things. We can change this later if need be or - possibly better add a table of classes for - exclusions. - --]] + local current_client = mouse.current_client + + if current_client and c ~= current_client then + mouser() + end + --+ no need to relocate the mouse if already over the + --> client. end) - --- [*] ------------------------------------------------------------- export -- ; +---------------------------------------------------------------------> export ; return mouser @@ -46,3 +62,5 @@ return mouser -- awful.client.run_or_raise(chromium, matcher('Google-chrome')) -- mouser() -- end), +-- naughty.notify({text=current_client.name}) +-- naughty.notify({text=focused_client.name})