mirror of
https://github.com/storytold/winit.git
synced 2026-11-30 18:26:33 +01:00
W42: Wayland: compile the KDE blur protocol only with wayland-kde-blur
The `wayland` feature, which is on by default, enabled wayland-protocols-plasma for the org_kde_kwin_blur_manager protocol. That crate is MIT, but the blur protocol XML it turns into code is LGPL-2.1-or-later, so every Linux build compiled LGPL-derived bindings. The new `wayland-kde-blur` feature, off by default and not part of `wayland`, enables the dependency and the blur code. Without it, Window::set_blur and WindowAttributes::with_blur are ignored on Wayland and the window logs the request at info level. With it, blur works as before. CI gets a job that fails when the default features, or any feature other than `wayland-kde-blur`, bring in wayland-protocols-plasma, and a Linux row that builds, tests and lints with `wayland-kde-blur`.
This commit is contained in:
1 parent
ad81a32589
commit
0ecdbe5e51
8 files changed
+58
-2
No files matched your search
@@ -35,6 +35,32 @@ jobs:
|
||||
echo 'To check for a diff, run `typos`'
|
||||
echo 'You can find typos here: https://crates.io/crates/typos'
|
||||
|
||||
kde-blur-opt-in:
|
||||
name: Check that the KDE blur protocol is opt-in
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: taiki-e/checkout-action@v1
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Only `wayland-kde-blur` brings in wayland-protocols-plasma
|
||||
# The protocol XML in wayland-protocols-plasma is LGPL-2.1-or-later.
|
||||
run: |
|
||||
set -eu
|
||||
plasma() {
|
||||
tree=$(cargo tree -e normal,build --target x86_64-unknown-linux-gnu --prefix none "$@") \
|
||||
|| { echo "cargo tree $* failed"; exit 2; }
|
||||
printf '%s\n' "$tree" | grep -q '^wayland-protocols-plasma '
|
||||
}
|
||||
others=$(cargo metadata --format-version 1 --no-deps \
|
||||
| jq -r '[.packages[] | select(.name == "winit") | .features | keys[]
|
||||
| select(. != "default" and . != "wayland-kde-blur")] | join(",")')
|
||||
if plasma; then echo 'the default features bring in wayland-protocols-plasma'; exit 1; fi
|
||||
if plasma --features="$others"; then
|
||||
echo "one of $others brings in wayland-protocols-plasma"; exit 1
|
||||
fi
|
||||
if ! plasma --no-default-features --features=wayland-kde-blur; then
|
||||
echo 'wayland-kde-blur does not bring in wayland-protocols-plasma'; exit 1
|
||||
fi
|
||||
|
||||
tests:
|
||||
name: Test ${{ matrix.toolchain }} ${{ matrix.platform.name }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
@@ -53,6 +79,7 @@ jobs:
|
||||
- { name: 'Linux 64bit', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, }
|
||||
- { name: 'X11', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: '--no-default-features --features=x11' }
|
||||
- { name: 'Wayland', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: '--no-default-features --features=wayland,wayland-dlopen' }
|
||||
- { name: 'Wayland KDE blur', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: '--features=wayland-kde-blur' }
|
||||
- { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
||||
- { name: 'Redox OS', target: x86_64-unknown-redox, os: ubuntu-latest, }
|
||||
- { name: 'macOS', target: x86_64-apple-darwin, os: macos-latest, }
|
||||
|
||||
+1
-1
@@ -63,13 +63,13 @@ wayland = [
|
||||
"wayland-client",
|
||||
"wayland-backend",
|
||||
"wayland-protocols",
|
||||
"wayland-protocols-plasma",
|
||||
"sctk",
|
||||
"ahash",
|
||||
"memmap2",
|
||||
"percent-encoding",
|
||||
]
|
||||
wayland-dlopen = ["wayland-backend/dlopen"]
|
||||
wayland-kde-blur = ["wayland", "dep:wayland-protocols-plasma"]
|
||||
wayland-csd-adwaita = ["sctk-adwaita", "sctk-adwaita/ab_glyph"]
|
||||
wayland-csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
|
||||
wayland-csd-adwaita-notitle = ["sctk-adwaita"]
|
||||
|
||||
@@ -34,6 +34,7 @@ input lives in `craft-tablet`).
|
||||
| W25 | `eb4007da` | X11/Wayland: `platform::latin_layout::KeyEventExtLatinLayout`, the key on the first Latin layout group for shortcuts on non-Latin layouts | none; to be proposed | upstream release with an equivalent | storytold/winit PR #5; craft-libs#198 (K2) |
|
||||
| W26 | `2b9cd1cf` | macOS: replaced text is deleted by UTF-8 byte count with the commit (`WindowExtMacOS::take_ime_delete_surrounding`, same shape as W27) | master: `Ime::DeleteSurrounding` (a new `Ime` variant breaks 0.30 matchers) | the egui → 0.31 move | storytold/winit PR #6 (`d103edae`) |
|
||||
| W27 | `f40c76a2` | Wayland: text-input-v3 surrounding text (`WindowExtWayland::set_ime_surrounding_text`, `set_ime_surrounding_text_with_change_cause`, `clear_ime_surrounding_text`), delete-surrounding attached to the commit (`take_ime_delete_surrounding` → `ImeDeleteSurrounding { before_bytes, after_bytes }`), per-seat preedit ownership and outgoing state waiting for a matching `done` (E21b) | master has both as core API (`Ime::DeleteSurrounding`) | the egui → 0.31 move | storytold/winit PR #7; craft-libs#198 (I7) |
|
||||
| W42 | `fix/kde-blur-optional` | Wayland: the KDE blur protocol (`wayland-protocols-plasma`, whose protocol XML is LGPL-2.1-or-later) is compiled only with the new `wayland-kde-blur` feature, off by default and not part of `wayland`; without it `set_blur`/`with_blur` are ignored on Wayland (CI job `kde-blur-opt-in` checks the dependency graph; CI row `Wayland KDE blur` builds the blur code) | none; master enables `wayland-protocols-plasma` with `wayland` | keep while the suite ships no LGPL code | storytold/vectorcraft#9113 |
|
||||
|
||||
Conflict resolved by hand: `wayland/seat/mod.rs` `remove_seat` keeps all three cleanups — cancel a
|
||||
file drag (W15), remove the seat from winit's clipboard (W15), destroy the seat's text input (W2).
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
//! * `wayland-csd-adwaita` (default).
|
||||
//! * `wayland-csd-adwaita-crossfont`.
|
||||
//! * `wayland-csd-adwaita-notitle`.
|
||||
//!
|
||||
//! ## Window blur
|
||||
//!
|
||||
//! [`Window::set_blur`] uses the KDE `org_kde_kwin_blur_manager` protocol, which is compiled only
|
||||
//! with the `wayland-kde-blur` cargo feature (off by default). Without it, blur requests are
|
||||
//! ignored.
|
||||
|
||||
use std::ffi::c_void;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
@@ -34,6 +34,7 @@ use crate::platform_impl::wayland::seat::{
|
||||
PointerConstraintsState, RelativePointerState, TextInputState, WinitPointerData,
|
||||
WinitPointerDataExt, WinitSeatState,
|
||||
};
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
use crate::platform_impl::wayland::types::kwin_blur::KWinBlurManager;
|
||||
use crate::platform_impl::wayland::types::wp_fractional_scaling::FractionalScalingManager;
|
||||
use crate::platform_impl::wayland::types::wp_viewporter::ViewporterState;
|
||||
@@ -125,6 +126,7 @@ pub struct WinitState {
|
||||
pub fractional_scaling_manager: Option<FractionalScalingManager>,
|
||||
|
||||
/// KWin blur manager.
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
pub kwin_blur_manager: Option<KWinBlurManager>,
|
||||
|
||||
/// Loop handle to re-register event sources, such as keyboard repeat.
|
||||
@@ -250,6 +252,7 @@ impl WinitState {
|
||||
window_events_sink: Default::default(),
|
||||
viewporter_state,
|
||||
fractional_scaling_manager,
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
kwin_blur_manager: KWinBlurManager::new(globals, queue_handle).ok(),
|
||||
|
||||
seats,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Wayland protocol implementation boilerplate.
|
||||
|
||||
pub mod cursor;
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
pub mod kwin_blur;
|
||||
pub mod wp_fractional_scaling;
|
||||
pub mod wp_viewporter;
|
||||
|
||||
@@ -28,6 +28,7 @@ use sctk::shell::WaylandSurface;
|
||||
use sctk::shm::slot::SlotPool;
|
||||
use sctk::shm::Shm;
|
||||
use sctk::subcompositor::SubcompositorState;
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
|
||||
|
||||
use crate::cursor::CustomCursor as RootCustomCursor;
|
||||
@@ -35,6 +36,7 @@ use crate::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, S
|
||||
use crate::error::{ExternalError, NotSupportedError};
|
||||
use crate::platform_impl::wayland::logical_to_physical_rounded;
|
||||
use crate::platform_impl::wayland::types::cursor::{CustomCursor, SelectedCursor};
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
use crate::platform_impl::wayland::types::kwin_blur::KWinBlurManager;
|
||||
use crate::platform_impl::{PlatformCustomCursor, WindowId};
|
||||
use crate::window::{CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme};
|
||||
@@ -263,7 +265,9 @@ pub struct WindowState {
|
||||
|
||||
viewport: Option<WpViewport>,
|
||||
fractional_scale: Option<WpFractionalScaleV1>,
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
blur: Option<OrgKdeKwinBlur>,
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
blur_manager: Option<KWinBlurManager>,
|
||||
|
||||
/// Whether the client side decorations have pending move operations.
|
||||
@@ -304,7 +308,9 @@ impl WindowState {
|
||||
.map(|fsm| fsm.fractional_scaling(window.wl_surface(), queue_handle));
|
||||
|
||||
Self {
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
blur: None,
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
blur_manager: winit_state.kwin_blur_manager.clone(),
|
||||
compositor,
|
||||
connection,
|
||||
@@ -1444,6 +1450,7 @@ impl WindowState {
|
||||
}
|
||||
|
||||
/// Make window background blurred
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
#[inline]
|
||||
pub fn set_blur(&mut self, blurred: bool) {
|
||||
if blurred && self.blur.is_none() {
|
||||
@@ -1460,6 +1467,15 @@ impl WindowState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Without the `wayland-kde-blur` feature, blur requests are ignored.
|
||||
#[cfg(not(feature = "wayland-kde-blur"))]
|
||||
#[inline]
|
||||
pub fn set_blur(&mut self, blurred: bool) {
|
||||
if blurred {
|
||||
info!("Blur needs the `wayland-kde-blur` feature, unable to change blur")
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the window title to a new value.
|
||||
///
|
||||
/// This will automatically truncate the title to something meaningful.
|
||||
@@ -1547,6 +1563,7 @@ impl WindowState {
|
||||
|
||||
impl Drop for WindowState {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(feature = "wayland-kde-blur")]
|
||||
if let Some(blur) = self.blur.take() {
|
||||
blur.release();
|
||||
}
|
||||
|
||||
+2
-1
@@ -954,7 +954,8 @@ impl Window {
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Android / iOS / X11 / Web / Windows:** Unsupported.
|
||||
/// - **Wayland:** Only works with org_kde_kwin_blur_manager protocol.
|
||||
/// - **Wayland:** Only works with org_kde_kwin_blur_manager protocol, and only when the
|
||||
/// `wayland-kde-blur` cargo feature is enabled. Without it, the request is ignored.
|
||||
#[inline]
|
||||
pub fn set_blur(&self, blur: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_blur", blur).entered();
|
||||
|
||||
Reference in new issue
Block a user