Help with a screen hiding extension

I’m trying to make an extension to hide the screen (turning it black) on command, and I do this using a clutter effect, the code can be found here. In the past weeks, I’ve asked here and on matrix for help and made good progress, but a few issues remain. I’m starting this thread to avoid getting stuck on the XY problem.

Two major issues:

  • When I plug two monitors I get heavy glitching, doesn’t happen with just one monitor.
  • With two monitor in join mode, one of the screens doesn’t turn fully black when the effect is activated.

Secondly, I have no idea of how to make a preference GUI as this is my first extension, and the example on the guide doesn’t work. I posted a thread about that before, but nobody answered and it got auto closed. This is a secondary optional goal.

I’m planning to publish the extension eventually, so I need to first fix these issues first. More detail below:

Glitching problem

I turn the screen black using a Clutter.BrightnessContrastEffect effect with the brightness turned to -1. To minimise latency, I want to have the effect always enabled, and toggle the value between -1 and 0 to hide/show the screen.
With multiple monitors plugged and the effect active at 0 brightness, moving a window causes several (compositor?) glitches, making it almost unusable. This happens for any non--1 value – at -1 it’s not evident because the screen is black.

Adding and removing the effect instead of just changing the uniform works as a workaround, but only because I need to make the screen black. If I wanted to do anything else this wouldn’t cut it.

“Incomplete” blacking problem

Regardless of the first issue, when the screen is blackened, the “unfocused” one doesn’t refresh completely, only the dash and the top-bar turn black. Doing anything on that monitor (moving the mouse, opening the overview) fixes it.
It only redraws the shell but not the entire screen, even though I changed an effect on the global stage. Can I queue a compositor-wide repaint?

1 Like

Adding offscreen effects, such as the BrightnessContrastEffect to MetaWindowGroup or one of its parents (such as the stage in your case) is known to break damage tracking when non-primary monitors are involved. This would need a fix in mutter.

It is probably related to offscreen effects slightly extending the paint area of the actor they are applied to conflicting with the culling code.

So there’s nothing I can do about those issues, short of modifying Mutter?
Can I workaround it some other way? Like using something other than BrightnessContrastEffect, that is not an offscreen effect?

Just for clarification, this should be a completely different issue from the one I experienced here, right? Because that doesn’t involve non primary display.

I guess you could add an opaque screen sized actor on top of everything if you want to hide stuff rather than using offscreen effects.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.