diff --git a/src/RynthCore.Engine/WebPanel/WebPanelHost.cs b/src/RynthCore.Engine/WebPanel/WebPanelHost.cs
index 8094090..52248bc 100644
--- a/src/RynthCore.Engine/WebPanel/WebPanelHost.cs
+++ b/src/RynthCore.Engine/WebPanel/WebPanelHost.cs
@@ -1041,10 +1041,34 @@ internal sealed unsafe class WebPanelHost
bool inPlace = IsAbove(_staHwnd, game) && (bandTop
? NextAbove(_staHwnd, IntPtr.Zero, skipTopmost: true) == IntPtr.Zero
: NextAbove(_staHwnd, IntPtr.Zero, skipTopmost: false) == target);
- if (inPlace) return;
+ if (inPlace) { ResetRaise(); return; }
SetWindowPos(_staHwnd, bandTop ? HWND_TOP : target, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ if (!bandTop || AtBandTop(game)) { ResetRaise(); return; }
+ // A topmost game: nothing in the normal band can go over it; leave it.
+ if (IsTopmost(game)) return;
+ if (_raiseBackoff > 0) { _raiseBackoff--; return; }
+ // While the game is the foreground window, HWND_TOP does not put ANY window over it, not even a new
+ // window of another process (probed in game 2026-11-13). Going topmost and straight back does: the
+ // panel lands at the top of the normal band, over the game, and the game keeps the foreground.
+ // NOACTIVATE on both, so focus never moves.
+ if (!_raiseLogged) { _raiseLogged = true; SafeLog("HWND_TOP did not raise the panel over the foreground game; raising via topmost and back"); }
+ SetWindowPos(_staHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ SetWindowPos(_staHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ if (AtBandTop(game)) { ResetRaise(); return; }
+ // If that keeps not working, say so once and back off to about once a second.
+ if (++_raiseMisses == 10) SafeLog("raising via topmost and back did not put the panel over the game");
+ if (_raiseMisses > 10) _raiseBackoff = 20;
}
+ /// Over the game with nothing but topmost windows (and its own dialogs) above it.
+ private bool AtBandTop(IntPtr game) => IsAbove(_staHwnd, game) && NextAbove(_staHwnd, IntPtr.Zero, skipTopmost: true) == IntPtr.Zero;
+
+ private void ResetRaise() { _raiseMisses = 0; _raiseBackoff = 0; }
+
+ private bool _raiseLogged; // panel thread only: log the topmost raise once per engine generation
+ private int _raiseMisses; // panel thread only: consecutive ticks the panel stayed under the game
+ private int _raiseBackoff; // panel thread only: ticks to skip before the next topmost attempt
+
///
/// The first window above that is not the panel or in its owner tree, not in
/// 's owner tree (the game, or none), and (with )
diff --git a/src/RynthCore.Engine/WebPanel/WebPanelNative.cs b/src/RynthCore.Engine/WebPanel/WebPanelNative.cs
index 16eda28..6a4cf92 100644
--- a/src/RynthCore.Engine/WebPanel/WebPanelNative.cs
+++ b/src/RynthCore.Engine/WebPanel/WebPanelNative.cs
@@ -20,6 +20,7 @@ internal static unsafe class WebPanelNative
public const int SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_SHOWNA = 8;
public const uint GW_HWNDPREV = 3, GA_ROOT = 2, GA_ROOTOWNER = 3;
public static readonly IntPtr HWND_TOP = IntPtr.Zero;
+ public static readonly IntPtr HWND_TOPMOST = new(-1), HWND_NOTOPMOST = new(-2);
public const uint EVENT_SYSTEM_FOREGROUND = 0x0003, WINEVENT_OUTOFCONTEXT = 0x0000;
public const int TRANSPARENT = 1, DEFAULT_GUI_FONT = 17, IDC_ARROW = 32512;