mirror of
https://github.com/1Remote/1Remote.git
synced 2026-04-25 13:36:03 +03:00
Labels
No labels
area-configuration
area-ct-app
area-ct-rdp
area-ct-remoteapp
area-ct-ssh
area-ct-vnc
area-launcher
area-list
area-tags
area-teamwork
bug
chore
dependencies
general-build/ci
general-performance
general-refactor
general-security
general-supportive
general-ux
meta-documentation
meta-enhancement
meta-enhancement
meta-feature
meta-help-wanted
meta-unknown-error
priority-hi
priority-low
pull-request
question
resolution-duplicate
resolution-invalid
resolution-wontfix
stale
task-put-off
task-still-considering
task-working-in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/1Remote#1897
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/1Remote/1Remote/pull/1005
Author: @Copilot
Created: 10/18/2025
Status: ❌ Closed
Base:
main← Head:copilot/fix-rdp-tab-focus-issue📝 Commits (3)
b5dee3cInitial plan155e020Fix RDP tab focus issue using Win32 SetForegroundWindow APIb5f3c5fImprove RDP focus handling with child window focus and SetFocus API📊 Changes
1 file changed (+43 additions, -10 deletions)
View changed files
📝
Ui/View/Host/ProtocolHosts/AxMsRdpClient09Host.xaml.cs(+43 -10)📄 Description
Problem
When switching between RDP tabs, keyboard focus remained on the previous (hidden) RDP session instead of transferring to the newly selected tab. Users had to manually click on the screen to regain proper keyboard focus, making tab switching frustrating and interrupting workflow.
This issue was reported in #530 and had been a known limitation as indicated by the comment in the code: "try to fix https://github.com/1Remote/1Remote/issues/530, but failed".
Root Cause
The RDP client is an ActiveX control (
AxMsRdpClient9NotSafeForScripting) hosted in aWindowsFormsHostwithin WPF. The existingFocusOnMe()method attempted to use standard WPF focus methods:However, these methods don't properly handle focus transfer to a Windows Forms control's native window handle. WPF's logical focus system and Windows Forms' focus mechanism are separate, and the ActiveX control requires setting focus at the Win32 window level.
Additionally, the RDP ActiveX control creates internal child windows for rendering and input handling. Simply focusing the parent control window is insufficient - the child window that actually handles keyboard input must be focused directly.
Solution
This fix uses Win32 APIs to properly set focus to the RDP control's child window when switching tabs. The implementation finds and focuses the child rendering/input window within the RDP ActiveX control hierarchy.
Changes Made
Added Win32 API Declarations:
SetForegroundWindow- Sets the window as the active foreground windowSetFocus- Sets keyboard focus to a specific windowGetWindow- Retrieves child windows from the control hierarchyFixed
GetHostHwnd()Method: Changed from returningIntPtr.Zeroto returning the actual RDP control's window handle with proper initialization checks:Updated
FocusOnMe()Method: Now properly handles the RDP control's window hierarchy:WindowsFormsHostcontainerGetWindowto find the child rendering/input windowSetFocus(with fallback to parent if no child found)SetForegroundWindowto activate the windowTesting
This fix requires a Windows environment for testing:
Impact
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.