Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows get shown on top when compton is active #204

Open
bebehei opened this issue Nov 10, 2018 · 31 comments
Open

windows get shown on top when compton is active #204

bebehei opened this issue Nov 10, 2018 · 31 comments
Labels

Comments

@bebehei
Copy link

bebehei commented Nov 10, 2018

Current Behavior

Windows appearing after i3lock's start and in combination with compton will get shown on top. When compton is not active, the behavior is not seen.

Here's a screenshot of a clean Ubuntu VM with the reproduction instructions executed:

screenshot-bionic

Expected Behavior

Windows shall get drawn below i3lock.

Reproduction Instructions

# On a clean Ubuntu 18.04 installation
$> sudo apt install i3-wm i3lock i3status dunst compton

# And after i3 login:
$> compton -c &
$> dunst &
$> (sleep 7 && notify-send a b) &
$> i3lock

Environment

Output of i3lock --version:

$> i3lock --version
i3lock: version 2.10 (2017-11-25) © 2010 Michael Stapelberg

Related

#130

Originally reported on dunst-project/dunst#553

@Airblader
Copy link
Member

Airblader commented Nov 10, 2018

@stapelberg Why did we want to open a new issue here? We fixed it, it broke stuff, we reverted it. I'm not sure what else there is to do?

@stapelberg
Copy link
Member

Can’t we find a new fix which doesn’t break? Or at least document the defect.

@bebehei
Copy link
Author

bebehei commented Nov 10, 2018

Oh, shit, I forgot the most important part: I cannot reproduce it on ArchLinux.

I've also cloned now i3lock's repo and tested the following tags/branches: 2.9.1, 2.10, 2.11.1, master. All show the same bad behavior in the Ubuntu VM.

I believe it's a problem in the coupling of some library, which is used by Ubuntu 18.04.

@bebehei bebehei closed this as completed Nov 10, 2018
@bebehei bebehei reopened this Nov 10, 2018
@bebehei
Copy link
Author

bebehei commented Nov 10, 2018

Sorry, my browser lagged. About "the library": I can definitely exclude compton: ArchLinux uses a fork of compton. I've compiled the fork on Ubuntu 18.04, but it doesn't help either.

@Airblader
Copy link
Member

@stapelberg The author of xsecurelock commented on #96 and said that they also have the problem with different compositors and different configs thereof. His idea (for xsecurelock) was to maybe make it a flag whether to use the overlay window or not. That's about the only thing I can think of.

@4goettma
Copy link

4goettma commented Nov 19, 2018

I can partially confirm the descriped behaviour on Arch Linux. (I'm using compton with compton -b --dbe, not sure whether it works too with compton -c. I had also cases where I can't confirm the behaviour, I will do soon further tests.)

$> i3lock --version
i3lock: version 2.11.1 © 2010 Michael Stapelberg
$> compton --version
v4-rc1-14-gf834cf2
$> uname -a
Linux <hostname> 4.18.16-arch1-1-ARCH #1 SMP PREEMPT Sat Oct 20 22:06:45 UTC 2018 x86_64 GNU/Linux

@bebehei
Copy link
Author

bebehei commented Nov 19, 2018

I can finally reproduce it on my own setup now, too. 🙈

Same compton and i3lock version, but Linux kernel 4.19.2-arch1-1-ARCH.

sandsmark added a commit to sandsmark/i3lock that referenced this issue Dec 31, 2018
Use the XComposite extension to get the composite overlay window,
instead of just using the normal root window. This ensures that
composited windows are covered.

This time, we hide it behind a config option because it might break
things more than it fixes.
@Airblader
Copy link
Member

@stapelberg How do you feel about hiding it behind a flag? We have a PR for that now.

@stapelberg
Copy link
Member

I’m not a fan of flags for bugfixes.

Ideally, the fix would work in all environments.
The next best thing is if the code can auto-detect where the fix works.

Have we really exhausted all approaches yet?

@Airblader
Copy link
Member

