mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-12 14:20:17 +01:00
Compare commits
14 Commits
shawn/Sett
...
async-cpp-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c89141a4 | ||
|
|
f2f17eb0f0 | ||
|
|
13cc6fd13e | ||
|
|
eedc6ceccc | ||
|
|
3b53810727 | ||
|
|
b1f933c0b3 | ||
|
|
876b03595f | ||
|
|
2f829a0a15 | ||
|
|
ac1a551605 | ||
|
|
9194bae1ee | ||
|
|
8f57522228 | ||
|
|
7578c77877 | ||
|
|
64ac14faa6 | ||
|
|
1a396dfd85 |
@@ -64,7 +64,6 @@
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<BuildStlModules>false</BuildStlModules>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<!-- TODO: _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING for compatibility with VS 17.8. Check if we can remove. -->
|
||||
<PreprocessorDefinitions>_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<!-- CLR + CFG are not compatible >:{ -->
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>inc;..\..\src\;..\..\src\common\Telemetry;telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/await /Zc:twoPhase- /Wv:18 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/Zc:twoPhase- /Wv:18 %(AdditionalOptions)</AdditionalOptions>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
|
||||
@@ -57,7 +57,7 @@ std::optional<fs::path> ObtainInstaller(bool& isUpToDate)
|
||||
|
||||
auto state = UpdateState::read();
|
||||
|
||||
const auto new_version_info = get_github_version_info_async().get();
|
||||
const auto new_version_info = std::move(get_github_version_info_async()).get();
|
||||
if (std::holds_alternative<version_up_to_date>(*new_version_info))
|
||||
{
|
||||
isUpToDate = true;
|
||||
@@ -76,7 +76,7 @@ std::optional<fs::path> ObtainInstaller(bool& isUpToDate)
|
||||
// Cleanup old updates before downloading the latest
|
||||
updating::cleanup_updates();
|
||||
|
||||
auto downloaded_installer = download_new_version(std::get<new_version_download_info>(*new_version_info)).get();
|
||||
auto downloaded_installer = std::move(download_new_version_async(std::get<new_version_download_info>(*new_version_info))).get();
|
||||
if (!downloaded_installer)
|
||||
{
|
||||
Logger::error("Couldn't download new installer");
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace // Strings in this namespace should not be localized
|
||||
|
||||
namespace updating
|
||||
{
|
||||
std::future<bool> uninstall_previous_msix_version_async()
|
||||
winrt::Windows::Foundation::IAsyncOperation<bool> uninstall_previous_msix_version_async()
|
||||
{
|
||||
winrt::Windows::Management::Deployment::PackageManager package_manager;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <future>
|
||||
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <common/version/helper.h>
|
||||
|
||||
namespace updating
|
||||
{
|
||||
std::future<bool> uninstall_previous_msix_version_async();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<bool> uninstall_previous_msix_version_async();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <winrt/Windows.System.h>
|
||||
|
||||
#include <wil/resource.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
#endif //PCH_H
|
||||
|
||||
|
||||
@@ -82,11 +82,7 @@ namespace updating
|
||||
// prevent the warning that may show up depend on the value of the constants (#defines)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4702)
|
||||
#if USE_STD_EXPECTED
|
||||
std::future<std::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||
#else
|
||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||
#endif
|
||||
wil::task<github_version_result> get_github_version_info_async(const bool prerelease)
|
||||
{
|
||||
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
||||
if constexpr (VERSION_MAJOR == 0 && VERSION_MINOR == 0)
|
||||
@@ -170,7 +166,7 @@ namespace updating
|
||||
return !ec ? std::optional{ installer_download_path } : std::nullopt;
|
||||
}
|
||||
|
||||
std::future<std::optional<std::filesystem::path>> download_new_version(const new_version_download_info& new_version)
|
||||
wil::task<std::optional<std::filesystem::path>> download_new_version_async(new_version_download_info new_version)
|
||||
{
|
||||
auto installer_download_path = create_download_path();
|
||||
if (!installer_download_path)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <future>
|
||||
#include <filesystem>
|
||||
#include <variant>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
@@ -16,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include <common/version/helper.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
namespace updating
|
||||
{
|
||||
@@ -32,13 +32,15 @@ namespace updating
|
||||
};
|
||||
using github_version_info = std::variant<new_version_download_info, version_up_to_date>;
|
||||
|
||||
std::future<std::optional<std::filesystem::path>> download_new_version(const new_version_download_info& new_version);
|
||||
std::filesystem::path get_pending_updates_path();
|
||||
#if USE_STD_EXPECTED
|
||||
std::future<std::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
||||
using github_version_result = std::expected<github_version_info, std::wstring>;
|
||||
#else
|
||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
||||
using github_version_result = nonstd::expected<github_version_info, std::wstring>;
|
||||
#endif
|
||||
|
||||
wil::task<github_version_result> get_github_version_info_async(bool prerelease = false);
|
||||
wil::task<std::optional<std::filesystem::path>> download_new_version_async(new_version_download_info new_version);
|
||||
std::filesystem::path get_pending_updates_path();
|
||||
void cleanup_updates();
|
||||
|
||||
// non-localized
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <future>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Storage.Streams.h>
|
||||
#include <winrt/Windows.Web.Http.h>
|
||||
@@ -21,15 +22,15 @@ namespace http
|
||||
headers.UserAgent().TryParseAdd(USER_AGENT);
|
||||
}
|
||||
|
||||
std::future<std::wstring> request(const winrt::Windows::Foundation::Uri& url)
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> request(winrt::Windows::Foundation::Uri url)
|
||||
{
|
||||
auto response = co_await m_client.GetAsync(url);
|
||||
(void)response.EnsureSuccessStatusCode();
|
||||
auto body = co_await response.Content().ReadAsStringAsync();
|
||||
co_return std::wstring(body);
|
||||
co_return body;
|
||||
}
|
||||
|
||||
std::future<void> download(const winrt::Windows::Foundation::Uri& url, const std::wstring& dstFilePath)
|
||||
winrt::Windows::Foundation::IAsyncAction download(winrt::Windows::Foundation::Uri url, std::wstring dstFilePath)
|
||||
{
|
||||
auto response = co_await m_client.GetAsync(url);
|
||||
(void)response.EnsureSuccessStatusCode();
|
||||
@@ -38,7 +39,7 @@ namespace http
|
||||
file_stream.Close();
|
||||
}
|
||||
|
||||
std::future<void> download(const winrt::Windows::Foundation::Uri& url, const std::wstring& dstFilePath, const std::function<void(float)>& progressUpdateCallback)
|
||||
winrt::Windows::Foundation::IAsyncAction download(winrt::Windows::Foundation::Uri url, std::wstring dstFilePath, std::function<void(float)> progressUpdateCallback)
|
||||
{
|
||||
auto response = co_await m_client.GetAsync(url, HttpCompletionOption::ResponseHeadersRead);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -5140,7 +5140,7 @@ bool IsPenInverted( WPARAM wParam )
|
||||
// Captures the specified screen using the capture APIs
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
std::future<winrt::com_ptr<ID3D11Texture2D>> CaptureScreenshotAsync(winrt::IDirect3DDevice const& device, winrt::GraphicsCaptureItem const& item, winrt::DirectXPixelFormat const& pixelFormat)
|
||||
wil::task<winrt::com_ptr<ID3D11Texture2D>> CaptureScreenshotAsync(winrt::IDirect3DDevice const& device, winrt::GraphicsCaptureItem const& item, winrt::DirectXPixelFormat const& pixelFormat)
|
||||
{
|
||||
auto d3dDevice = GetDXGIInterfaceFromObject<ID3D11Device>(device);
|
||||
winrt::com_ptr<ID3D11DeviceContext> d3dContext;
|
||||
@@ -5176,9 +5176,7 @@ std::future<winrt::com_ptr<ID3D11Texture2D>> CaptureScreenshotAsync(winrt::IDire
|
||||
framePool.Close();
|
||||
|
||||
auto texture = GetDXGIInterfaceFromObject<ID3D11Texture2D>(frame.Surface());
|
||||
auto result = util::CopyD3DTexture(d3dDevice, texture, true);
|
||||
|
||||
co_return result;
|
||||
co_return util::CopyD3DTexture(d3dDevice, texture, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -5205,10 +5203,7 @@ winrt::com_ptr<ID3D11Texture2D>CaptureScreenshot(winrt::DirectXPixelFormat const
|
||||
|
||||
auto item = util::CreateCaptureItemForMonitor(hMon);
|
||||
|
||||
auto capture = CaptureScreenshotAsync(device, item, pixelFormat);
|
||||
capture.wait();
|
||||
|
||||
return capture.get();
|
||||
return CaptureScreenshotAsync(device, item, pixelFormat).get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
// WIL
|
||||
#include <wil/com.h>
|
||||
#include <wil/resource.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
// DirectX
|
||||
#include <d3d11_4.h>
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
<None Include="Microsoft.Terminal.UI.def" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\</OutDir>
|
||||
<OutDir>$(RepoRoot)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\</OutDir>
|
||||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ProjectGuid>{AF2349B8-E5B6-4004-9502-687C1C7730B1}</ProjectGuid>
|
||||
<AssemblyName>PowerToys.PreviewHandlerCommon</AssemblyName>
|
||||
<!-- AutoUnify resolves WindowsBase version conflict (WebView2.Wpf refs .NET 5 version, we target .NET 9) -->
|
||||
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -173,7 +173,8 @@ void ProcessNewVersionInfo(const github_version_info& version_info,
|
||||
// Cleanup old updates before downloading the latest
|
||||
updating::cleanup_updates();
|
||||
|
||||
if (download_new_version(new_version_info).get())
|
||||
auto downloaded_installer = std::move(download_new_version_async(new_version_info)).get();
|
||||
if (downloaded_installer)
|
||||
{
|
||||
state.state = UpdateState::readyToInstall;
|
||||
state.downloadedInstallerFilename = new_version_info.installer_filename;
|
||||
@@ -232,7 +233,7 @@ void PeriodicUpdateWorker()
|
||||
bool version_info_obtained = false;
|
||||
try
|
||||
{
|
||||
const auto new_version_info = get_github_version_info_async().get();
|
||||
const auto new_version_info = std::move(get_github_version_info_async()).get();
|
||||
if (new_version_info.has_value())
|
||||
{
|
||||
version_info_obtained = true;
|
||||
@@ -272,7 +273,7 @@ void CheckForUpdatesCallback()
|
||||
auto state = UpdateState::read();
|
||||
try
|
||||
{
|
||||
auto new_version_info = get_github_version_info_async().get();
|
||||
auto new_version_info = std::move(get_github_version_info_async()).get();
|
||||
if (!new_version_info)
|
||||
{
|
||||
// We couldn't get a new version from github for some reason, log error
|
||||
|
||||
@@ -32,3 +32,4 @@
|
||||
#include <winrt/Windows.Storage.h>
|
||||
|
||||
#include <wil/resource.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
Reference in New Issue
Block a user