rules: check for xtest and disable modifier checking if not available

This commit is contained in:
Peter F. Patel-Schneider 2022-01-16 20:15:39 -05:00
parent 56936a4d0a
commit f6b25a9685
1 changed files with 18 additions and 14 deletions

View File

@ -66,6 +66,7 @@ except Exception:
if x11:
display = Display()
try:
context = display.record_create_context(
0, [record.AllClients], [{
'core_requests': (0, 0),
@ -79,6 +80,9 @@ if x11:
'client_died': False,
}]
)
except Exception:
_log.warn('X11 xtest not available - Modifiers and KeyPress will not work correctly', exc_info=_sys.exc_info())
context = None
modifier_keycodes = display.get_modifier_mapping()
current_key_modifiers = 0
@ -104,7 +108,7 @@ def key_press_handler(reply):
current_key_modifiers = event.state & ~(1 << mod) if mod is not None else event.state
if x11:
if x11 and context is not None:
_thread.start_new_thread(display.record_enable_context, (context, key_press_handler))
# display.record_free_context(context) when should this be done??