logic change
This commit is contained in:
parent
6350814975
commit
08ffc36589
50
init.lua
50
init.lua
|
@ -1,40 +1,56 @@
|
||||||
-- [*] ------------------------------------------------------- dependencies -- ;
|
--------------------------------------------------------------> dependencies ;
|
||||||
|
|
||||||
local gears = require('gears')
|
local gears = require('gears')
|
||||||
|
|
||||||
-- [*] ------------------------------------------------------------ methods -- ;
|
-------------------------------------------------------------------> methods ;
|
||||||
|
|
||||||
local mouser = function ()
|
local mouser = function ()
|
||||||
gears.timer.weak_start_new(0.1, function()
|
gears.timer.weak_start_new(0.05, function()
|
||||||
local c = client.focus
|
local c = client.focus
|
||||||
local cgeometry = c:geometry()
|
local cgeometry = c:geometry()
|
||||||
mouse.coords({ x = cgeometry.x + cgeometry.width/2 , y = cgeometry.y + cgeometry.height/2 })
|
mouse.coords({ x = cgeometry.x + cgeometry.width/2 , y = cgeometry.y + cgeometry.height/2 })
|
||||||
end)
|
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)
|
client.connect_signal("focus", function(c)
|
||||||
|
local focused_client = c
|
||||||
|
--+ client the focus is going towards
|
||||||
|
|
||||||
|
gears.timer.weak_start_new(0.05, function()
|
||||||
local current_client = mouse.current_client
|
local current_client = mouse.current_client
|
||||||
|
|
||||||
if current_client and c ~= current_client then
|
if not current_client then
|
||||||
mouser()
|
mouser() return false
|
||||||
end -- [+] no need to relocate the mouse if already over the client
|
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)
|
end)
|
||||||
|
|
||||||
|
|
||||||
client.connect_signal("unmanage", function(c)
|
client.connect_signal("unmanage", function(c)
|
||||||
|
local current_client = mouse.current_client
|
||||||
|
|
||||||
|
if current_client and c ~= current_client then
|
||||||
mouser()
|
mouser()
|
||||||
--[[
|
end
|
||||||
I think no client check behaviour is better when we
|
--+ no need to relocate the mouse if already over the
|
||||||
close things. We can change this later if need be or
|
--> client.
|
||||||
possibly better add a table of classes for
|
|
||||||
exclusions.
|
|
||||||
--]]
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
---------------------------------------------------------------------> export ;
|
||||||
-- [*] ------------------------------------------------------------- export -- ;
|
|
||||||
|
|
||||||
return mouser
|
return mouser
|
||||||
|
|
||||||
|
@ -46,3 +62,5 @@ return mouser
|
||||||
-- awful.client.run_or_raise(chromium, matcher('Google-chrome'))
|
-- awful.client.run_or_raise(chromium, matcher('Google-chrome'))
|
||||||
-- mouser()
|
-- mouser()
|
||||||
-- end),
|
-- end),
|
||||||
|
-- naughty.notify({text=current_client.name})
|
||||||
|
-- naughty.notify({text=focused_client.name})
|
||||||
|
|
Loading…
Reference in New Issue