wayland: Support blur via ext-background-effect-v1 protocol (#7615)

* Add ext-background-effect-v1 support for wayland
* Deprecate `kde_window_background_blur`; use `wayland_window_background_blur`
* Update changelog (replace old kde… option entry with wayland…)

---------

Co-authored-by: Benoit de Chezelles <benoit.dechezelles@gmail.com>
This commit is contained in:
1Capito1andBenoit de Chezelles authored and GitHub committed 2026-07-13 18:57:32 +02:00
1 parent fff02ca501
commit 6f3d3d84f2
9 files changed
+165 -19

No files matched your search

+8 -1
View File
@@ -571,9 +571,16 @@ pub struct Config {
pub macos_window_background_blur: i64,
/// Only works on KDE Wayland
#[dynamic(default)]
#[dynamic(
default,
deprecated = "this option has been replaced with `wayland_window_background_blur` and will be removed in a future release"
)]
pub kde_window_background_blur: bool,
/// Only works on Wayland compositors that support ext-background-effect-v1 protocol
#[dynamic(default)]
pub wayland_window_background_blur: bool,
/// Only works on Windows
#[dynamic(default)]
pub win32_system_backdrop: SystemBackdrop,
+3 -3
View File
@@ -128,9 +128,9 @@ As features stabilize some brief notes about them will accumulate here.
@BenBergman! #6328 #6873 #6875
* [cell_widths](config/lua/config/cell_widths.md) option for explicit
control over cell widths. Thanks to @hamano! #6289 #6290
* [kde_window_background_blur](config/lua/config/kde_window_background_blur.md) option
to enable window blur when running under KDE Plasma on Wayland systems.
Thanks to @psomani16k! #6905
* [wayland_window_background_blur](config/lua/config/wayland_window_background_blur.md) option
to enable window blur on Wayland compositors supporting the `ext-background-effect-v1` protocol.
Thanks to @psomani16k, @1Capito1 & @bew! #6905 #7615
* [reverse_video_cursor_min_contrast](config/lua/config/reverse_video_cursor_min_contrast.md)
option. Thanks to @jameshurst! #6584 ?2861
* [text_min_contrast_ratio](config/lua/config/text_min_contrast_ratio.md) to more generally
@@ -6,6 +6,8 @@ tags:
{{since('nightly')}}
*Deprecated; this option was added & deprecated in the same version. Use [wayland_window_background_blur](wayland_window_background_blur.md) instead*
When combined with `window_background_opacity`, enables background blur
using the KDE Wayland blur protocol.
@@ -26,5 +26,5 @@ The default value for `macos_window_background_blur` is `0`.
See also [win32_system_backdrop](win32_system_backdrop.md) for a similar
effect on Windows.
See also [kde_window_background_blur](kde_window_background_blur.md) for a similar
effect on KDE Wayland.
See also [wayland_window_background_blur](wayland_window_background_blur.md) for a similar
effect on Linux Wayland.
@@ -0,0 +1,29 @@
---
tags:
- appearance
---
# wayland_window_background_blur = false
When combined with `window_background_opacity`, enables background blur
using the Wayland background effect protocol.
This can be used to produce a translucent window effect rather than
a crystal clear transparent window effect.
This effect can be achieved by adding the following to the configuration:
```lua
config.window_background_opacity = 0.4
config.wayland_window_background_blur = true
```
!!! note
Wayland compositors may need to have blur enabled explicitely.
e.g. on KDE Plasma, enable the _Blur_ plugin in _Window Effect_ settings.
[Screenshot](../../../screenshots/wezterm-ext-background-effects-v1.png)
See also [win32_system_backdrop](./win32_system_backdrop.md) for a similar
effect on Windows
See also [macos_window_background_blur](./macos_window_background_blur.md) for
a similar effect on macOS
@@ -32,8 +32,8 @@ for the backdrop effect to work. For best results with both `"Mica"` and
See also [macos_window_background_blur](macos_window_background_blur.md) for
a similar effect on macOS.
See also [kde_window_background_blur](kde_window_background_blur.md) for a similar
effect on KDE Wayland.
See also [wayland_window_background_blur](wayland_window_background_blur.md) for a similar
effect on Linux Wayland.
## Acrylic
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