I didn't try to research this more, but with my current knowledge I can't think of anything else to try. @divVerent has the most knowledge about this with xsecurelock as far as I can see, and so his comment on #96 is the best information available to me.

Apart from a flag he suggested detecting the compositor, but that won't work in my opinion: 1) Only enabling it if no compositor is present kills the entire usecase since we usually only see this issue when a compositor is running and 2) if used a whitelist and didn't whitelist compton we might as well not bother at all, because compton is by far the most common compositor used with i3lock.

Looking at xsecurelock right now, some things seem to have happened:

  1. It uses composite by default now but has an option to disable it.
  2. There's an obscurer window feature, which sounds like what i3lock is doing too (didn't look in detail though). Noteworthy here is that the obscurer window is 1px smaller to prevent the compositor from unredirecting (I have no idea what that means)

sandsmark added a commit to sandsmark/i3lock that referenced this issue Dec 31, 2018
Use the XComposite extension to get the composite overlay window,
instead of just using the normal root window. This ensures that
composited windows are covered.

This time, we hide it behind a config option because it might break
things more than it fixes.
@stapelberg
Copy link
Member

Finally got a chance to look at this in a little more detail. IIUC, compositors are supposed to be transparent (conceptually, not visually) as far as X11 programs are concerned.

The relevant difference when running with a compositor vs. running without a compositor is that i3lock’s raise_loop is no longer notified of the i3lock lock window being obscured by another window: https://github.com/i3/i3lock/blob/f6e0218fa7a4a6045792e61bcae10e16d34dcd2b/i3lock.c#L952-957

It’s not 100% clear to me why these notifications are no longer sent by the X11 server when compositing is used, but I do see that compton has its own concept of a window stack: https://github.com/yshui/compton/blob/93f0d80572e47a1297dbf1af18a4ef498fa0bfe2/src/win.c#L1742-L1779

@yshui What do you think about synthesizing VisibilityNotify X11 events when compton’s window stacking changes? Do you know how other screen lockers work with compton, if they do?

@yshui
Copy link

yshui commented Oct 9, 2019

I am not familiar with synthesizing X11 events, if you could point me to information about how I can do that, it would be appreciated. (Looks like I just need to use xcb_send_event?)

This behavior of X server surprises me. Do we know exactly why the X server is doing that? Is this actually a X server bug?

Relevant code seems to be: https://gitlab.freedesktop.org/xorg/xserver/blob/master/mi/mivaltree.c#L196-200 and https://gitlab.freedesktop.org/xorg/xserver/blob/master/mi/mivaltree.c#L482

@stapelberg
Copy link
Member

I am not familiar with synthesizing X11 events, if you could point me to information about how I can do that, it would be appreciated.

Have a look at https://github.com/i3/i3/blob/0b4d4e799b4c4608cf4309624191e73711e48d6b/src/xcb.c#L90-L111 for how we do it in i3.

I haven’t looked at the X server implementation yet.

@yshui
Copy link

yshui commented Oct 9, 2019

Does this problem only occur when using compton? How does other compositors deal with this problem?

@divVerent
Copy link

divVerent commented Oct 9, 2019

There's an obscurer window feature, which sounds like what i3lock is doing too (didn't look in detail though). Noteworthy here is that the obscurer window is 1px smaller to prevent the compositor from unredirecting (I have no idea what that means)

FYI the point of the reduced size is that some compositors - especially kwin - hide the composite overlay window when there is a window that occupies the entire screen, thereby making the screen lock transparent too.

So if the obscurer window had full size, we'd end up in situations where the entire screen is white (in case of xsecurelock, as that's the obscurer window's color); with the reduced size, the composite overlay window stays active and its child windows (which xsecurelock created) get drawn.

However, i3lock is much simpler than xsecurelock, so for i3lock I'd actually suggest another approach: why not have a full-sized obscurer and draw the login BOTH on the obscurer AND on a full-size child of the composite overlay window? That actually should be more compatible than what xsecurelock does, and will work because there's not much of a cost to drawing everything twice.

