summaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp60
1 files changed, 57 insertions, 3 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 5736ae1585..5d27fae148 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -588,7 +588,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
mb->set_position(Vector2(old_x, old_y));
}
- if (uMsg != WM_MOUSEWHEEL) {
+ if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) {
if (mb->is_pressed()) {
if (++pressrc > 0)
@@ -1487,6 +1487,12 @@ Size2 OS_Windows::get_window_size() const {
GetClientRect(hWnd, &r);
return Vector2(r.right - r.left, r.bottom - r.top);
}
+Size2 OS_Windows::get_real_window_size() const {
+
+ RECT r;
+ GetWindowRect(hWnd, &r);
+ return Vector2(r.right - r.left, r.bottom - r.top);
+}
void OS_Windows::set_window_size(const Size2 p_size) {
video_mode.width = p_size.width;
@@ -1655,7 +1661,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han
PRemoveDllDirectory remove_dll_directory = (PRemoveDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "RemoveDllDirectory");
bool has_dll_directory_api = ((add_dll_directory != NULL) && (remove_dll_directory != NULL));
- DLL_DIRECTORY_COOKIE cookie;
+ DLL_DIRECTORY_COOKIE cookie = NULL;
if (p_also_set_library_path && has_dll_directory_api) {
cookie = add_dll_directory(path.get_base_dir().c_str());
@@ -1663,7 +1669,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han
p_library_handle = (void *)LoadLibraryExW(path.c_str(), NULL, (p_also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0);
- if (p_also_set_library_path && has_dll_directory_api) {
+ if (cookie) {
remove_dll_directory(cookie);
}
@@ -2211,6 +2217,36 @@ String OS_Windows::get_locale() const {
return "en";
}
+// We need this because GetSystemInfo() is unreliable on WOW64
+// see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724381(v=vs.85).aspx
+// Taken from MSDN
+typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
+LPFN_ISWOW64PROCESS fnIsWow64Process;
+
+BOOL is_wow64() {
+ BOOL wow64 = FALSE;
+
+ fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
+
+ if (fnIsWow64Process) {
+ if (!fnIsWow64Process(GetCurrentProcess(), &wow64)) {
+ wow64 = FALSE;
+ }
+ }
+
+ return wow64;
+}
+
+int OS_Windows::get_processor_count() const {
+ SYSTEM_INFO sysinfo;
+ if (is_wow64())
+ GetNativeSystemInfo(&sysinfo);
+ else
+ GetSystemInfo(&sysinfo);
+
+ return sysinfo.dwNumberOfProcessors;
+}
+
OS::LatinKeyboardVariant OS_Windows::get_latin_keyboard_variant() const {
unsigned long azerty[] = {
@@ -2412,6 +2448,24 @@ String OS_Windows::get_user_data_dir() const {
return ProjectSettings::get_singleton()->get_resource_path();
}
+String OS_Windows::get_unique_id() const {
+
+ HW_PROFILE_INFO HwProfInfo;
+ ERR_FAIL_COND_V(!GetCurrentHwProfile(&HwProfInfo), "");
+ return String(HwProfInfo.szHwProfileGuid);
+}
+
+void OS_Windows::set_ime_position(const Point2 &p_pos) {
+
+ HIMC himc = ImmGetContext(hWnd);
+ COMPOSITIONFORM cps;
+ cps.dwStyle = CFS_FORCE_POSITION;
+ cps.ptCurrentPos.x = p_pos.x;
+ cps.ptCurrentPos.y = p_pos.y;
+ ImmSetCompositionWindow(himc, &cps);
+ ImmReleaseContext(hWnd, himc);
+}
+
bool OS_Windows::is_joy_known(int p_device) {
return input->is_joy_mapped(p_device);
}