Skip to content

Commit

Permalink
Store TS_SYNC_EVENT before module load
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matt335672 committed Aug 5, 2024
1 parent ba1d939 commit 3f568b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
12 changes: 12 additions & 0 deletions xrdp/xrdp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 4 additions & 0 deletions xrdp/xrdp_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions xrdp/xrdp_wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3f568b4

Please sign in to comment.