From 014d191f66a2282e8562f2a835d30b0246da72a1 Mon Sep 17 00:00:00 2001 From: Anurag Priyam Date: Tue, 21 Feb 2012 20:25:55 +0530 Subject: [PATCH] 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 Signed-off-by: Uli Schlachter --- event.c | 2 -- keygrabber.c | 3 +-- luadoc/keygrabber.lua | 16 ++++++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/event.c b/event.c index db18807ca..c28a3ca2b 100644 --- a/event.c +++ b/event.c @@ -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 */ } diff --git a/keygrabber.c b/keygrabber.c index 85c20a93c..6f683a5d6 100644 --- a/keygrabber.c +++ b/keygrabber.c @@ -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. diff --git a/luadoc/keygrabber.lua b/luadoc/keygrabber.lua index f7ae788ea..8b70196aa 100644 --- a/luadoc/keygrabber.lua +++ b/luadoc/keygrabber.lua @@ -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. --

-- function resize(c)
--- keygrabber.run(function(mod, key, event)
--- if event == "release" then return true end

+-- keygrabber.run(function(mod, key, event)
+-- if event == "release" then return end

-- -- if key == 'Up' then awful.client.moveresize(0, 0, 0, 5, c)
-- elseif key == 'Down' then awful.client.moveresize(0, 0, 0, -5, c)
@@ -26,7 +26,7 @@ module("keygrabber") -- else keygrabber.stop()
-- end

-- --- return true
+-- end)
-- end
--