Skip to content

Commit

Permalink
Merge pull request #7 from idietmoran/dev-win32
Browse files Browse the repository at this point in the history
fixed issue when clicking title bar
  • Loading branch information
Stateford authored Apr 5, 2018
2 parents 5532c90 + c419424 commit d75e0ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/bin/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ void cursorLock(void* arguments)
HANDLE hMessageEmpty = CreateEvent(NULL, FALSE, TRUE, _T("EMPTY"));
winArgs *args = (winArgs*)arguments;

POINT cursorPos;

while(args->active)
{
//DWORD waiting = WaitForSingleObject(hMessageStop, INFINITE);
Expand All @@ -85,6 +87,8 @@ void cursorLock(void* arguments)
ClientToScreen(args->window->hWnd, &args->window->size.left);
ClientToScreen(args->window->hWnd, &args->window->size.right);

getCurrentMousePos(&cursorPos);

HWND active = GetForegroundWindow();

if(args->window->hWnd == active)
Expand All @@ -98,13 +102,21 @@ void cursorLock(void* arguments)
_endthread();
}

BOOL checkClientArea(POINT* cursorPos, RECT* rect)
{
return cursorPos->y <= rect->bottom && cursorPos->y >= rect->top;
}


int __stdcall cursorLockEx(void* arguments)
{
HANDLE hMessageStop = CreateEvent(NULL, FALSE, FALSE, _T("STOP"));
HANDLE hMessageEmpty = CreateEvent(NULL, FALSE, TRUE, _T("EMPTY"));
winArgs *args = (winArgs*)arguments;
WINDOW activeWindow = *args->window;

POINT cursorPos;

while (*args->active)
{
//DWORD waiting = WaitForSingleObject(hMessageStop, INFINITE);
Expand All @@ -118,7 +130,9 @@ int __stdcall cursorLockEx(void* arguments)

HWND active = GetForegroundWindow();

if (activeWindow.hWnd == active)
getCurrentMousePos(&cursorPos);

if (activeWindow.hWnd == active && checkClientArea(&cursorPos, &activeWindow.size))
{
ClipCursor(&activeWindow.size);
}
Expand Down
2 changes: 2 additions & 0 deletions src/bin/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ void lockFocused(WINDOW*);

void cursorLock(void*);

BOOL checkClientArea(POINT*, RECT*);

int __stdcall cursorLockEx(void* arguments);

#endif

0 comments on commit d75e0ae

Please sign in to comment.