mirror of
https://github.com/storytold/winit.git
synced 2026-11-30 18:26:33 +01:00
Merge pull request #43 from dotCooCoo/fix/kde-blur-optional
W42: Wayland: compile the KDE blur protocol only with the wayland-kde-blur feature
This commit is contained in:
10 files changed
+67
-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"]
|
||||
|
||||
@@ -77,6 +77,8 @@ If your PR makes notable changes to Winit's features, please update this section
|
||||
- **Window resize increments**: When the window gets resized, the application can choose to snap the window's
|
||||
size to specific values.
|
||||
- **Window transparency**: Winit allows the creation of windows with a transparent background.
|
||||
- **Window blur**: Winit can ask the system to blur the background of a transparent window. On Wayland
|
||||
this needs the `wayland-kde-blur` feature and a compositor with `org_kde_kwin_blur_manager`.
|
||||
- **Window maximization**: The windows created by winit can be maximized upon creation.
|
||||
- **Window maximization toggle**: The windows created by winit can be maximized and unmaximized after
|
||||
creation.
|
||||
|
||||
@@ -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 | `0ecdbe5e` | 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/winit PR #43; storytold/vectorcraft#9113 |
|
||||
| W30 | this commit | Linux: the first window created without an activation token takes the launcher's (`XDG_ACTIVATION_TOKEN` on Wayland, `DESKTOP_STARTUP_ID` on X11) and hands it back as one given through `with_activation_token` would be (`platform_impl/linux/startup_token.rs`), so GNOME drops the busy cursor and a Wayland window opens focused; later windows don't reuse the spent token, an empty or oversized (over 1,024 bytes) token is ignored, and the variable stays in the environment (changing it while other threads may read it is unsound) | none; to be proposed | upstream release that hands the launcher's token to the first window | pdfcraft vendor patch (14); cadcraft#2030 (`tests/winit_startup_token.rs`) |
|
||||
| W36 | `924c77b4` | Windows: an Alt code (Alt+0181 for µ) types its character; Windows sends it in `WM_CHAR` after Alt's key-up, which the keyboard builder dropped as IME text. It goes on a press of an unidentified key (as `VK_PACKET` is reported) with a release after it | none found; to be proposed | upstream release with an equivalent | pdfcraft#5746 |
|
||||
|
||||
|
||||
@@ -49,3 +49,10 @@ changelog entry.
|
||||
a second one.
|
||||
- On Wayland, report two-finger touchpad `PinchGesture` and `RotationGesture` on compositors that
|
||||
support the pointer gestures protocol.
|
||||
|
||||
### Changed
|
||||
|
||||
- On Wayland, window blur needs the new `wayland-kde-blur` feature, which is off by default and not
|
||||
part of `wayland`. Without it, `Window::set_blur` and `WindowAttributes::with_blur` do nothing on
|
||||
Wayland. The implicit `wayland-protocols-plasma` feature has been removed; enable
|
||||
`wayland-kde-blur` instead.
|
||||
@@ -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, PointerGesturesState, 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;
|
||||
@@ -128,6 +129,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.
|
||||
@@ -253,6 +255,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(),
|
||||
pointer_gestures: PointerGesturesState::new(globals, queue_handle).ok(),
|
||||
|
||||
|
||||
@@ -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