1
0
Эх сурвалжийг харах

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
Sam Lantinga 7 жил өмнө
parent
commit
3176a7f5e9

+ 8 - 1
src/video/windows/SDL_windowsevents.c

@@ -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;
@@ -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 */

+ 12 - 4
src/video/windows/SDL_windowswindow.c

@@ -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)
@@ -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;
@@ -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;
     }