From cb51336a5de1227a024fd019989d44c1771090a2 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 25 Sep 2023 10:43:33 -0400 Subject: [PATCH] chore: update sctk fixes sctk_drag example --- core/Cargo.toml | 2 +- examples/sctk_drag/Cargo.toml | 2 +- examples/sctk_drag/src/main.rs | 1 + examples/sctk_todos/Cargo.toml | 2 +- runtime/Cargo.toml | 2 +- sctk/Cargo.toml | 6 +++--- sctk/src/application.rs | 6 +++++- sctk/src/event_loop/mod.rs | 18 ++++++++++-------- sctk/src/event_loop/state.rs | 6 ++---- sctk/src/handlers/data_device/data_source.rs | 5 ++--- widget/Cargo.toml | 2 +- 11 files changed, 28 insertions(+), 24 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 272b5039e2..cf183fb19b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,7 +16,7 @@ bitflags = "1.2" thiserror = "1" log = "0.4.17" twox-hash = { version = "1.5", default-features = false } -sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "f49df45", optional = true } +sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "dc8c4a0", optional = true } [dependencies.palette] version = "0.7" diff --git a/examples/sctk_drag/Cargo.toml b/examples/sctk_drag/Cargo.toml index 87954cd8d6..49422ca62b 100644 --- a/examples/sctk_drag/Cargo.toml +++ b/examples/sctk_drag/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "f49df45" } +sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "dc8c4a0" } iced = { path = "../..", default-features = false, features = ["wayland", "debug", "a11y"] } iced_style = { path = "../../style" } env_logger = "0.10" diff --git a/examples/sctk_drag/src/main.rs b/examples/sctk_drag/src/main.rs index 8e7bb5cfbc..874a2b0c5f 100644 --- a/examples/sctk_drag/src/main.rs +++ b/examples/sctk_drag/src/main.rs @@ -267,6 +267,7 @@ impl iced_style::application::StyleSheet for CustomTheme { fn appearance(&self, style: &Self::Style) -> application::Appearance { iced_style::application::Appearance { background_color: Color::from_rgba(1.0, 0.0, 1.0, 1.0), + icon_color: Color::BLACK, text_color: Color::from_rgb(0.0, 1.0, 0.0), } } diff --git a/examples/sctk_todos/Cargo.toml b/examples/sctk_todos/Cargo.toml index 009eab54ed..b779f6026e 100644 --- a/examples/sctk_todos/Cargo.toml +++ b/examples/sctk_todos/Cargo.toml @@ -10,7 +10,7 @@ iced = { path = "../..", default-features=false, features = ["async-std", "wayla serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" once_cell = "1.15" -sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "f49df45" } +sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "dc8c4a0" } iced_style = { path = "../../style" } log = "0.4.17" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e71981d8cd..861dd8f557 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -14,7 +14,7 @@ wayland = ["iced_accessibility?/accesskit_unix", "iced_core/wayland", "sctk"] [dependencies] thiserror = "1" -sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "f49df45", optional = true } +sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "dc8c4a0", optional = true } [dependencies.iced_core] version = "0.10" diff --git a/sctk/Cargo.toml b/sctk/Cargo.toml index 375b42424f..e462dc7a36 100644 --- a/sctk/Cargo.toml +++ b/sctk/Cargo.toml @@ -15,13 +15,13 @@ a11y = ["iced_accessibility", "iced_runtime/a11y"] [dependencies] tracing = "0.1" thiserror = "1.0" -sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "f49df45" } -wayland-protocols = { version = "0.30.0", features = [ "staging"]} +sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "dc8c4a0" } +wayland-protocols = { version = "0.31.0", features = [ "staging"]} # sctk = { package = "smithay-client-toolkit", path = "../../fork/client-toolkit/" } raw-window-handle = "0.5" enum-repr = "0.2" futures = "0.3" -wayland-backend = {version = "0.1.0", features = ["client_system"]} +wayland-backend = {version = "0.3.1", features = ["client_system"]} float-cmp = "0.9" smithay-clipboard = "0.6" accesskit = { version = "0.8.1", optional = true } diff --git a/sctk/src/application.rs b/sctk/src/application.rs index cab42bdc17..ca2f91102e 100644 --- a/sctk/src/application.rs +++ b/sctk/src/application.rs @@ -255,7 +255,11 @@ where .create_surface(&event_loop.state.queue_handle); // let (display, context, config, surface) = init_egl(&wl_surface, 100, 100); - let backend = event_loop.state.connection.backend(); + let backend = event_loop + .wayland_dispatcher + .as_source_ref() + .connection() + .backend(); let qh = event_loop.state.queue_handle.clone(); let wrapper = SurfaceDisplayWrapper:: { comp_surface: None, diff --git a/sctk/src/event_loop/mod.rs b/sctk/src/event_loop/mod.rs index 88c8752baf..c19cecbdb7 100644 --- a/sctk/src/event_loop/mod.rs +++ b/sctk/src/event_loop/mod.rs @@ -29,7 +29,6 @@ use iced_runtime::command::platform_specific::{ window::SctkWindowSettings, }, }; -use sctk::data_device_manager::data_source::DragSource; use sctk::{ compositor::CompositorState, data_device_manager::DataDeviceManagerState, @@ -38,7 +37,7 @@ use sctk::{ calloop::{self, EventLoop}, client::{ globals::registry_queue_init, protocol::wl_surface::WlSurface, - ConnectError, Connection, DispatchError, Proxy, WaylandSource, + ConnectError, Connection, DispatchError, Proxy, }, }, registry::RegistryState, @@ -46,6 +45,10 @@ use sctk::{ shell::{wlr_layer::LayerShell, xdg::XdgShell, WaylandSurface}, shm::Shm, }; +use sctk::{ + data_device_manager::data_source::DragSource, + reexports::calloop_wayland_source::WaylandSource, +}; #[cfg(feature = "a11y")] use std::sync::{Arc, Mutex}; use std::{ @@ -121,7 +124,7 @@ where calloop::channel::Event::Closed => {} }) .unwrap(); - let wayland_source = WaylandSource::new(event_queue).unwrap(); + let wayland_source = WaylandSource::new(connection, event_queue); let wayland_dispatcher = calloop::Dispatcher::new( wayland_source, @@ -162,7 +165,6 @@ where event_loop, wayland_dispatcher, state: SctkState { - connection, registry_state, seat_state: SeatState::new(&globals, &qh), output_state: OutputState::new(&globals, &qh), @@ -306,7 +308,7 @@ where // Still, we set the exit code to the error's OS error code, or to 1 if not possible. let exit_code = loop { // Send pending events to the server. - match self.state.connection.flush() { + match self.wayland_dispatcher.as_source_ref().connection().flush() { Ok(_) => {} Err(error) => { break match error { @@ -748,7 +750,7 @@ where Event::SetCursor(iced_icon) => { if let Some(ptr) = self.state.seats.get(0).and_then(|s| s.ptr.as_ref()) { let icon = conversion::cursor_icon(iced_icon); - let _ = ptr.set_cursor(&self.state.connection, icon); + let _ = ptr.set_cursor(&self.wayland_dispatcher.as_source_ref().connection(), icon); } } @@ -1164,7 +1166,7 @@ where Some(s) => s, None => return, }; - let mut reader = BufReader::new(f); + let mut reader = BufReader::new(f.as_ref()); let consumed = match reader.fill_buf() { Ok(buf) => { if buf.is_empty() { @@ -1222,7 +1224,7 @@ where Some(s) => s, None => return, }; - let mut reader = BufReader::new(f); + let mut reader = BufReader::new(f.as_ref()); let consumed = match reader.fill_buf() { Ok(buf) => { if buf.is_empty() { diff --git a/sctk/src/event_loop/state.rs b/sctk/src/event_loop/state.rs index d2773685d7..4a3e519d3a 100644 --- a/sctk/src/event_loop/state.rs +++ b/sctk/src/event_loop/state.rs @@ -1,5 +1,4 @@ use std::{ - collections::HashMap, fmt::{Debug, Formatter}, num::NonZeroU32, }; @@ -13,7 +12,7 @@ use crate::{ }, sctk_event::{ LayerSurfaceEventVariant, PopupEventVariant, SctkEvent, - SurfaceCompositorUpdate, WindowEventVariant, + WindowEventVariant, }, }; @@ -50,7 +49,7 @@ use sctk::{ wl_surface::{self, WlSurface}, wl_touch::WlTouch, }, - Connection, QueueHandle, + QueueHandle, }, }, registry::RegistryState, @@ -334,7 +333,6 @@ pub struct SctkState { pub(crate) xdg_shell_state: XdgShell, pub(crate) layer_shell: Option, pub(crate) data_device_manager_state: DataDeviceManagerState, - pub(crate) connection: Connection, pub(crate) token_ctr: u32, } diff --git a/sctk/src/handlers/data_device/data_source.rs b/sctk/src/handlers/data_device/data_source.rs index 673d58626f..4de6343359 100644 --- a/sctk/src/handlers/data_device/data_source.rs +++ b/sctk/src/handlers/data_device/data_source.rs @@ -10,7 +10,6 @@ use sctk::{ Connection, QueueHandle, }, }; -use std::fmt::Debug; use std::io::{BufWriter, Write}; use tracing::error; @@ -74,7 +73,7 @@ impl DataSourceHandler for SctkState { Some(s) => s, None => return, }; - let mut writer = BufWriter::new(f); + let mut writer = BufWriter::new(f.as_ref()); let slice = &data.as_slice()[cur_index ..(cur_index + writer.capacity()).min(data.len())]; match writer.write(slice) { @@ -142,7 +141,7 @@ impl DataSourceHandler for SctkState { Some(s) => s, None => return, }; - let mut writer = BufWriter::new(f); + let mut writer = BufWriter::new(f.as_ref()); let slice = &data.as_slice()[cur_index ..(cur_index + writer.capacity()).min(data.len())]; match writer.write(slice) { diff --git a/widget/Cargo.toml b/widget/Cargo.toml index 1018dc6b93..1170b18758 100644 --- a/widget/Cargo.toml +++ b/widget/Cargo.toml @@ -22,7 +22,7 @@ wayland = ["sctk"] [dependencies] unicode-segmentation = "1.6" num-traits = "0.2" -sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "f49df45", optional = true } +sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "dc8c4a0", optional = true } thiserror = "1" [dependencies.iced_runtime]