Linux: Allow using XKB key names to bind shortcuts to keys not supported by GLFW

Useful to bind keys such as the play/pause or volume buttons. Also can
be used to bind non-ascii keys on international keyboards. Fixes #665
This commit is contained in:
Kovid Goyal
2018-06-22 12:41:50 +05:30
parent 5dd3243674
commit c8fc21d336
7 changed files with 104 additions and 36 deletions

View File

@@ -69,7 +69,7 @@ def load_all_shaders(semi_transparent=0):
load_borders_program()
def init_graphics(debug_keyboard=False):
def init_glfw(debug_keyboard=False):
glfw_module = 'cocoa' if is_macos else ('wayland' if is_wayland else 'x11')
if debug_keyboard:
os.environ['GLFW_DEBUG_KEYBOARD'] = '1'
@@ -95,7 +95,7 @@ def get_new_os_window_trigger(opts):
from .fast_data_types import cocoa_set_new_window_trigger
new_os_window_shortcuts.sort(key=prefer_cmd_shortcuts, reverse=True)
for candidate in new_os_window_shortcuts:
if cocoa_set_new_window_trigger(*candidate):
if cocoa_set_new_window_trigger(candidate[0], candidate[2]):
new_os_window_trigger = candidate
break
return new_os_window_trigger
@@ -240,10 +240,10 @@ def _main():
if not is_first:
talk_to_instance(args)
return
init_glfw(args.debug_keyboard) # needed for parsing native keysyms
opts = create_opts(args)
if opts.editor != '.':
os.environ['EDITOR'] = opts.editor
init_graphics(args.debug_keyboard)
try:
with setup_profiling(args):
# Avoid needing to launch threads to reap zombies