The problem was described here: http://thread.gmane.org/gmane.comp.window-managers.awesome.devel/6921

The patch looks not very elegant but I don't know how to make it better provided we want to save the "visible == true" functionality. I guess it was done so that clicking some specific menu entry leaves menu unclosed (does Awesome use it anywhere?). This means that menu must stay the whole time while command executes and only after decide to close itself (and subsequently stop keygrabber) or not.

Patch is attatched.

Best regards,
Alexander
>From 6de4c1ab088cf91c064d6fb9c672d0e428c527bc Mon Sep 17 00:00:00 2001
From: Alexander Yakushev <[email protected]>
Date: Mon, 26 Mar 2012 17:49:05 +0300
Subject: [PATCH] awful.menu: Don't break menu commands that need keygrabber

With recent modification of awful.menu (so that it now uses keygrabber
by default) commands that use keygrabber themselves try to run it
while the first keygrabber (menu one) is still active. This fix makes
the menu keygrabber stop before the command executes.

Signed-off-by: Alexander Yakushev <[email protected]>
---
 lib/awful/menu.lua.in |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in
index 8dd1763..8cace0e 100644
--- a/lib/awful/menu.lua.in
+++ b/lib/awful/menu.lua.in
@@ -258,9 +258,10 @@ function exec(menu, num, opts)
         get_root(menu):hide()
         util.spawn(cmd)
     elseif type(cmd) == "function" then
+        capi.keygrabber.stop()
         local visible, action = cmd(item, menu)
         if not visible then
-            get_root(menu):hide()
+            get_root(menu):hide(true)
         else
             menu:update()
             if menu.items[num] then
@@ -330,7 +331,8 @@ end
 
 --- Hide a menu popup.
 -- @param menu The menu to hide.
-function hide(menu)
+-- @param leave_keygrabber If true then keygrabber won't be stopped.
+function hide(menu, leave_keygrabber)
     -- Remove items from screen
     for i = 1, #menu.items do
         menu:item_leave(i)
@@ -344,7 +346,7 @@ function hide(menu)
     if cur_menu == menu then
         cur_menu = cur_menu.parent
     end
-    if not cur_menu then
+    if not cur_menu and not leave_keygrabber then
         capi.keygrabber.stop()
     end
     menu.wibox.visible = false
-- 
1.7.9.4

Reply via email to