Skip to content

Commit

Permalink
b/218679437 Add setting to control Windows shortcut handling (#611)
Browse files Browse the repository at this point in the history
* Keep default (only pass shortcuts in full-screen mode)
* Add setting to change behavior (always, never)

This addresses #607.
  • Loading branch information
jpassing authored Feb 11, 2022
1 parent b6a52c6 commit 0db0d8b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@ public enum RdpNetworkLevelAuthentication
_Default = Enabled
}

public enum RdpHookWindowsKeys
{
//
// NB. Values correspond to IMsRdpClientSecuredSettings::KeyboardHookMode.
//
Never = 0,
Always = 1,
FullScreenOnly = 2,


[Browsable(false)]
_Default = FullScreenOnly
}

public abstract class ConnectionSettingsBase : IRegistrySettingsCollection
{
//---------------------------------------------------------------------
Expand All @@ -215,6 +229,7 @@ public abstract class ConnectionSettingsBase : IRegistrySettingsCollection
public RegistryEnumSetting<RdpRedirectPort> RdpRedirectPort { get; private set; }
public RegistryEnumSetting<RdpRedirectDrive> RdpRedirectDrive { get; private set; }
public RegistryEnumSetting<RdpRedirectDevice> RdpRedirectDevice { get; private set; }
public RegistryEnumSetting<RdpHookWindowsKeys> RdpHookWindowsKeys { get; private set; }

internal IEnumerable<ISetting> RdpSettings => new ISetting[]
{
Expand All @@ -237,7 +252,8 @@ public abstract class ConnectionSettingsBase : IRegistrySettingsCollection
this.RdpRedirectSmartCard,
this.RdpRedirectPort,
this.RdpRedirectDrive,
this.RdpRedirectDevice
this.RdpRedirectDevice,
this.RdpHookWindowsKeys
};

internal bool IsRdpSetting(ISetting setting) => this.RdpSettings.Contains(setting);
Expand Down Expand Up @@ -429,6 +445,13 @@ protected void InitializeFromKey(RegistryKey key)
Categories.RdpResources,
ConnectionSettings.RdpRedirectDevice._Default,
key);
this.RdpHookWindowsKeys = RegistryEnumSetting<RdpHookWindowsKeys>.FromKey(
"RdpHookWindowsKeys",
"Enable Windows shortcuts",
"Enable Windows shortcuts (like Win+R)",
Categories.RdpAdvanced,
ConnectionSettings.RdpHookWindowsKeys._Default,
key);

//
// SSH Settings.
Expand Down Expand Up @@ -509,6 +532,8 @@ protected static void ApplyOverlay<T>(
baseSettings.RdpRedirectDrive.OverlayBy(overlaySettings.RdpRedirectDrive);
prototype.RdpRedirectDevice = (RegistryEnumSetting<RdpRedirectDevice>)
baseSettings.RdpRedirectDevice.OverlayBy(overlaySettings.RdpRedirectDevice);
prototype.RdpHookWindowsKeys = (RegistryEnumSetting<RdpHookWindowsKeys>)
baseSettings.RdpHookWindowsKeys.OverlayBy(overlaySettings.RdpHookWindowsKeys);

prototype.SshPort = (RegistryDwordSetting)
baseSettings.SshPort.OverlayBy(overlaySettings.SshPort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,8 @@ InstanceConnectionSettings settings
//
// Keyboard settings.
//
// NB. Apply key combinations to the remote server only when the client is running
// in full-screen mode.
this.rdpClient.SecuredSettings2.KeyboardHookMode = 2;
this.rdpClient.SecuredSettings2.KeyboardHookMode =
(int)settings.RdpHookWindowsKeys.EnumValue;

advancedSettings.allowBackgroundInput = 1;

Expand Down

0 comments on commit 0db0d8b

Please sign in to comment.