Created
July 9, 2022 11:34
-
-
Save adamnejm/41c43ff5ff16d84c242d93f33bb85d0f to your computer and use it in GitHub Desktop.
AwesomeWM - Blocking mouse scroll bind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Focus different client | |
-- The input is passed to the client before switching focus *(just like in `unfocus_client.lua)* | |
client.connect_signal("request::default_mousebindings", function() | |
awful.mouse.append_client_mousebindings { | |
awful.button({ "Mod4" }, 4, function(c) | |
for _, other in ipairs(client.get()) do | |
if other ~= c then | |
client.focus = other | |
break | |
end | |
end | |
gears.timer.delayed_call(function() | |
client.focus = c | |
end) | |
end), | |
} | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Mousegrabber that runs for some amount of loops | |
-- Prevents the client from receiving the input as long as the mouse hasn't moved | |
-- Unable to determine when to stop grabbing, since `data.buttons[4]` is always `false` | |
client.connect_signal("request::default_mousebindings", function() | |
awful.mouse.append_client_mousebindings { | |
awful.button({ "Mod4" }, 4, function(c) | |
local count = 5 | |
mousegrabber.run(function(data) | |
print("Scrolled up on " .. c.class) | |
count = count - 1 | |
return count > 0 | |
end, "arrow") | |
end), | |
} | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Mousegrabber that runs only once | |
-- No discernible difference | |
client.connect_signal("request::default_mousebindings", function() | |
awful.mouse.append_client_mousebindings { | |
awful.button({ "Mod4" }, 4, function(c) | |
mousegrabber.run(function(data) | |
print("Scrolled up on " .. c.class) | |
return false | |
end, "arrow") | |
end), | |
} | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Move the mouse to empty space or space that is occupied by a different client | |
-- Doesn't work for the initial input | |
-- After initial input it reliably(?) prevents the client from receiving input | |
client.connect_signal("request::default_mousebindings", function() | |
awful.mouse.append_client_mousebindings { | |
awful.button({ "Mod4" }, 4, function(c) | |
local previous = mouse.coords() | |
mouse.coords { -- Position on screen where [no client] / [client different that `c`] is present | |
x = 1930, y = 1110, | |
} | |
gears.timer.delayed_call(function() | |
mouse.coords { | |
x = previous.x, y = previous.y, | |
} | |
end) | |
print("Scrolled up on " .. c.class) | |
end), | |
} | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Call either `mouse::enter` or `mouse::leave` | |
-- No discernible difference | |
client.connect_signal("request::default_mousebindings", function() | |
awful.mouse.append_client_mousebindings { | |
awful.button({ "Mod4" }, 4, function(c) | |
c:emit_signal("mouse::leave") | |
client.emit_signal("mouse::leave", c) | |
print("Scrolled up on " .. c.class) | |
end), | |
} | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Unfocus the client | |
-- The input is passed to the client before switching focus | |
client.connect_signal("request::default_mousebindings", function() | |
awful.mouse.append_client_mousebindings { | |
awful.button({ "Mod4" }, 4, function(c) | |
client.focus = nil | |
print("Scrolled up on " .. c.class) | |
end), | |
} | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment