summaryrefslogtreecommitdiff
path: root/gui-wm/wayfire/files/wayfire-0.11.0-r56-cube-warp-rest.patch
blob: b1a2bc95c0f46c9d73849ad233e5a2228d598aba (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
--- a/plugins/cube/cube.cpp
+++ b/plugins/cube/cube.cpp
@@ -220,7 +220,7 @@
                 auto push_background_damage = [=] (const wf::regionf_t& damage)
                 {
                     // An opaque effect or hidden image owns these pixels.
-                    if (double(self->cube->backdrop_image_opacity) > 0 && !self->cube->warp_visible())
+                    if (self->cube->show_backdrop_image())
                         push_damage(self->get_bounding_box());
                 };
                 output_background->gen_render_instances(output_background_instances,
@@ -272,7 +272,7 @@
                 wf::regionf_t background_damage = our_damage;
                 auto background_target =
                     target.translated(-wf::origin(self->get_bounding_box()));
-                if (double(self->cube->backdrop_image_opacity) > 0 && !self->cube->warp_visible())
+                if (self->cube->show_backdrop_image())
                 {
                     for (auto& instance : output_background_instances)
                     {
@@ -454,6 +454,7 @@
 
     wf::option_wrapper_t<std::string> background_mode{"cube/background_mode"};
     wf::option_wrapper_t<double> backdrop_image_opacity;
+    wf::option_wrapper_t<bool> warp_animate_at_rest;
     wf::option_wrapper_t<wf::color_t> backdrop_color{"cube/background"};
 
     bool warp_visible() const
@@ -462,10 +463,23 @@
             std::string(background_mode) == "warp";
     }
 
+    bool show_backdrop_image() const
+    {
+        return std::string(background_mode) != "none" &&
+            double(backdrop_image_opacity) > 0 && !warp_visible();
+    }
+
+    bool warp_should_animate() const
+    {
+        return render_node && !cube_render_paused && !shutting_down &&
+            std::string(background_mode) == "warp" &&
+            (!resting_renderer || (bool(warp_animate_at_rest) && double(backdrop_image_opacity) < 1));
+    }
+
     void sync_warp_animation()
     {
         if (!warp_background) return;
-        warp_background->set_active(warp_visible());
+        warp_background->set_active(warp_should_animate());
         if (!warp_background->animated())
         {
             warp_timer.disconnect();
@@ -473,7 +487,7 @@
         {
             warp_timer.set_timeout(warp_background->frame_interval(), [this]
             {
-                if (!warp_visible() || !warp_background->animated()) return false;
+                if (!warp_should_animate() || !warp_background->animated()) return false;
                 wf::scene::damage_node(render_node, render_node->get_bounding_box());
                 output->render->schedule_redraw();
                 return true;
@@ -513,7 +527,7 @@
         } else if (last_background_mode == "cubemap")
         {
             background = std::make_unique<wf_cube_background_cubemap>();
-        } else if (last_background_mode == "warp")
+        } else if (last_background_mode == "warp" || last_background_mode == "none")
         {
             background.reset();
         } else
@@ -646,8 +660,19 @@
         render_at_rest.load_option("cube/render_at_rest");
         ensure_warp_option<double>("backdrop_image_opacity", 1.0);
         backdrop_image_opacity.load_option("cube/backdrop_image_opacity");
-        backdrop_image_opacity.set_callback([this] { output->render->damage_whole(); });
+        backdrop_image_opacity.set_callback([this]
+        {
+            sync_warp_animation();
+            output->render->damage_whole();
+        });
         backdrop_color.set_callback([this] { output->render->damage_whole(); });
+        ensure_warp_option<bool>("warp_animate_at_rest", true);
+        warp_animate_at_rest.load_option("cube/warp_animate_at_rest");
+        warp_animate_at_rest.set_callback([this]
+        {
+            sync_warp_animation();
+            output->render->damage_whole();
+        });
         ensure_warp_option<double>("warp_speed", 0.8);
         ensure_warp_option<double>("warp_density", 1.0);
         ensure_warp_option<double>("warp_streak_length", 0.6);
@@ -1003,7 +1028,6 @@
 
         refresh_cube_geometry();
         resting_renderer = true;
-        sync_warp_animation();
         return_to_rest = false;
         animation.in_exit = false;
         animation.cube_animation.rotation.set(0, 0);
@@ -1016,6 +1040,7 @@
         update_view_matrix();
         render_node = std::make_shared<cube_render_node_t>(this);
         add_cube_render_node();
+        sync_warp_animation();
         output->render->add_effect(&pre_hook, wf::OUTPUT_EFFECT_PRE);
         output->render->set_require_depth_buffer(true);
         output->render->damage_whole();
@@ -1604,7 +1629,8 @@
 
             // Fill the pixels withheld from the wallpaper pass before drawing
             // the faces. Never fade windows or foreground desktop surfaces.
-            const float opacity = warp_visible() ? 1.0f :
+            const bool no_background = std::string(background_mode) == "none";
+            const float opacity = (no_background || warp_visible()) ? 1.0f :
                 1.0f - std::clamp(double(backdrop_image_opacity), 0.0, 1.0);
             if (opacity > 0 && std::string(background_mode) == "warp")
             {
@@ -1612,7 +1638,9 @@
                     wf::dimensions(output->get_relative_geometry()), opacity);
             } else if (opacity > 0)
             {
-                auto color = wf::color_t(backdrop_color);
+                // None clears the owned pixels even when the image opacity
+                // is 100%, preventing wallpaper or stale tunnel frames.
+                auto color = no_background ? wf::color_t{0, 0, 0, 1} : wf::color_t(backdrop_color);
                 color.a = opacity;
                 color.r *= opacity; color.g *= opacity; color.b *= opacity;
                 GL_CALL(glDisable(GL_DEPTH_TEST));
--- a/metadata/cube.xml
+++ b/metadata/cube.xml
@@ -153,7 +153,7 @@
 		<!-- Background -->
 		<option name="background_mode" type="string">
 			<_short>Background mode</_short>
-			<_long>Sets the background mode.</_long>
+			<_long>Choose a backdrop behind Cube. None removes the desktop image and background effects, leaving black behind the workspace faces. Windows and panels stay visible.</_long>
 			<default>simple</default>
 			<desc>
 				<value>simple</value>
@@ -170,6 +170,10 @@
 			<desc>
 				<value>warp</value>
 				<_name>Warp tunnel</_name>
+			</desc>
+			<desc>
+				<value>none</value>
+				<_name>None</_name>
 			</desc>
 		</option>
 		<option name="background" type="color">
@@ -179,7 +183,7 @@
 		</option>
 		<option name="backdrop_image_opacity" type="double">
 			<_short>Backdrop image opacity</_short>
-			<_long>Opacity of the fixed desktop image behind Cube. Set to zero to remove the image, or use a value between zero and one to fade it into Cube's background. Windows and panels keep their opacity. Warp replaces the image during movement and remains still behind the resting Cube when the image is hidden.</_long>
+			<_long>Opacity of the fixed desktop image behind Cube. Set to zero to remove the image, or use a value between zero and one to fade it into Cube's background. Windows and panels keep their opacity. Warp replaces the image during movement. At rest, a visible tunnel keeps moving when Animate at rest is enabled. None always removes the image and effects.</_long>
 			<default>1.0</default>
 			<min>0</min>
 			<max>1</max>
@@ -187,7 +191,12 @@
 		</option>
 		<group>
 			<_short>Warp tunnel</_short>
-			<_long>Choose Warp tunnel in Background mode to fly through a starfield behind Cube. The viewpoint spans joined monitors. It animates during mouse and keyboard Cube movement. Backdrop image opacity controls whether the resting Cube shows the desktop image, a still tunnel, or a blend of both.</_long>
+			<_long>Choose Warp tunnel in Background mode to fly through a starfield behind Cube. The viewpoint spans joined monitors. Backdrop image opacity controls whether the resting Cube shows the desktop image, the tunnel, or a blend of both.</_long>
+			<option name="warp_animate_at_rest" type="bool">
+				<_short>Animate at rest</_short>
+				<_long>Keep a visible warp tunnel moving after mouse or keyboard rotation ends. Disable to freeze the tunnel while Cube is at rest. A fully opaque backdrop image hides the resting tunnel.</_long>
+				<default>true</default>
+			</option>
 			<option name="warp_speed" type="double">
 				<_short>Travel speed</_short>
 				<_long>Forward travel speed. Set to zero to pause the stars and tunnel.</_long>
@@ -261,7 +270,7 @@
 			</option>
 			<option name="warp_fps" type="int">
 				<_short>Tunnel frame rate</_short>
-				<_long>Animation frame rate while Cube is held still. Workspace transitions retain their normal refresh rate.</_long>
+				<_long>Animation frame rate when Cube is at rest or held still with the mouse. Workspace transitions retain their normal refresh rate.</_long>
 				<default>30</default>
 				<min>10</min>
 				<max>120</max>