summaryrefslogtreecommitdiff
path: root/gui-wm/wayfire/files/wayfire-0.11.0-r36-cube-fixed-top.patch
blob: 8f7f48e62a3332529b23c06b4951b64e302a1652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
--- a/plugins/cube/cube.cpp
+++ b/plugins/cube/cube.cpp
@@ -14,6 +14,7 @@
 #include <wayfire/workspace-stream.hpp>
 #include <wayfire/render-manager.hpp>
 #include <wayfire/workspace-set.hpp>
+#include <wayfire/window-scope.hpp>
 #include <wayfire/scene-operations.hpp>
 #include <wayfire/unstable/translation-node.hpp>
 #include <wayfire/view-transform.hpp>
@@ -50,6 +51,103 @@
 
 namespace
 {
+// Cube replaces the desktop through TOP, but only selected panels rotate.
+// Fixed TOP surfaces (including the dock) must remain above both the cube
+// textures and any held-window image. Do not reparent their real/input nodes.
+class fixed_top_layer_node_t : public wf::scene::node_t
+{
+    wf::output_t *output;
+    std::string rotating_namespace;
+
+    class instance_t : public wf::scene::render_instance_t
+    {
+        std::shared_ptr<fixed_top_layer_node_t> self;
+        std::vector<wf::scene::render_instance_uptr> children;
+
+        wf::regionf_t fullscreen_mask() const
+        {
+            if (auto mask = self->output->get_data<wf::physical_fullscreen_regions_t>())
+            {
+                return mask->hidden;
+            }
+
+            return {};
+        }
+
+      public:
+        instance_t(fixed_top_layer_node_t *node, wf::scene::damage_callback push_damage) :
+            self(std::static_pointer_cast<fixed_top_layer_node_t>(node->shared_from_this()))
+        {
+            auto damage = [self = this->self, push_damage] (const wf::regionf_t& region)
+            {
+                push_damage(region + wf::origin(self->output->get_layout_geometry()));
+            };
+            for (const auto& child : self->output->node_for_layer(wf::scene::layer::TOP)->get_children())
+            {
+                auto view = wf::node_to_view(child);
+                const bool rotates = view && view->role == wf::VIEW_ROLE_DESKTOP_ENVIRONMENT &&
+                    !self->rotating_namespace.empty() &&
+                    (self->rotating_namespace == "*" || view->get_app_id() == self->rotating_namespace);
+                if (child->is_enabled() && !rotates)
+                {
+                    child->gen_render_instances(children, damage, self->output);
+                }
+            }
+        }
+
+        void schedule_instructions(std::vector<wf::scene::render_instruction_t>& instructions,
+            const wf::render_target_t& target, wf::regionf_t& damage) override
+        {
+            auto box = self->get_bounding_box();
+            auto offset = wf::origin(box);
+            auto local_damage = (damage & box) - offset;
+            auto excluded = local_damage & fullscreen_mask();
+            local_damage ^= excluded;
+            auto local_target = target.translated(-offset);
+            for (auto& child : children)
+            {
+                child->schedule_instructions(instructions, local_target, local_damage);
+            }
+
+            local_damage |= excluded;
+            damage ^= box;
+            damage |= (local_damage + offset) & box;
+        }
+
+        void compute_visibility(wf::output_t *output, wf::regionf_t& visible) override
+        {
+            auto offset = wf::origin(self->get_bounding_box());
+            visible -= offset;
+            auto excluded = visible & fullscreen_mask();
+            visible ^= excluded;
+            for (auto& child : children) child->compute_visibility(output, visible);
+            visible |= excluded;
+            visible += offset;
+        }
+
+        void presentation_feedback(wf::output_t *output) override
+        {
+            for (auto& child : children) child->presentation_feedback(output);
+        }
+    };
+
+  public:
+    fixed_top_layer_node_t(wf::output_t *output, std::string rotating_namespace) :
+        node_t(false), output(output), rotating_namespace(std::move(rotating_namespace))
+    {}
+
+    wf::geometry_t get_bounding_box() override { return output->get_layout_geometry(); }
+
+    void gen_render_instances(std::vector<wf::scene::render_instance_uptr>& instances,
+        wf::scene::damage_callback damage, wf::output_t *shown_on) override
+    {
+        if (shown_on == output)
+        {
+            instances.push_back(std::make_unique<instance_t>(this, damage));
+        }
+    }
+};
+
 class wayfire_cube : public wf::per_output_plugin_instance_t, public wf::pointer_interaction_t
 {
     class fixed_view_overlay_node_t : public wf::scene::node_t
@@ -122,7 +220,7 @@
                     push_damage(self->get_bounding_box());
                 };
                 output_background->gen_render_instances(output_background_instances,
-                    push_background_damage, self->cube->output);
+                    push_background_damage, self->cube->output, false);
 
                 self->connect(&on_cube_damage);
 
