Skip to content

Commit

Permalink
Merge pull request #31 from idietmoran/dev-win32
Browse files Browse the repository at this point in the history
fixed an issue where borderless windowed would not work properly with…
  • Loading branch information
Stateford authored Apr 22, 2018
2 parents 8393487 + fc47abe commit 3ad0c72
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
.vs/
*.DLOCK
notes.MD
*.un~
*.swp
*.cmake
*.txt
makefile
/CMakeFiles/
.gitignore~
*.txt~
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file

## [1.0.8]
### Fixed
- Fixed an issue where borderless windows without fullscreen would cause the game to not work properly
- This was caused by not resizing the window after removing the title bar

### Removed
- Removed recommendation to using only borderless window with fullscreen


## [1.0.7]
### Added
- Added recommendation to using only borderless window without fullscreen
- Added recommendation to using only borderless window with fullscreen

### Fixed
- Fixed an issue where background processes would appear in the selection box
Expand Down
23 changes: 23 additions & 0 deletions src/bin/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ inline void borderlessWindow(HWND activeWindow)
SetWindowLongPtr(activeWindow, GWL_EXSTYLE, GetWindowLongPtr(activeWindow, GWL_EXSTYLE)^WS_EX_WINDOWEDGE);
}

void resizeBorderless(WINDOW activeWindow, PREVIOUSRECT* prev)
{
GetClientRect(activeWindow.hWnd, &activeWindow.size);
ClientToScreen(activeWindow.hWnd, (LPPOINT)&activeWindow.size.left);
ClientToScreen(activeWindow.hWnd, (LPPOINT)&activeWindow.size.right);

prev->width = activeWindow.size.right - activeWindow.size.left;
prev->height = activeWindow.size.bottom - activeWindow.size.top;
prev->x = activeWindow.size.left;
prev->y = activeWindow.size.top;

SetWindowPos(activeWindow.hWnd, NULL, prev->x, prev->y, prev->width, prev->height, 0);
}


void fullScreen(WINDOW activeWindow, PREVIOUSRECT *prev)
{
GetClientRect(activeWindow.hWnd, &activeWindow.size);
Expand Down Expand Up @@ -114,7 +129,11 @@ int __stdcall cursorLockEx(void* arguments)
// borderless window w/o full screen breaks cursor placement
// on most games...
if(settings->borderlessWindow)
{
borderlessWindow(currentWindow);
if (!settings->fullScreen)
resizeBorderless(activeWindow, &previousrect);
}

if(settings->fullScreen)
fullScreen(activeWindow, &previousrect);
Expand Down Expand Up @@ -180,7 +199,11 @@ int __stdcall cursorLockEx(void* arguments)
SetWindowLongPtr(currentWindow, GWL_STYLE, GetWindowLongPtr(currentWindow, GWL_STYLE)|WS_SIZEBOX);

if(settings->borderlessWindow)
{
borderlessWindow(currentWindow);
if (!settings->fullScreen)
resizeBorderless(activeWindow, &previousrect);
}

if (settings->fullScreen)
disableFullScreen(activeWindow, &previousrect);
Expand Down
1 change: 1 addition & 0 deletions src/bin/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ BOOL checkClientArea(POINT*, RECT*);
BOOL checkResizeStyle(HWND);
void borderlessWindow(HWND);
void undoborderlessWindow(HWND);
void resizeBorderless(WINDOW, PREVIOUSRECT*);
void fullScreen(WINDOW, PREVIOUSRECT*);
void disableFullScreen(WINDOW, PREVIOUSRECT*);

Expand Down
Binary file modified src/displayLock-win32.aps
Binary file not shown.
Binary file modified src/displayLock-win32.rc
Binary file not shown.
4 changes: 2 additions & 2 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void writeSettings(SETTINGS settings)
PathAppend(path, TEXT("\\settings.DLOCK"));
FILE *file = _wfopen(path, TEXT("w"));

if(file != NULL)
if(file != NULL || file == 0)
{
fwrite(&settings, sizeof(settings), 1, file);
}
Expand All @@ -85,7 +85,7 @@ void readSettings(SETTINGS *settings)

// if if opening file is succcessful read into struct
// otherwise use default settings
if (file != NULL)
if (file != NULL || file == 0)
fread(settings, sizeof(*settings), 1, file);
else
defaultSettings(settings);
Expand Down

0 comments on commit 3ad0c72

Please sign in to comment.