Permalink
Browse files

Periodically run

SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_SYSTEM_REQUIRED);

to reset the input timer.

Note that this does not use g_application.m_AppFocused, due to a bug: if
the application doesn't have focus to begin with, m_AppFocused is true
until we gain focus and lose it again, because no WM_KILLFOCUS is ever
received.  I'm not fixing that here to keep the scope of this change
small.
  • Loading branch information...
1 parent 67ee34f commit 204ee143e3f738418b93688efb631295a76233a3 @zewt committed Aug 18, 2012
Showing with 16 additions and 0 deletions.
  1. +13 −0 xbmc/windowing/windows/WinEventsWin32.cpp
  2. +3 −0 xbmc/windowing/windows/WinSystemWin32.cpp
View
13 xbmc/windowing/windows/WinEventsWin32.cpp
@@ -719,6 +719,19 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
//some other app has painted over our window, mark everything as dirty
g_windowManager.MarkDirty();
break;
+ case WM_TIMER:
+ {
+ bool hasFocus = GetForegroundWindow() == hWnd;
+ CLog::Log(LOGDEBUG,"WM_TIMER has focus: %i", hasFocus);
+
+ // Reset the input idle timer.
+ if(hasFocus)
+ SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_SYSTEM_REQUIRED);
+
+ // Schedule the next timer.
+ SetTimer(hWnd, 0, 1000, NULL);
+ break;
+ }
case BONJOUR_EVENT:
CZeroconf::GetInstance()->ProcessResults();
break;
View
3 xbmc/windowing/windows/WinSystemWin32.cpp
@@ -126,6 +126,9 @@ bool CWinSystemWin32::CreateNewWindow(const CStdString& name, bool fullScreen, R
ResizeInternal(true);
+ // Start WM_TIMER.
+ SetTimer(hWnd, 0, 1000, NULL);
+
// Show the window
ShowWindow( m_hWnd, SW_SHOWDEFAULT );
UpdateWindow( m_hWnd );

0 comments on commit 204ee14

Please sign in to comment.