windows: Use FindWindow to locate the window related to the timer
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / windows / platform-implement-win.cpp
index 3e51425..4a2a60b 100755 (executable)
@@ -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;
 }
@@ -279,7 +290,7 @@ void KillTimer(intptr_t id)
   delete info;
 }
 
-const char* GetKeyName( int keyCode )
+std::string GetKeyName( int keyCode )
 {
   switch( keyCode )
   {
@@ -361,6 +372,10 @@ const char* GetKeyName( int keyCode )
     }
     default:
     {
+      if (keyCode > 0 && keyCode < 128)
+      {
+        return std::string(1u, static_cast<char>(keyCode));
+      }
       break;
     }
   }