Skip to content

Commit afd7ae8

Browse files
committed
Refactor window settings handling by removing redundant comments and improving code clarity
1 parent 4d9ab70 commit afd7ae8

2 files changed

Lines changed: 0 additions & 11 deletions

File tree

src/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
499499
g_state.closing = false;
500500
return 0;
501501
case WM_DESTROY:
502-
// Save window position and size before destroying
503502
{
504503
WINDOWPLACEMENT wp = {};
505504
wp.length = sizeof(WINDOWPLACEMENT);
506505
if (GetWindowPlacement(hwnd, &wp))
507506
{
508-
// Always save the normal position, even if maximized or minimized
509507
RECT rect = wp.rcNormalPosition;
510508
g_state.windowX = rect.left;
511509
g_state.windowY = rect.top;

src/modules/settings.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,14 @@ void LoadWindowSettings()
133133
DWORD size = sizeof(x);
134134
if (RegQueryValueExW(hKey, WINDOW_X_VALUE, nullptr, nullptr, reinterpret_cast<LPBYTE>(&x), &size) == ERROR_SUCCESS)
135135
{
136-
// Cast DWORD to int - on Windows, this preserves negative coordinates correctly
137136
g_state.windowX = static_cast<int>(x);
138137
}
139-
140138
DWORD y = 0;
141139
size = sizeof(y);
142140
if (RegQueryValueExW(hKey, WINDOW_Y_VALUE, nullptr, nullptr, reinterpret_cast<LPBYTE>(&y), &size) == ERROR_SUCCESS)
143141
{
144-
// Cast DWORD to int - on Windows, this preserves negative coordinates correctly
145142
g_state.windowY = static_cast<int>(y);
146143
}
147-
148144
DWORD width = 0;
149145
size = sizeof(width);
150146
if (RegQueryValueExW(hKey, WINDOW_WIDTH_VALUE, nullptr, nullptr, reinterpret_cast<LPBYTE>(&width), &size) == ERROR_SUCCESS)
@@ -154,7 +150,6 @@ void LoadWindowSettings()
154150
g_state.windowWidth = static_cast<int>(width);
155151
}
156152
}
157-
158153
DWORD height = 0;
159154
size = sizeof(height);
160155
if (RegQueryValueExW(hKey, WINDOW_HEIGHT_VALUE, nullptr, nullptr, reinterpret_cast<LPBYTE>(&height), &size) == ERROR_SUCCESS)
@@ -167,13 +162,10 @@ void LoadWindowSettings()
167162

168163
RegCloseKey(hKey);
169164
}
170-
171-
// Validate that the window position is visible on at least one monitor
172165
RECT rc = {g_state.windowX, g_state.windowY, g_state.windowX + g_state.windowWidth, g_state.windowY + g_state.windowHeight};
173166
HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONULL);
174167
if (!hMonitor)
175168
{
176-
// Window would be off-screen, reset to default
177169
g_state.windowX = CW_USEDEFAULT;
178170
g_state.windowY = CW_USEDEFAULT;
179171
}
@@ -184,7 +176,6 @@ void SaveWindowSettings()
184176
HKEY hKey;
185177
if (RegCreateKeyExW(HKEY_CURRENT_USER, SETTINGS_KEY, 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr) == ERROR_SUCCESS)
186178
{
187-
// Store coordinates as REG_DWORD - static_cast preserves bit pattern for negative values
188179
DWORD x = static_cast<DWORD>(g_state.windowX);
189180
RegSetValueExW(hKey, WINDOW_X_VALUE, 0, REG_DWORD,
190181
reinterpret_cast<const BYTE *>(&x),

0 commit comments

Comments
 (0)