This commit is contained in:
AlastorFox committed 2026-10-01 04:38:11 +03:00
1 parent 54a3e81109
commit e1ef325b3a
11 files changed
+505 -7

No files matched your search

+24 -3
View File
@@ -1,6 +1,8 @@
using System.Windows;
using System.Windows.Interop;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.Wpf;
using FoxBrowser.Native;
namespace FoxBrowser.UI;
@@ -10,14 +12,33 @@ public partial class ExtensionPopupWindow : Window
private readonly string _extensionId;
private readonly string _popupPage;
public ExtensionPopupWindow(CoreWebView2Environment environment, string extensionId, string popupPage, System.Drawing.Point screenPosition)
public ExtensionPopupWindow(
CoreWebView2Environment environment,
string extensionId,
string popupPage,
System.Windows.Point screenPosition,
System.Windows.Rect workingArea)
{
InitializeComponent();
_environment = environment;
_extensionId = extensionId;
_popupPage = popupPage;
Left = screenPosition.X;
Top = screenPosition.Y;
WindowStartupLocation = WindowStartupLocation.Manual;
SourceInitialized += (_, _) => Win32Interop.RemovePopupFrame(new WindowInteropHelper(this).Handle);
Width = Math.Min(Width, Math.Max(220, workingArea.Width - 8));
Height = Math.Min(Height, Math.Max(160, workingArea.Height - 8));
// Keep the popup on the monitor where the extension button lives.
// If there is no room below the toolbar, open it above the button.
var left = Math.Min(screenPosition.X, workingArea.Right - Width - 4);
left = Math.Max(left, workingArea.Left + 4);
var top = screenPosition.Y + 4;
if (top + Height > workingArea.Bottom - 4)
top = screenPosition.Y - Height - 4;
top = Math.Max(top, workingArea.Top + 4);
Left = left;
Top = top;
Deactivated += (_, _) => Close();
Loaded += async (_, _) => await InitializeAsync();
}