keygrabber: continue grabbing till keygrabber.stop is explicitly called

Returning true from the callback just to signal keygrabber to continue grabbing
felt redundant (and silly :|).

This will break old code that relied on returning false to stop grabbing,
instead of calling keygrabber.stop.

And fix keygrabber docs.

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Anurag Priyam 2012-02-21 20:25:55 +05:30 committed by Uli Schlachter
parent a0e21bb7f7
commit 014d191f66
3 changed files with 9 additions and 12 deletions

View File

@ -516,8 +516,6 @@ event_handle_key(xcb_key_press_event_t *ev)
warn("error running function: %s", lua_tostring(globalconf.L, -1));
luaA_keygrabber_stop(globalconf.L);
}
else if(!lua_isboolean(globalconf.L, -1) || !lua_toboolean(globalconf.L, -1))
luaA_keygrabber_stop(globalconf.L);
}
lua_pop(globalconf.L, 1); /* pop returned value or function if not called */
}

View File

@ -88,8 +88,7 @@ keygrabber_handlekpress(lua_State *L, xcb_key_press_event_t *e)
}
/** Grab keyboard and read pressed keys, calling callback function at each key
* pressed. The callback function must return a boolean value: true to
* continue grabbing, false to stop.
* press, until keygrabber.stop is called.
* The function is called with 3 arguments:
* a table containing modifiers keys, a string with the key pressed and a
* string with either "press" or "release" to indicate the event type.

View File

@ -3,21 +3,21 @@
-- @copyright 2008-2009 Julien Danjou
module("keygrabber")
--- Grab keyboard and read pressed keys, calling callback function at each key
-- pressed. The callback function must return a boolean value: true to
-- continue grabbing, false to stop.
-- The function is called with 3 arguments:
---
-- Grab keyboard and read pressed keys, calling callback function at each key
-- press, until keygrabber.stop is called.
-- The callback function is passed three arguments:
-- a table containing modifiers keys, a string with the key pressed and a
-- string with either "press" or "release" to indicate the event type.
-- @param func A callback function as described above.
-- @param callback A callback function as described above.
-- @name run
-- @class function
-- @usage Following function can be bound to a key, and used to resize a client
-- using keyboard.
-- <p><code>
-- function resize(c) <br/>
-- keygrabber.run(function(mod, key, event) </br>
-- if event == "release" then return true end </br><br/>
-- keygrabber.run(function(mod, key, event) </br>
-- if event == "release" then return end </br></br>
--
-- if key == 'Up' then awful.client.moveresize(0, 0, 0, 5, c) <br/>
-- elseif key == 'Down' then awful.client.moveresize(0, 0, 0, -5, c) <br/>
@ -26,7 +26,7 @@ module("keygrabber")
-- else keygrabber.stop() <br/>
-- end <br/><br/>
--
-- return true <br/>
-- end) <br/>
-- end <br/>
-- </code></p>