fix: feature gates
This commit is contained in:
parent
f6daee14ac
commit
b3b0ab1cd5
26 changed files with 176 additions and 101 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
|
@ -787,6 +787,13 @@ dependencies = [
|
|||
"cfg_aliases",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build_helpers"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"cfg_aliases",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "built"
|
||||
version = "0.8.0"
|
||||
|
|
@ -2957,6 +2964,7 @@ dependencies = [
|
|||
name = "iced"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"build_helpers",
|
||||
"criterion",
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -3008,6 +3016,7 @@ version = "0.14.0"
|
|||
dependencies = [
|
||||
"approx",
|
||||
"bitflags 2.11.0",
|
||||
"build_helpers",
|
||||
"bytes",
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -3114,6 +3123,7 @@ dependencies = [
|
|||
name = "iced_runtime"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"build_helpers",
|
||||
"bytes",
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -3181,6 +3191,7 @@ version = "0.14.0"
|
|||
dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"bitflags 2.11.0",
|
||||
"build_helpers",
|
||||
"bytemuck",
|
||||
"cosmic-client-toolkit",
|
||||
"cryoglyph",
|
||||
|
|
@ -3210,6 +3221,7 @@ dependencies = [
|
|||
name = "iced_widget"
|
||||
version = "0.14.2"
|
||||
dependencies = [
|
||||
"build_helpers",
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -3231,6 +3243,7 @@ dependencies = [
|
|||
name = "iced_winit"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"build_helpers",
|
||||
"cosmic-client-toolkit",
|
||||
"cursor-icon",
|
||||
"dnd",
|
||||
|
|
|
|||
23
Cargo.toml
23
Cargo.toml
|
|
@ -118,13 +118,17 @@ winit = [
|
|||
"iced_accessibility?/accesskit_winit",
|
||||
"iced_program/winit",
|
||||
]
|
||||
wayland = ["iced_renderer/wayland", "iced_winit/wayland"]
|
||||
cctk = ["iced_winit/cctk", "iced_widget/cctk", "iced_core/cctk", "wayland"]
|
||||
# Enables the sctk shell.
|
||||
wayland = [
|
||||
"iced_renderer/wayland",
|
||||
"iced_winit/wayland",
|
||||
"iced_runtime/wayland",
|
||||
"iced_widget/wayland",
|
||||
"iced_core/wayland",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
iced_devtools.workspace = true
|
||||
iced_devtools.optional = true
|
||||
iced_debug.workspace = true
|
||||
|
||||
iced_program.workspace = true
|
||||
|
|
@ -134,10 +138,9 @@ iced_renderer.workspace = true
|
|||
iced_runtime.workspace = true
|
||||
iced_widget.workspace = true
|
||||
iced_winit.workspace = true
|
||||
iced_devtools.optional = true
|
||||
iced_winit.optional = true
|
||||
iced_tester.workspace = true
|
||||
iced_tester.optional = true
|
||||
iced_winit.optional = true
|
||||
iced_highlighter.workspace = true
|
||||
iced_highlighter.optional = true
|
||||
iced_accessibility.workspace = true
|
||||
|
|
@ -190,6 +193,7 @@ members = [
|
|||
"winit",
|
||||
"examples/*",
|
||||
"accessibility",
|
||||
"build_helpers",
|
||||
]
|
||||
exclude = ["examples/integration"]
|
||||
|
||||
|
|
@ -308,8 +312,6 @@ winit = { git = "https://github.com/pop-os/winit.git", tag = "cosmic-0.14" }
|
|||
winit-core = { git = "https://github.com/pop-os/winit.git", tag = "cosmic-0.14" }
|
||||
cursor-icon = "1.1.0"
|
||||
|
||||
sctk = { package = "smithay-client-toolkit", version = "0.20.0" }
|
||||
|
||||
[workspace.lints.rust]
|
||||
rust_2018_idioms = { level = "deny", priority = -1 }
|
||||
unused_results = "deny"
|
||||
|
|
@ -334,3 +336,6 @@ useless_conversion = "deny"
|
|||
|
||||
[workspace.lints.rustdoc]
|
||||
broken_intra_doc_links = "forbid"
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "./build_helpers" }
|
||||
|
|
|
|||
3
build.rs
Normal file
3
build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
17
build_helpers/Cargo.toml
Normal file
17
build_helpers/Cargo.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
name = "build_helpers"
|
||||
version.workspace = true
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
categories.workspace = true
|
||||
keywords.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
cfg_aliases = { version = "0.2.1" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
23
build_helpers/src/lib.rs
Normal file
23
build_helpers/src/lib.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use cfg_aliases::cfg_aliases;
|
||||
|
||||
pub fn cfg_aliases_setup() {
|
||||
// The script doesn't depend on our code
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
// Setup cfg aliases
|
||||
cfg_aliases! {
|
||||
// Systems.
|
||||
android_platform: { target_os = "android" },
|
||||
wasm_platform: { all(target_family = "wasm", not(target_os = "emscripten")) },
|
||||
macos_platform: { target_os = "macos" },
|
||||
ios_platform: { target_os = "ios" },
|
||||
windows_platform: { target_os = "windows" },
|
||||
apple: { any(target_os = "ios", target_os = "macos") },
|
||||
free_unix: { all(unix, not(apple), not(android_platform), not(target_os = "emscripten")) },
|
||||
redox: { target_os = "redox" },
|
||||
|
||||
// Native displays.
|
||||
wayland_platform: { all(feature = "wayland", free_unix, not(wasm), not(redox)) },
|
||||
orbital_platform: { redox },
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ crisp = []
|
|||
basic-shaping = []
|
||||
advanced-shaping = []
|
||||
a11y = ["iced_accessibility"]
|
||||
wayland = ["cctk"]
|
||||
|
||||
[dependencies]
|
||||
palette = "0.7"
|
||||
|
|
@ -43,8 +44,6 @@ window_clipboard.workspace = true
|
|||
dnd.workspace = true
|
||||
mime.workspace = true
|
||||
|
||||
cctk.workspace = true
|
||||
cctk.optional = true
|
||||
# /TODO(POP)
|
||||
[dependencies.iced_accessibility]
|
||||
version = "0.1.0"
|
||||
|
|
@ -56,3 +55,10 @@ raw-window-handle.workspace = true
|
|||
|
||||
[dev-dependencies]
|
||||
approx = "0.5"
|
||||
|
||||
[target.'cfg(all(unix, not(any(target_os = "redox", target_family = "wasm", target_os = "android", target_vendor = "apple"))))'.dependencies]
|
||||
cctk.workspace = true
|
||||
cctk.optional = true
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "../build_helpers" }
|
||||
|
|
|
|||
3
core/build.rs
Normal file
3
core/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@ use crate::keyboard;
|
|||
use crate::mouse;
|
||||
use crate::touch;
|
||||
use crate::window;
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
|
||||
#[cfg(wayland_platform)]
|
||||
/// A platform specific event for wayland
|
||||
pub mod wayland;
|
||||
/// A user interface event.
|
||||
|
|
@ -49,7 +50,7 @@ pub enum Event {
|
|||
/// A platform specific event
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum PlatformSpecific {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
/// A Wayland specific event
|
||||
Wayland(wayland::Event),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ workspace = true
|
|||
debug = []
|
||||
selector = ["dep:iced_selector"]
|
||||
a11y = ["iced_accessibility", "iced_core/a11y"]
|
||||
cctk = ["iced_core/cctk", "dep:cctk"]
|
||||
wayland = ["iced_core/wayland", "dep:cctk"]
|
||||
|
||||
[dependencies]
|
||||
bytes.workspace = true
|
||||
|
|
@ -33,9 +33,14 @@ sipper.optional = true
|
|||
iced_selector.workspace = true
|
||||
iced_selector.optional = true
|
||||
iced_futures.features = ["thread-pool"]
|
||||
cctk.workspace = true
|
||||
cctk.optional = true
|
||||
iced_accessibility.workspace = true
|
||||
iced_accessibility.optional = true
|
||||
window_clipboard.workspace = true
|
||||
dnd.workspace = true
|
||||
|
||||
[target.'cfg(all(unix, not(any(target_os = "redox", target_family = "wasm", target_os = "android", target_vendor = "apple"))))'.dependencies]
|
||||
cctk.workspace = true
|
||||
cctk.optional = true
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "../build_helpers" }
|
||||
|
|
|
|||
3
runtime/build.rs
Normal file
3
runtime/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
|
|
@ -2,23 +2,23 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
/// Platform specific actions defined for wayland
|
||||
pub mod wayland;
|
||||
|
||||
/// Platform specific actions defined for wayland
|
||||
pub enum Action {
|
||||
/// Wayland Specific Actions
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
Wayland(wayland::Action),
|
||||
}
|
||||
|
||||
impl fmt::Debug for Action {
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
Action::Wayland(action) => action.fmt(_f),
|
||||
#[cfg(not(all(feature = "cctk", target_os = "linux")))]
|
||||
#[cfg(not(wayland_platform))]
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ pub fn frames() -> Subscription<(Id, Instant)> {
|
|||
_ => None,
|
||||
})
|
||||
}
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
/// Subscribes to the frames of the window of the running application.
|
||||
///
|
||||
/// The resulting [`Subscription`] will produce items at a rate equal to the
|
||||
|
|
|
|||
|
|
@ -606,7 +606,7 @@ pub mod font {
|
|||
pub mod event {
|
||||
//! Handle events of a user interface.
|
||||
pub use crate::core::event::PlatformSpecific;
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub use crate::core::event::wayland;
|
||||
pub use crate::core::event::{Event, Status};
|
||||
pub use iced_futures::event::{listen, listen_raw, listen_with};
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ svg = ["iced_graphics/svg", "resvg/text"]
|
|||
web-colors = ["iced_graphics/web-colors"]
|
||||
webgl = ["wgpu/webgl"]
|
||||
strict-assertions = []
|
||||
wayland = ["cctk"]
|
||||
|
||||
[dependencies]
|
||||
iced_debug.workspace = true
|
||||
|
|
@ -65,4 +66,6 @@ x11rb = { version = "0.13.1", features = [
|
|||
"dri3",
|
||||
"randr",
|
||||
] }
|
||||
sctk.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "../build_helpers" }
|
||||
|
|
|
|||
3
wgpu/build.rs
Normal file
3
wgpu/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
//! Display rendering results on windows.
|
||||
pub mod compositor;
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
mod wayland;
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||
mod x11;
|
||||
|
|
|
|||
|
|
@ -9,15 +9,10 @@ use crate::graphics::{self, Shell, Viewport};
|
|||
use crate::settings::{self, Settings};
|
||||
use crate::{Engine, Renderer};
|
||||
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
use super::wayland::get_wayland_device_ids;
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||
#[cfg(wayland_platform)]
|
||||
use super::x11::get_x11_device_ids;
|
||||
use std::future::Future;
|
||||
|
||||
/// A window graphics backend for iced powered by `wgpu`.
|
||||
pub struct Compositor {
|
||||
|
|
@ -64,11 +59,7 @@ impl Compositor {
|
|||
compatible_window: Option<W>,
|
||||
shell: Shell,
|
||||
) -> Result<Self, Error> {
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
let ids = compatible_window.as_ref().and_then(|window| {
|
||||
get_wayland_device_ids(window)
|
||||
.or_else(|| get_x11_device_ids(window))
|
||||
|
|
@ -80,7 +71,7 @@ impl Compositor {
|
|||
// 3. and the user didn't set an adapter name,
|
||||
// 4. and the user didn't request the high power pref
|
||||
// => don't load the nvidia icd, as it might power on the gpu in hybrid setups causing severe delays
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||
#[cfg(wayland_platform)]
|
||||
if !matches!(ids, Some((0x10de, _)))
|
||||
&& std::env::var_os("__NV_PRIME_RENDER_OFFLOAD")
|
||||
.is_none_or(|var| var == "0")
|
||||
|
|
@ -140,11 +131,7 @@ impl Compositor {
|
|||
let mut adapter = None;
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
if std::env::var_os("WGPU_ADAPTER_NAME").is_none() {
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
if let Some((vendor_id, device_id)) = ids {
|
||||
adapter = instance
|
||||
.enumerate_adapters(settings.backends)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::graphics::compositor::Window;
|
||||
use sctk::{
|
||||
use cctk::sctk::{
|
||||
dmabuf::{DmabufFeedback, DmabufHandler, DmabufState},
|
||||
registry::{ProvidesRegistryState, RegistryState},
|
||||
registry_handlers,
|
||||
|
|
@ -111,5 +111,5 @@ pub fn get_wayland_device_ids<W: Window>(window: &W) -> Option<(u16, u16)> {
|
|||
}
|
||||
}
|
||||
|
||||
sctk::delegate_dmabuf!(AppData);
|
||||
sctk::delegate_registry!(AppData);
|
||||
cctk::sctk::delegate_dmabuf!(AppData);
|
||||
cctk::sctk::delegate_registry!(AppData);
|
||||
|
|
|
|||
|
|
@ -29,15 +29,13 @@ highlighter = ["dep:iced_highlighter"]
|
|||
advanced = []
|
||||
crisp = []
|
||||
a11y = ["iced_accessibility"]
|
||||
cctk = ["iced_runtime/cctk", "dep:cctk"]
|
||||
wayland = ["iced_runtime/wayland", "dep:cctk"]
|
||||
|
||||
[dependencies]
|
||||
iced_renderer.workspace = true
|
||||
iced_runtime.workspace = true
|
||||
iced_accessibility.workspace = true
|
||||
iced_accessibility.optional = true
|
||||
cctk.workspace = true
|
||||
cctk.optional = true
|
||||
num-traits.workspace = true
|
||||
log.workspace = true
|
||||
rustc-hash.workspace = true
|
||||
|
|
@ -57,3 +55,10 @@ pulldown-cmark.optional = true
|
|||
|
||||
iced_highlighter.workspace = true
|
||||
iced_highlighter.optional = true
|
||||
|
||||
[target.'cfg(all(unix, not(any(target_os = "redox", target_family = "wasm", target_os = "android", target_vendor = "apple"))))'.dependencies]
|
||||
cctk.workspace = true
|
||||
cctk.optional = true
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "../build_helpers" }
|
||||
|
|
|
|||
3
widget/build.rs
Normal file
3
widget/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
|
|
@ -14,7 +14,18 @@ keywords.workspace = true
|
|||
workspace = true
|
||||
|
||||
[features]
|
||||
wayland = ["winit/wayland", "wayland-csd-adwaita"]
|
||||
wayland = [
|
||||
"winit/wayland",
|
||||
"wayland-csd-adwaita",
|
||||
"wayland-protocols",
|
||||
"raw-window-handle",
|
||||
"iced_runtime/wayland",
|
||||
"wayland-backend",
|
||||
"xkbcommon",
|
||||
"xkbcommon-dl",
|
||||
"xkeysym",
|
||||
"dep:cctk",
|
||||
]
|
||||
default = ["x11", "wayland-dlopen"]
|
||||
debug = ["iced_debug/enable"]
|
||||
sysinfo = ["dep:sysinfo"]
|
||||
|
|
@ -26,17 +37,6 @@ program = []
|
|||
wayland-dlopen = ["winit/wayland-dlopen"]
|
||||
wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
|
||||
a11y = ["iced_accessibility", "iced_runtime/a11y"]
|
||||
cctk = [
|
||||
"wayland",
|
||||
"wayland-protocols",
|
||||
"raw-window-handle",
|
||||
"iced_runtime/cctk",
|
||||
"wayland-backend",
|
||||
"xkbcommon",
|
||||
"xkbcommon-dl",
|
||||
"xkeysym",
|
||||
"dep:cctk",
|
||||
]
|
||||
# Prevents multiple separate process instances.
|
||||
single-instance = []
|
||||
|
||||
|
|
@ -64,7 +64,8 @@ iced_debug.workspace = true
|
|||
iced_program.workspace = true
|
||||
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
[target.'cfg(all(unix, not(any(target_os = "redox", target_family = "wasm", target_os = "android", target_vendor = "apple"))))'.dependencies]
|
||||
|
||||
mundy.workspace = true
|
||||
mundy.optional = true
|
||||
|
||||
|
|
@ -89,3 +90,6 @@ winapi.workspace = true
|
|||
web-sys.workspace = true
|
||||
web-sys.features = ["Document", "Window", "HtmlCanvasElement"]
|
||||
wasm-bindgen-futures.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "../build_helpers" }
|
||||
|
|
|
|||
3
winit/build.rs
Normal file
3
winit/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ impl Clipboard {
|
|||
})
|
||||
.unwrap_or(State::Unavailable);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(wayland_platform)]
|
||||
if let State::Connected { clipboard, .. } = &state {
|
||||
clipboard.init_dnd(Box::new(sender));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ pub fn window_event(
|
|||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||
Some(Event::Window(window::Event::Rescaled(scale_factor as f32)))
|
||||
}
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
WindowEvent::SuggestedBounds(bounds) => {
|
||||
let size = bounds.map(|bounds| {
|
||||
let size = bounds.to_logical(scale_factor);
|
||||
|
|
@ -437,7 +437,7 @@ pub fn window_event(
|
|||
),
|
||||
)))
|
||||
}
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
WindowEvent::WindowStateChanged => {
|
||||
use cctk::sctk::reexports::csd_frame::WindowState;
|
||||
use winit::platform::wayland::WindowExtWayland;
|
||||
|
|
@ -1491,7 +1491,7 @@ pub fn winit_key_code(
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
fn winit_native_key_code(
|
||||
keycode: keyboard::key::NativeCode,
|
||||
) -> winit::keyboard::NativeKeyCode {
|
||||
|
|
@ -1515,7 +1515,7 @@ fn winit_native_key_code(
|
|||
}
|
||||
|
||||
/// Reconstruct the raw keycode
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub fn physical_to_scancode(physical: keyboard::key::Physical) -> Option<u32> {
|
||||
let Some(physical_key) = (match physical {
|
||||
keyboard::key::Physical::Code(code) => {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ mod window;
|
|||
pub use clipboard::Clipboard;
|
||||
pub use error::Error;
|
||||
pub use proxy::Proxy;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::dpi::PhysicalPosition;
|
||||
use winit::dpi::PhysicalSize;
|
||||
|
||||
|
|
@ -92,10 +91,10 @@ where
|
|||
|
||||
let event_loop = EventLoop::new().expect("Create event loop");
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
let is_wayland =
|
||||
winit::platform::wayland::EventLoopExtWayland::is_wayland(&event_loop);
|
||||
#[cfg(not(all(feature = "cctk", target_os = "linux")))]
|
||||
#[cfg(not(wayland_platform))]
|
||||
let is_wayland = false;
|
||||
|
||||
// TODO this is new..
|
||||
|
|
@ -260,7 +259,7 @@ where
|
|||
| winit::event::WindowEvent::Moved(_)
|
||||
);
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
if matches!(event, WindowEvent::RedrawRequested) {
|
||||
for id in
|
||||
|
|
@ -575,10 +574,7 @@ where
|
|||
.expect("Send event");
|
||||
}
|
||||
Control::Winit(id, e) => {
|
||||
#[cfg(all(
|
||||
feature = "cctk",
|
||||
target_os = "linux"
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
if matches!(e, WindowEvent::RedrawRequested)
|
||||
{
|
||||
|
|
@ -774,7 +770,7 @@ async fn run_instance<P>(
|
|||
|
||||
let mut platform_specific_handler =
|
||||
crate::platform_specific::PlatformSpecific::default();
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
if is_wayland {
|
||||
platform_specific_handler = platform_specific_handler.with_wayland(
|
||||
control_sender.clone(),
|
||||
|
|
@ -885,7 +881,7 @@ async fn run_instance<P>(
|
|||
on_open,
|
||||
resize_border,
|
||||
} => {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
platform_specific_handler.send_wayland(
|
||||
platform_specific::Action::TrackWindow(window.clone(), id),
|
||||
);
|
||||
|
|
@ -1054,7 +1050,7 @@ async fn run_instance<P>(
|
|||
continue;
|
||||
}
|
||||
// XX must force update to corner radius before the surface is committed.
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
if (window.surface_version != window.state.surface_version()
|
||||
|| window.logical_size() != window.state.logical_size())
|
||||
&& !crate::subsurface_widget::is_subsurface(window_id)
|
||||
|
|
@ -1394,7 +1390,7 @@ async fn run_instance<P>(
|
|||
}
|
||||
});
|
||||
let no_window_events = window_events.is_empty();
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
window_events.push(core::Event::PlatformSpecific(
|
||||
core::event::PlatformSpecific::Wayland(
|
||||
core::event::wayland::Event::RequestResize,
|
||||
|
|
@ -2126,7 +2122,7 @@ where
|
|||
_ = control_sender.start_send(Control::Cleanup(id)).ok();
|
||||
}
|
||||
let proxy = clipboard.proxy();
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
platform_specific
|
||||
.send_wayland(platform_specific::Action::RemoveWindow(id));
|
||||
if let Some(window) = window_manager.remove(id) {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,20 @@
|
|||
//! Wayland specific shell
|
||||
//!
|
||||
|
||||
use std::{borrow::Cow, collections::HashMap, sync::Arc};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
use cctk::sctk::reexports::client::Connection;
|
||||
use iced_graphics::{Compositor, compositor};
|
||||
use iced_graphics::compositor;
|
||||
use iced_runtime::{
|
||||
core::{Vector, window},
|
||||
platform_specific, user_interface,
|
||||
user_interface,
|
||||
};
|
||||
use winit::raw_window_handle::HasWindowHandle;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub mod wayland;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub use wayland::*;
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
use wayland_backend::client::Backend;
|
||||
|
||||
use crate::{CreateCompositor, Program, WindowManager};
|
||||
|
||||
|
|
@ -35,7 +31,7 @@ pub type UserInterfaces<'a, P> = HashMap<
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
Wayland(sctk_event::SctkEvent),
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +57,7 @@ impl SurfaceIdWrapper {
|
|||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PlatformSpecific {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
wayland: WaylandSpecific,
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +67,7 @@ impl PlatformSpecific {
|
|||
action: iced_runtime::platform_specific::Action,
|
||||
) {
|
||||
match action {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
iced_runtime::platform_specific::Action::Wayland(a) => {
|
||||
self.send_wayland(wayland::Action::Action(a));
|
||||
}
|
||||
|
|
@ -82,14 +78,14 @@ impl PlatformSpecific {
|
|||
&mut self,
|
||||
keep: F,
|
||||
) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
self.wayland.retain_subsurfaces(keep);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn clear_subsurface_list(&mut self) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
self.wayland.clear_subsurface_list();
|
||||
}
|
||||
|
|
@ -100,7 +96,7 @@ impl PlatformSpecific {
|
|||
id: window::Id,
|
||||
window: &dyn HasWindowHandle,
|
||||
) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
use cctk::sctk::reexports::client::{
|
||||
Proxy, protocol::wl_surface::WlSurface,
|
||||
|
|
@ -151,7 +147,7 @@ impl PlatformSpecific {
|
|||
pub(crate) fn create_surface(
|
||||
&mut self,
|
||||
) -> Option<Box<dyn HasWindowHandle + Send + Sync + 'static>> {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
return self.wayland.create_surface();
|
||||
}
|
||||
|
|
@ -167,7 +163,7 @@ impl PlatformSpecific {
|
|||
data: &[u8],
|
||||
offset: Vector,
|
||||
) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
return self.wayland.update_surface_shm(
|
||||
surface, width, height, scale, data, offset,
|
||||
|
|
@ -195,7 +191,7 @@ pub(crate) async fn handle_event<'a, 'b, P>(
|
|||
P: Program,
|
||||
{
|
||||
match e {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
Event::Wayland(e) => {
|
||||
platform_specific
|
||||
.wayland
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue