Skip to content

Commit ddcd4dc

Browse files
committed
Inhibit output rendering from wayfire directly instead of relying on clients
This also disables inhibiting outputs from client side, as this could lead to a black screen forever if the client does not uninhibit.
1 parent 209ab88 commit ddcd4dc

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

metadata/animate.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<option name="startup_duration" type="animation">
9595
<_short>System fade duration when Wayfire starts</_short>
9696
<_long>Sets the duration of fading (in milliseconds) when Wayfire starts.</_long>
97-
<default>600ms linear</default>
97+
<default>250ms linear</default>
9898
</option>
9999
<!-- Fade animation -->
100100
<option name="fade_enabled_for" type="string">

plugins/animate/animate.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <wayfire/signal-definitions.hpp>
44
#include <wayfire/render-manager.hpp>
55
#include <wayfire/workspace-set.hpp>
6+
#include <wayfire/view-helpers.hpp>
67
#include <wayfire/core.hpp>
8+
#include <wayfire/util.hpp>
79
#include "animate.hpp"
810
#include "plugins/common/wayfire/plugins/common/shared-core-data.hpp"
911
#include "system_fade.hpp"
@@ -202,6 +204,12 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
202204

203205
wf::shared_data::ref_ptr_t<wf::animate::animate_effects_registry_t> effects_registry;
204206

207+
/**
208+
* Single-shot inhibit timer to uninhibit output rendering in case a
209+
* client fails to place a surface on the background layer in time.
210+
*/
211+
std::map<wf::output_t*, wf::wl_timer<false>> inhibit_timers;
212+
205213
template<class animation_t>
206214
void register_effect(std::string name, wf::option_sptr_t<wf::animation_description_t> option)
207215
{
@@ -237,6 +245,11 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
237245
output->connect(&on_view_pre_unmap);
238246
output->connect(&on_render_start);
239247
output->connect(&on_minimize_request);
248+
output->render->add_inhibit(true);
249+
inhibit_timers[output].set_timeout(400, [=] ()
250+
{
251+
output->render->add_inhibit(false);
252+
});
240253
}
241254

242255
void handle_output_removed(wf::output_t *output) override
@@ -408,6 +421,21 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
408421
/* TODO: enhance - add more animations */
409422
wf::signal::connection_t<wf::view_mapped_signal> on_view_mapped = [=] (wf::view_mapped_signal *ev)
410423
{
424+
/* If a client has attached a surface to the background layer,
425+
* uninhibit outputs which were inhibited when wayfire started. */
426+
if (wf::get_view_layer(ev->view) == wf::scene::layer::BACKGROUND)
427+
{
428+
auto output = ev->view->get_output();
429+
if (output)
430+
{
431+
if (inhibit_timers[output].is_connected())
432+
{
433+
inhibit_timers[output].disconnect();
434+
output->render->add_inhibit(false);
435+
}
436+
}
437+
}
438+
411439
auto animation = get_animation_for_view("open", open_animation, ev->view);
412440
set_animation(ev->view, animation.animation_name,
413441
wf::animate::ANIMATION_TYPE_MAP, animation.duration);

plugins/protocols/wayfire-shell.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ struct wayfire_shell_toggle_menu_signal
204204
*/
205205
class wfs_output
206206
{
207-
uint32_t num_inhibits = 0;
208207
wl_resource *shell_resource;
209208
wl_resource *resource;
210209
wf::output_t *output;
@@ -271,13 +270,6 @@ class wfs_output
271270
}
272271

273272
disconnect_from_output();
274-
/* Remove any remaining inhibits, otherwise the compositor will never
275-
* be "unlocked" */
276-
while (num_inhibits > 0)
277-
{
278-
this->output->render->add_inhibit(false);
279-
--num_inhibits;
280-
}
281273
}
282274

283275
wfs_output(const wfs_output &) = delete;
@@ -287,26 +279,21 @@ class wfs_output
287279

288280
void inhibit_output()
289281
{
290-
++this->num_inhibits;
291282
if (this->output)
292283
{
293-
this->output->render->add_inhibit(true);
284+
LOGW(
285+
"Ignoring inhibit call, left in for historical reasons.\
286+
Wayfire now manages all inhibits internally");
294287
}
295288
}
296289

297290
void inhibit_output_done()
298291
{
299-
if (this->num_inhibits == 0)
300-
{
301-
wl_resource_post_no_memory(resource);
302-
303-
return;
304-
}
305-
306-
--this->num_inhibits;
307292
if (this->output)
308293
{
309-
this->output->render->add_inhibit(false);
294+
LOGW(
295+
"Ignoring inhibit done call, left in for historical reasons.\
296+
Wayfire now manages all inhibits internally");
310297
}
311298
}
312299

0 commit comments

Comments
 (0)