app: added enddraw() and deactivate_surface()
[staging/windowmanager.git] / src / app.hpp
index 8f30d96..ac2eca6 100644 (file)
@@ -21,6 +21,7 @@
 #include <memory>
 #include <unordered_map>
 #include <unordered_set>
+#include <deque>
 
 #include "afb_binding_api.hpp"
 #include "config.hpp"
@@ -41,7 +42,10 @@ struct controller;
 namespace wm {
 
 struct id_allocator {
-   unsigned next = 0x0100'0000;
+   constexpr static unsigned id_shift = 20;
+   constexpr static unsigned id_mask = (1 << id_shift) - 1;
+
+   unsigned next = 1;
 
    // Surfaces that where requested but not yet created
    std::unordered_map<unsigned, std::string> surfaces;
@@ -56,6 +60,7 @@ struct id_allocator {
    // Insert and return a new ID
    unsigned generate_id(std::string const &name) {
       unsigned sid = this->next++;
+      sid <<= id_shift;
       this->surfaces[sid] = name;
       // this->pending_surfaces.insert({sid});
       this->names[name] = sid;
@@ -117,6 +122,8 @@ struct App {
 
    struct id_allocator id_alloc;
 
+   std::deque<unsigned> last_active;
+
    explicit App(wl::display *d);
    ~App();
 
@@ -132,12 +139,14 @@ struct App {
 
    void surface_set_layout(uint32_t surface_id);
    char const *activate_surface(uint32_t surface_id);
+   char const *deactivate_surface(uint32_t surface_id);
 
    // Allocate a surface ID for this role
    result<int> request_surface(char const *drawing_name);
 
    // Activate (i.e. make visible, if allowed!) a surface
    char const *activate_surface(char const *drawing_name);
+   char const *deactivate_surface(char const *drawing_name);
 
    // add tasks, executed after dispatch_events()
    void add_task(char const *name, std::function<void()> &&f);