Skip to content

Commit

Permalink
#4265 try keyval_to_unicode if string fails
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 13, 2024
1 parent 14bd959 commit 01b36a9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions xpra/client/gtk3/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2398,16 +2398,23 @@ def parse_key_event(self, event, pressed):
key_event.keyval = keyval or 0
key_event.keycode = keycode
key_event.group = event.group
key_event.pressed = pressed
try:
key_event.string = event.string or ""
except UnicodeDecodeError as e:
keylog("parse_key_event(%s, %s)", event, pressed, exc_info=True)
if first_time("key-%s-%s" % (keycode, keyname)):
keylog.warn("Warning: failed to parse string for key")
keylog.warn(" keyname=%s, keycode=%s", keyname, keycode)
keylog.warn(" %s", e)
key_event.string = ""
key_event.pressed = pressed
keylog(f"failed to parse string value of {event}", exc_info=True)
try:
codepoint = Gdk.keyval_to_unicode(keyval)
key_event.string = chr(codepoint)
except ValueError as ve:
if first_time(f"key-{keycode}-{keyname}"):
keylog("parse_key_event(%s, %s)", event, pressed, exc_info=True)
keylog.warn("Warning: failed to parse string for key")
keylog.warn(f" {keyname=}, {keycode=}")
keylog.warn(f" {keyval=}, group={event.group}")
keylog.warn(" modifiers=%s", csv(key_event.modifiers))
keylog.warn(" %s", e)
keylog.warn(f" unicode keyval also failed: {ve}")
keyeventlog("parse_key_event(%s, %s)=%s", event, pressed, key_event)
return key_event

Expand Down

0 comments on commit 01b36a9

Please sign in to comment.