@@ -269,6 +367,7 @@
 
     std::unique_ptr<wf::input_grab_t> input_grab;
     std::shared_ptr<cube_render_node_t> render_node;
+    std::shared_ptr<fixed_top_layer_node_t> fixed_top_node;
     std::shared_ptr<wf::scene::translation_node_t> fixed_overlay_node;
     wayfire_toplevel_view fixed_overlay_view = nullptr;
     wayfire_toplevel_view post_move_dim_view = nullptr;
@@ -630,6 +729,11 @@
     void add_cube_render_node()
     {
         add_desktop_render_node(render_node);
+        if (fixed_top_node) wf::scene::remove_child(fixed_top_node);
+        fixed_top_node = std::make_shared<fixed_top_layer_node_t>(output, rotate_layer_shell);
+        wf::scene::node_ptr anchor = fixed_overlay_node ?
+            wf::scene::node_ptr(fixed_overlay_node) : wf::scene::node_ptr(render_node);
+        add_desktop_render_node(fixed_top_node, anchor);
     }
 
     void rebuild_cube_render_node()
@@ -644,6 +748,15 @@
         add_cube_render_node();
     }
 
+    void clear_unused_fixed_top_node()
+    {
+        if (!render_node && !fixed_overlay_node && fixed_top_node)
+        {
+            wf::scene::remove_child(fixed_top_node);
+            fixed_top_node = nullptr;
+        }
+    }
+
     void pause_cube_render(bool pause)
     {
         if (pause)
@@ -652,6 +765,7 @@
             {
                 wf::scene::remove_child(render_node);
                 render_node = nullptr;
+                clear_unused_fixed_top_node();
                 cube_render_paused = true;
                 output->render->damage_whole();
             }
@@ -727,6 +841,7 @@
 
         wf::scene::remove_child(fixed_overlay_node);
         fixed_overlay_node = nullptr;
+        clear_unused_fixed_top_node();
     }
 
     void clear_post_move_window_dim()
@@ -745,6 +860,8 @@
             fixed_overlay_node = nullptr;
         }
 
+        clear_unused_fixed_top_node();
+
         post_move_dim_view = nullptr;
         fixed_overlay_added_transformer = false;
     }
@@ -838,6 +955,7 @@
         fixed_workspace_view = nullptr;
         workspace_animation_anchor.reset();
         clear_fixed_workspace_overlay();
+        clear_unused_fixed_top_node();
         release_cube_input();
         output->deactivate_plugin(&grab_interface);
 
--- a/plugins/vswitch/vswitch.cpp
+++ b/plugins/vswitch/vswitch.cpp
@@ -385,7 +385,6 @@
     std::unique_ptr<vswitch_basic_plugin> algorithm;
     std::unique_ptr<wf::vswitch::control_bindings_t> bindings;
     wayfire_toplevel_view held_dim_view = nullptr;
-    std::shared_ptr<wf::scene::translation_node_t> held_dim_overlay_node;
     uint32_t held_dim_modifiers = 0;
     std::weak_ptr<wf::toplevel_view_interface_t> held_move_view;
     uint32_t held_move_modifiers = 0;