Of course, no matter what, i3lock should also detect events that indicate that another window is obscuring it (by bringing itself to front while locked). For that reason xsecurelock listens to VisibilityNotify.

@yshui
Copy link

yshui commented Oct 9, 2019

Of course, no matter what, i3lock should also detect events that indicate that another window is obscuring it (by bringing itself to front while locked). For that reason xsecurelock listens to VisibilityNotify.

i3lock does exactly that. the problem here is the VisibilityNotify is not sent when a compositor is active.

@yshui
Copy link

yshui commented Oct 9, 2019

draw the login BOTH on the obscurer AND on a full-size child of the composite overlay window?

this is both brilliant and absolutely terrifying.

@stapelberg
Copy link
Member

FYI the point of the reduced size is that some compositors - especially kwin - hide the composite overlay window when there is a window that occupies the entire screen, thereby making the screen lock transparent too.

I don’t fully understand this yet: doesn’t hiding the composite overlay window mean that the screen locker window is visible? Where does transparency come into the picture?

(Also, is kwin’s rationale that full-screen applications are often 3D games or otherwise hardware-accelerated programs?)

However, i3lock is much simpler than xsecurelock, so for i3lock I'd actually suggest another approach: why not have a full-sized obscurer and draw the login BOTH on the obscurer AND on a full-size child of the composite overlay window?

Are compositors actually okay with X11 clients creating child windows of the composite overlay window?

I’m asking because making i3lock’s lock window (we only have a single window right now, no separate obscurer window) a child of the composite overlay is what we have tried previously, but that flickers — sometimes the composite overlay window will be visible, sometimes i3lock (whichever draws most recently, I suppose?).

@stapelberg
Copy link
Member

Does this problem only occur when using compton? How does other compositors deal with this problem?

I can reproduce the issue with unagi, too. Are there any others that would be good to test?

If you want to run the test yourself, here’s how I trigger the problem (using SSH and one terminal per command for convenience):

DISPLAY=:0 dunst &
DISPLAY=:0 compton --experimental-backends --log-level DEBUG
DISPLAY=:0 i3lock --debug -n
DISPLAY=:0 notify-send test

@stapelberg
Copy link
Member

Relevant code seems to be: https://gitlab.freedesktop.org/xorg/xserver/blob/master/mi/mivaltree.c#L196-200 and https://gitlab.freedesktop.org/xorg/xserver/blob/master/mi/mivaltree.c#L482

Here are Xorg’s SendVisibilityNotify calls when dunst obscures i3lock (without a compositor running): https://gist.github.com/stapelberg/38c8320608d3bd0cc5dcb3206f3a6484

When a compositor is running, the breakpoint is only hit once: https://gist.github.com/stapelberg/06bf82b1e9cec104772a0b80411631ac

The first breakpoint hit in each of these gists is the event being sent to the window itself (as per the pWin pointer values).

Here are the results of running p *pWin whenever https://gitlab.freedesktop.org/xorg/xserver/blob/3340ddf37743fdf197dfc16a97107435ff53c6e4/mi/mivaltree.c#L678 is hit:

https://gist.github.com/stapelberg/6d3ffa21c636c00151132b54d8bed4b6 (without compositor)
https://gist.github.com/stapelberg/2d07cfd9862f0b4fff91ba2deb291325 (with compositor)

I’m out of time for now, but perhaps something sticks out to you?

@yshui
Copy link

yshui commented Oct 15, 2019

I can reproduce the issue with unagi, too.

I think this is strong enough evidence this is not a compton issue.

I’m out of time for now, but perhaps something sticks out to you?

If I read the code correctly, when a compositor is running, window are always considered fully visible. Your debugger output seems to confirm this. Without compositor, you can see some visibility = 1 (VisibilityPartiallyObscured), with compositor, visibility is either 3 (VisibilityNotViewable) or 0 (VisibilityUnobscured)

@yshui
Copy link

yshui commented Oct 15, 2019

Whether this is an intentional behavior of X server, I don't know. I certainly cannot find any documentation about it.

@stapelberg
Copy link
Member

