Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/RdpManager/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -63,6 +64,9 @@ public class AppSettings
// Domyślne przekierowania dla NOWO tworzonych serwerów RDP (istniejące zachowują swoje).
public bool DefaultRedirectClipboard { get; set; } = true;
public bool DefaultRedirectDrives { get; set; } = false; // dyski + drukarki
/// <summary>Gdzie działają skróty Windows (Win, Alt+Tab) w sesji RDP: 0 = na tym komputerze,
/// 1 = na komputerze zdalnym. Serwer może to nadpisać (ServerInfo.KeyboardHookMode).</summary>
public int RdpKeyboardHookMode { get; set; }
// Ile sekund czekać na TCP zanim serwer uznamy za offline (sonda osiągalności).
public int ProbeTimeoutSeconds { get; set; } = 2;

Expand Down Expand Up @@ -143,6 +147,16 @@ public class AppSettings
/// Domyślnie wyłączone — dane z sondowania osiągalności w tle.</summary>
public bool ShowLatency { get; set; }

/// <summary>Szerokość panelu bocznego (lista serwerów) w px przed zoomem UI. Zmieniana przeciąganiem
/// prawej krawędzi panelu (issue #268); przy wczytaniu przycinana do zakresu Min–Max.</summary>
public double SidebarWidth { get; set; } = SidebarWidthDefault;
public const double SidebarWidthDefault = 228;
public const double SidebarWidthMin = 180;
public const double SidebarWidthMax = 480;

public static double ClampSidebarWidth(double width) =>
double.IsNaN(width) ? SidebarWidthDefault : Math.Clamp(width, SidebarWidthMin, SidebarWidthMax);

/// <summary>Własny kolor akcentu („#RRGGBB"); pusty = domyślny Compass (per motyw). Compass §4.7 —
/// nadpisuje rodzinę kluczy Accent* i akcent kontrolek WPF-UI (ThemeManager).</summary>
public string AccentColor { get; set; } = "";
Expand Down
10 changes: 7 additions & 3 deletions src/RdpManager/Controllers/FullscreenController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ private void ShowFocusPeek()
// samą skalę co panel dokowany i mieścił się na ekranie (przy <100% był ucięty od dołu).
_owner.FocusPeekScale.ScaleX = _owner.FocusPeekScale.ScaleY = _owner.RootScale.ScaleY;
_owner.FocusPeekClip.Height = _owner.BodyGrid.ActualHeight;
double peekWidth = PeekWidth(); // rail + panel o szerokości ustawionej przez użytkownika
_owner.FocusPeekClip.Width = peekWidth;
// Solidne podłoże pod prześwitującym panelem (Panel ~3%) — bez niego treść sesji przebija peek.
_owner.FocusPeekClip.Background = FocusPeekBackground();
_owner.FocusPeekPopup.IsOpen = true;

