ADD: When in revelation mode, middle click will close the window

under the pointer.

This is very useful for window management. When you have many
windows open and you want to close some, you can just open
revelation and close the windows with middle mouse.

I have maintained your coding style, but I recommend not testing
boolean variables against true/false. So instead of
if mouse.buttons[1] == true then ...
you would have
if mouse.buttons[1] then

and instead of
if mouse.buttons[1] == false then -- doesn't actually appear in
code
you would have
if not mouse.buttons[1] then ...

That's just a minor niggle though.
This commit is contained in:
Falco Peijnenburg 2011-12-21 22:42:20 +01:00
parent 563e92714f
commit e8f6064bd2
1 changed files with 10 additions and 1 deletions

View File

@ -127,12 +127,21 @@ function expose(rule, s)
capi.keygrabber.run(keyboardhandler(restore))
local pressedMiddle = false
capi.mousegrabber.run(function(mouse)
local c = awful.mouse.client_under_pointer()
if mouse.buttons[1] == true then
local c = awful.mouse.client_under_pointer()
selectfn(restore)(c)
return false
elseif mouse.buttons[2] == true and pressedMiddle == false and c ~= nil then -- is true whenever the button is down.
pressedMiddle = true -- extra variable needed to prevent script from spam-closing windows
c:kill()
return true
elseif mouse.buttons[2] == false and pressedMiddle == true then
pressedMiddle = false
end
return true
--Strange but on my machine only fleur worked as a string.
--stole it from