From e62a38c91999d4ed1092e92ba73f3cc052356493 Mon Sep 17 00:00:00 2001 From: Celyn Walters Date: Sun, 31 Mar 2019 18:23:14 +0100 Subject: [PATCH] Fixed Aero snap gap in Windows 10 (only) --- build.bat | 8 ++++---- hooks.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/build.bat b/build.bat index 8276cdd..0526b46 100755 --- a/build.bat +++ b/build.bat @@ -34,7 +34,7 @@ if "%1" == "all" ( echo Building release build %prefix32%gcc -o bin/AltDrag.exe altdrag.c bin/altdrag.o -mwindows -lshlwapi -lwininet -lcomctl32 -O2 -s if not exist bin/AltDrag.exe. exit /b - %prefix32%gcc -o bin/hooks.dll hooks.c bin/hooks.o -mdll -lshlwapi -lcomctl32 -lpsapi -lole32 -O2 -s + %prefix32%gcc -o bin/hooks.dll hooks.c bin/hooks.o -mdll -lshlwapi -lcomctl32 -lpsapi -lole32 -ldwmapi -O2 -s if not exist bin/hooks.dll. exit /b if "%x64%" == "1" ( @@ -42,7 +42,7 @@ if "%1" == "all" ( %prefix64%windres include/hooks.rc bin/hooks_x64.o %prefix64%gcc -o bin/HookWindows_x64.exe hookwindows_x64.c bin/hookwindows_x64.o -mwindows -lshlwapi -O2 -s if not exist bin/HookWindows_x64.exe. exit /b - %prefix64%gcc -o bin/hooks_x64.dll hooks.c bin/hooks_x64.o -mdll -lshlwapi -lcomctl32 -lpsapi -O2 -s + %prefix64%gcc -o bin/hooks_x64.dll hooks.c bin/hooks_x64.o -mdll -lshlwapi -lcomctl32 -lpsapi -ldwmapi -O2 -s if not exist bin/hooks_x64.dll. exit /b ) @@ -55,7 +55,7 @@ if "%1" == "all" ( start localization/import_languages.exe ) else ( %prefix32%gcc -o AltDrag.exe altdrag.c bin/altdrag.o -mwindows -lshlwapi -lwininet -lcomctl32 -lole32 -g -DDEBUG - %prefix32%gcc -o hooks.dll hooks.c bin/hooks.o -mdll -lshlwapi -lcomctl32 -lpsapi -lole32 -g -DDEBUG + %prefix32%gcc -o hooks.dll hooks.c bin/hooks.o -mdll -lshlwapi -lcomctl32 -lpsapi -lole32 -ldwmapi -g -DDEBUG if "%x64%" == "0" ( if exist hooks_x64.dll ( @@ -70,7 +70,7 @@ if "%1" == "all" ( %prefix64%windres include/hookwindows_x64.rc bin/hookwindows_x64.o %prefix64%windres include/hooks.rc bin/hooks_x64.o %prefix64%gcc -o HookWindows_x64.exe hookwindows_x64.c bin/hookwindows_x64.o -mwindows -lshlwapi -g -DDEBUG - %prefix64%gcc -o hooks_x64.dll hooks.c bin/hooks_x64.o -mdll -lshlwapi -lcomctl32 -lpsapi -lole32 -g -DDEBUG + %prefix64%gcc -o hooks_x64.dll hooks.c bin/hooks_x64.o -mdll -lshlwapi -lcomctl32 -lpsapi -lole32 -ldwmapi -g -DDEBUG ) if "%1" == "run" ( diff --git a/hooks.c b/hooks.c index c4428fb..29eb809 100644 --- a/hooks.c +++ b/hooks.c @@ -22,6 +22,7 @@ #include #include #include +#include // Stuff missing in MinGW CLSID my_CLSID_MMDeviceEnumerator = {0xBCDE0395,0xE52F,0x467C,{0x8E,0x3D,0xC4,0x57,0x92,0x91,0x69,0x2E}}; @@ -837,7 +838,19 @@ void MouseMove() { state.wndentry->width = state.origin.width; state.wndentry->height = state.origin.height; - // Move + // Move and include the border (Windows 10) + RECT rect, frame; + GetWindowRect(state.hwnd, &rect); + DwmGetWindowAttribute(state.hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, &frame, sizeof(RECT)); + RECT border; + border.left = frame.left - rect.left; + border.top = frame.top - rect.top; + border.right = rect.right - frame.right; + border.bottom = rect.bottom - frame.bottom; + posx -= border.left; + posy -= border.top; + wndwidth += border.left + border.right; + wndheight += border.top + border.bottom; MoveWindow(state.hwnd, posx, posy, wndwidth, wndheight, TRUE); // Get new size after move