Store TS_SYNC_EVENT before module load

When a connection is made to a system with the client numlock pressed, a
TS_SYNC_EVENT is sent before the module is loaded. This TS_SYNC_EVENT
correctly contains the NumLock status as 'pressed'. The event is, however,
discarded as the module isn't loaded.

When the module is loaded, a TS_SYNC_EVENT is not sent again unless
client focus is removed from the xrdp window and re-applied. As a
result, the NumLock state is incorrect unless this is done.

This commit stores the last TS_SYNC_EVENT sent before a module is
loaded. When the module is loaded, the sync state can be correctly
communicated to the module.
This commit is contained in:
matt335672 2024-06-24 15:14:57 +01:00
parent ba1d93930a
commit 3f568b42fb
3 changed files with 27 additions and 6 deletions

View File

@ -526,6 +526,18 @@ xrdp_mm_setup_mod2(struct xrdp_mm *self)
if (self->mod->mod_connect(self->mod) == 0)
{
rv = 0; /* connect success */
// If we've received a recent TS_SYNC_EVENT, pass it on to
// the module so (e.g.) NumLock starts in the right state.
if (self->last_sync_saved)
{
int key_flags = self->last_sync_key_flags;
int device_flags = self->last_sync_device_flags;
self->last_sync_saved = 0;
self->mod->mod_event(self->mod, WM_KEYBRD_SYNC, key_flags,
device_flags, key_flags, device_flags);
}
}
else
{

View File

@ -447,6 +447,10 @@ struct xrdp_mm
struct display_control_monitor_layout_data *resize_data;
struct list *resize_queue;
tbus resize_ready;
/* Last sync event if a module isn't loaded */
int last_sync_saved;
int last_sync_key_flags;
int last_sync_device_flags;
};
struct xrdp_key_info

View File

@ -1673,13 +1673,18 @@ xrdp_wm_key_sync(struct xrdp_wm *self, int device_flags, int key_flags)
self->caps_lock = 1;
}
if (self->mm->mod != 0)
if (self->mm->mod != 0 && self->mm->mod->mod_event != 0)
{
if (self->mm->mod->mod_event != 0)
{
self->mm->mod->mod_event(self->mm->mod, WM_KEYBRD_SYNC, key_flags,
device_flags, key_flags, device_flags);
}
self->mm->mod->mod_event(self->mm->mod, WM_KEYBRD_SYNC, key_flags,
device_flags, key_flags, device_flags);
}
else
{
// Save the event for when the module is loaded
self->mm->last_sync_saved = 1;
self->mm->last_sync_key_flags = key_flags;
self->mm->last_sync_device_flags = device_flags;
}
return 0;