Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Aero snap gap in Windows 10 (only) #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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" (
%prefix64%windres include/hookwindows_x64.rc bin/hookwindows_x64.o
%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
)

Expand All @@ -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 (
Expand All @@ -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" (
Expand Down
15 changes: 14 additions & 1 deletion hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <psapi.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#include <dwmapi.h>

// Stuff missing in MinGW
CLSID my_CLSID_MMDeviceEnumerator = {0xBCDE0395,0xE52F,0x467C,{0x8E,0x3D,0xC4,0x57,0x92,0x91,0x69,0x2E}};
Expand Down Expand Up @@ -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
Expand Down