Skip to content

Commit

Permalink
#178 avoided loading keymap on x11 twice during the start
Browse files Browse the repository at this point in the history
  • Loading branch information
ldrahnik committed May 26, 2024
1 parent 118a6b4 commit 89babcc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions numberpad.py
Expand Up @@ -34,6 +34,7 @@
keyboard_state = None
display = None
keymap_loaded = False
listening_touchpad_events_started = False

logging.basicConfig(
format='%(asctime)s %(levelname)s %(message)s',
Expand Down Expand Up @@ -451,7 +452,7 @@ def load_keymap_listener_wayland():


def load_keymap_listener_x11():
global stop_threads, display
global stop_threads, display, listening_touchpad_events_started

try:

Expand All @@ -460,9 +461,10 @@ def load_keymap_listener_x11():
event = display.next_event()
if event.type == Xlib.X.MappingNotify and event.count > 0 and event.request == Xlib.X.MappingKeyboard:

display.refresh_keyboard_mapping(event)
load_evdev_keys_for_x11()
#raise Xlib.error.ConnectionClosedError("fd") # testing purpose only
if listening_touchpad_events_started or not keymap_loaded:
display.refresh_keyboard_mapping(event)
load_evdev_keys_for_x11()
#raise Xlib.error.ConnectionClosedError("fd") # testing purpose only
except:
log.exception("X11 load keymap listener error. Exiting")
os.kill(os.getpid(), signal.SIGUSR1)
Expand Down Expand Up @@ -2432,6 +2434,7 @@ def signal_handler(signal, frame):
threads.append(t)
t.start()

listening_touchpad_events_started = True
listen_touchpad_events()
except:
logging.exception("Listening touchpad events unexpectedly failed")
Expand Down

0 comments on commit 89babcc

Please sign in to comment.