Fix VS 2026 Windows build

This commit is contained in:
2026-06-16 09:34:17 +02:00
parent ad76aeb751
commit 52d633c6e1
9 changed files with 40 additions and 24 deletions

View File

@@ -11,10 +11,6 @@
#include <deque>
#include <map>
extern HWND hWnd;
extern std::deque<std::packaged_task<void()>> main_tasklist;
extern std::mutex main_task_mutex;
void destroy_window();
void async_lock();
void async_unlock();
@@ -27,6 +23,8 @@ void win32_save_window_state();
bool win32_vr_start();
void win32_vr_stop();
std::string GetLastErrorAsString();
HWND pp_windows_main_window_handle();
void pp_windows_enqueue_main_task(std::packaged_task<void()> task);
namespace pp::platform::windows {
@@ -166,19 +164,18 @@ void handle_gl_callback(
void show_cursor(bool visible)
{
std::lock_guard<std::mutex> lock(main_task_mutex);
main_tasklist.emplace_back([=] {
pp_windows_enqueue_main_task(std::packaged_task<void()>([=] {
if (visible)
while (ShowCursor(true) < 0);
else
while (ShowCursor(false) >= 0);
});
}));
}
std::string clipboard_text()
{
std::string ret;
if (OpenClipboard(hWnd))
if (OpenClipboard(pp_windows_main_window_handle()))
{
if (HANDLE h = GetClipboardData(CF_TEXT))
{
@@ -196,7 +193,7 @@ std::string clipboard_text()
bool set_clipboard_text(const std::string& s)
{
bool success = false;
if (OpenClipboard(hWnd))
if (OpenClipboard(pp_windows_main_window_handle()))
{
// owned by SetClipboardData
if (HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, s.size() + 1))
@@ -222,7 +219,7 @@ std::string open_file(const char* filter)
char fileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hwndOwner = pp_windows_main_window_handle();
ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
@@ -240,7 +237,7 @@ std::string save_file(const char* filter)
char fileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hwndOwner = pp_windows_main_window_handle();
ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
@@ -258,7 +255,7 @@ std::string open_directory()
char Buffer[MAX_PATH];
ZeroMemory(Buffer, MAX_PATH);
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = hWnd;
bi.hwndOwner = pp_windows_main_window_handle();
bi.pszDisplayName = Buffer;
bi.lpszTitle = "Title";
bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;