mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
Handle Quit event more gracefully
This commit is contained in:
16
PortabilityLayer/AppEventHandler.cpp
Normal file
16
PortabilityLayer/AppEventHandler.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "AppEventHandler.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
IAppEventHandler *AppEventHandler::ms_instance;
|
||||
|
||||
IAppEventHandler *AppEventHandler::GetInstance()
|
||||
{
|
||||
return ms_instance;
|
||||
}
|
||||
|
||||
void AppEventHandler::SetInstance(IAppEventHandler *instance)
|
||||
{
|
||||
ms_instance = instance;
|
||||
}
|
||||
}
|
||||
19
PortabilityLayer/AppEventHandler.h
Normal file
19
PortabilityLayer/AppEventHandler.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct IAppEventHandler
|
||||
{
|
||||
virtual void OnQuit() = 0;
|
||||
};
|
||||
|
||||
class AppEventHandler
|
||||
{
|
||||
public:
|
||||
static IAppEventHandler *GetInstance();
|
||||
static void SetInstance(IAppEventHandler *instance);
|
||||
|
||||
private:
|
||||
static IAppEventHandler *ms_instance;
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "PLCore.h"
|
||||
#include "AppEventHandler.h"
|
||||
#include "PLEventQueue.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLMovies.h"
|
||||
@@ -135,6 +136,14 @@ static void TranslateVOSEvent(const GpVOSEvent *vosEvent, uint32_t timestamp, Po
|
||||
case GpVOSEventTypes::kVideoResolutionChanged:
|
||||
TranslateVideoResolutionChangedEvent(vosEvent->m_event.m_resolutionChangedEvent);
|
||||
break;
|
||||
case GpVOSEventTypes::kQuit:
|
||||
if (TimeTaggedVOSEvent *evt = queue->Enqueue())
|
||||
*evt = TimeTaggedVOSEvent::Create(*vosEvent, timestamp);
|
||||
|
||||
if (PortabilityLayer::IAppEventHandler *appHandler = PortabilityLayer::AppEventHandler::GetInstance())
|
||||
appHandler->OnQuit();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@
|
||||
<ClInclude Include="AEHandlerDesc.h" />
|
||||
<ClInclude Include="AEManager.h" />
|
||||
<ClInclude Include="AntiAliasTable.h" />
|
||||
<ClInclude Include="AppEventHandler.h" />
|
||||
<ClInclude Include="ArrayTools.h" />
|
||||
<ClInclude Include="BinarySearch.h" />
|
||||
<ClInclude Include="BinHex4.h" />
|
||||
@@ -303,6 +304,7 @@
|
||||
<ClCompile Include="..\stb\stb_image_write.c" />
|
||||
<ClCompile Include="AEManager.cpp" />
|
||||
<ClCompile Include="AntiAliasTable.cpp" />
|
||||
<ClCompile Include="AppEventHandler.cpp" />
|
||||
<ClCompile Include="BinHex4.cpp" />
|
||||
<ClCompile Include="BitmapImage.cpp" />
|
||||
<ClCompile Include="ByteSwap.cpp" />
|
||||
|
||||
@@ -483,6 +483,9 @@
|
||||
<ClInclude Include="ArrayTools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AppEventHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CFileStream.cpp">
|
||||
@@ -758,5 +761,8 @@
|
||||
<ClCompile Include="TextPlacer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AppEventHandler.cpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user