mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-04-28 17:11:14 +00:00
remove recreate behaviour from activate event on mac, and emit event to handler instead
This commit is contained in:
@@ -25,6 +25,41 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public static bool SocketDebug { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when the user clicks on the dock on Mac
|
||||
/// <para/>
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public event Action Activate
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_appActivate == null)
|
||||
{
|
||||
BridgeConnector.On("app-activate", () =>
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
_appActivate();
|
||||
}
|
||||
});
|
||||
}
|
||||
_appActivate += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_appActivate -= value;
|
||||
|
||||
if (_appActivate == null)
|
||||
{
|
||||
BridgeConnector.Off("app-activate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _appActivate;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when all windows have been closed.
|
||||
/// <para/>
|
||||
|
||||
@@ -116,14 +116,14 @@ namespace ElectronNET.API
|
||||
}
|
||||
});
|
||||
|
||||
if (loadUrl.ToUpper() == "HTTP://LOCALHOST")
|
||||
if (string.Equals(loadUrl, "HTTP://LOCALHOST", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
loadUrl = $"{loadUrl}:{BridgeSettings.WebPort}";
|
||||
}
|
||||
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
if (isWindows10())
|
||||
if (IsWindows10())
|
||||
{
|
||||
options.Width = options.Width + 14;
|
||||
options.Height = options.Height + 7;
|
||||
@@ -140,22 +140,20 @@ namespace ElectronNET.API
|
||||
{
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
if (isWindows10())
|
||||
if (IsWindows10())
|
||||
{
|
||||
options.X = options.X - 7;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BridgeConnector.Emit("createBrowserWindow", JObject.FromObject(options, _keepDefaultValuesSerializer), loadUrl);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private bool isWindows10()
|
||||
private bool IsWindows10()
|
||||
{
|
||||
return RuntimeInformation.OSDescription.Contains("Windows 10");
|
||||
return OperatingSystem.IsWindowsVersionAtLeast(10);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user