[client,windows] Implement complete keyboard indicator synchronization

This commit is contained in:
tsz8899
2026-02-07 02:33:01 +08:00
parent 5c7aae27d0
commit 9c3b638a5c
3 changed files with 38 additions and 0 deletions

View File

@@ -477,10 +477,14 @@ static BOOL wf_post_connect(freerdp* instance)
context->update->BeginPaint = wf_begin_paint;
context->update->DesktopResize = wf_desktop_resize;
context->update->EndPaint = wf_end_paint;
context->update->SetKeyboardIndicators = wf_keyboard_set_indicators;
wf_register_pointer(context->graphics);
wfc->floatbar = wf_floatbar_new(wfc, wfc->hInstance,
freerdp_settings_get_uint32(settings, FreeRDP_Floatbar));
wf_event_focus_in(wfc);
return TRUE;
}

View File

@@ -787,6 +787,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
g_focus_hWnd = hWnd;
freerdp_set_focus(wfc->common.context.instance);
wf_event_focus_in(wfc);
break;
case WM_KILLFOCUS:
@@ -965,3 +966,34 @@ static BOOL wf_scale_mouse_event_ex(wfContext* wfc, UINT16 flags, UINT16 buttonM
return wf_pub_mouse_event(wfc, flags, px, py);
}
#endif
BOOL wf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags)
{
wfContext* wfc = (wfContext*)context;
BYTE keyState[256];
if (!wfc || !GetKeyboardState(keyState))
return FALSE;
if (led_flags & KBD_SYNC_NUM_LOCK)
keyState[VK_NUMLOCK] |= 1;
else
keyState[VK_NUMLOCK] &= ~1;
if (led_flags & KBD_SYNC_CAPS_LOCK)
keyState[VK_CAPITAL] |= 1;
else
keyState[VK_CAPITAL] &= ~1;
if (led_flags & KBD_SYNC_SCROLL_LOCK)
keyState[VK_SCROLL] |= 1;
else
keyState[VK_SCROLL] &= ~1;
if (led_flags & KBD_SYNC_KANA_LOCK)
keyState[VK_KANA] |= 1;
else
keyState[VK_KANA] &= ~1;
return SetKeyboardState(keyState);
}

View File

@@ -30,6 +30,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
void wf_event_focus_in(wfContext* wfc);
BOOL wf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags);
#define KBD_TAG CLIENT_TAG("windows")
#ifdef WITH_DEBUG_KBD
#define DEBUG_KBD(...) WLog_DBG(KBD_TAG, __VA_ARGS__)