-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa840b3
commit c1a7221
Showing
7 changed files
with
131 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#include <winrt/Windows.System.h> | ||
#include <dispatcherqueue.h> | ||
namespace robmikh::common::desktop | ||
{ | ||
namespace impl | ||
{ | ||
inline winrt::fire_and_forget ShutdownAndThenPostQuitMessage(winrt::Windows::System::DispatcherQueueController const& controller, int exitCode) | ||
{ | ||
auto queue = controller.DispatcherQueue(); | ||
co_await controller.ShutdownQueueAsync(); | ||
co_await queue; | ||
PostQuitMessage(exitCode); | ||
co_return; | ||
} | ||
} | ||
|
||
inline auto CreateDispatcherQueueControllerForCurrentThread() | ||
{ | ||
namespace abi = ABI::Windows::System; | ||
|
||
DispatcherQueueOptions options | ||
{ | ||
sizeof(DispatcherQueueOptions), | ||
DQTYPE_THREAD_CURRENT, | ||
DQTAT_COM_NONE | ||
}; | ||
|
||
winrt::Windows::System::DispatcherQueueController controller{ nullptr }; | ||
winrt::check_hresult(CreateDispatcherQueueController(options, reinterpret_cast<abi::IDispatcherQueueController**>(winrt::put_abi(controller)))); | ||
return controller; | ||
} | ||
|
||
inline int ShutdownDispatcherQueueControllerAndWait(winrt::Windows::System::DispatcherQueueController const& controller, int exitCode) | ||
{ | ||
impl::ShutdownAndThenPostQuitMessage(controller, exitCode); | ||
MSG msg = {}; | ||
while (GetMessageW(&msg, nullptr, 0, 0)) | ||
{ | ||
TranslateMessage(&msg); | ||
DispatchMessageW(&msg); | ||
} | ||
return static_cast<int>(msg.wParam); | ||
} | ||
} |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Windows.CppWinRT" version="2.0.221104.6" targetFramework="native" /> | ||
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.231216.1" targetFramework="native" /> | ||
</packages> |
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 @@ | ||
#include "pch.h" |
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,29 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
|
||
// Windows | ||
#include <windows.h> | ||
#include <windowsx.h> | ||
|
||
// Must come before C++/WinRT | ||
#include <wil/cppwinrt.h> | ||
|
||
// WinRT | ||
#include <winrt/Windows.Foundation.h> | ||
#include <winrt/Windows.Foundation.Collections.h> | ||
#include <winrt/Windows.Foundation.Numerics.h> | ||
#include <winrt/Windows.System.h> | ||
#include <winrt/Windows.UI.Core.h> | ||
#include <winrt/Windows.UI.h> | ||
#include <winrt/Windows.UI.Composition.h> | ||
#include <winrt/Windows.UI.Composition.Desktop.h> | ||
#include <winrt/Windows.UI.Popups.h> | ||
#include <winrt/Windows.Graphics.Capture.h> | ||
#include <winrt/Windows.Graphics.DirectX.h> | ||
#include <winrt/Windows.Graphics.DirectX.Direct3d11.h> | ||
|
||
// WIL | ||
#include <wil/resource.h> | ||
|
||
#include "dispatcherQueue.desktop.interop.h" |