Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ thiserror = "2.0.12"
wayland-backend = "0.3.0"
wayland-client = "0.31.1"
wayland-cursor = "0.31.0"
wayland-protocols = { version = "0.32.1", features = ["client", "staging", "unstable"] }
wayland-protocols = { version = "0.32.9", features = ["client", "staging", "unstable"] }
wayland-protocols-experimental = { version = "20251230.0.1", features = ["client"] }
wayland-protocols-misc = { version = "0.3.6", features = ["client"] }
wayland-protocols-wlr = { version = "0.3.1", features = ["client"] }
Expand Down
106 changes: 106 additions & 0 deletions src/background_effect.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
use wayland_client::{
globals::GlobalList, protocol::wl_surface, Connection, Dispatch, QueueHandle, WEnum,
};
use wayland_protocols::ext::background_effect::v1::client::{
ext_background_effect_manager_v1, ext_background_effect_surface_v1,
};

use crate::{error::GlobalError, globals::GlobalData, registry::GlobalProxy};

pub struct BackgroundEffectState {

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (stable)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (stable)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (stable)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check failure on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / lint

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / ci (1.71.0)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (beta)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (beta)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (beta)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation

Check warning on line 10 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
manager: GlobalProxy<ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1>,
capabilities: Option<ext_background_effect_manager_v1::Capability>,
}

impl BackgroundEffectState {
pub fn new<D>(globals: &GlobalList, qh: &QueueHandle<D>) -> Self
where
D: Dispatch<ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1, GlobalData>
+ 'static,
{
let manager = GlobalProxy::from(globals.bind(qh, 1..=1, GlobalData));
Self { manager, capabilities: None }
}

pub fn capabilities(&self) -> Option<ext_background_effect_manager_v1::Capability> {
self.capabilities
}

pub fn get_background_effect<D>(
&self,
surface: &wl_surface::WlSurface,
qh: &QueueHandle<D>,
) -> Result<ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1, GlobalError>
where
D: Dispatch<ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1, GlobalData>
+ 'static,
{
Ok(self.manager.get()?.get_background_effect(surface, qh, GlobalData))
}
}

pub trait BackgroundEffectHandler {
fn background_effect_state(&mut self) -> &mut BackgroundEffectState;
fn update_capabilities(&mut self);
}

impl<D> Dispatch<ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1, GlobalData, D>
for BackgroundEffectState
where
D: Dispatch<ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1, GlobalData>
+ BackgroundEffectHandler,
{
fn event(
data: &mut D,
_manager: &ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1,
event: ext_background_effect_manager_v1::Event,
_: &GlobalData,
_conn: &Connection,
_qh: &QueueHandle<D>,
) {
match event {
ext_background_effect_manager_v1::Event::Capabilities { flags } => {
let flags = match flags {
WEnum::Value(value) => value,
WEnum::Unknown(value) => {
ext_background_effect_manager_v1::Capability::from_bits_retain(value)
}
};
data.background_effect_state().capabilities = Some(flags);
data.update_capabilities();
}
_ => unreachable!(),
}
}
}

impl<D> Dispatch<ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1, GlobalData, D>
for BackgroundEffectState
where
D: Dispatch<ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1, GlobalData>,
{
fn event(
_data: &mut D,
_surface: &ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1,
event: ext_background_effect_surface_v1::Event,
_: &GlobalData,
_conn: &Connection,
_qh: &QueueHandle<D>,
) {
match event {

Check failure on line 90 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / lint

this match could be replaced by its body itself
_ => unreachable!(),
}
}
}

#[macro_export]
macro_rules! delegate_background_effect {
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
$crate::reexports::client::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::protocols::ext::background_effect::v1::client::ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1: $crate::globals::GlobalData
] => $crate::background_effect::BackgroundEffectState);
$crate::reexports::client::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::protocols::ext::background_effect::v1::client::ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1: $crate::globals::GlobalData
] => $crate::background_effect::BackgroundEffectState);
};
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub mod reexports {
}

pub mod activation;
pub mod background_effect;
pub mod compositor;
pub mod data_device_manager;
pub mod dmabuf;
Expand Down
Loading