From: Andrew Eikum Subject: [PATCH] winex11.drv: Throttle calls to XResetScreenSaver Message-Id: <20190917130936.s5g5hyby3tayske2@foghorn.codeweavers.com> Date: Tue, 17 Sep 2019 08:09:36 -0500 Frequent calls to XResetScreenSaver cause performance problems on some GPU drivers, see https://bugs.freedesktop.org/show_bug.cgi?id=110659 Signed-off-by: Andrew Eikum --- dlls/winex11.drv/window.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index fb97ec5a0d4..c97cc6a9e0b 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1793,10 +1793,20 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, switch (msg) { case WM_WINE_NOTIFY_ACTIVITY: - XResetScreenSaver( gdi_display ); - XFlush( gdi_display ); + { + static ULONGLONG last = 0; + ULONGLONG now = GetTickCount64(); + /* calling XResetScreenSaver too often can cause performance + * problems, so throttle it */ + if (now > last + 5000) + { + XResetScreenSaver( gdi_display ); + XFlush( gdi_display ); + last = now; + } break; } + } return desktop_orig_wndproc( hwnd, msg, wp, lp ); } -- 2.23.0