chore: cleanup platform specific code
This commit is contained in:
parent
a11b828280
commit
3b7f0bec0e
18 changed files with 109 additions and 101 deletions
|
|
@ -118,8 +118,9 @@ winit = [
|
||||||
"iced_accessibility?/accesskit_winit",
|
"iced_accessibility?/accesskit_winit",
|
||||||
"iced_program/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.
|
# Enables the sctk shell.
|
||||||
wayland = ["iced_widget/wayland", "iced_core/wayland", "iced_winit/wayland"]
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ crisp = []
|
||||||
basic-shaping = []
|
basic-shaping = []
|
||||||
advanced-shaping = []
|
advanced-shaping = []
|
||||||
a11y = ["iced_accessibility"]
|
a11y = ["iced_accessibility"]
|
||||||
wayland = ["cctk"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
palette = "0.7"
|
palette = "0.7"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::keyboard;
|
||||||
use crate::mouse;
|
use crate::mouse;
|
||||||
use crate::touch;
|
use crate::touch;
|
||||||
use crate::window;
|
use crate::window;
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
/// A platform specific event for wayland
|
/// A platform specific event for wayland
|
||||||
pub mod wayland;
|
pub mod wayland;
|
||||||
/// A user interface event.
|
/// A user interface event.
|
||||||
|
|
@ -49,7 +49,7 @@ pub enum Event {
|
||||||
/// A platform specific event
|
/// A platform specific event
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum PlatformSpecific {
|
pub enum PlatformSpecific {
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
/// A Wayland specific event
|
/// A Wayland specific event
|
||||||
Wayland(wayland::Event),
|
Wayland(wayland::Event),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ workspace = true
|
||||||
debug = []
|
debug = []
|
||||||
selector = ["dep:iced_selector"]
|
selector = ["dep:iced_selector"]
|
||||||
a11y = ["iced_accessibility", "iced_core/a11y"]
|
a11y = ["iced_accessibility", "iced_core/a11y"]
|
||||||
wayland = ["iced_core/wayland", "cctk"]
|
cctk = ["iced_core/cctk", "dep:cctk"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytes.workspace = true
|
bytes.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
/// Platform specific actions defined for wayland
|
/// Platform specific actions defined for wayland
|
||||||
pub mod wayland;
|
pub mod wayland;
|
||||||
|
|
||||||
/// Platform specific actions defined for wayland
|
/// Platform specific actions defined for wayland
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
/// Wayland Specific Actions
|
/// Wayland Specific Actions
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
Wayland(wayland::Action),
|
Wayland(wayland::Action),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Action {
|
impl fmt::Debug for Action {
|
||||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
Action::Wayland(action) => action.fmt(_f),
|
Action::Wayland(action) => action.fmt(_f),
|
||||||
#[cfg(not(feature = "wayland"))]
|
#[cfg(not(feature = "wayland"))]
|
||||||
_ => Ok(()),
|
_ => Ok(()),
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ pub fn frames() -> Subscription<(Id, Instant)> {
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
/// Subscribes to the frames of the window of the running application.
|
/// Subscribes to the frames of the window of the running application.
|
||||||
///
|
///
|
||||||
/// The resulting [`Subscription`] will produce items at a rate equal to the
|
/// The resulting [`Subscription`] will produce items at a rate equal to the
|
||||||
|
|
|
||||||
|
|
@ -606,7 +606,7 @@ pub mod font {
|
||||||
pub mod event {
|
pub mod event {
|
||||||
//! Handle events of a user interface.
|
//! Handle events of a user interface.
|
||||||
pub use crate::core::event::PlatformSpecific;
|
pub use crate::core::event::PlatformSpecific;
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
pub use crate::core::event::wayland;
|
pub use crate::core::event::wayland;
|
||||||
pub use crate::core::event::{Event, Status};
|
pub use crate::core::event::{Event, Status};
|
||||||
pub use iced_futures::event::{listen, listen_raw, listen_with};
|
pub use iced_futures::event::{listen, listen_raw, listen_with};
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ resvg.optional = true
|
||||||
rustix = { version = "0.38" }
|
rustix = { version = "0.38" }
|
||||||
raw-window-handle.workspace = true
|
raw-window-handle.workspace = true
|
||||||
cctk.workspace = true
|
cctk.workspace = true
|
||||||
|
cctk.optional = true
|
||||||
wayland-protocols.workspace = true
|
wayland-protocols.workspace = true
|
||||||
wayland-backend = { version = "0.3.3", features = ["client_system"] }
|
wayland-backend = { version = "0.3.3", features = ["client_system"] }
|
||||||
wayland-client = { version = "0.31.2" }
|
wayland-client = { version = "0.31.2" }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
//! Display rendering results on windows.
|
//! Display rendering results on windows.
|
||||||
pub mod compositor;
|
pub mod compositor;
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
#[cfg(all(
|
||||||
|
unix,
|
||||||
|
feature = "cctk",
|
||||||
|
not(target_os = "macos"),
|
||||||
|
not(target_os = "redox")
|
||||||
|
))]
|
||||||
mod wayland;
|
mod wayland;
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||||
mod x11;
|
mod x11;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,12 @@ use crate::graphics::{self, Shell, Viewport};
|
||||||
use crate::settings::{self, Settings};
|
use crate::settings::{self, Settings};
|
||||||
use crate::{Engine, Renderer};
|
use crate::{Engine, Renderer};
|
||||||
|
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
#[cfg(all(
|
||||||
|
unix,
|
||||||
|
feature = "cctk",
|
||||||
|
not(target_os = "macos"),
|
||||||
|
not(target_os = "redox")
|
||||||
|
))]
|
||||||
use super::wayland::get_wayland_device_ids;
|
use super::wayland::get_wayland_device_ids;
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||||
use super::x11::get_x11_device_ids;
|
use super::x11::get_x11_device_ids;
|
||||||
|
|
@ -60,7 +65,12 @@ impl Compositor {
|
||||||
compatible_window: Option<W>,
|
compatible_window: Option<W>,
|
||||||
shell: Shell,
|
shell: Shell,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
#[cfg(all(
|
||||||
|
unix,
|
||||||
|
feature = "cctk",
|
||||||
|
not(target_os = "macos"),
|
||||||
|
not(target_os = "redox")
|
||||||
|
))]
|
||||||
let ids = compatible_window.as_ref().and_then(|window| {
|
let ids = compatible_window.as_ref().and_then(|window| {
|
||||||
get_wayland_device_ids(window)
|
get_wayland_device_ids(window)
|
||||||
.or_else(|| get_x11_device_ids(window))
|
.or_else(|| get_x11_device_ids(window))
|
||||||
|
|
@ -72,7 +82,12 @@ impl Compositor {
|
||||||
// 3. and the user didn't set an adapter name,
|
// 3. and the user didn't set an adapter name,
|
||||||
// 4. and the user didn't request the high power pref
|
// 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
|
// => 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(all(
|
||||||
|
unix,
|
||||||
|
feature = "cctk",
|
||||||
|
not(target_os = "macos"),
|
||||||
|
not(target_os = "redox")
|
||||||
|
))]
|
||||||
if !matches!(ids, Some((0x10de, _)))
|
if !matches!(ids, Some((0x10de, _)))
|
||||||
&& std::env::var_os("__NV_PRIME_RENDER_OFFLOAD")
|
&& std::env::var_os("__NV_PRIME_RENDER_OFFLOAD")
|
||||||
.is_none_or(|var| var == "0")
|
.is_none_or(|var| var == "0")
|
||||||
|
|
@ -133,6 +148,7 @@ impl Compositor {
|
||||||
if std::env::var_os("WGPU_ADAPTER_NAME").is_none() {
|
if std::env::var_os("WGPU_ADAPTER_NAME").is_none() {
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
unix,
|
unix,
|
||||||
|
feature = "cctk",
|
||||||
not(target_os = "macos"),
|
not(target_os = "macos"),
|
||||||
not(target_os = "redox")
|
not(target_os = "redox")
|
||||||
))]
|
))]
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ use cctk::sctk::{
|
||||||
};
|
};
|
||||||
use raw_window_handle::{RawDisplayHandle, WaylandDisplayHandle};
|
use raw_window_handle::{RawDisplayHandle, WaylandDisplayHandle};
|
||||||
use wayland_client::{
|
use wayland_client::{
|
||||||
backend::Backend, globals::registry_queue_init, protocol::wl_buffer,
|
Connection, QueueHandle, backend::Backend, globals::registry_queue_init,
|
||||||
Connection, QueueHandle,
|
protocol::wl_buffer,
|
||||||
};
|
};
|
||||||
use wayland_protocols::wp::linux_dmabuf::zv1::client::{
|
use wayland_protocols::wp::linux_dmabuf::zv1::client::{
|
||||||
zwp_linux_buffer_params_v1, zwp_linux_dmabuf_feedback_v1,
|
zwp_linux_buffer_params_v1, zwp_linux_dmabuf_feedback_v1,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ highlighter = ["dep:iced_highlighter"]
|
||||||
advanced = []
|
advanced = []
|
||||||
crisp = []
|
crisp = []
|
||||||
a11y = ["iced_accessibility"]
|
a11y = ["iced_accessibility"]
|
||||||
wayland = ["cctk", "iced_runtime/wayland"]
|
cctk = ["iced_runtime/cctk", "dep:cctk"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced_renderer.workspace = true
|
iced_renderer.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -14,18 +14,7 @@ keywords.workspace = true
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
wayland = [
|
wayland = ["winit/wayland", "wayland-csd-adwaita"]
|
||||||
"winit/wayland",
|
|
||||||
"cctk",
|
|
||||||
"wayland-protocols",
|
|
||||||
"raw-window-handle",
|
|
||||||
"iced_runtime/wayland",
|
|
||||||
"wayland-backend",
|
|
||||||
"xkbcommon",
|
|
||||||
"xkbcommon-dl",
|
|
||||||
"xkeysym",
|
|
||||||
"wayland-csd-adwaita",
|
|
||||||
]
|
|
||||||
default = ["x11", "wayland-dlopen"]
|
default = ["x11", "wayland-dlopen"]
|
||||||
debug = ["iced_debug/enable"]
|
debug = ["iced_debug/enable"]
|
||||||
sysinfo = ["dep:sysinfo"]
|
sysinfo = ["dep:sysinfo"]
|
||||||
|
|
@ -37,6 +26,17 @@ program = []
|
||||||
wayland-dlopen = ["winit/wayland-dlopen"]
|
wayland-dlopen = ["winit/wayland-dlopen"]
|
||||||
wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
|
wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
|
||||||
a11y = ["iced_accessibility", "iced_runtime/a11y"]
|
a11y = ["iced_accessibility", "iced_runtime/a11y"]
|
||||||
|
cctk = [
|
||||||
|
"wayland",
|
||||||
|
"wayland-protocols",
|
||||||
|
"raw-window-handle",
|
||||||
|
"iced_runtime/cctk",
|
||||||
|
"wayland-backend",
|
||||||
|
"xkbcommon",
|
||||||
|
"xkbcommon-dl",
|
||||||
|
"xkeysym",
|
||||||
|
"dep:cctk",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ pub fn window_attributes(
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
use winit::platform::wayland::WindowAttributesWayland;
|
use winit::platform::wayland::WindowAttributesWayland;
|
||||||
|
|
||||||
|
|
@ -424,7 +424,7 @@ pub fn window_event(
|
||||||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||||
Some(Event::Window(window::Event::Rescaled(scale_factor as f32)))
|
Some(Event::Window(window::Event::Rescaled(scale_factor as f32)))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
WindowEvent::SuggestedBounds(bounds) => {
|
WindowEvent::SuggestedBounds(bounds) => {
|
||||||
let size = bounds.map(|bounds| {
|
let size = bounds.map(|bounds| {
|
||||||
let size = bounds.to_logical(scale_factor);
|
let size = bounds.to_logical(scale_factor);
|
||||||
|
|
@ -437,7 +437,7 @@ pub fn window_event(
|
||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
WindowEvent::WindowStateChanged => {
|
WindowEvent::WindowStateChanged => {
|
||||||
use cctk::sctk::reexports::csd_frame::WindowState;
|
use cctk::sctk::reexports::csd_frame::WindowState;
|
||||||
use winit::platform::wayland::WindowExtWayland;
|
use winit::platform::wayland::WindowExtWayland;
|
||||||
|
|
@ -1491,7 +1491,7 @@ pub fn winit_key_code(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
fn winit_native_key_code(
|
fn winit_native_key_code(
|
||||||
keycode: keyboard::key::NativeCode,
|
keycode: keyboard::key::NativeCode,
|
||||||
) -> winit::keyboard::NativeKeyCode {
|
) -> winit::keyboard::NativeKeyCode {
|
||||||
|
|
@ -1515,7 +1515,7 @@ fn winit_native_key_code(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reconstruct the raw keycode
|
/// Reconstruct the raw keycode
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
pub fn physical_to_scancode(physical: keyboard::key::Physical) -> Option<u32> {
|
pub fn physical_to_scancode(physical: keyboard::key::Physical) -> Option<u32> {
|
||||||
let Some(physical_key) = (match physical {
|
let Some(physical_key) = (match physical {
|
||||||
keyboard::key::Physical::Code(code) => {
|
keyboard::key::Physical::Code(code) => {
|
||||||
|
|
|
||||||
|
|
@ -98,10 +98,10 @@ where
|
||||||
|
|
||||||
let event_loop = EventLoop::new().expect("Create event loop");
|
let event_loop = EventLoop::new().expect("Create event loop");
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
let is_wayland =
|
let is_wayland =
|
||||||
winit::platform::wayland::EventLoopExtWayland::is_wayland(&event_loop);
|
winit::platform::wayland::EventLoopExtWayland::is_wayland(&event_loop);
|
||||||
#[cfg(not(feature = "wayland"))]
|
#[cfg(not(all(feature = "cctk", target_os = "linux")))]
|
||||||
let is_wayland = false;
|
let is_wayland = false;
|
||||||
|
|
||||||
// TODO this is new..
|
// TODO this is new..
|
||||||
|
|
@ -193,7 +193,10 @@ where
|
||||||
error: Option<Error>,
|
error: Option<Error>,
|
||||||
system_theme: Option<oneshot::Sender<theme::Mode>>,
|
system_theme: Option<oneshot::Sender<theme::Mode>>,
|
||||||
control_sender: mpsc::UnboundedSender<Control>,
|
control_sender: mpsc::UnboundedSender<Control>,
|
||||||
|
|
||||||
|
#[cfg(feature = "a11y")]
|
||||||
|
adapters: std::collections::HashMap<window::Id, (u64, iced_accessibility::accesskit_winit::Adapter)>,
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
is_booted: std::rc::Rc<std::cell::RefCell<bool>>,
|
is_booted: std::rc::Rc<std::cell::RefCell<bool>>,
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
|
@ -216,6 +219,9 @@ where
|
||||||
error: None,
|
error: None,
|
||||||
system_theme: Some(system_theme_sender),
|
system_theme: Some(system_theme_sender),
|
||||||
|
|
||||||
|
#[cfg(feature = "a11y")]
|
||||||
|
adapters: Default::default(),
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
canvas: None,
|
canvas: None,
|
||||||
};
|
};
|
||||||
|
|
@ -257,7 +263,7 @@ where
|
||||||
| winit::event::WindowEvent::Moved(_)
|
| winit::event::WindowEvent::Moved(_)
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
if matches!(event, WindowEvent::RedrawRequested) {
|
if matches!(event, WindowEvent::RedrawRequested) {
|
||||||
for id in
|
for id in
|
||||||
|
|
@ -558,7 +564,7 @@ where
|
||||||
.expect("Send event");
|
.expect("Send event");
|
||||||
}
|
}
|
||||||
Control::Winit(id, e) => {
|
Control::Winit(id, e) => {
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
if matches!(e, WindowEvent::RedrawRequested)
|
if matches!(e, WindowEvent::RedrawRequested)
|
||||||
{
|
{
|
||||||
|
|
@ -621,22 +627,23 @@ where
|
||||||
proxy: self.control_sender.clone(),
|
proxy: self.control_sender.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.sender
|
_ = self.adapters.insert(
|
||||||
.start_send(Event::A11yAdapter(
|
id,
|
||||||
id,
|
(
|
||||||
(
|
node_id,
|
||||||
node_id,
|
Adapter::with_direct_handlers(
|
||||||
Adapter::with_direct_handlers(
|
event_loop,
|
||||||
event_loop,
|
window.as_ref(),
|
||||||
window.as_ref(),
|
activation_handler,
|
||||||
activation_handler,
|
action_handler,
|
||||||
action_handler,
|
deactivation_handler,
|
||||||
deactivation_handler,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
))
|
),
|
||||||
.expect("send event");
|
);
|
||||||
}
|
}
|
||||||
|
Control::Cleanup(id) => {
|
||||||
|
_ = self.adapters.remove(&id);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
break;
|
break;
|
||||||
|
|
@ -680,11 +687,11 @@ enum Event<Message: 'static> {
|
||||||
Accessibility(window::Id, iced_accessibility::accesskit::ActionRequest),
|
Accessibility(window::Id, iced_accessibility::accesskit::ActionRequest),
|
||||||
#[cfg(feature = "a11y")]
|
#[cfg(feature = "a11y")]
|
||||||
AccessibilityEnabled(bool),
|
AccessibilityEnabled(bool),
|
||||||
#[cfg(feature = "a11y")]
|
// #[cfg(feature = "a11y")]
|
||||||
A11yAdapter(
|
// A11yAdapter(
|
||||||
window::Id,
|
// window::Id,
|
||||||
(u64, iced_accessibility::accesskit_winit::Adapter),
|
// (u64, iced_accessibility::accesskit_winit::Adapter),
|
||||||
),
|
// ),
|
||||||
Winit(winit::window::WindowId, winit::event::WindowEvent),
|
Winit(winit::window::WindowId, winit::event::WindowEvent),
|
||||||
AboutToWait,
|
AboutToWait,
|
||||||
UserEvent(Action<Message>),
|
UserEvent(Action<Message>),
|
||||||
|
|
@ -697,6 +704,7 @@ enum Control {
|
||||||
ChangeFlow(winit::event_loop::ControlFlow),
|
ChangeFlow(winit::event_loop::ControlFlow),
|
||||||
Exit,
|
Exit,
|
||||||
Crash(Error),
|
Crash(Error),
|
||||||
|
Cleanup(window::Id),
|
||||||
CreateWindow {
|
CreateWindow {
|
||||||
id: window::Id,
|
id: window::Id,
|
||||||
settings: window::Settings,
|
settings: window::Settings,
|
||||||
|
|
@ -743,7 +751,7 @@ async fn run_instance<P>(
|
||||||
|
|
||||||
let mut platform_specific_handler =
|
let mut platform_specific_handler =
|
||||||
crate::platform_specific::PlatformSpecific::default();
|
crate::platform_specific::PlatformSpecific::default();
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
if is_wayland {
|
if is_wayland {
|
||||||
platform_specific_handler = platform_specific_handler.with_wayland(
|
platform_specific_handler = platform_specific_handler.with_wayland(
|
||||||
control_sender.clone(),
|
control_sender.clone(),
|
||||||
|
|
@ -774,7 +782,7 @@ async fn run_instance<P>(
|
||||||
let mut dnd_surface_id: Option<window::Id> = None;
|
let mut dnd_surface_id: Option<window::Id> = None;
|
||||||
|
|
||||||
#[cfg(feature = "a11y")]
|
#[cfg(feature = "a11y")]
|
||||||
let (mut adapters, mut a11y_enabled) = (Default::default(), false);
|
let mut a11y_enabled = false;
|
||||||
|
|
||||||
#[cfg(all(feature = "linux-theme-detection", target_os = "linux"))]
|
#[cfg(all(feature = "linux-theme-detection", target_os = "linux"))]
|
||||||
let mut system_theme = {
|
let mut system_theme = {
|
||||||
|
|
@ -836,7 +844,7 @@ async fn run_instance<P>(
|
||||||
control_sender
|
control_sender
|
||||||
.start_send(Control::InitAdapter(id, window.clone()))
|
.start_send(Control::InitAdapter(id, window.clone()))
|
||||||
.expect("Send control message");
|
.expect("Send control message");
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
platform_specific_handler.send_wayland(
|
platform_specific_handler.send_wayland(
|
||||||
platform_specific::Action::TrackWindow(window.clone(), id),
|
platform_specific::Action::TrackWindow(window.clone(), id),
|
||||||
);
|
);
|
||||||
|
|
@ -1012,7 +1020,7 @@ async fn run_instance<P>(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// XX must force update to corner radius before the surface is committed.
|
// XX must force update to corner radius before the surface is committed.
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
if (window.surface_version != window.state.surface_version()
|
if (window.surface_version != window.state.surface_version()
|
||||||
|| window.logical_size() != window.state.logical_size()
|
|| window.logical_size() != window.state.logical_size()
|
||||||
) && !crate::subsurface_widget::is_subsurface(window_id)
|
) && !crate::subsurface_widget::is_subsurface(window_id)
|
||||||
|
|
@ -1382,7 +1390,7 @@ async fn run_instance<P>(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let no_window_events = window_events.is_empty();
|
let no_window_events = window_events.is_empty();
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
window_events.push(core::Event::PlatformSpecific(
|
window_events.push(core::Event::PlatformSpecific(
|
||||||
core::event::PlatformSpecific::Wayland(
|
core::event::PlatformSpecific::Wayland(
|
||||||
core::event::wayland::Event::RequestResize,
|
core::event::wayland::Event::RequestResize,
|
||||||
|
|
@ -1646,8 +1654,6 @@ async fn run_instance<P>(
|
||||||
&mut window_manager,
|
&mut window_manager,
|
||||||
&mut user_interfaces,
|
&mut user_interfaces,
|
||||||
&mut clipboard,
|
&mut clipboard,
|
||||||
#[cfg(feature = "a11y")]
|
|
||||||
&mut adapters,
|
|
||||||
CreateCompositor {
|
CreateCompositor {
|
||||||
proxy: &proxy,
|
proxy: &proxy,
|
||||||
display_handle: &display_handle,
|
display_handle: &display_handle,
|
||||||
|
|
@ -1884,10 +1890,6 @@ async fn run_instance<P>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "a11y")]
|
|
||||||
Event::A11yAdapter(id, adapter) => {
|
|
||||||
_ = adapters.insert(id, adapter);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2124,8 +2126,9 @@ where
|
||||||
window::Action::Close(id) => {
|
window::Action::Close(id) => {
|
||||||
let _ = ui_caches.remove(&id);
|
let _ = ui_caches.remove(&id);
|
||||||
let _ = interfaces.remove(&id);
|
let _ = interfaces.remove(&id);
|
||||||
|
_ = control_sender.start_send(Control::Cleanup(id)).ok();
|
||||||
let proxy = clipboard.proxy();
|
let proxy = clipboard.proxy();
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
platform_specific
|
platform_specific
|
||||||
.send_wayland(platform_specific::Action::RemoveWindow(id));
|
.send_wayland(platform_specific::Action::RemoveWindow(id));
|
||||||
if let Some(window) = window_manager.remove(id) {
|
if let Some(window) = window_manager.remove(id) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use std::{borrow::Cow, collections::HashMap, sync::Arc};
|
use std::{borrow::Cow, collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
use cctk::sctk::reexports::client::Connection;
|
use cctk::sctk::reexports::client::Connection;
|
||||||
use iced_graphics::{Compositor, compositor};
|
use iced_graphics::{Compositor, compositor};
|
||||||
use iced_runtime::{
|
use iced_runtime::{
|
||||||
|
|
@ -12,12 +12,12 @@ use iced_runtime::{
|
||||||
};
|
};
|
||||||
use winit::raw_window_handle::HasWindowHandle;
|
use winit::raw_window_handle::HasWindowHandle;
|
||||||
|
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
pub mod wayland;
|
pub mod wayland;
|
||||||
|
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
pub use wayland::*;
|
pub use wayland::*;
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
use wayland_backend::client::Backend;
|
use wayland_backend::client::Backend;
|
||||||
|
|
||||||
use crate::{CreateCompositor, Program, WindowManager};
|
use crate::{CreateCompositor, Program, WindowManager};
|
||||||
|
|
@ -35,7 +35,7 @@ pub type UserInterfaces<'a, P> = HashMap<
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
Wayland(sctk_event::SctkEvent),
|
Wayland(sctk_event::SctkEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ impl SurfaceIdWrapper {
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct PlatformSpecific {
|
pub struct PlatformSpecific {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
wayland: WaylandSpecific,
|
wayland: WaylandSpecific,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ impl PlatformSpecific {
|
||||||
action: iced_runtime::platform_specific::Action,
|
action: iced_runtime::platform_specific::Action,
|
||||||
) {
|
) {
|
||||||
match action {
|
match action {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
iced_runtime::platform_specific::Action::Wayland(a) => {
|
iced_runtime::platform_specific::Action::Wayland(a) => {
|
||||||
self.send_wayland(wayland::Action::Action(a));
|
self.send_wayland(wayland::Action::Action(a));
|
||||||
}
|
}
|
||||||
|
|
@ -82,14 +82,14 @@ impl PlatformSpecific {
|
||||||
&mut self,
|
&mut self,
|
||||||
keep: F,
|
keep: F,
|
||||||
) {
|
) {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
self.wayland.retain_subsurfaces(keep);
|
self.wayland.retain_subsurfaces(keep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clear_subsurface_list(&mut self) {
|
pub(crate) fn clear_subsurface_list(&mut self) {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
self.wayland.clear_subsurface_list();
|
self.wayland.clear_subsurface_list();
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ impl PlatformSpecific {
|
||||||
id: window::Id,
|
id: window::Id,
|
||||||
window: &dyn HasWindowHandle,
|
window: &dyn HasWindowHandle,
|
||||||
) {
|
) {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
use cctk::sctk::reexports::client::{
|
use cctk::sctk::reexports::client::{
|
||||||
Proxy, protocol::wl_surface::WlSurface,
|
Proxy, protocol::wl_surface::WlSurface,
|
||||||
|
|
@ -151,7 +151,7 @@ impl PlatformSpecific {
|
||||||
pub(crate) fn create_surface(
|
pub(crate) fn create_surface(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Option<Box<dyn HasWindowHandle + Send + Sync + 'static>> {
|
) -> Option<Box<dyn HasWindowHandle + Send + Sync + 'static>> {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
return self.wayland.create_surface();
|
return self.wayland.create_surface();
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ impl PlatformSpecific {
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
offset: Vector,
|
offset: Vector,
|
||||||
) {
|
) {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
{
|
{
|
||||||
return self.wayland.update_surface_shm(
|
return self.wayland.update_surface_shm(
|
||||||
surface, width, height, scale, data, offset,
|
surface, width, height, scale, data, offset,
|
||||||
|
|
@ -190,16 +190,12 @@ pub(crate) async fn handle_event<'a, 'b, P>(
|
||||||
>,
|
>,
|
||||||
user_interfaces: &mut UserInterfaces<'a, P>,
|
user_interfaces: &mut UserInterfaces<'a, P>,
|
||||||
clipboard: &mut crate::Clipboard,
|
clipboard: &mut crate::Clipboard,
|
||||||
#[cfg(feature = "a11y")] adapters: &mut std::collections::HashMap<
|
|
||||||
window::Id,
|
|
||||||
(u64, iced_accessibility::accesskit_winit::Adapter),
|
|
||||||
>,
|
|
||||||
create_compositor: CreateCompositor<'b, P>,
|
create_compositor: CreateCompositor<'b, P>,
|
||||||
) where
|
) where
|
||||||
P: Program,
|
P: Program,
|
||||||
{
|
{
|
||||||
match e {
|
match e {
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||||
Event::Wayland(e) => {
|
Event::Wayland(e) => {
|
||||||
platform_specific
|
platform_specific
|
||||||
.wayland
|
.wayland
|
||||||
|
|
@ -211,8 +207,6 @@ pub(crate) async fn handle_event<'a, 'b, P>(
|
||||||
window_manager,
|
window_manager,
|
||||||
user_interfaces,
|
user_interfaces,
|
||||||
clipboard,
|
clipboard,
|
||||||
#[cfg(feature = "a11y")]
|
|
||||||
adapters,
|
|
||||||
create_compositor,
|
create_compositor,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
||||||
|
|
@ -164,10 +164,6 @@ impl WaylandSpecific {
|
||||||
>,
|
>,
|
||||||
user_interfaces: &mut UserInterfaces<'a, P>,
|
user_interfaces: &mut UserInterfaces<'a, P>,
|
||||||
clipboard: &mut crate::Clipboard,
|
clipboard: &mut crate::Clipboard,
|
||||||
#[cfg(feature = "a11y")] adapters: &mut HashMap<
|
|
||||||
window::Id,
|
|
||||||
(u64, iced_accessibility::accesskit_winit::Adapter),
|
|
||||||
>,
|
|
||||||
create_compositor: CreateCompositor<'b, P>,
|
create_compositor: CreateCompositor<'b, P>,
|
||||||
) where
|
) where
|
||||||
P: Program,
|
P: Program,
|
||||||
|
|
@ -213,8 +209,6 @@ impl WaylandSpecific {
|
||||||
events,
|
events,
|
||||||
clipboard,
|
clipboard,
|
||||||
subsurface_state,
|
subsurface_state,
|
||||||
#[cfg(feature = "a11y")]
|
|
||||||
adapters,
|
|
||||||
create_compositor,
|
create_compositor,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
||||||
|
|
@ -361,10 +361,6 @@ impl SctkEvent {
|
||||||
events: &mut Vec<(Option<window::Id>, iced_runtime::core::Event)>,
|
events: &mut Vec<(Option<window::Id>, iced_runtime::core::Event)>,
|
||||||
clipboard: &mut Clipboard,
|
clipboard: &mut Clipboard,
|
||||||
subsurface_state: &mut Option<SubsurfaceState>,
|
subsurface_state: &mut Option<SubsurfaceState>,
|
||||||
#[cfg(feature = "a11y")] adapters: &mut HashMap<
|
|
||||||
window::Id,
|
|
||||||
(u64, iced_accessibility::accesskit_winit::Adapter),
|
|
||||||
>,
|
|
||||||
create_compositor_data: CreateCompositor<'b, P>,
|
create_compositor_data: CreateCompositor<'b, P>,
|
||||||
) where
|
) where
|
||||||
P: Program,
|
P: Program,
|
||||||
|
|
@ -472,8 +468,7 @@ impl SctkEvent {
|
||||||
x: -horizontal.value120 as f32 / 120.,
|
x: -horizontal.value120 as f32 / 120.,
|
||||||
y: -vertical.value120 as f32 / 120.,
|
y: -vertical.value120 as f32 / 120.,
|
||||||
}
|
}
|
||||||
} else if horizontal.discrete != 0
|
} else if horizontal.discrete != 0 || vertical.discrete != 0
|
||||||
|| vertical.discrete != 0
|
|
||||||
{
|
{
|
||||||
mouse::ScrollDelta::Lines {
|
mouse::ScrollDelta::Lines {
|
||||||
x: -horizontal.discrete as f32,
|
x: -horizontal.discrete as f32,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue