-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6174 from AvaloniaUI/feature/2736-applicationShou…
…ldTerminate OSX: Handle applicationShouldTerminate
- Loading branch information
Showing
10 changed files
with
111 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Avalonia.Controls/Platform/IPlatformLifetimeEventsImpl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace Avalonia.Platform | ||
{ | ||
public interface IPlatformLifetimeEventsImpl | ||
{ | ||
/// <summary> | ||
/// Raised by the platform when a shutdown is requested. | ||
/// </summary> | ||
/// <remarks> | ||
/// Raised on on OSX via the Quit menu or right-clicking on the application icon and selecting Quit. | ||
/// </remarks> | ||
event EventHandler<CancelEventArgs> ShutdownRequested; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using Avalonia.Native.Interop; | ||
using Avalonia.Platform; | ||
|
||
namespace Avalonia.Native | ||
{ | ||
internal class AvaloniaNativeApplicationPlatform : CallbackBase, IAvnApplicationEvents | ||
internal class AvaloniaNativeApplicationPlatform : CallbackBase, IAvnApplicationEvents, IPlatformLifetimeEventsImpl | ||
{ | ||
public event EventHandler<CancelEventArgs> ShutdownRequested; | ||
|
||
void IAvnApplicationEvents.FilesOpened(IAvnStringArray urls) | ||
{ | ||
((IApplicationPlatformEvents)Application.Current).RaiseUrlsOpened(urls.ToStringArray()); | ||
} | ||
|
||
public int TryShutdown() | ||
{ | ||
if (ShutdownRequested is null) return 1; | ||
var e = new CancelEventArgs(); | ||
ShutdownRequested(this, e); | ||
return (!e.Cancel).AsComBool(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters