Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sdl
- Fixing rendering borderless window. Need to force windows to send a WM_NCCALCSIZE then return 0 for non-client area size.

- Adding WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX to borderless windows, for reasons noted in comments.

- Fix SetupWindowData() setting SDL_WINDOW_BORDERLESS. This was being cleared at window creation, causing hanlding for the first WM_NCCALCSIZE message to fail
  • Loading branch information
slouken committed Sep 22, 2017
1 parent cc023b6 commit 3176a7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/video/windows/SDL_windowsevents.c
Expand Up @@ -949,6 +949,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;

case WM_NCCALCSIZE:
{
// When borderless, need to tell windows that the size of the non-client area is 0
if ( wParam == TRUE && SDL_GetWindowFlags( data->window ) & SDL_WINDOW_BORDERLESS )
return 0;
}
break;

case WM_NCHITTEST:
{
SDL_Window *window = data->window;
Expand Down Expand Up @@ -976,7 +984,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
break;

}

/* If there's a window proc, assume it's going to handle messages */
Expand Down
16 changes: 12 additions & 4 deletions src/video/windows/SDL_windowswindow.c
Expand Up @@ -51,9 +51,14 @@ static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
static WCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow");
static ATOM SDL_HelperWindowClass = 0;

// for borderless Windows, still want the following flags:
// - WS_CAPTION: this seems to enable the Windows minimize animation
// - WS_SYSMENU: enables system context menu on task bar
// - WS_MINIMIZEBOX: window will respond to Windows minimize commands sent to all windows, such as windows key + m, shaking title bar, etc.

#define STYLE_BASIC (WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
#define STYLE_FULLSCREEN (WS_POPUP)
#define STYLE_BORDERLESS (WS_POPUP)
#define STYLE_BORDERLESS (WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)
#define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)
#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX)
#define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE)
Expand Down Expand Up @@ -216,10 +221,10 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre
} else {
window->flags &= ~SDL_WINDOW_SHOWN;
}
if (style & (WS_BORDER | WS_THICKFRAME)) {
window->flags &= ~SDL_WINDOW_BORDERLESS;
} else {
if (style & WS_POPUP) {
window->flags |= SDL_WINDOW_BORDERLESS;
} else {
window->flags &= ~SDL_WINDOW_BORDERLESS;
}
if (style & WS_THICKFRAME) {
window->flags |= SDL_WINDOW_RESIZABLE;
Expand Down Expand Up @@ -306,6 +311,9 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
return -1;
}

// Inform Windows of the frame change so we can respond to WM_NCCALCSIZE
SetWindowPos( hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE );

if (!(window->flags & SDL_WINDOW_OPENGL)) {
return 0;
}
Expand Down

0 comments on commit 3176a7f

Please sign in to comment.