// 260 ms = MotionSlow ze skali ruchu (Themes/Metrics.xaml): panel pokonuje 280 px, więc
// 260 ms = MotionSlow ze skali ruchu (Themes/Metrics.xaml): panel pokonuje ~280 px, więc
// dostaje najdłuższy czas — przy 160 ms ruch na tym dystansie czyta się jak przeskok.
var slide = new System.Windows.Media.Animation.DoubleAnimation(-280, 0,
var slide = new System.Windows.Media.Animation.DoubleAnimation(-peekWidth, 0,
new Duration(TimeSpan.FromMilliseconds(260)))
{
EasingFunction = new System.Windows.Media.Animation.CubicEase
Expand All @@ -168,12 +170,14 @@ private void ShowFocusPeek()
_owner.FocusPeekSlide.BeginAnimation(System.Windows.Media.TranslateTransform.XProperty, slide);
}

private double PeekWidth() => _owner.Rail.Width + _owner.Sidebar.Width;

internal void HideFocusPeek()
{
if (!_focusPeeking) return;
_focusPeeking = false;
_owner.FocusPeekSlide.BeginAnimation(System.Windows.Media.TranslateTransform.XProperty, null);
_owner.FocusPeekSlide.X = -280;
_owner.FocusPeekSlide.X = -PeekWidth();
_owner.FocusPeekPopup.IsOpen = false;
_owner.FocusPeekHost.Children.Remove(_owner.Rail);
_owner.FocusPeekHost.Children.Remove(_owner.Sidebar);
Expand Down
9 changes: 9 additions & 0 deletions src/RdpManager/Core/RdpConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ public static class RdpConfigurator
/// <summary>Tryb dźwięku → zakres 0..2 (mapuje na AudioRedirectionMode).</summary>
public static uint ClampAudioMode(int mode) => (uint)Math.Clamp(mode, 0, 2);

/// <summary>Tryb skrótów Windows (SecuredSettings2.KeyboardHookMode): ustawienie serwera (0/1) wygrywa,
/// inaczej globalne. Tryb 2 („zdalnie tylko w pełnym ekranie") pomijamy: dotyczy pełnego ekranu
/// samej kontrolki, a Waypoint robi pełny ekran własnym oknem, więc 2 działało jak 0.</summary>
public static int KeyboardHookMode(int serverMode, int globalMode)
{
if (serverMode == 0 || serverMode == 1) return serverMode;
return globalMode == 1 ? 1 : 0;
}

/// <summary>Metoda użycia bramy RD Gateway: 0 gdy brak hosta bramy; inaczej wartość skonfigurowana,
/// a 0 przy podanym hoście traktujemy jak 1 („zawsze przez bramę").</summary>
public static uint GatewayUsageMethod(string gatewayHostname, int configured)
Expand Down
4 changes: 4 additions & 0 deletions src/RdpManager/Core/RdpFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public static ServerInfo Parse(string content)
if (map.TryGetValue("drivestoredirect", out var drv))
s.RedirectDrives = !string.IsNullOrWhiteSpace(drv);
if (TryGetInt(map, "audiomode", out var audio)) s.AudioMode = Clamp(audio, 0, 2);
// 2 = domyślne mstsc („tylko w pełnym ekranie") — u nas zostaje -1, czyli wg ustawień.
if (TryGetInt(map, "keyboardhook", out var kbd) && (kbd == 0 || kbd == 1)) s.KeyboardHookMode = kbd;
if (TryGetInt(map, "authentication level", out var auth)) s.AuthenticationLevel = Clamp(auth, 0, 2);
if (TryGetInt(map, "use multimon", out var mm)) s.UseAllMonitors = mm != 0;
if (TryGetInt(map, "administrative session", out var admin)) s.AdminSession = admin != 0;
Expand Down Expand Up @@ -108,6 +110,8 @@ public static string Serialize(ServerInfo s)
sb.Append("redirectprinters:i:").Append(s.RedirectPrinters ? "1" : "0").Append("\r\n");
sb.Append("drivestoredirect:s:").Append(s.RedirectDrives ? "*" : "").Append("\r\n");
sb.Append("audiomode:i:").Append(Clamp(s.AudioMode, 0, 2).ToString(CultureInfo.InvariantCulture)).Append("\r\n");
if (s.KeyboardHookMode == 0 || s.KeyboardHookMode == 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 | Confidence: High

Servers normally use KeyboardHookMode = -1 to inherit the global setting. The connection resolver applies that global choice, but the exporter receives only the server and writes keyboardhook only for explicit overrides. Thus, an inherited remote choice is omitted and mstsc uses its default mode 2—remote only in full screen—while an inherited local choice is not explicitly preserved in a full-screen mstsc session. Existing round-trip tests intentionally expect omission to preserve Waypoint's inheritance marker on reimport, but that does not preserve effective behavior in an mstsc-compatible export.

Evidence: changed region in src/RdpManager/Core/RdpFile.cs; changed region in src/RdpManager/Core/RdpConfigurator.cs; changed region in src/RdpManager/Models/ServerInfo.cs; changed region in tests/RdpManager.Tests/KeyboardHookModeTests.cs.

sb.Append("keyboardhook:i:").Append(s.KeyboardHookMode.ToString(CultureInfo.InvariantCulture)).Append("\r\n");
sb.Append("authentication level:i:").Append(Clamp(s.AuthenticationLevel, 0, 2).ToString(CultureInfo.InvariantCulture)).Append("\r\n");
sb.Append("use multimon:i:").Append(s.UseAllMonitors ? "1" : "0").Append("\r\n");
sb.Append("administrative session:i:").Append(s.AdminSession ? "1" : "0").Append("\r\n");
Expand Down
24 changes: 24 additions & 0 deletions src/RdpManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,17 @@
<!-- Import celowo bez przycisku tutaj — rail ma dedykowany NavImport (ten sam OpenImport_Click). -->
</StackPanel>
</Border>

<!-- Uchwyt zmiany szerokości panelu (issue #268): przeciągnięcie prawej krawędzi.
Wewnątrz Sidebar, więc przy peeku w trybie skupienia jedzie razem z nim. -->
<Thumb x:Name="SidebarResizeThumb" Grid.RowSpan="4" Width="5" HorizontalAlignment="Right"
Cursor="SizeWE" DragDelta="SidebarResize_DragDelta" DragCompleted="SidebarResize_DragCompleted">
<Thumb.Template>
<ControlTemplate TargetType="Thumb">
<Border Background="Transparent"/>
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Grid>
</Border>

Expand Down Expand Up @@ -1025,6 +1036,19 @@
<ui:ToggleSwitch x:Name="SetRedirClip" Grid.Column="1" VerticalAlignment="Center"/>
</Grid>
</Border>
<Border Style="{DynamicResource SetRow}">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{DynamicResource S.set.kbdhook}" Style="{DynamicResource SetLbl}"/>
<TextBlock Text="{DynamicResource S.set.kbdhook.sub}" Style="{DynamicResource SetSub}"/>
</StackPanel>
<ComboBox x:Name="SetKeyboardHook" Grid.Column="1" Width="190" VerticalAlignment="Center">
<ComboBoxItem Content="{DynamicResource S.kbdhook.local}"/>
<ComboBoxItem Content="{DynamicResource S.kbdhook.remote}"/>
</ComboBox>
</Grid>
</Border>
<Border Style="{DynamicResource SetRow}" BorderThickness="0">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
Expand Down
15 changes: 14 additions & 1 deletion src/RdpManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
_vm.UseRecentIds(_settings.RecentIds); // współdziel listę „ostatnich" z ustawieniami
_tabs.LoadTabGroups(); // grupy kart z poprzedniej sesji (przypisanie po Id serwera)
ApplyUiScale(_settings.UiScale);
Sidebar.Width = AppSettings.ClampSidebarWidth(_settings.SidebarWidth);

_fs.Init(); // pasek pełnoekranowy (opóźnienie + polling) + peek trybu skupienia (PR 5)

Expand Down Expand Up @@ -1119,6 +1120,7 @@ private void LoadSettingsForm()
SelectColorDepthSeg(_settings.ColorDepth);
SetRedirClip.IsChecked = _settings.DefaultRedirectClipboard;
SetRedirDrives.IsChecked = _settings.DefaultRedirectDrives;
SetKeyboardHook.SelectedIndex = _settings.RdpKeyboardHookMode == 1 ? 1 : 0;
SetProbeTimeout.Text = _settings.ProbeTimeoutSeconds.ToString();
SetAutoReconnect.IsChecked = _settings.AutoReconnect;
SetReachEnabled.IsChecked = _settings.ReachabilityEnabled;
Expand Down Expand Up @@ -1373,6 +1375,7 @@ private void SaveSettings_Click(object sender, RoutedEventArgs e)
_settings.RdpScalePercent = RdpDisplay.ParseScale(ComboTag(SetRdpScale));
_settings.DefaultRedirectClipboard = SetRedirClip.IsChecked == true;
_settings.DefaultRedirectDrives = SetRedirDrives.IsChecked == true;
_settings.RdpKeyboardHookMode = SetKeyboardHook.SelectedIndex == 1 ? 1 : 0;
_settings.ProbeTimeoutSeconds = int.TryParse(SetProbeTimeout.Text.Trim(), out var pt) ? Math.Clamp(pt, 1, 60) : 2;
_settings.AutoReconnect = SetAutoReconnect.IsChecked == true;
_settings.ReachabilityEnabled = SetReachEnabled.IsChecked == true;
Expand Down Expand Up @@ -1895,6 +1898,16 @@ private FrameworkElement StatCard(string label, string value)

private void FsBarThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) => _fs.OnBarThumbDragDelta(e);

// Szerokość panelu bocznego (issue #268). Zapis dopiero po puszczeniu myszy, nie co ruch.
private void SidebarResize_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) =>
Sidebar.Width = AppSettings.ClampSidebarWidth(Sidebar.Width + e.HorizontalChange);

private void SidebarResize_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
{
_settings.SidebarWidth = Sidebar.Width;
QueueSettingsSave();
}



// Przyklejony nagłówek grupy (układ „Płaskie sekcje") — nakładka nad listą, aktualizowana
Expand Down Expand Up @@ -3078,7 +3091,7 @@ internal void DuplicateServer(ServerInfo src)
Protocol = src.Protocol, PrivateKeyPath = src.PrivateKeyPath,
Tunnels = new List<string>(src.Tunnels ?? new List<string>()),
RedirectClipboard = src.RedirectClipboard, RedirectDrives = src.RedirectDrives,
RedirectPrinters = src.RedirectPrinters, AudioMode = src.AudioMode,
RedirectPrinters = src.RedirectPrinters, AudioMode = src.AudioMode, KeyboardHookMode = src.KeyboardHookMode,
AuthenticationLevel = src.AuthenticationLevel, UseAllMonitors = src.UseAllMonitors,
AdminSession = src.AdminSession, MacAddress = src.MacAddress,
RemoteAppProgram = src.RemoteAppProgram, RemoteAppArgs = src.RemoteAppArgs,
Expand Down
4 changes: 4 additions & 0 deletions src/RdpManager/Models/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public class ServerInfo
/// <summary>Dźwięk: 0 = odtwarzaj lokalnie, 1 = nie odtwarzaj, 2 = odtwarzaj na serwerze.</summary>
public int AudioMode { get; set; }

/// <summary>Gdzie działają skróty Windows (Win, Alt+Tab) w sesji RDP: -1 = jak w ustawieniach,
/// 0 = na tym komputerze, 1 = na komputerze zdalnym (issue #270).</summary>
public int KeyboardHookMode { get; set; } = -1;

/// <summary>
/// Weryfikacja tożsamości serwera (mapuje na IMsRdpClientAdvancedSettings.AuthenticationLevel):
/// 0 = nie sprawdzaj (niebezpieczne, ryzyko MITM),
Expand Down
3 changes: 2 additions & 1 deletion src/RdpManager/RdpConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public static void Apply(AxMsRdpClient11NotSafeForScripting rdp, ServerInfo serv
adv.RedirectDrives = server.RedirectDrives;
adv.RedirectPrinters = server.RedirectPrinters;
adv.AudioRedirectionMode = RdpConfigurator.ClampAudioMode(server.AudioMode);
try { rdp.SecuredSettings2.KeyboardHookMode = 2; } catch { } // Alt+Tab/Win -> zdalna w pełnym ekranie
// Skróty Windows (Win, Alt+Tab) lokalnie albo w sesji; da się ustawić tylko przed połączeniem.
try { rdp.SecuredSettings2.KeyboardHookMode = RdpConfigurator.KeyboardHookMode(server.KeyboardHookMode, settings.RdpKeyboardHookMode); } catch { }

// UseMultimon = false: pełny ekran kontrolki (FullScreen + UseMultimon) crashuje w WindowsFormsHost
// (SEH w DispatchMessage). Multi-monitor realizujemy rozpięciem NASZEGO okna, nie kontrolki.
Expand Down
9 changes: 9 additions & 0 deletions src/RdpManager/ServerEditWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@
</StackPanel>
</Grid>

<StackPanel Margin="0,10,0,4" Width="260" HorizontalAlignment="Left">
<TextBlock Style="{StaticResource SeLbl}" Text="{DynamicResource S.set.kbdhook}"/>
<ComboBox x:Name="EdKeyboardHook" HorizontalAlignment="Stretch">
<ComboBoxItem Content="{DynamicResource S.kbdhook.default}"/>
<ComboBoxItem Content="{DynamicResource S.kbdhook.local}"/>
<ComboBoxItem Content="{DynamicResource S.kbdhook.remote}"/>
</ComboBox>
</StackPanel>

<TextBlock Style="{StaticResource SeSub}" Margin="0,14,0,8" Text="{DynamicResource S.se.gateway}"/>
<ui:TextBox x:Name="GatewayHostBox" PlaceholderText="{DynamicResource S.se.gateway.ph}"/>
<StackPanel Margin="0,10,0,0" Width="260" HorizontalAlignment="Left">
Expand Down
2 changes: 2 additions & 0 deletions src/RdpManager/ServerEditWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public ServerEditWindow(ServerInfo server, string currentPassword, List<Credenti
TagsBox.Text = server.Tags == null ? "" : string.Join(", ", server.Tags);
NotesBox.Text = server.Notes ?? "";
EdAudio.SelectedIndex = Math.Clamp(server.AudioMode, 0, 2);
EdKeyboardHook.SelectedIndex = server.KeyboardHookMode == 0 || server.KeyboardHookMode == 1 ? server.KeyboardHookMode + 1 : 0;
EdAuthLevel.SelectedIndex = Math.Clamp(server.AuthenticationLevel, 0, 2);
GatewayHostBox.Text = server.GatewayHostname ?? "";
EdGatewayUsage.SelectedIndex = Math.Clamp(server.GatewayUsageMethod, 0, 2);
Expand Down Expand Up @@ -434,6 +435,7 @@ private void Save_Click(object sender, RoutedEventArgs e)
_server.Tags = ParseTags(TagsBox.Text);
_server.Notes = NotesBox.Text.Trim();
_server.AudioMode = EdAudio.SelectedIndex < 0 ? 0 : EdAudio.SelectedIndex;
_server.KeyboardHookMode = EdKeyboardHook.SelectedIndex <= 0 ? -1 : EdKeyboardHook.SelectedIndex - 1;
_server.AuthenticationLevel = EdAuthLevel.SelectedIndex < 0 ? 2 : EdAuthLevel.SelectedIndex;
_server.GatewayHostname = GatewayHostBox.Text.Trim();
_server.GatewayUsageMethod = EdGatewayUsage.SelectedIndex < 0 ? 0 : EdGatewayUsage.SelectedIndex;
Expand Down
5 changes: 5 additions & 0 deletions src/RdpManager/Themes/Strings.en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<sys:String x:Key="S.set.sec.profiles">CREDENTIAL PROFILES</sys:String>
<sys:String x:Key="S.set.redirclip">Redirect clipboard</sys:String>
<sys:String x:Key="S.set.redirdrives">Redirect drives and printers</sys:String>
<sys:String x:Key="S.set.kbdhook">Windows key combinations (Win, Alt+Tab)</sys:String>
<sys:String x:Key="S.set.kbdhook.sub">Where they apply in an RDP session. Takes effect on the next connection.</sys:String>
<sys:String x:Key="S.kbdhook.default">As in settings</sys:String>
<sys:String x:Key="S.kbdhook.local">On this computer</sys:String>
<sys:String x:Key="S.kbdhook.remote">On the remote computer</sys:String>
<sys:String x:Key="S.set.timeout">Connection timeout (s)</sys:String>
<sys:String x:Key="S.set.timeout.sub">Seconds before aborting the attempt (reachability probe)</sys:String>
<sys:String x:Key="S.set.about.sub">Version, updates and changelog.</sys:String>
Expand Down
5 changes: 5 additions & 0 deletions src/RdpManager/Themes/Strings.pl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<sys:String x:Key="S.set.sec.profiles">PROFILE POŚWIADCZEŃ</sys:String>
<sys:String x:Key="S.set.redirclip">Przekieruj schowek</sys:String>
<sys:String x:Key="S.set.redirdrives">Przekieruj dyski i drukarki</sys:String>
<sys:String x:Key="S.set.kbdhook">Skróty Windows (Win, Alt+Tab)</sys:String>
<sys:String x:Key="S.set.kbdhook.sub">Gdzie działają w sesji RDP. Zmiana działa od następnego połączenia.</sys:String>
<sys:String x:Key="S.kbdhook.default">Jak w ustawieniach</sys:String>
<sys:String x:Key="S.kbdhook.local">Na tym komputerze</sys:String>
<sys:String x:Key="S.kbdhook.remote">Na komputerze zdalnym</sys:String>
<sys:String x:Key="S.set.timeout">Limit czasu połączenia (s)</sys:String>
<sys:String x:Key="S.set.timeout.sub">Sekundy do przerwania próby (sonda osiągalności)</sys:String>
<sys:String x:Key="S.set.about.sub">Wersja, aktualizacje i historia zmian.</sys:String>
Expand Down
Loading