@@ -504,12 +503,6 @@
             wf::scene::set_node_enabled(held_dim_view->get_transformed_node(), true);
         }
 
-        if (held_dim_overlay_node)
-        {
-            wf::scene::remove_child(held_dim_overlay_node);
-            held_dim_overlay_node = nullptr;
-        }
-
         held_dim_view = nullptr;
         held_dim_modifiers = 0;
     }
@@ -586,19 +579,12 @@
         remove_held_dim_transformers(view);
         view->get_transformed_node()->add_transformer(transformer,
             wf::TRANSFORMER_2D, held_dim_transformer_name);
-        wf::scene::set_node_enabled(view->get_transformed_node(), false);
-
-        auto overlay = std::make_shared<wf::vswitch::vswitch_overlay_node_t>(view);
-        held_dim_overlay_node =
-            std::make_shared<wf::scene::translation_node_t>();
-        held_dim_overlay_node->set_children_list({overlay});
-        held_dim_overlay_node->set_offset(wf::origin(output->get_layout_geometry()));
-        wf::scene::add_front(wf::get_core().scene(), held_dim_overlay_node);
-
+        // Modifier feedback changes opacity, not stacking. Cube owns the
+        // stationary carried-window image during an actual workspace move;
+        // a root-front copy here would paint above panels, docks and locks.
         held_dim_view = view;
         held_dim_modifiers = wf::get_core().seat->get_keyboard_modifiers();
-        wf::scene::damage_node(held_dim_overlay_node,
-            held_dim_overlay_node->get_bounding_box());
+        view->damage();
     }
 
     /**
--- a/src/api/wayfire/workspace-stream.hpp
+++ b/src/api/wayfire/workspace-stream.hpp
@@ -54,6 +54,11 @@
     std::string stringify() const override;
     void gen_render_instances(std::vector<scene::render_instance_uptr>& instances,
         scene::damage_callback push_damage, wf::output_t *output) override;
+    // Cube's fixed background omits TOP surfaces, which have their own
+    // foreground pass. A non-virtual overload preserves the existing node
+    // layout and plugin ABI.
+    void gen_render_instances(std::vector<scene::render_instance_uptr>& instances,
+        scene::damage_callback push_damage, wf::output_t *output, bool include_top_layer);
     // The bounding box of a workspace stream is
     // (0, 0, output_width, output_height).
     wf::geometry_t get_bounding_box() override;
--- a/src/output/workspace-stream.cpp
+++ b/src/output/workspace-stream.cpp
@@ -40,7 +40,7 @@
 
   public:
     workspace_stream_instance_t(workspace_stream_node_t *self,
-        scene::damage_callback push_damage)
+        scene::damage_callback push_damage, bool include_top_layer)
     {
         this->self = self;
         auto translate_and_push_damage = [this, push_damage] (wf::regionf_t damage)
@@ -55,6 +55,11 @@
 
         for (auto& output_node : wf::collect_output_nodes(wf::get_core().scene(), self->output))
         {
+            if (!include_top_layer && output_node == self->output->node_for_layer(scene::layer::TOP))
+            {
+                continue;
+            }
+
             // A workspace contains desktop content only. In particular, cube/expo
             // subpasses must never fold a launcher, screensaver or lock into the desktop.
             if (output_node == self->output->node_for_layer(scene::layer::OVERLAY) ||
@@ -231,8 +236,15 @@
     std::vector<scene::render_instance_uptr>& instances,
     scene::damage_callback push_damage, wf::output_t *output)
 {
+    gen_render_instances(instances, push_damage, output, true);
+}
+
+void workspace_stream_node_t::gen_render_instances(
+    std::vector<scene::render_instance_uptr>& instances,
+    scene::damage_callback push_damage, wf::output_t *output, bool include_top_layer)
+{
     instances.push_back(std::make_unique<workspace_stream_instance_t>(this,
-        push_damage));
+        push_damage, include_top_layer));
 }
 
 std::string workspace_stream_node_t::stringify() const