awesome icon indicating copy to clipboard operation
awesome copied to clipboard

awful.keygrabber.run() does not consider Shift as a modifier key

Open dbedrenko opened this issue 2 years ago • 0 comments

Output of awesome --version:

awesome v4.3 (Too long) • Compiled against Lua 5.3.6 (running with Lua 5.3) • D-Bus support: ✔ • execinfo support: ✔ • xcb-randr version: 1.6 • LGI version: 0.9.2

How to reproduce the issue:

  1. Place these functions and keybinds in your rc.lua:
local keygrabber = keygrabber
local gears = require("gears")

-- Helps print a table.
function dump(o)
   if type(o) == 'table' then
      local s = '{ '
      for k,v in pairs(o) do
         if type(k) ~= 'number' then k = '"'..k..'"' end
         s = s .. '['..k..'] = ' .. dump(v) .. ','
      end
      return s .. '} '
   else
      return tostring(o)
   end
end

function switch(dir, mod_key1, release_key, mod_key2, key_switch)
	keygrabber.run(
		function (mod, key, event)
			print()
			print("Start function")
			print("mod:", dump(mod))
			print("mod_key1:", mod_key1)
			print("mod_key2:", mod_key2)
			if gears.table.hasitem(mod, mod_key1) then
				print("Key", key)
				print("release_Key", release_key)
				print("event", event)
       			        if gears.table.hasitem(mod, mod_key2) then
				        print("GO PREV")
			        else
				        print("GO FORWARD")
			        end
                        end
                end
      )
end

globalkeys = awful.util.table.join(
    awful.key({ "Mod1",           }, "Tab",
       function ()
		switch( 1, "Mod1", "Alt_L", "Shift_L", "Tab")
       end),
    awful.key({ "Mod1", "Shift"   }, "Tab",
       function ()
		switch(-1, "Mod1", "Alt_L", "Shift_L", "Tab")
       end),
)
  1. Press Alt and hold.
  2. Press Tab and release it.
  3. Press Shift and hold.
  4. Press Tab and release it.

Actual result:

"GO PREV" was never printed. The full output:

Start function
mod:    { [1] = Mod1,[2] = Mod2,}
mod_key1:       Mod1
mod_key2:       Shift_L
Key     Tab
release_Key     Alt_L
event   release

Start function
mod:    { [1] = Mod1,[2] = Mod2,}
mod_key1:       Mod1
mod_key2:       Shift_L
Key     Shift_L
release_Key     Alt_L
event   press

Start function
mod:    { [1] = Mod1,[2] = Mod2,}
mod_key1:       Mod1
mod_key2:       Shift_L
Key     Tab
release_Key     Alt_L
event   press
INSIDE SWITCH
GO FORWARD

Expected result:

"GO PREV" should be printed because "Shift" was pressed and should be in the Modifier Table mod.

Additional context:

I'm trying to get this Alt+Tab switcher working. It can cycle forward, but not cycle back (when I Alt+Shift+Tab): https://github.com/berlam/awesome-switcher#configuration

X11 modifiers on my computer:

$ xmodmap
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock
control     Control_L (0x25),  Control_L (0x42),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

I'm on latest Arch Linux btw.

dbedrenko avatar Jan 11 '22 00:01 dbedrenko