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
151 changes: 131 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
name = "smithay"
version = "0.6.0"
authors = ["Victor Berger <[email protected]>", "Drakulix (Victoria Brekenfeld)"]
authors = [
"Victor Berger <[email protected]>",
"Drakulix (Victoria Brekenfeld)",
]
license = "MIT"
description = "Smithay is a library for writing wayland compositors."
repository = "https://github.com/Smithay/smithay"
Expand Down Expand Up @@ -37,14 +40,27 @@ drm-fourcc = "^2.2.0"
drm = { version = "0.14.0", optional = true }
drm-ffi = { version = "0.9.0", optional = true }
errno = "0.3.5"
gbm = { version = "0.18.0", optional = true, default-features = false, features = ["drm-support"] }
gbm = { version = "0.18.0", optional = true, default-features = false, features = [
"drm-support",
] }
glow = { version = "0.16", optional = true }
input = { version = "0.9.0", default-features = false, features=["libinput_1_19"], optional = true }
input = { version = "0.9.0", default-features = false, features = [
"libinput_1_19",
], optional = true }
indexmap = "2.0"
libc = "0.2.103"
libseat = { version = "0.2.3", optional = true, default-features = false }
libloading = { version="0.8.0", optional = true }
rustix = { version = "1.0.7", features = ["event", "fs", "mm", "net", "pipe", "process", "shm", "time"] }
libloading = { version = "0.8.0", optional = true }
rustix = { version = "1.0.7", features = [
"event",
"fs",
"mm",
"net",
"pipe",
"process",
"shm",
"time",
] }
rand = "0.9.0"
scopeguard = { version = "1.1.0", optional = true }
tracing = "0.1.37"
Expand All @@ -56,19 +72,35 @@ udev = { version = "0.9.0", optional = true }
wayland-client = { version = "0.31.10", optional = true }
wayland-cursor = { version = "0.31.10", optional = true }
wayland-egl = { version = "0.32.7", optional = true }
wayland-protocols = { version = "0.32.8", features = ["unstable", "staging", "server"], optional = true }
wayland-protocols-wlr = { version = "0.3.8", features = ["server"], optional = true }
wayland-protocols-misc = { version = "0.3.8", features = ["server"], optional = true }
wayland-protocols = { version = "0.32.8", features = [
"unstable",
"staging",
"server",
], optional = true }
wayland-protocols-wlr = { version = "0.3.8", features = [
"server",
], optional = true }
wayland-protocols-misc = { version = "0.3.8", features = [
"server",
], optional = true }
wayland-server = { version = "0.31.9", optional = true }
wayland-sys = { version = "0.31.6", optional = true }
wayland-backend = { version = "0.3.10", optional = true }
winit = { version = "0.30.0", default-features = false, features = ["wayland", "wayland-dlopen", "x11", "rwh_06"], optional = true }
x11rb = { version = "0.13.0", optional = true, features = ["res"]}
xkbcommon = { version = "0.8.0", features = ["wayland"]}
winit = { version = "0.30.0", default-features = false, features = [
"wayland",
"wayland-dlopen",
"x11",
"rwh_06",
], optional = true }
x11rb = { version = "0.13.0", optional = true, features = ["res"] }
xkbcommon = { version = "0.8.0", features = ["wayland"] }
encoding_rs = { version = "0.8.33", optional = true }
profiling = "1.0.13"
smallvec = "1.11"
pixman = { version = "0.2.1", features = ["drm-fourcc", "sync"], optional = true }
pixman = { version = "0.2.1", features = [
"drm-fourcc",
"sync",
], optional = true }
aliasable = { version = "0.1.3", optional = true }
atomic_float = "1.1.0"
sha2 = "0.10.9"
Expand All @@ -85,9 +117,41 @@ pkg-config = { version = "0.3.17", optional = true }
cc = { version = "1.0.79", optional = true }

