Skip to content

Commit 1510d25

Browse files
committed
Cache GUIVM keyboard layout in qvm-start-daemon
On XFCE systems with multiple keyboard layouts and with XFCE Keyboard Layout widget, X raises two `XKLAVIER_ALLOW_SECONDARY` events shortly after each other (see 1st issue). The current intended behaviour is to ignore the 2nd event by checking if the GUIVMs current layout is similar to the new requested layout. Unfortunately, after setting the GUIVM's keyboard layout, Qubes Core goes to this loop to propagate the new layout to all child qubes: https://github.com/QubesOS/qubes-core-admin/blob/main/qubes/ext/gui.py#L162-L170 And even if we move the condition after that loop just before it, it is still too slow to report back the new layout via qubesdb for `qvm-stat-daemon` use. In order to avoid this race condition, it would be better to cache the layout within `qvm-start-daemon` itself. fixes: QubesOS/qubes-issues#8441 fixes: QubesOS/qubes-issues#6517
1 parent f9eb4a5 commit 1510d25

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

qubesadmin/tools/qvm_start_daemon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ def __init__(self, binary_string):
363363
self.options = ",".join(
364364
opt for opt in self.options.split(",") if not opt.startswith("grp:")
365365
)
366+
self.current_layout = None
366367

367368
def get_property(self, layout_num):
368369
"""Return the selected keyboard layout as formatted for keyboard_layout
@@ -449,10 +450,9 @@ def update_keyboard_layout(self):
449450
"""Update current vm's keyboard_layout property"""
450451
new_property = self.keyboard_layout.get_property(self.selected_layout)
451452

452-
current_property = self.current_vm.keyboard_layout
453-
454-
if new_property != current_property:
453+
if new_property != self.keyboard_layout.current_layout:
455454
self.current_vm.keyboard_layout = new_property
455+
self.keyboard_layout.current_layout = new_property
456456

457457
def event_reader(self, callback):
458458
"""Poll for X events related to keyboard layout"""

0 commit comments

Comments
 (0)