Revert "Enable scaling to fit various screen resolutions"
[apps/agl-service-windowmanager-2017.git] / src / window_manager.cpp
index de322df..862341a 100644 (file)
@@ -29,7 +29,7 @@ extern "C"
 namespace wm
 {
 
-static const unsigned kTimeOut = 3000000UL; /* 3s */
+static const uint64_t kTimeOut = 3ULL; /* 3s */
 
 /* DrawingArea name used by "{layout}.{area}" */
 const char kNameLayoutNormal[] = "normal";
@@ -235,7 +235,7 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
         HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
         if (!lid)
         {
-            return Err<int>("Drawing name does not match any role, Fallback is disabled");
+            return Err<int>("Drawing name does not match any role, fallback is disabled");
         }
     }
 
@@ -289,7 +289,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
         HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
         if (!lid)
         {
-            return "Drawing name does not match any role, Fallback is disabled";
+            return "Drawing name does not match any role, fallback is disabled";
         }
     }
 
@@ -726,6 +726,8 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area)
               layer_id);
 
     // set destination to the display rectangle
+    s->set_source_rectangle(0, 0, w, h);
+    this->layout_commit();
     s->set_destination_rectangle(x, y, w, h);
 
     // update area information
@@ -1088,6 +1090,15 @@ WMError WindowManager::setInvisibleTask(const std::string &role, bool split)
 {
     unsigned req_num = g_app_list.currentRequestNumber();
     HMI_SEQ_DEBUG(req_num, "set current visible app to invisible task");
+    bool found = false;
+    auto trigger = g_app_list.getRequest(req_num, &found);
+    // I don't check found == true here because this is checked in caller.
+    if(trigger.role == "homescreen")
+    {
+        HMI_SEQ_INFO(req_num, "In case of 'homescreen' visible, don't change app to invisible");
+        return WMError::SUCCESS;
+    }
+
     // This task is copied from original actiavete surface
     const char *drawing_name = this->rolenew2old[role].c_str();
     auto const &surface_id = this->lookup_id(role.c_str());
@@ -1099,7 +1110,6 @@ WMError WindowManager::setInvisibleTask(const std::string &role, bool split)
     int surface;
     TaskVisible task_visible = TaskVisible::INVISIBLE;
     bool end_draw_finished = true;
-    bool found = false;
 
     for (auto const &l : this->layers.mapping)
     {
@@ -1435,17 +1445,22 @@ void WindowManager::emitScreenUpdated(unsigned req_num)
     {
         HMI_DEBUG("wm", "afb_event_push failed: %m");
     }
-    json_object_put(jarray);
 }
 
 void WindowManager::setTimer()
 {
+    struct timespec ts;
+    if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) {
+        HMI_ERROR("wm", "Could't set time (clock_gettime() returns with error");
+        return;
+    }
+
     HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate");
     if (g_timer_ev_src == nullptr)
     {
         // firsttime set into sd_event
         int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_ev_src,
-            CLOCK_REALTIME, time(NULL) * (1000000UL) + kTimeOut, 1, processTimerHandler, this);
+            CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this);
         if (ret < 0)
         {
             HMI_ERROR("wm", "Could't set timer");
@@ -1454,7 +1469,7 @@ void WindowManager::setTimer()
     else
     {
         // update timer limitation after second time
-        sd_event_source_set_time(g_timer_ev_src, time(NULL) * (1000000UL) + kTimeOut);
+        sd_event_source_set_time(g_timer_ev_src, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL);
         sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_ONESHOT);
     }
 }