Skip to content

Commit ed1ae03

Browse files
authored
Refactor GPU state refresh mechanism
Refactor GPU state refresh handling to use event-driven approach instead of timers. Update comments for clarity.
1 parent b56d5bd commit ed1ae03

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/win/win_helpers.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
#include "win_helpers.h"
22

33
#include "../util/startup.h"
4-
#include "../tray/tray_menu.h"
5-
#include "../gpu/gpu_state.h"
64
#include "../util/logging.h"
75

86
// Globals from main.cpp
97
extern GpuState g_displayGpuState;
108
extern GpuState g_renderGpuState;
11-
extern bool g_forceRenderGpu;
9+
extern bool g_forceRenderGpu;
1210

13-
// Forward declaration from main.cpp
11+
// From main.cpp
1412
extern void RefreshGpuState(HWND hwnd);
1513

16-
// Restart GPU driver (same as Ctrl+Win+Shift+B)
14+
// Restart GPU driver (Ctrl+Win+Shift+B)
1715
void RestartGpuDriver()
1816
{
19-
// This triggers a graphics subsystem reset
20-
// Equivalent to pressing Ctrl+Win+Shift+B
2117
keybd_event(VK_CONTROL, 0, 0, 0);
2218
keybd_event(VK_LWIN, 0, 0, 0);
2319
keybd_event(VK_SHIFT, 0, 0, 0);
@@ -33,8 +29,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3329
{
3430
switch (msg)
3531
{
36-
case WM_TIMER:
37-
// Periodic GPU refresh
32+
case WM_DISPLAYCHANGE:
33+
case WM_DEVICECHANGE:
34+
case WM_POWERBROADCAST:
35+
// Event-driven refresh: no polling, no timers
3836
RefreshGpuState(hwnd);
3937
return 0;
4038

0 commit comments

Comments
 (0)