Thanks for looking into it. I have filed https://gitlab.freedesktop.org/xorg/xserver/issues/922, so hopefully we’ll hear from xorg folks about whether this behavior is intended or a bug.

@vincentbernat
Copy link
Contributor

vincentbernat commented Jan 17, 2020

As a simple workaround, I simply kill compton before i3lock and restart it after. It also fixes the issue that if the RandR settings change, i3lock doesn't end behind all the windows. i3lock is invoked by xss-lock in my case, with the -n option.

@divVerent
Copy link

divVerent commented Jan 17, 2020 via email

@yshui
Copy link

yshui commented Jan 18, 2020

@stapelberg I just added support for _NET_WM_BYPASS_COMPOSITOR. now i3lock can set that property to prevent picom (compton) from redirecting the window (if the user has --unredir-if-possible set), even if i3lock is obscured by another window.

this should solve this problem.

@divVerent
Copy link

divVerent commented Jan 18, 2020 via email

@divVerent
Copy link

divVerent commented Jan 18, 2020 via email

@yshui
Copy link

yshui commented Jan 19, 2020

@divVerent You are right. But compton (picom) does not implement the "MUST NOT bypass if it would cause differences from the composited appearance" bit.

Maybe you couldn't use this property to solve this problem in general, but it would work if the compositor is picom.

stapelberg added a commit to stapelberg/i3lock that referenced this issue Jan 20, 2020
For compositors which support it (picom >v7.5, formerly known as compton), this
should result in the i3lock window no longer being composited, hence fixing
issue i3#204.

related to i3#204
@stapelberg
Copy link
Member

Sent pull request #256 to add the hint, I think it can’t hurt :)

stapelberg added a commit to stapelberg/i3lock that referenced this issue Jan 20, 2020
For compositors which support it (picom >v7.5, formerly known as compton), this
should result in the i3lock window no longer being composited, hence fixing
issue i3#204.

related to i3#204
stapelberg added a commit that referenced this issue Jan 20, 2020
For compositors which support it (picom >v7.5, formerly known as compton), this
should result in the i3lock window no longer being composited, hence fixing
issue #204.

related to #204
@stapelberg stapelberg added the bug label Feb 19, 2020
bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this issue Jun 15, 2020
https://build.opensuse.org/request/show/814595
by user mia + dimstar_suse
- Since it requires dbus, use dbus by default.
- Updated to version 8
  * You can now use the time variable in window shaders to get a
    timestamp. An example usage is to create animated effects,
    e.g. https://streamable.com/e0x7r
  * --max-brightness, which allows you to dim windows that are
    too bright. When enabled, all windows' average brightness will
    be clamped to the set value.
  * Automatic configuration file reloading after it's changed.
  * A lot of the artifacts seen with blur and use-damage enabled
    are fixed.
  * _NET_WM_BYPASS_COMPOSITOR property are now handled.
    (Related to i3/i3lock#204)
  * Completely transparent windows won't have a blurred background
    anymore.
  * Improved fullscreen window detection. Now EWMH is used to
    detect fullscreen windows
@ouuan
Copy link

ouuan commented Jun 21, 2021

I think this is just #22 and no one has mentioned it yet?

Hedroed pushed a commit to Hedroed/i3lock that referenced this issue Nov 23, 2021
For compositors which support it (picom >v7.5, formerly known as compton), this
should result in the i3lock window no longer being composited, hence fixing
issue i3#204.

related to i3#204
wlhlm pushed a commit to wlhlm/i3lock that referenced this issue Jun 5, 2022
For compositors which support it (picom >v7.5, formerly known as compton), this
should result in the i3lock window no longer being composited, hence fixing
issue i3#204.

related to i3#204
sh1r4s3 pushed a commit to sh1r4s3/i3lock-gif that referenced this issue Jun 26, 2022
* Tab completion

* Added --special-passthrough flag

* Integration with autotools

* Fixed build test

* Update completions

* Indent

Co-authored-by: Raymond Li <hi@raymond.li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants