Fix: Remote Desktop — 60fps, Screen-Wechsel live, Consent-Dialog sichtbar (v2.3.0)

- CaptureModeRunner: Thread.Sleep(150) → 16ms (~60fps) + Skip-if-unchanged via Pixel-Hash
- RtcService: rdp_switch_screen Handler — Screen wechseln ohne Consent-Dialog
- RtcService: Fallback bei Consent-Fehler → rdp_denied statt silent capture
- RdpConsentWindow: WindowStyle=ToolWindow + ShowInTaskbar=True (jetzt in Taskleiste sichtbar)
- RemoteDesktopPanel: Screen-Dropdown auch während aktiver Verbindung nutzbar
- Version: 2.2.0 → 2.3.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 09:23:36 +02:00
parent 0b2943087d
commit 99830e25f4
9 changed files with 64 additions and 16 deletions

View File

@@ -24,7 +24,6 @@ public static class CaptureModeRunner
var encParams = new EncoderParameters(1);
encParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60L);
// Capture-Region bestimmen: 0 = alle Screens, 1-N = spezifischer Screen
var allScreens = System.Windows.Forms.Screen.AllScreens;
Rectangle captureRect;
if (screenIdx <= 0 || screenIdx > allScreens.Length)
@@ -40,14 +39,27 @@ public static class CaptureModeRunner
captureRect = allScreens[screenIdx - 1].Bounds;
}
uint lastHash = 0;
var sw = System.Diagnostics.Stopwatch.StartNew();
while (tcp.Connected)
{
sw.Restart();
try
{
using var bmp = new Bitmap(captureRect.Width, captureRect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(bmp))
g.CopyFromScreen(captureRect.X, captureRect.Y, 0, 0, new Size(captureRect.Width, captureRect.Height));
var hash = SampleHash(bmp);
if (hash == lastHash)
{
var elapsed = (int)sw.ElapsedMilliseconds;
if (elapsed < 16) Thread.Sleep(16 - elapsed);
continue;
}
lastHash = hash;
byte[] jpeg;
using (var ms = new MemoryStream())
{
@@ -55,16 +67,32 @@ public static class CaptureModeRunner
jpeg = ms.ToArray();
}
// 4-Byte Länge (LE) + JPEG-Daten
stream.Write(BitConverter.GetBytes(jpeg.Length));
stream.Write(jpeg);
stream.Flush();
}
catch { break; }
Thread.Sleep(150); // ~6-7 fps
var frameMs = (int)sw.ElapsedMilliseconds;
if (frameMs < 16) Thread.Sleep(16 - frameMs); // cap at ~60 fps
}
}
catch { /* Verbindung fehlgeschlagen → Exit */ }
}
private static uint SampleHash(Bitmap bmp)
{
// Sample 64 evenly-distributed pixels — fast change detection, O(1)
uint h = 2166136261u;
int w = bmp.Width, ht = bmp.Height;
int stepX = Math.Max(1, w / 8);
int stepY = Math.Max(1, ht / 8);
for (int y = 0; y < ht; y += stepY)
for (int x = 0; x < w; x += stepX)
{
var c = bmp.GetPixel(x, y);
h = (h ^ (uint)c.ToArgb()) * 16777619u;
}
return h;
}
}