diff options
Diffstat (limited to 'platform/windows')
| -rw-r--r-- | platform/windows/README.md | 2 | ||||
| -rw-r--r-- | platform/windows/display_server_windows.cpp | 56 | ||||
| -rw-r--r-- | platform/windows/display_server_windows.h | 5 | ||||
| -rw-r--r-- | platform/windows/export/export_plugin.cpp | 13 | ||||
| -rw-r--r-- | platform/windows/joypad_windows.cpp | 6 | ||||
| -rw-r--r-- | platform/windows/key_mapping_windows.cpp | 6 | ||||
| -rw-r--r-- | platform/windows/os_windows.cpp | 8 |
7 files changed, 71 insertions, 25 deletions
diff --git a/platform/windows/README.md b/platform/windows/README.md index 4c775576fe..bda9ddd924 100644 --- a/platform/windows/README.md +++ b/platform/windows/README.md @@ -11,5 +11,5 @@ used by this platform. - Instructions on building this platform port from source. - [Exporting for Windows](https://docs.godotengine.org/en/latest/tutorials/export/exporting_for_windows.html) - Instructions on using the compiled export templates to export a project. -- [Changing application icon for Windows](https://docs.godotengine.org/en/stable/tutorials/export/changing_application_icon_for_windows.html) +- [Changing application icon for Windows](https://docs.godotengine.org/en/latest/tutorials/export/changing_application_icon_for_windows.html) - Instructions on using a custom icon for the exported project executable. diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index d2889a3442..388a799c1c 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -90,6 +90,7 @@ bool DisplayServerWindows::has_feature(Feature p_feature) const { case FEATURE_SWAP_BUFFERS: case FEATURE_KEEP_SCREEN_ON: case FEATURE_TEXT_TO_SPEECH: + case FEATURE_SCREEN_CAPTURE: return true; default: return false; @@ -264,15 +265,15 @@ BitField<MouseButtonMask> DisplayServerWindows::mouse_get_button_state() const { void DisplayServerWindows::clipboard_set(const String &p_text) { _THREAD_SAFE_METHOD_ - if (!windows.has(last_focused_window)) { - return; // No focused window? + if (!windows.has(MAIN_WINDOW_ID)) { + return; } // Convert LF line endings to CRLF in clipboard content. // Otherwise, line endings won't be visible when pasted in other software. String text = p_text.replace("\r\n", "\n").replace("\n", "\r\n"); // Avoid \r\r\n. - if (!OpenClipboard(windows[last_focused_window].hWnd)) { + if (!OpenClipboard(windows[MAIN_WINDOW_ID].hWnd)) { ERR_FAIL_MSG("Unable to open clipboard."); } EmptyClipboard(); @@ -305,12 +306,12 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { String DisplayServerWindows::clipboard_get() const { _THREAD_SAFE_METHOD_ - if (!windows.has(last_focused_window)) { - return String(); // No focused window? + if (!windows.has(MAIN_WINDOW_ID)) { + return String(); } String ret; - if (!OpenClipboard(windows[last_focused_window].hWnd)) { + if (!OpenClipboard(windows[MAIN_WINDOW_ID].hWnd)) { ERR_FAIL_V_MSG("", "Unable to open clipboard."); } @@ -631,6 +632,26 @@ int DisplayServerWindows::screen_get_dpi(int p_screen) const { EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcDpi, (LPARAM)&data); return data.dpi; } + +Color DisplayServerWindows::screen_get_pixel(const Point2i &p_position) const { + Point2i pos = p_position + _get_screens_origin(); + + POINT p; + p.x = pos.x; + p.y = pos.y; + if (win81p_LogicalToPhysicalPointForPerMonitorDPI) { + win81p_LogicalToPhysicalPointForPerMonitorDPI(0, &p); + } + HDC dc = GetDC(0); + COLORREF col = GetPixel(dc, p.x, p.y); + if (col != CLR_INVALID) { + return Color(float(col & 0x000000FF) / 256.0, float((col & 0x0000FF00) >> 8) / 256.0, float((col & 0x00FF0000) >> 16) / 256.0, 1.0); + } + ReleaseDC(NULL, dc); + + return Color(); +} + float DisplayServerWindows::screen_get_refresh_rate(int p_screen) const { _THREAD_SAFE_METHOD_ @@ -3404,16 +3425,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } break; case WM_SYSKEYUP: case WM_KEYUP: - if (windows[window_id].ime_suppress_next_keyup) { - windows[window_id].ime_suppress_next_keyup = false; - break; - } - [[fallthrough]]; case WM_SYSKEYDOWN: case WM_KEYDOWN: { - if (windows[window_id].ime_in_progress) { - break; - } if (wParam == VK_SHIFT) { shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); } @@ -3427,6 +3440,14 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } } + if (windows[window_id].ime_suppress_next_keyup && (uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP)) { + windows[window_id].ime_suppress_next_keyup = false; + break; + } + if (windows[window_id].ime_in_progress) { + break; + } + if (mouse_mode == MOUSE_MODE_CAPTURED) { // When SetCapture is used, ALT+F4 hotkey is ignored by Windows, so handle it ourselves if (wParam == VK_F4 && alt_mem && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)) { @@ -4020,6 +4041,7 @@ GetImmersiveUserColorSetPreferencePtr DisplayServerWindows::GetImmersiveUserColo bool DisplayServerWindows::winink_available = false; GetPointerTypePtr DisplayServerWindows::win8p_GetPointerType = nullptr; GetPointerPenInfoPtr DisplayServerWindows::win8p_GetPointerPenInfo = nullptr; +LogicalToPhysicalPointForPerMonitorDPIPtr DisplayServerWindows::win81p_LogicalToPhysicalPointForPerMonitorDPI = nullptr; typedef enum _SHC_PROCESS_DPI_AWARENESS { SHC_PROCESS_DPI_UNAWARE = 0, @@ -4148,10 +4170,12 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } // Note: Windows Ink API for pen input, available on Windows 8+ only. + // Note: DPI conversion API, available on Windows 8.1+ only. HMODULE user32_lib = LoadLibraryW(L"user32.dll"); if (user32_lib) { win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType"); win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo"); + win81p_LogicalToPhysicalPointForPerMonitorDPI = (LogicalToPhysicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "LogicalToPhysicalPointForPerMonitorDPI"); winink_available = win8p_GetPointerType && win8p_GetPointerPenInfo; } @@ -4237,7 +4261,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win window_position = screen_get_position(p_screen) + (screen_get_size(p_screen) - p_resolution) / 2; } - WindowID main_window = _create_window(p_mode, p_vsync_mode, 0, Rect2i(window_position, p_resolution)); + WindowID main_window = _create_window(p_mode, p_vsync_mode, p_flags, Rect2i(window_position, p_resolution)); ERR_FAIL_COND_MSG(main_window == INVALID_WINDOW_ID, "Failed to create main window."); joypad = new JoypadWindows(&windows[MAIN_WINDOW_ID].hWnd); @@ -4309,7 +4333,7 @@ DisplayServer *DisplayServerWindows::create_func(const String &p_rendering_drive vformat("Your video card drivers seem not to support the required Vulkan version.\n\n" "If possible, consider updating your video card drivers or using the OpenGL 3 driver.\n\n" "You can enable the OpenGL 3 driver by starting the engine from the\n" - "command line with the command:\n'%s --rendering-driver opengl3'\n\n" + "command line with the command:\n\n \"%s\" --rendering-driver opengl3\n\n" "If you have recently updated your video card drivers, try rebooting.", executable_name), "Unable to initialize Vulkan video driver"); diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 0d2137d048..1b36b0951e 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -259,6 +259,7 @@ typedef struct tagPOINTER_PEN_INFO { typedef BOOL(WINAPI *GetPointerTypePtr)(uint32_t p_id, POINTER_INPUT_TYPE *p_type); typedef BOOL(WINAPI *GetPointerPenInfoPtr)(uint32_t p_id, POINTER_PEN_INFO *p_pen_info); +typedef BOOL(WINAPI *LogicalToPhysicalPointForPerMonitorDPIPtr)(HWND hwnd, LPPOINT lpPoint); typedef struct { BYTE bWidth; // Width, in pixels, of the image @@ -305,6 +306,9 @@ class DisplayServerWindows : public DisplayServer { static GetPointerTypePtr win8p_GetPointerType; static GetPointerPenInfoPtr win8p_GetPointerPenInfo; + // DPI conversion API + static LogicalToPhysicalPointForPerMonitorDPIPtr win81p_LogicalToPhysicalPointForPerMonitorDPI; + void _update_tablet_ctx(const String &p_old_driver, const String &p_new_driver); String tablet_driver; Vector<String> tablet_drivers; @@ -524,6 +528,7 @@ public: virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Color screen_get_pixel(const Point2i &p_position) const override; virtual void screen_set_keep_on(bool p_enable) override; //disable screensaver virtual bool screen_is_kept_on() const override; diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index 4107a8a17e..941e72c8f3 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -490,6 +490,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p return FAILED; } #else + int id_type = 1; if (p_preset->get("codesign/identity") != "") { args.push_back("-pkcs12"); args.push_back(p_preset->get("codesign/identity")); @@ -500,7 +501,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p #endif //password - if (p_preset->get("codesign/password") != "") { + if ((id_type == 1) && (p_preset->get("codesign/password") != "")) { #ifdef WINDOWS_ENABLED args.push_back("/p"); #else @@ -574,7 +575,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p String str; Error err = OS::get_singleton()->execute(signtool_path, args, &str, nullptr, true); if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) { -#ifndef WINDOWS_ENABLED +#ifdef WINDOWS_ENABLED add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start signtool executable. Configure signtool path in the Editor Settings (Export > Windows > signtool), or disable \"Codesign\" in the export preset.")); #else add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start osslsigncode executable. Configure signtool path in the Editor Settings (Export > Windows > osslsigncode), or disable \"Codesign\" in the export preset.")); @@ -878,7 +879,11 @@ Error EditorExportPlatformWindows::run(const Ref<EditorExportPreset> &p_preset, print_line("Creating temporary directory..."); ep.step(TTR("Creating temporary directory..."), 2); String temp_dir; +#ifndef WINDOWS_ENABLED err = ssh_run_on_remote(host, port, extra_args_ssh, "powershell -command \\\"\\$tmp = Join-Path \\$Env:Temp \\$(New-Guid); New-Item -Type Directory -Path \\$tmp | Out-Null; Write-Output \\$tmp\\\"", &temp_dir); +#else + err = ssh_run_on_remote(host, port, extra_args_ssh, "powershell -command \"$tmp = Join-Path $Env:Temp $(New-Guid); New-Item -Type Directory -Path $tmp ^| Out-Null; Write-Output $tmp\"", &temp_dir); +#endif if (err != OK || temp_dir.is_empty()) { CLEANUP_AND_RETURN(err); } @@ -890,6 +895,10 @@ Error EditorExportPlatformWindows::run(const Ref<EditorExportPreset> &p_preset, CLEANUP_AND_RETURN(err); } + if (cmd_args.is_empty()) { + cmd_args = " "; + } + { String run_script = p_preset->get("ssh_remote_deploy/run_script"); run_script = run_script.replace("{temp_dir}", temp_dir); diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 7ae26e6cf4..91efe09160 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -516,11 +516,13 @@ void JoypadWindows::joypad_vibration_stop_xinput(int p_device, uint64_t p_timest void JoypadWindows::load_xinput() { xinput_get_state = &_xinput_get_state; xinput_set_state = &_xinput_set_state; + bool legacy_xinput = false; xinput_dll = LoadLibrary("XInput1_4.dll"); if (!xinput_dll) { xinput_dll = LoadLibrary("XInput1_3.dll"); if (!xinput_dll) { xinput_dll = LoadLibrary("XInput9_1_0.dll"); + legacy_xinput = true; } } @@ -529,7 +531,9 @@ void JoypadWindows::load_xinput() { return; } - XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputGetState"); + // (LPCSTR)100 is the magic number to get XInputGetStateEx, which also provides the state for the guide button + LPCSTR get_state_func_name = legacy_xinput ? "XInputGetState" : (LPCSTR)100; + XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, get_state_func_name); XInputSetState_t set_func = (XInputSetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputSetState"); if (!func || !set_func) { unload_xinput(); diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp index d43f74126d..b376854c0c 100644 --- a/platform/windows/key_mapping_windows.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -257,8 +257,8 @@ void KeyMappingWindows::initialize() { scansym_map[0x17] = Key::I; scansym_map[0x18] = Key::O; scansym_map[0x19] = Key::P; - scansym_map[0x1A] = Key::BRACELEFT; - scansym_map[0x1B] = Key::BRACERIGHT; + scansym_map[0x1A] = Key::BRACKETLEFT; + scansym_map[0x1B] = Key::BRACKETRIGHT; scansym_map[0x1C] = Key::ENTER; scansym_map[0x1D] = Key::CTRL; scansym_map[0x1E] = Key::A; @@ -315,7 +315,7 @@ void KeyMappingWindows::initialize() { scansym_map[0x51] = Key::KP_3; scansym_map[0x52] = Key::KP_0; scansym_map[0x53] = Key::KP_PERIOD; - scansym_map[0x57] = Key::SECTION; + scansym_map[0x56] = Key::SECTION; scansym_map[0x57] = Key::F11; scansym_map[0x58] = Key::F12; scansym_map[0x5B] = Key::META; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d384049fb5..6e219fb929 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -69,6 +69,11 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; #define WM_POINTERUPDATE 0x0245 #endif +// Missing in MinGW headers before 8.0. +#ifndef DWRITE_FONT_WEIGHT_SEMI_LIGHT +#define DWRITE_FONT_WEIGHT_SEMI_LIGHT (DWRITE_FONT_WEIGHT)350 +#endif + #if defined(__GNUC__) // Workaround GCC warning from -Wcast-function-type. #define GetProcAddress (void *)GetProcAddress @@ -673,9 +678,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, } CloseHandle(pipe[0]); // Close pipe read handle. - } else { - WaitForSingleObject(pi.pi.hProcess, INFINITE); } + WaitForSingleObject(pi.pi.hProcess, INFINITE); if (r_exitcode) { DWORD ret2; |
