Skip to content

Commit

Permalink
fixed an issue where the UI would not revert when application is clos…
Browse files Browse the repository at this point in the history
…ed (#97)

* fixed an issue where the UI would not revert when application is closed

* fixed appveyor
  • Loading branch information
Stateford committed Jan 6, 2019
1 parent c3cb6dd commit 26c3d42
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
environment:
vers: "2.1.1"
vers: "2.1.3"
type: "develop"

version: '{branch}/2.1.1.{build}'
version: '{branch}/2.1.3.{build}'

image: Visual Studio 2017

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file

# [2.1.3]
- Fixed an issue where the UI would not revert to correct state when locked application is closed without explicitly closing the program

# [2.1.0]
### Added
- Added a system tray icon
Expand Down
4 changes: 3 additions & 1 deletion Display-Lock/DisplayLock.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
WINDOW_VIEW_CONTROLS windowControls = { 0 };
SETTINGS settings = { 0 }; // application settings
ARGS args = {0};
volatile BOOL running = FALSE;
BOOL running = FALSE;

// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
Expand Down Expand Up @@ -264,6 +264,7 @@ INT_PTR CALLBACK MainWindow(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPara

// show the default window
ShowWindow(mainWindowControls.windowView, SW_SHOW);
args.controls = mainWindowControls;
return (INT_PTR)TRUE;

case WM_NOTIFY:
Expand Down Expand Up @@ -310,6 +311,7 @@ INT_PTR CALLBACK windowViewProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
parent = GetParent(GetParent(GetParent(hDlg)));
args.hWnd = parent;
return (INT_PTR)TRUE;

case WM_COMMAND:
switch (LOWORD(wParam))
{
Expand Down
Binary file modified dispLib/include/common.h
Binary file not shown.
10 changes: 2 additions & 8 deletions dispLib/src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ int CALLBACK cursorLock(void* arguments)
SetForegroundWindow(selectedWindow.hWnd);
SetActiveWindow(selectedWindow.hWnd);
}




if (checkResizeStyle(selectedWindow.hWnd))
{
Expand All @@ -181,7 +178,6 @@ int CALLBACK cursorLock(void* arguments)
styleChanged = TRUE;
}


while (*isRunning)
{
// check if window is closed
Expand All @@ -202,6 +198,8 @@ int CALLBACK cursorLock(void* arguments)
if (!checkProcess(selectedWindow))
{
*args->clipRunning = FALSE;

PostMessage(args->controls.windowView, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_WINDOWS_STOP, 0), 0);
break;
}

Expand All @@ -216,11 +214,9 @@ int CALLBACK cursorLock(void* arguments)
else if (selectedWindow.hWnd == active && GetAsyncKeyState(VK_LBUTTON) == 0)
ClipCursor(&selectedWindow.size);


Sleep(1);
}


// if window style was changed, change it back using the OR (|)
if (styleChanged)
SetWindowLongPtr(selectedWindow.hWnd, GWL_STYLE, GetWindowLongPtr(selectedWindow.hWnd, GWL_STYLE) | WS_SIZEBOX);
Expand All @@ -235,8 +231,6 @@ int CALLBACK cursorLock(void* arguments)
if (settings->fullScreen)
disableFullScreen(selectedWindow, &previousRect);



ClipCursor(NULL); // release the cursor clip
_endthreadex(1); // end the thread
return 1;
Expand Down

0 comments on commit 26c3d42

Please sign in to comment.