@@ -53,6 +53,23 @@ void IdleBySleeping(FpsIdling &ioIdling) {
5353 }
5454}
5555
56+ #ifdef _WIN32
57+ void UpdateWindowCorners (GLFWwindow *window) {
58+ HWND hwnd = glfwGetWin32Window (window);
59+
60+ WINDOWPLACEMENT placement = {};
61+ placement.length = sizeof (WINDOWPLACEMENT);
62+ GetWindowPlacement (hwnd, &placement);
63+
64+ bool isMaximized = (placement.showCmd == SW_SHOWMAXIMIZED);
65+
66+ DWM_WINDOW_CORNER_PREFERENCE cornerPref =
67+ isMaximized ? DWMWCP_DONOTROUND : DWMWCP_ROUND;
68+ DwmSetWindowAttribute (hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &cornerPref,
69+ sizeof (cornerPref));
70+ }
71+ #endif
72+
5673void Application::run () {
5774 auto startupBegin = std::chrono::high_resolution_clock::now ();
5875
@@ -104,8 +121,8 @@ void Application::run() {
104121
105122 glfwSetWindowUserPointer (window, resizeState);
106123
107- glfwSetMouseButtonCallback (window, WindowCallbacks::mouse_button_callback );
108- glfwSetCursorPosCallback (window, WindowCallbacks::cursor_pos_callback );
124+ glfwSetMouseButtonCallback (window, WindowCallbacks::mouseButtonCB );
125+ glfwSetCursorPosCallback (window, WindowCallbacks::cursorPosCB );
109126
110127 Storage storage;
111128 storage.initTOML ();
@@ -146,9 +163,6 @@ void Application::run() {
146163 HWND hwnd = glfwGetWin32Window (window);
147164 SetProcessDpiAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
148165
149- MARGINS margins = {1 , 1 , 1 , 1 };
150- DwmExtendFrameIntoClientArea (hwnd, &margins);
151-
152166 DWM_WINDOW_CORNER_PREFERENCE cornerPref = DWMWCP_ROUND;
153167 DwmSetWindowAttribute (hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &cornerPref,
154168 sizeof (cornerPref));
@@ -160,6 +174,10 @@ void Application::run() {
160174
161175 glfwPollEvents ();
162176
177+ #ifdef _WIN32
178+ UpdateWindowCorners (window);
179+ #endif
180+
163181 int display_w, display_h;
164182 glfwGetFramebufferSize (window, &display_w, &display_h);
165183 glViewport (0 , 0 , display_w, display_h);
@@ -186,8 +204,8 @@ void Application::run() {
186204 glfwTerminate ();
187205}
188206
189- void WindowCallbacks::mouse_button_callback (GLFWwindow *window, int button,
190- int action, int mods) {
207+ void WindowCallbacks::mouseButtonCB (GLFWwindow *window, int button, int action ,
208+ int mods) {
191209 if (button != GLFW_MOUSE_BUTTON_LEFT) return ;
192210
193211 ResizeState *state =
@@ -217,8 +235,8 @@ void WindowCallbacks::mouse_button_callback(GLFWwindow *window, int button,
217235 }
218236}
219237
220- void WindowCallbacks::cursor_pos_callback (GLFWwindow *window, double xpos,
221- double ypos) {
238+ void WindowCallbacks::cursorPosCB (GLFWwindow *window, double xpos,
239+ double ypos) {
222240 ResizeState *state =
223241 static_cast <ResizeState *>(glfwGetWindowUserPointer (window));
224242 if (!state) return ;
0 commit comments