From 3f74d6fdf92f70eb4e5369b4cfeb4eeafc131e56 Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 14 Apr 2020 19:37:12 +0200 Subject: [PATCH] Remove necessary #defines. Added exception handling flag. --- windows/build.gradle.kts | 3 ++- windows/src/main/cpp/Decorations.cpp | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/windows/build.gradle.kts b/windows/build.gradle.kts index b9b26db8..ac77d94a 100644 --- a/windows/build.gradle.kts +++ b/windows/build.gradle.kts @@ -21,7 +21,8 @@ library { binaries.configureEach { compileTask.get().compilerArgs.addAll( when (toolChain) { - is Gcc, is Clang, is VisualCpp -> listOf("--std=c++11") + is Gcc, is Clang -> listOf("--std=c++11") + is VisualCpp -> listOf("/EHsc") else -> emptyList() } ) diff --git a/windows/src/main/cpp/Decorations.cpp b/windows/src/main/cpp/Decorations.cpp index 7e597ece..0bcfe1db 100644 --- a/windows/src/main/cpp/Decorations.cpp +++ b/windows/src/main/cpp/Decorations.cpp @@ -28,8 +28,6 @@ #include #include -#define GWL_WNDPROC -4 - std::map wrapper_map = std::map(); LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam, WindowWrapper *wrapper) @@ -244,13 +242,13 @@ bool InstallDecorations(HWND handle, bool is_popup) SetupWindowStyle(handle); ExtendClientFrame(handle); - WNDPROC proc = reinterpret_cast(GetWindowLongPtr(handle, GWL_WNDPROC)); + WNDPROC proc = reinterpret_cast(GetWindowLongPtr(handle, GWLP_WNDPROC)); WindowWrapper *wrapper = new WindowWrapper(); wrapper->prev_proc = proc; wrapper->popup_menu = is_popup; wrapper_map[handle] = wrapper; - SetWindowLongPtr(handle, GWL_WNDPROC, (LONG_PTR)WindowWrapper::WindowProc); + SetWindowLongPtr(handle, GWLP_WNDPROC, (LONG_PTR)WindowWrapper::WindowProc); UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED; SetWindowPos(handle, NULL, 0, 0, 0, 0, flags); return true; @@ -270,7 +268,7 @@ Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_uninstallDe auto wrap = wrapper_map[handle]; if (wrap) { - SetWindowLongPtr(handle, GWL_WNDPROC, reinterpret_cast(wrap->prev_proc)); + SetWindowLongPtr(handle, GWLP_WNDPROC, reinterpret_cast(wrap->prev_proc)); wrapper_map.erase(handle); delete (wrap); }