app: remove spurious comment
[staging/windowmanager.git] / src / app.cpp
index 6a7f5b4..57d1b17 100644 (file)
@@ -307,8 +307,6 @@ void App::surface_set_layout(uint32_t surface_id) {
 
    // configure surface to wxh dimensions
    s->set_configuration(w, h);
-   // set source rect to "entire surface"
-   s->set_source_rectangle(0, 0, w, h);
    // set destination to the display rectangle
    s->set_destination_rectangle(x, y, w, h);
 
@@ -321,6 +319,35 @@ void App::surface_set_layout(uint32_t surface_id) {
             surface_id, layer_id, x, y, w, h);
 }
 
+char const *App::activate_surface(uint32_t surface_id) {
+   if (! this->controller->surface_exists(surface_id)) {
+      return "Surface does not exist";
+   }
+
+   // This shouild involve a policy check, but as we do not (yet) have
+   // such a thing, we will just switch to this surface.
+   // XXX: input focus missing!!1
+
+   // Make it visible, no (or little effect) if already visible
+   auto &s = this->controller->surfaces[surface_id];
+   s->set_visibility(1);
+
+   // Set all others invisible
+   for (auto &i: this->controller->surfaces) {
+      auto &si = this->controller->sprops[i.second->id];
+      if (si.visibility == 1 && si.id != s->id && int(si.id) != this->layers.main_surface) {
+         i.second->set_visibility(0);
+      }
+   }
+
+   // commit changes
+   this->controller->commit_changes();
+   this->display->flush();
+
+   // no error
+   return nullptr;
+}
+
 void App::add_task(char const *name, std::function<void()> &&f) {
    this->pending.emplace_back(std::make_pair(name, f));
 }
@@ -402,6 +429,15 @@ binding_api::result_type binding_api::debug_terminate() {
    return Ok(json_object_new_object());
 }
 
+binding_api::result_type binding_api::demo_activate_surface(
+        uint32_t surfaceid) {
+   char const *e = this->app->activate_surface(surfaceid);
+   if (e) {
+      return Err<json_object *>(e);
+   }
+   return Ok(json_object_new_object());
+}
+
 //                  _             _ _            _                 _
 //   ___ ___  _ __ | |_ _ __ ___ | | | ___ _ __ | |__   ___   ___ | | _____
 //  / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|| '_ \ / _ \ / _ \| |/ / __|