Browse Source

Windows: Use constants defined in Windows 11 SDK instead of replicating them

spotless
Jannis Weis 3 years ago
parent
commit
2b952fb9fa
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 32
      windows/src/main/cpp/Decorations.cpp
  2. 7
      windows/src/main/cpp/Decorations.h

32
windows/src/main/cpp/Decorations.cpp

@ -25,6 +25,12 @@
#include "Decorations.h" #include "Decorations.h"
#include "Registry.h" #include "Registry.h"
#include "com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows.h" #include "com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows.h"
#include <windowsx.h>
#include <dwmapi.h>
#include <map>
#include <iostream>
#include <shellapi.h>
#include <winuser.h>
#ifndef WM_NCUAHDRAWCAPTION #ifndef WM_NCUAHDRAWCAPTION
#define WM_NCUAHDRAWCAPTION (0x00AE) #define WM_NCUAHDRAWCAPTION (0x00AE)
@ -190,22 +196,6 @@ static void UpdateRegion(WindowWrapper *wrapper) {
return SHAppBarMessage(ABM_GETAUTOHIDEBAREX, &data); return SHAppBarMessage(ABM_GETAUTOHIDEBAREX, &data);
} }
[[nodiscard]] static inline bool IsWindowSnappedTop(RECT rcWork, RECT rcWindow) {
return rcWindow.left == rcWork.left && rcWindow.right == rcWork.right && rcWindow.top == rcWork.top;
}
[[nodiscard]] static inline bool IsWindowSnappedBottom(RECT rcWork, RECT rcWindow) {
return rcWindow.left == rcWork.left && rcWindow.right == rcWork.right && rcWindow.bottom == rcWork.bottom;
}
[[nodiscard]] static inline bool IsWindowSnappedLeft(RECT rcWork, RECT rcWindow) {
return rcWindow.left == rcWork.left && rcWindow.bottom == rcWork.bottom && rcWindow.top == rcWork.top;
}
[[nodiscard]] static inline bool IsWindowSnappedRight(RECT rcWork, RECT rcWindow) {
return rcWindow.right == rcWork.right && rcWindow.bottom == rcWork.bottom && rcWindow.top == rcWork.top;
}
[[nodiscard]] static inline MONITORINFO GetMonitorInfo(WindowWrapper &wrapper) { [[nodiscard]] static inline MONITORINFO GetMonitorInfo(WindowWrapper &wrapper) {
HMONITOR mon = MonitorFromWindow(wrapper.window, MONITOR_DEFAULTTOPRIMARY); HMONITOR mon = MonitorFromWindow(wrapper.window, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi; MONITORINFO mi;
@ -330,14 +320,6 @@ static void SetupWindowStyle(HWND handle) {
SetWindowLongPtr(handle, GWL_STYLE, style); SetWindowLongPtr(handle, GWL_STYLE, style);
} }
enum M_DWMWINDOWATTRIBUTE {
DWMWA_WINDOW_CORNER_PREFERENCE = 33
};
enum DWM_WINDOW_CORNER_PREFERENCE {
DWMWCP_DEFAULT = 0, DWMWCP_DONOTROUND = 1, DWMWCP_ROUND = 2, DWMWCP_ROUNDSMALL = 3
};
static bool InstallDecorations(HWND handle, bool is_popup) { static bool InstallDecorations(HWND handle, bool is_popup) {
// Prevent multiple installations overriding the real window procedure. // Prevent multiple installations overriding the real window procedure.
auto it = wrapper_map.find(handle); auto it = wrapper_map.find(handle);
@ -347,7 +329,7 @@ static bool InstallDecorations(HWND handle, bool is_popup) {
if (is_popup || !is_windows_11) { if (is_popup || !is_windows_11) {
ExtendClientFrame(handle); ExtendClientFrame(handle);
if (is_popup) { if (is_popup) {
auto attribute = M_DWMWINDOWATTRIBUTE::DWMWA_WINDOW_CORNER_PREFERENCE; auto attribute = DWMWINDOWATTRIBUTE::DWMWA_WINDOW_CORNER_PREFERENCE;
auto preference = DWM_WINDOW_CORNER_PREFERENCE::DWMWCP_ROUNDSMALL; auto preference = DWM_WINDOW_CORNER_PREFERENCE::DWMWCP_ROUNDSMALL;
DwmSetWindowAttribute(handle, attribute, &preference, sizeof(preference)); DwmSetWindowAttribute(handle, attribute, &preference, sizeof(preference));
} }

7
windows/src/main/cpp/Decorations.h

@ -22,14 +22,7 @@
* SOFTWARE. * SOFTWARE.
* *
*/ */
#include <stdio.h>
#include <windows.h> #include <windows.h>
#include <windowsx.h>
#include <dwmapi.h>
#include <map>
#include <iostream>
#include <shellapi.h>
#include <winuser.h>
class WindowWrapper { class WindowWrapper {
public: public:

Loading…
Cancel
Save