contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.44k stars 107 forks source link

KDE Wayland does not have blur support #1265

Open takase1121 opened 1 year ago

takase1121 commented 1 year ago

Contour Terminal version

0.4.0-master-a75936b0

Installer source

something else (please specify below)

Operating System

Arch Linux 6.5.7-zen1-1-zen

Architecture

x86-64

Other Software

KDE Wayland: 5.27.8 KDE QT: 5.15.11

Steps to reproduce

  1. Enable transparency and blur in config.
  2. Run contour
  3. Blur is not applied
  4. Set backend to XCB
  5. Blur is applied

Expected Behavior

Blur is applied on Wayland. This might need the KDE specific protocol.

https://invent.kde.org/libraries/plasma-wayland-protocols/-/blob/master/src/protocols/blur.xml https://wayland.app/protocols/kde-blur

Actual Behavior

No blur is applied.

Additional notes

Relevant Wezterm issue: https://github.com/wez/wezterm/issues/1614

christianparpart commented 1 year ago

Many thanks for the link also. This should help knowing in which direction to head for.

Sadly I have not done any Wayland specific programming yet, and I have to see how we can implement this without adding a huge dependency to Contour.

To see how we're handling Blur on KDE's KWin (X11), GNOME, and on Windows, see here:

https://github.com/contour-terminal/contour/blob/ee0ad51a38160889e346effd572ac6175c747fdb/src/contour/BlurBehind.cpp#L134-L142

Not sure yet what complexity would be added for adding KWin/Wayland to the list.

Many thanks, Christian.

p.s.: going to label it as good-first-issue because that's not requiring any deep knowledge except knowing how to talk to KWin through Wayland. :)

takase1121 commented 1 year ago

I'm not familiar with C++, CMake and Wayland, but this is my impression of how to implement this feature:

  1. Generate C protocol header and code from this XML file: https://invent.kde.org/libraries/plasma-wayland-protocols/-/blob/master/src/protocols/blur.xml and somehow include it in the project
  2. Use QPlatformNativeInterface to get a wl_surface.
  3. Create a org_kde_kwin_blur_manager, create a wl_region with the Window dimensions, and call org_kde_kwin_blur::set_region()
  4. Deal with lifetimes of the various Wayland projects.

I don't know the specifics. I could try to create a prototype in C, but I still don't know the exact way it works.

Alternatively, I think it might be good to clarify that only the XCB backend supports blurring in the README and website.

christianparpart commented 1 year ago

We certainly should clarify that this only applies to X11, unless it seems trivial to implement before the next release (which should be coming soon'ish) :).

Thanks for the insights!

takase1121 commented 1 year ago

Some follow up: I managed to get it "working" (read barely working) in here: https://github.com/takase1121/qt-kde-blur-example. It uses KWayland to interact with the protocols directly; as KWayland is obviously a KDE thing and this might not be desirable.

I cobbled together a tiny example (and you need to set window opacity via KDE window rule), it will probably crash as well on non-KDE platforms), but it sure gets the blur right!

Sidenote: the blur part didn't exactly work well either. I think you need to set the region every time something updates, so there are occasional flickering.

image

I hope someone more knowledgeable in this area steps in and finds a better way.

Yaraslaut commented 1 year ago

@Utkarsh-khambra you are using Wayland, but on GNOME, right? can you check if blur is working for you there, so then we can see what we can do. and thanks to @takase1121 we have an idea how to make it happen on kde

takase1121 commented 1 year ago

That's no way that would work in anywhere but KDE. That's a KDE specific protocol that I think no one else supports.

My main concern is with KDE because the README points out KDE is supported. Generally one would assume this means both X11 and Wayland sessions are supported.

Yaraslaut commented 1 year ago

That's no way that would work in anywhere but KDE. That's a KDE specific protocol that I think no one else supports.

* GNOME: [blur my shell extension](https://extensions.gnome.org/extension/3193/blur-my-shell/)

* wlroots compositors vary; some compositors supports blur via window rules; some don't. This is about as good as it gets before [ext_blur](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/43) gets merged.

My main concern is with KDE because the README points out KDE is supported. Generally one would assume this means both X11 and Wayland sessions are supported.

I understand that, its just that we need to figure out what to do with wayland on gnome as well. Overall i think that it we need to support every desktop environment specific protocoll for blur background this will turn into mess

christianparpart commented 1 year ago

@Yaraslaut true, but KDE on Wayland is something I see willing to support, due to personal use of KDE :)

All the other platforms, well, what we could do (to some degree already have), is abstracting away a common API that our code is using, and hide the complexity there. Should we implement it for every compositor out there? Certainly not, but only those that we have personal interest in (for me for exmaple that's KDE/X11, and maybe Wayland, as my SteamDeck uses KDE/Wayland :)), but GNOME and all the others, I think we kind of rely on external contributions whenever people feel the need for it.

Overall I think that's a good call for a central API to communicate that. Just like what was happening to dark/light mode detection and change event exposure through DBus over org.freedesktop namespace. A similar thing should happen for GUI features like Blur.

Utkarsh-khambra commented 1 year ago

I understand that, its just that we need to figure out what to do with wayland on gnome as well.

On Gnome last time I tested, blur my shell worked fine. Gnome has an issue for blurred background ,but I don't see any progress on it so far.

uspasojevic96 commented 1 year ago

That's no way that would work in anywhere but KDE. That's a KDE specific protocol that I think no one else supports.

* GNOME: [blur my shell extension](https://extensions.gnome.org/extension/3193/blur-my-shell/)

* wlroots compositors vary; some compositors supports blur via window rules; some don't. This is about as good as it gets before [ext_blur](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/43) gets merged.

My main concern is with KDE because the README points out KDE is supported. Generally one would assume this means both X11 and Wayland sessions are supported.

My question is, did you try only pure Wayland or did you try XWayland?

takase1121 commented 1 year ago

That's no way that would work in anywhere but KDE. That's a KDE specific protocol that I think no one else supports.

* GNOME: [blur my shell extension](https://extensions.gnome.org/extension/3193/blur-my-shell/)

* wlroots compositors vary; some compositors supports blur via window rules; some don't. This is about as good as it gets before [ext_blur](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/43) gets merged.

My main concern is with KDE because the README points out KDE is supported. Generally one would assume this means both X11 and Wayland sessions are supported.

My question is, did you try only pure Wayland or did you try XWayland?

Not sure which part of this is unclear, but pure Wayland. XWayland works just fine. It should've worked in both, which is why I'm here.