On Tue, Feb 21, 2012 at 10:45 PM, Anurag Priyam
<anurag08pri...@gmail.com> wrote:
> On Tue, Feb 21, 2012 at 10:33 PM, Daniel Silverstone
> <dsilv...@digital-scurf.org> wrote:
[...]
>> local keygrabber = (args.keygrabber == nil) and true or args.keygrabber
>>
>> That might work better for you
>
> Thanks Daniel.
>
> I will resend it tomorrow.  Need to study for tomorrow's exam now.

Sorry people.  I was caught up with exams and post exams partying around :).

Here is the correct patch, tested on both values (keygrabber =
true/false) this time.  But before this patch is applied, we should
perhaps consider removing keygrabber support from menu instead.
Optionally allowing keygrabbers adds to the complexity of the code.
And for what gains?  Without keygrabber enabled, you can't even close
the menu by pressing 'Escape' key (this is what prompted me to change
the default to true).

-- 
Anurag Priyam
From 5f8412a6e80824e7b5401ce3e26452760871b7c9 Mon Sep 17 00:00:00 2001
From: Anurag Priyam <anurag08pri...@gmail.com>
Date: Tue, 21 Feb 2012 21:52:53 +0530
Subject: [PATCH] awful.menu: enable keyboard navigation by default

Thanks to Daniel Silverstone for pointing out how to better deal with falsy
parameters.

Signed-off-by: Anurag Priyam <anurag08pri...@gmail.com>
---
 awesomerc.lua.in      |    2 +-
 lib/awful/menu.lua.in |    5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/awesomerc.lua.in b/awesomerc.lua.in
index 3929d9f..ceac430 100644
--- a/awesomerc.lua.in
+++ b/awesomerc.lua.in
@@ -210,7 +210,7 @@ globalkeys = awful.util.table.join(
             awful.client.focus.byidx(-1)
             if client.focus then client.focus:raise() end
         end),
-    awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
+    awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
 
     -- Layout manipulation
     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in
index 3e8566f..6dcdfc3 100644
--- a/lib/awful/menu.lua.in
+++ b/lib/awful/menu.lua.in
@@ -317,12 +317,13 @@ end
 --- Show a menu.
 -- @param menu The menu to show.
 -- @param args.keygrabber A boolean enabling or not the keyboard navigation.
+-- Default is true.
 -- @param args.coords Menu position defaulting to mouse.coords()
 function show(menu, args)
     args = args or {}
     local coords = args.coords or nil
     local screen_index = capi.mouse.screen
-    local keygrabber = args.keygrabber or false
+    local keygrabber = (args.keygrabber == nil) and true or args.keygrabber
 
     if not set_size(menu) then return end
     set_coords(menu, screen_index, coords)
@@ -367,6 +368,7 @@ end
 --- Toggle menu visibility.
 -- @param menu The menu to show if it's hidden, or to hide if it's shown.
 -- @param args.keygrabber A boolean enabling or not the keyboard navigation.
+-- Default is true.
 -- @param args.coords Menu position {x,y}
 function toggle(menu, args)
     if menu.wibox.visible then
@@ -489,6 +491,7 @@ end
 --- Build a popup menu with running clients and shows it.
 -- @param menu Menu table, see new() function for more informations
 -- @param args.keygrabber A boolean enabling or not the keyboard navigation.
+-- Default is true.
 -- @return The menu.
 function clients(menu, args) -- FIXME crude api
     menu = menu or {}
-- 
1.7.9

Reply via email to