From d7be18652d706b03d16e0a99d26935a60fc77ba8 Mon Sep 17 00:00:00 2001 From: Wander Lairson Costa Date: Mon, 21 Dec 2020 14:39:42 -0300 Subject: [PATCH] windows: Use FindWindow to locate the window related to the timer If our window is not the foreground window, GetActiveWindow() will return a null handle, which causes the call to SetTimer to ignore the given timer ID. We solve this by calling FindWindow() passing the window class name when GetActiveWindow returns null. Change-Id: Icc3e3c9f3fd0f9cfb4f4e8cb97fabffe347c7b5d --- .../window-system/windows/platform-implement-win.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dali/internal/window-system/windows/platform-implement-win.cpp b/dali/internal/window-system/windows/platform-implement-win.cpp index c56d31e..4a2a60b 100755 --- a/dali/internal/window-system/windows/platform-implement-win.cpp +++ b/dali/internal/window-system/windows/platform-implement-win.cpp @@ -261,13 +261,24 @@ void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nTimerid, DWORD dwTime) intptr_t SetTimer(int interval, timerCallback callback, void *data) { + HWND hwnd = GetActiveWindow(); + if (!hwnd) + { + hwnd = FindWindow(DALI_WINDOW_CLASS_NAME.c_str(), nullptr); + } + + if (!hwnd) + { + return -1; + } + TTimerCallbackInfo *callbackInfo = new TTimerCallbackInfo; callbackInfo->data = data; callbackInfo->callback = callback; - callbackInfo->hWnd = ::GetActiveWindow(); + callbackInfo->hWnd = hwnd; INT_PTR timerID = (INT_PTR)callbackInfo; - ::SetTimer( callbackInfo->hWnd, timerID, interval, TimerProc ); + ::SetTimer( hwnd, timerID, interval, TimerProc ); return timerID; } -- 2.7.4