Add mouse utils
This commit is contained in:
parent
60e73ee390
commit
ab90eaa114
|
@ -17,6 +17,7 @@ local naughty = require("naughty")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local volume_widget = require("widgets.volume-widget.volume")
|
local volume_widget = require("widgets.volume-widget.volume")
|
||||||
local dpi = beautiful.xresources.apply_dpi
|
local dpi = beautiful.xresources.apply_dpi
|
||||||
|
local mouse_utils = require("mouse_utils")
|
||||||
|
|
||||||
|
|
||||||
local modkey = "Mod4"
|
local modkey = "Mod4"
|
||||||
|
@ -87,8 +88,6 @@ local function move_client(sel, dir)
|
||||||
client.focus = sel
|
client.focus = sel
|
||||||
sel:raise()
|
sel:raise()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- screen.focus(sel.screen)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
local mouse_utils = {}
|
||||||
|
|
||||||
|
function mouse_utils.move_mouse_onto_focused_client()
|
||||||
|
local c = client.focus
|
||||||
|
if c then
|
||||||
|
local geometry = c:geometry()
|
||||||
|
local mouse_coords = mouse.coords()
|
||||||
|
local margin = 10
|
||||||
|
-- Don't move the mouse if it's already over the client
|
||||||
|
if not (mouse_coords.x > geometry.x - margin
|
||||||
|
and mouse_coords.x < geometry.x + geometry.width + margin
|
||||||
|
and mouse_coords.y > geometry.y - margin
|
||||||
|
and mouse_coords.y < geometry.y + geometry.height + margin) then
|
||||||
|
|
||||||
|
local x = geometry.x + geometry.width/2
|
||||||
|
local y = geometry.y + geometry.height/2
|
||||||
|
mouse.coords({x = x, y = y}, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return mouse_utils
|
|
@ -10,6 +10,7 @@
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local grid = require("layout.grid")
|
local grid = require("layout.grid")
|
||||||
|
local mouse_utils = require("mouse_utils")
|
||||||
|
|
||||||
|
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
|
@ -132,17 +133,6 @@ screen.connect_signal("property::geometry", awesome.restart)
|
||||||
collectgarbage("setpause", 110)
|
collectgarbage("setpause", 110)
|
||||||
collectgarbage("setstepmul", 1000)
|
collectgarbage("setstepmul", 1000)
|
||||||
|
|
||||||
local function move_mouse_onto_focused_client()
|
|
||||||
local c = client.focus
|
|
||||||
if c then
|
|
||||||
local geometry = c:geometry()
|
|
||||||
local x = geometry.x + geometry.width/2
|
|
||||||
local y = geometry.y + geometry.height/2
|
|
||||||
mouse.coords({x = x, y = y}, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
client.connect_signal("property::maximized", function(focused)
|
client.connect_signal("property::maximized", function(focused)
|
||||||
local hide = focused.maximized or focused.fullscreen
|
local hide = focused.maximized or focused.fullscreen
|
||||||
for i, c in ipairs(client.get()) do
|
for i, c in ipairs(client.get()) do
|
||||||
|
@ -168,7 +158,7 @@ client.connect_signal("focus", function(c)
|
||||||
if #c.screen.clients > 1 then
|
if #c.screen.clients > 1 then
|
||||||
c.border_color = beautiful.border_focus
|
c.border_color = beautiful.border_focus
|
||||||
end
|
end
|
||||||
move_mouse_onto_focused_client()
|
gears.timer.delayed_call(mouse_utils.move_mouse_onto_focused_client)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
client.connect_signal("unfocus", function(c)
|
client.connect_signal("unfocus", function(c)
|
||||||
|
|
|
@ -3,6 +3,7 @@ vim.api.nvim_set_keymap("n", "j", "gj", {})
|
||||||
vim.api.nvim_set_keymap("n", "k", "gk", {})
|
vim.api.nvim_set_keymap("n", "k", "gk", {})
|
||||||
vim.api.nvim_set_keymap("n", "<S-k>", "<Nop>", {})
|
vim.api.nvim_set_keymap("n", "<S-k>", "<Nop>", {})
|
||||||
vim.api.nvim_set_keymap("v", "<S-y>", "\"+y", { noremap = true })
|
vim.api.nvim_set_keymap("v", "<S-y>", "\"+y", { noremap = true })
|
||||||
|
vim.api.nvim_set_keymap("n", "<S-p>", "\"+p", { noremap = true })
|
||||||
vim.api.nvim_set_keymap("v", "<S-p>", "\"+p", { noremap = true })
|
vim.api.nvim_set_keymap("v", "<S-p>", "\"+p", { noremap = true })
|
||||||
vim.api.nvim_set_keymap("n", "<C-U>", "<C-O>", { noremap = true })
|
vim.api.nvim_set_keymap("n", "<C-U>", "<C-O>", { noremap = true })
|
||||||
vim.api.nvim_set_keymap("n", "<C-E>", "<C-U>", { noremap = true })
|
vim.api.nvim_set_keymap("n", "<C-E>", "<C-U>", { noremap = true })
|
||||||
|
|
|
@ -197,3 +197,4 @@ alias vim="nvim"
|
||||||
alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
|
alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
|
||||||
alias xbindkeys="xbindkeys -f $XDG_CONFIG_HOME/xbindkeys/config"
|
alias xbindkeys="xbindkeys -f $XDG_CONFIG_HOME/xbindkeys/config"
|
||||||
alias python=python3
|
alias python=python3
|
||||||
|
alias r=". ranger"
|
||||||
|
|
Loading…
Reference in New Issue