Merge branch 'master' into vulkan

This commit is contained in:
Triang3l
2022-05-10 15:57:50 +03:00
48 changed files with 3809 additions and 6711 deletions

View File

@@ -113,8 +113,6 @@ Win32FilePicker::~Win32FilePicker() = default;
bool Win32FilePicker::Show(Window* parent_window) {
// TODO(benvanik): FileSaveDialog.
assert_true(mode() == Mode::kOpen);
// TODO(benvanik): folder dialogs.
assert_true(type() == Type::kFile);
Microsoft::WRL::ComPtr<IFileDialog> file_dialog;
HRESULT hr =
@@ -134,37 +132,41 @@ bool Win32FilePicker::Show(Window* parent_window) {
if (!SUCCEEDED(hr)) {
return false;
}
// FOS_PICKFOLDERS
// FOS_FILEMUSTEXIST
// FOS_PATHMUSTEXIST
flags |= FOS_FORCEFILESYSTEM;
if (multi_selection()) {
flags |= FOS_ALLOWMULTISELECT;
}
if (type() == Type::kDirectory) {
flags |= FOS_PICKFOLDERS;
}
hr = file_dialog->SetOptions(flags);
if (!SUCCEEDED(hr)) {
return false;
}
// Set the file types to display only. Notice that this is a 1-based array.
std::vector<std::pair<std::u16string, std::u16string>> file_pairs;
std::vector<COMDLG_FILTERSPEC> file_types;
for (const auto& extension : this->extensions()) {
const auto& file_pair =
file_pairs.emplace_back(std::move(xe::to_utf16(extension.first)),
std::move(xe::to_utf16(extension.second)));
file_types.push_back(
{(LPCWSTR)file_pair.first.c_str(), (LPCWSTR)file_pair.second.c_str()});
}
hr = file_dialog->SetFileTypes(static_cast<UINT>(file_types.size()),
file_types.data());
if (!SUCCEEDED(hr)) {
return false;
}
if (type() == Type::kFile) {
// Set the file types to display only. Notice that this is a 1-based array.
std::vector<std::pair<std::u16string, std::u16string>> file_pairs;
std::vector<COMDLG_FILTERSPEC> file_types;
for (const auto& extension : this->extensions()) {
const auto& file_pair =
file_pairs.emplace_back(std::move(xe::to_utf16(extension.first)),
std::move(xe::to_utf16(extension.second)));
file_types.push_back({(LPCWSTR)file_pair.first.c_str(),
(LPCWSTR)file_pair.second.c_str()});
}
hr = file_dialog->SetFileTypes(static_cast<UINT>(file_types.size()),
file_types.data());
if (!SUCCEEDED(hr)) {
return false;
}
hr = file_dialog->SetFileTypeIndex(1);
if (!SUCCEEDED(hr)) {
return false;
hr = file_dialog->SetFileTypeIndex(1);
if (!SUCCEEDED(hr)) {
return false;
}
}
// Create an event handling object, and hook it up to the dialog.

View File

@@ -21,5 +21,6 @@ project("xenia-ui")
filter("platforms:Windows")
links({
"DXGI",
"dwmapi",
"dxgi",
})

View File

@@ -23,8 +23,8 @@
#include "xenia/ui/virtual_key.h"
#include "xenia/ui/windowed_app_context_win.h"
// For per-monitor DPI awareness v1.
#include <ShellScalingApi.h>
#include <dwmapi.h>
namespace xe {
namespace ui {
@@ -182,6 +182,14 @@ bool Win32Window::OpenImpl() {
}
}
// Disable rounded corners starting with Windows 11 (or silently receive and
// ignore E_INVALIDARG on Windows versions before 10.0.22000.0), primarily to
// preserve all pixels of the guest output.
DWM_WINDOW_CORNER_PREFERENCE window_corner_preference = DWMWCP_DONOTROUND;
DwmSetWindowAttribute(hwnd_, DWMWA_WINDOW_CORNER_PREFERENCE,
&window_corner_preference,
sizeof(window_corner_preference));
// Disable flicks.
ATOM atom = GlobalAddAtomW(L"MicrosoftTabletPenServiceProperty");
const DWORD_PTR dwHwndTabletProperty =