[features]
default = ["backend_drm", "backend_gbm", "backend_libinput", "backend_udev", "backend_session_libseat", "backend_x11", "backend_winit", "desktop", "renderer_gl", "renderer_pixman", "renderer_multi", "xwayland", "wayland_frontend", "backend_vulkan"]
backend_winit = ["winit", "backend_egl", "wayland-client", "wayland-cursor", "wayland-egl", "renderer_gl"]
backend_x11 = ["x11rb", "x11rb/dri3", "x11rb/xfixes", "x11rb/xinput", "x11rb/present", "x11rb_event_source", "backend_gbm", "backend_drm", "backend_egl"]
default = [
"backend_drm",
"backend_gbm",
"backend_libinput",
"backend_udev",
"backend_session_libseat",
"backend_x11",
"backend_winit",
"desktop",
"renderer_gl",
"renderer_pixman",
"renderer_multi",
"xwayland",
"wayland_frontend",
"backend_vulkan",
]
backend_winit = [
"winit",
"backend_egl",
"wayland-client",
"wayland-cursor",
"wayland-egl",
"renderer_gl",
]
backend_x11 = [
"x11rb",
"x11rb/dri3",
"x11rb/xfixes",
"x11rb/xinput",
"x11rb/present",
"x11rb_event_source",
"backend_gbm",
"backend_drm",
"backend_egl",
]
backend_drm = ["drm", "drm-ffi"]
backend_gbm = ["gbm", "cc", "pkg-config", "backend_drm"]
backend_gbm_has_fd_for_plane = []
Expand All @@ -104,12 +168,36 @@ renderer_glow = ["renderer_gl", "glow"]
renderer_multi = ["backend_drm", "aliasable"]
renderer_pixman = ["pixman"]
renderer_test = []
use_system_lib = ["wayland_frontend", "wayland-backend/server_system", "wayland-sys", "gbm?/import-wayland"]
use_system_lib = [
"wayland_frontend",
"wayland-backend/server_system",
"wayland-sys",
"gbm?/import-wayland",
]
use_bindgen = ["drm-ffi/use_bindgen", "gbm/use_bindgen", "input/use_bindgen"]
wayland_frontend = ["wayland-server", "wayland-protocols", "wayland-protocols-wlr", "wayland-protocols-misc", "tempfile"]
wayland_frontend = [
"wayland-server",
"wayland-protocols",
"wayland-protocols-wlr",
"wayland-protocols-misc",
"tempfile",
]
x11rb_event_source = ["x11rb"]
xwayland = ["encoding_rs", "wayland_frontend", "x11rb/composite", "x11rb/xfixes", "x11rb/randr", "x11rb_event_source", "scopeguard"]
test_all_features = ["default", "use_system_lib", "renderer_glow", "renderer_test"]
xwayland = [
"encoding_rs",
"wayland_frontend",
"x11rb/composite",
"x11rb/xfixes",
"x11rb/randr",
"x11rb_event_source",
"scopeguard",
]
test_all_features = [
"default",
"use_system_lib",
"renderer_glow",
"renderer_test",
]

[[example]]
name = "minimal"
Expand All @@ -129,7 +217,13 @@ required-features = ["backend_vulkan"]

[[example]]
name = "buffer_test"
required-features = ["backend_drm", "backend_gbm", "backend_egl", "backend_vulkan", "renderer_gl"]
required-features = [
"backend_drm",
"backend_gbm",
"backend_egl",
"backend_vulkan",
"renderer_gl",
]

[[bench]]
name = "benchmark"
Expand All @@ -142,3 +236,20 @@ harness = false
[profile.release-with-debug]
inherits = "release"
debug = true

[patch.crates-io]
wayland-client = { git = "https://github.com/Smithay/wayland-rs", optional = true }
wayland-protocols = { git = "https://github.com/Smithay/wayland-rs", features = [
"unstable",
"staging",
"server",
], optional = true }
wayland-protocols-wlr = { git = "https://github.com/Smithay/wayland-rs", features = [
"server",
], optional = true }
wayland-protocols-misc = { git = "https://github.com/Smithay/wayland-rs", features = [
"server",
], optional = true }
wayland-server = { git = "https://github.com/Smithay/wayland-rs", optional = true }
wayland-sys = { git = "https://github.com/Smithay/wayland-rs", optional = true }
wayland-backend = { git = "https://github.com/Smithay/wayland-rs", optional = true }
142 changes: 142 additions & 0 deletions src/wayland/background_effect/dispatch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
use crate::wayland::background_effect::{BackgroundEffectState, BackgroundEffectSurfaceData};
use crate::wayland::{
background_effect::{BackgroundEffectSurfaceCachedState, BackgroundEffectSurfaceUserData},
compositor::with_states,
};
use wayland_protocols::ext::background_effect::v1::server::{
ext_background_effect_manager_v1::{
Capability, Error as ManagerError, ExtBackgroundEffectManagerV1, Request as ManagerRequest,
},
ext_background_effect_surface_v1::{
Error as SurfaceError, ExtBackgroundEffectSurfaceV1, Request as SurfaceRequest,
},
};
use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource};

