Skip to content

Commit

Permalink
refactor: disable wayland in winit shell by default
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Oct 21, 2024
1 parent ec8f7a7 commit 4dd4cfb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
4 changes: 3 additions & 1 deletion winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords.workspace = true
workspace = true

[features]
default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
default = ["x11"]
debug = ["iced_runtime/debug"]
system = ["sysinfo"]
program = []
Expand All @@ -30,6 +30,8 @@ wayland = [
"xkbcommon-dl",
"xkeysym",
"iced_runtime/wayland",
"wayland-dlopen",
"wayland-csd-adwaita",
]
wayland-dlopen = ["winit/wayland-dlopen"]
wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
Expand Down
22 changes: 17 additions & 5 deletions winit/src/platform_specific/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//! Wayland specific shell
//!
use std::collections::HashMap;

use iced_graphics::Compositor;
use iced_runtime::{core::window, platform_specific, Debug};
use sctk::reexports::client::Connection;
use wayland::sctk_event::UserInterfaces;
use iced_runtime::{core::window, user_interface, Debug};

#[cfg(all(feature = "wayland", target_os = "linux"))]
pub mod wayland;

#[cfg(all(feature = "wayland", target_os = "linux"))]
pub use wayland::*;
#[cfg(all(feature = "wayland", target_os = "linux"))]
use wayland_backend::client::Backend;

use crate::{program::WindowManager, Program};
Expand Down Expand Up @@ -52,7 +53,7 @@ impl PlatformSpecific {
) {
match action {
#[cfg(all(feature = "wayland", target_os = "linux"))]
platform_specific::Action::Wayland(a) => {
iced_runtime::platform_specific::Action::Wayland(a) => {
self.send_wayland(wayland::Action::Action(a));
}
}
Expand Down Expand Up @@ -92,7 +93,7 @@ impl PlatformSpecific {
wayland_display_handle.display.as_ptr().cast(),
)
};
Connection::from_backend(backend)
sctk::reexports::client::Connection::from_backend(backend)
}
_ => {
return;
Expand Down Expand Up @@ -136,6 +137,17 @@ impl PlatformSpecific {
}
}

pub type UserInterfaces<'a, P> = HashMap<
window::Id,
user_interface::UserInterface<
'a,
<P as Program>::Message,
<P as Program>::Theme,
<P as Program>::Renderer,
>,
rustc_hash::FxBuildHasher,
>;

pub(crate) fn handle_event<'a, P, C>(
e: Event,
events: &mut Vec<(Option<window::Id>, iced_runtime::core::Event)>,
Expand Down
3 changes: 1 addition & 2 deletions winit/src/platform_specific/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use sctk::reexports::calloop;
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::seat::keyboard::Modifiers;
use sctk_event::SctkEvent;
use sctk_event::UserInterfaces;
use std::{collections::HashMap, sync::Arc};
use subsurface_widget::{SubsurfaceInstance, SubsurfaceState};
use wayland_backend::client::ObjectId;
Expand Down Expand Up @@ -128,7 +127,7 @@ impl WaylandSpecific {
compositor: &mut C,
window_manager: &mut WindowManager<P, C>,
debug: &mut Debug,
user_interfaces: &mut UserInterfaces<'a, P>,
user_interfaces: &mut super::UserInterfaces<'a, P>,
clipboard: &mut crate::Clipboard,
#[cfg(feature = "a11y")] adapters: &mut HashMap<
window::Id,
Expand Down
12 changes: 1 addition & 11 deletions winit/src/platform_specific/wayland/sctk_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,6 @@ pub struct SurfaceCompositorUpdate {
/// New scale factor.
pub scale_factor: Option<i32>,
}
pub type UserInterfaces<'a, P> = HashMap<
SurfaceId,
user_interface::UserInterface<
'a,
<P as Program>::Message,
<P as Program>::Theme,
<P as Program>::Renderer,
>,
rustc_hash::FxBuildHasher,
>;

impl SctkEvent {
pub(crate) fn process<'a, P, C>(
Expand All @@ -305,7 +295,7 @@ impl SctkEvent {
control_sender: &mpsc::UnboundedSender<Control>,
proxy: &EventLoopProxy,
debug: &mut Debug,
user_interfaces: &mut UserInterfaces<'a, P>,
user_interfaces: &mut crate::platform_specific::UserInterfaces<'a, P>,
events: &mut Vec<(Option<window::Id>, iced_runtime::core::Event)>,
clipboard: &mut Clipboard,
subsurface_state: &mut Option<SubsurfaceState>,
Expand Down

0 comments on commit 4dd4cfb

Please sign in to comment.