+10 -2
View File
@@ -30,6 +30,7 @@ use wayland_client::globals::GlobalList;
use wayland_client::protocol::wl_keyboard::WlKeyboard;
use wayland_client::protocol::wl_output::WlOutput;
use wayland_client::{delegate_dispatch, Connection, QueueHandle};
use wayland_protocols::ext::background_effect::v1::client::ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1;
use wayland_protocols::wp::text_input::zv3::client::zwp_text_input_manager_v3::ZwpTextInputManagerV3;
use wayland_protocols::wp::text_input::zv3::client::zwp_text_input_v3::ZwpTextInputV3;
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
@@ -89,6 +90,8 @@ pub(super) struct WaylandState {
pub(super) shm: Shm,
pub(super) mem_pool: RefCell<SlotPool>,
pub(super) kde_blur_manager: Option<OrgKdeKwinBlurManager>,
pub(super) ext_background_effect_manager: Option<ExtBackgroundEffectManagerV1>,
pub(super) ext_background_effect_can_blur: bool,
}
impl WaylandState {
@@ -100,7 +103,10 @@ impl WaylandState {
let subcompositor =
SubcompositorState::bind(compositor.wl_compositor().clone(), globals, qh)?;
let blur_manager: Option<OrgKdeKwinBlurManager> = globals.bind(qh, 1..=1, GlobalData).ok();
let kde_blur_manager: Option<OrgKdeKwinBlurManager> =
globals.bind(qh, 1..=1, GlobalData).ok();
let ext_background_effect_manager: Option<ExtBackgroundEffectManagerV1> =
globals.bind(qh, 1..=1, GlobalData).ok();
let wayland_state = WaylandState {
registry: RegistryState::new(globals),
output: OutputState::new(globals, qh),
@@ -133,7 +139,9 @@ impl WaylandState {
primary_selection_source: None,
shm,
mem_pool: RefCell::new(mem_pool),
kde_blur_manager: blur_manager,
kde_blur_manager,
ext_background_effect_manager,
ext_background_effect_can_blur: false,
};
Ok(wayland_state)
}
+109 -9
View File
@@ -42,6 +42,8 @@ use wayland_client::protocol::wl_region::WlRegion;
use wayland_client::protocol::wl_surface::WlSurface;
use wayland_client::{Connection as WConnection, Dispatch, Proxy, QueueHandle};
use wayland_egl::{is_available as egl_is_available, WlEglSurface};
use wayland_protocols::ext::background_effect::v1::client::ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1;
use wayland_protocols::ext::background_effect::v1::client::ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1;
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
use wezterm_font::FontConfiguration;
@@ -327,6 +329,7 @@ impl WaylandWindow {
wegl_surface: None,
gl_state: None,
ext_background_effect_surface: None,
}));
let window_handle = Window::Wayland(WaylandWindow(window_id));
@@ -336,7 +339,7 @@ impl WaylandWindow {
.events
.assign_window(window_handle.clone());
inner.borrow().update_window_background_blur();
inner.borrow_mut().update_window_background_blur();
{
let windows = &conn.wayland_state.borrow().windows;
@@ -605,6 +608,7 @@ pub struct WaylandWindowInner {
// libraries will segfault on shutdown
wegl_surface: Option<WlEglSurface>,
gl_state: Option<Rc<glium::backend::Context>>,
ext_background_effect_surface: Option<ExtBackgroundEffectSurfaceV1>,
}
impl WaylandWindowInner {
@@ -1288,18 +1292,79 @@ impl WaylandWindowInner {
self.update_window_background_blur();
}
fn update_window_background_blur(&self) {
fn update_window_background_blur(&mut self) {
let conn = WaylandConnection::get().unwrap().wayland();
let qh = conn.event_queue.borrow().handle();
let wayland_state = conn.wayland_state.borrow();
if let Some(manager) = &wayland_state.kde_blur_manager {
let kde_blur = manager.create(self.surface(), &qh, GlobalData);
if self.config.kde_window_background_blur {
kde_blur.set_region(None);
} else {
kde_blur.release();
let win_wl_surface = self.surface().clone();
let bg_blur_wanted =
self.config.wayland_window_background_blur || self.config.kde_window_background_blur;
if wayland_state.ext_background_effect_manager.is_some() {
let manager = &wayland_state.ext_background_effect_manager.clone().unwrap();
// Check if bg blur is disabled -> cleanup past state & return
if !bg_blur_wanted {
if let Some(ext_effect_surface) = self.ext_background_effect_surface.take() {
log::trace!(
"ext window bg: dropping surface {:?}, associated with win {:?}",
ext_effect_surface.id(),
win_wl_surface.id(),
);
ext_effect_surface.destroy();
}
return;
}
kde_blur.commit();
if !wayland_state.ext_background_effect_can_blur {
// Nothing else to do here
return;
}
// Get or create the associated surface used for background effects
let blur_surface = self.ext_background_effect_surface.get_or_insert_with(|| {
log::trace!(
"ext window bg: creating blur surface, for win {:?}",
win_wl_surface.id(),
);
let surface = manager.get_background_effect(&win_wl_surface, &qh, GlobalData);
log::trace!(
"ext window bg: created blur surface {:?}, for win {:?}",
surface.id(),
win_wl_surface.id(),
);
surface
});
let region: WlRegion = wayland_state
.compositor
.wl_compositor()
.create_region(&qh, GlobalData);
region.add(
0,
0,
self.dimensions.pixel_width as i32,
self.dimensions.pixel_height as i32,
);
blur_surface.set_blur_region(Some(&region));
region.destroy();
} else if let Some(manager) = &wayland_state.kde_blur_manager {
let blur_surface = manager.create(&win_wl_surface, &qh, GlobalData);
if bg_blur_wanted {
log::trace!(
"kde window bg: setting up blur surface for win {:?}",
win_wl_surface.id()
);
blur_surface.set_region(None);
} else {
log::trace!(
"kde window bg: clearing blur surface for win {:?}",
win_wl_surface.id()
);
blur_surface.release();
}
blur_surface.commit();
} else if bg_blur_wanted {
log::warn!("window bg: blur wanted but no provider available");
}
}
}
@@ -1494,6 +1559,41 @@ impl Dispatch<WlRegion, GlobalData> for WaylandState {
}
}
impl Dispatch<ExtBackgroundEffectManagerV1, GlobalData> for WaylandState {
fn event(
state: &mut Self,
_proxy: &ExtBackgroundEffectManagerV1,
event: <ExtBackgroundEffectManagerV1 as Proxy>::Event,
_data: &GlobalData,
_conn: &WConnection,
_qhandle: &QueueHandle<Self>,
) {
use wayland_protocols::ext::background_effect::v1::client::ext_background_effect_manager_v1::Event;
const BLUR_CAPABILITY_FLAG: u32 = 1;
if let Event::Capabilities { flags } = event {
let flags: u32 = flags.into();
log::trace!("ext window bg: got capabilities: {flags:#x?}");
state.ext_background_effect_can_blur = flags & BLUR_CAPABILITY_FLAG != 0;
log::trace!(
"ext window bg: can blur: {}",
state.ext_background_effect_can_blur
);
}
}
}
impl Dispatch<ExtBackgroundEffectSurfaceV1, GlobalData> for WaylandState {
fn event(
_state: &mut Self,
_proxy: &ExtBackgroundEffectSurfaceV1,
_event: <ExtBackgroundEffectSurfaceV1 as Proxy>::Event,
_data: &GlobalData,
_conn: &WConnection,
_qhandle: &QueueHandle<Self>,
) {
}
}
/// User-data attached to each [`WlSurface`] via [`smithay_client_toolkit`].
///
/// Associates a surface with its owning window ID, allowing lookups