// GlobalDispatch for ext_background_effect_manager_v1
impl<D> GlobalDispatch<ExtBackgroundEffectManagerV1, (), D> for BackgroundEffectState
where
D: GlobalDispatch<ExtBackgroundEffectManagerV1, ()>,
D: Dispatch<ExtBackgroundEffectManagerV1, ()>,
D: Dispatch<ExtBackgroundEffectSurfaceV1, BackgroundEffectSurfaceUserData>,
D: 'static,
{
fn bind(
_state: &mut D,
_handle: &DisplayHandle,
_client: &Client,
resource: New<ExtBackgroundEffectManagerV1>,
_global_data: &(),
data_init: &mut DataInit<'_, D>,
) {
let manager = data_init.init(resource, ());
// For now, always advertise blur capability
manager.capabilities(Capability::Blur);
}
}

// Dispatch for ext_background_effect_manager_v1
impl<D> Dispatch<ExtBackgroundEffectManagerV1, (), D> for BackgroundEffectState
where
D: Dispatch<ExtBackgroundEffectManagerV1, ()>,
D: Dispatch<ExtBackgroundEffectSurfaceV1, BackgroundEffectSurfaceUserData>,
D: 'static,
{
fn request(
_state: &mut D,
_client: &Client,
manager: &ExtBackgroundEffectManagerV1,
request: ManagerRequest,
_data: &(),
_dh: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
tracing::info!("Received request: {:#?}", request);
match request {
ManagerRequest::GetBackgroundEffect { id, surface } => {
let already_taken = with_states(&surface, |states| {
states
.data_map
.insert_if_missing_threadsafe(BackgroundEffectSurfaceData::new);
let data = states.data_map.get::<BackgroundEffectSurfaceData>().unwrap();
let already = data.is_resource_attached();
if !already {
data.set_is_resource_attached(true);
}
already
});

if already_taken {
manager.post_error(
ManagerError::BackgroundEffectExists,
"wl_surface already has a background effect object attached",
);
} else {
data_init.init(id, BackgroundEffectSurfaceUserData::new(surface));
}
}
ManagerRequest::Destroy => {}
_ => {}
}
}
}

// Dispatch for ext_background_effect_surface_v1
impl<D> Dispatch<ExtBackgroundEffectSurfaceV1, BackgroundEffectSurfaceUserData, D> for BackgroundEffectState
where
D: Dispatch<ExtBackgroundEffectSurfaceV1, BackgroundEffectSurfaceUserData>,
{
fn request(
_state: &mut D,
_client: &Client,
obj: &ExtBackgroundEffectSurfaceV1,
request: SurfaceRequest,
data: &BackgroundEffectSurfaceUserData,
_dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
tracing::info!("Received request: {:#?}", request);

match request {
SurfaceRequest::SetBlurRegion { region } => {
let Some(surface) = data.wl_surface() else {
obj.post_error(SurfaceError::SurfaceDestroyed, "wl_surface was destroyed");
return;
};

with_states(&surface, |states| {
let mut cached = states.cached_state.get::<BackgroundEffectSurfaceCachedState>();
let pending = cached.pending();
pending.blur_region =
region.map(|r| crate::wayland::compositor::get_region_attributes(&r));
});
}
SurfaceRequest::Destroy => {
let Some(surface) = data.wl_surface() else {
obj.post_error(SurfaceError::SurfaceDestroyed, "wl_surface was destroyed");
return;
};

with_states(&surface, |states| {
states
.data_map
.get::<BackgroundEffectSurfaceData>()
.unwrap()
.set_is_resource_attached(false);
let mut cached = states.cached_state.get::<BackgroundEffectSurfaceCachedState>();
cached.pending().blur_region = None;
});
}
_ => {}
}
}

fn destroyed(
_state: &mut D,
_client_id: wayland_server::backend::ClientId,
_object: &ExtBackgroundEffectSurfaceV1,
_data: &BackgroundEffectSurfaceUserData,
) {
// No-op: cleanup is handled by double-buffering and surface destruction
}
}
Loading