app: do not use the Qt surface ID shift hack
[staging/windowmanager.git] / src / app.cpp
index 76668cc..c672052 100644 (file)
@@ -313,10 +313,15 @@ void App::surface_set_layout(uint32_t surface_id) {
    s->set_destination_rectangle(x, y, w, h);
 
    // XXX: The main_surface will be visible regardless
-   s->set_visibility(
-      surface_id == static_cast<unsigned>(this->layers.main_surface) ? 1 : 0);
+   //s->set_visibility(
+   //   surface_id == static_cast<unsigned>(this->layers.main_surface) ? 1 : 0);
    this->controller->layers[layer_id]->add_surface(s.get());
 
+   if (surface_id == static_cast<unsigned>(this->layers.main_surface)) {
+      logdebug("Activating main_surface (%d)", surface_id);
+      this->activate_surface(surface_id);
+   }
+
    logdebug("Surface %u now on layer %u with rect { %d, %d, %d, %d }",
             surface_id, layer_id, x, y, w, h);
 }
@@ -352,7 +357,6 @@ char const *App::activate_surface(uint32_t surface_id) {
    /// // XXX: I am not sure I even need 5 elements...
    /// this->last_active.resize(std::min(int(this->last_active.size()), 5));
 
-
    // no error
    return nullptr;
 }
@@ -414,7 +418,7 @@ void App::execute_pending() {
 // | .__/|_|  \___/_/\_\_|\___|\__,_| |_____| \_/ \___|_| |_|\__|___/
 // |_|
 void App::surface_created(uint32_t surface_id) {
-   surface_id &= id_allocator::id_mask;
+   //surface_id >>= id_allocator::id_shift;
 
    logdebug("surface_id is %u", surface_id);
 
@@ -424,7 +428,7 @@ void App::surface_created(uint32_t surface_id) {
 }
 
 void App::surface_removed(uint32_t surface_id) {
-   surface_id &= id_allocator::id_mask;
+   //surface_id >>= id_allocator::id_shift;
 
    logdebug("surface_id is %u", surface_id);
 
@@ -441,6 +445,22 @@ void App::surface_removed(uint32_t surface_id) {
                   });
 }
 
+void App::emit_activated(char const *label) {
+   this->api.send_event("activated", json_object_new_string(label));
+}
+
+void App::emit_deactivated(char const *label) {
+   this->api.send_event("deactivated", json_object_new_string(label));
+}
+
+void App::emit_syncdraw(char const *label) {
+   this->api.send_event("syncdraw", json_object_new_string(label));
+}
+
+void App::emit_visible(char const *label, bool is_visible) {
+   this->api.send_event(is_visible ? "visible" : "invisible", json_object_new_string(label));
+}
+
 result<int> App::request_surface(char const *drawing_name) {
    auto lid = this->layers.get_layer_id(std::string(drawing_name));
    if (!lid) {
@@ -475,7 +495,11 @@ char const *App::activate_surface(char const *drawing_name) {
    if (osid) {
       logdebug("ativate surface with name %s and id %u", drawing_name,
                osid.value());
-      return this->activate_surface(osid.value());
+      auto ret = this->activate_surface(osid.value());
+      if (!ret) {
+         this->emit_activated(drawing_name);
+      }
+      return ret;
    }
 
    logerror("surface %s unknown", drawing_name);