Skip to content

Commit

Permalink
feat: sctk shell
Browse files Browse the repository at this point in the history
fix: quad rendering including border only inside of the bounds

fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)

cleanup: fix & format

fix: use iced_core::Font

cleanup

fix: allow leaving out winit & iced-sctk

fix: settings

fix: slider draw improvements

fix: websocket example

fix: modal example

fix: scrollable example

fix: toast example

fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces

fix: todos panic

fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples

wip (iced-sctk): window resize with icons

feat (iced-sctk): support for setting cursor

refactor: default decorations to client

fix: set window geometry after receiving configure

fix: size limits with no max bound must be cut off

fix: send size update when autosized surface resizes

fix: use ceil size for positioner

cleanup: remove dbg statement

fix: remove a destroyed surface from compositor surfaces

fix errors after rebase and wip scaling support

fix: handling of scale factor in set_logical_size

fix (sctk_drag example): add .into for border radius

fix: fractional scaling

sctk: Fire RedrawRequests

wip: animations via frame event

fix / refactor iced-sctk redraw & frame event handling

cleanup: note about frame request in iced-sctk

fix: send resize when necessary for layer surface and popups too

fix: always request redraw for a new surface

fix: scaling and autosize surface improvements

refactor: sctk_lazy keyboard interactivity

feat(sctk): configurable natural_scroll property

feat: send state and capabilities events when there are changes

fix: redraw when an update is needed and clean up the logic

Update sctk to latest commit

Fix compilation of sctk drag example

fix(sctk): update interface before checking if it has a redraw request

refactor: after autosize surface resize wait to redraw until the resize has been applied

refactor: better handling of autosize surfaces

chore: update sctk

chore: update sctk

fixes sctk_drag example

fix: default to ControlFlow::Wait for applications with no surface

this seems to help CPU usage for app library and launcher

default to 250ms timeout in the event loop

Update sctk

sctk: Implement xdg-activation support

fix: don't require Flags to be clone for settings on wayland

chore: error if neither winit or wayland feature is set

chore: Allow compiling without windowing system (#65)

fix(iced-sctk): handle exit_on_close_request

fix: make sure that each widget operation operates on every interface

This should be ok even for widget actions like focus next because there can only ever be a single focused widget

cargo fmt

cleanup: dbg statement

fix(iced-sctk): replace panic with handling for remaining enum variants

refactor: use iced clipboard for interacting with the selection

refactor: allow passing an activation token when creating a window

sctk: Add support for `ext-session-lock` protocol

fix(sctk): build and use tree for layout of autosize surfaces

Update winit to latest commit used by upstream iced
  • Loading branch information
wash2 committed Dec 7, 2023
1 parent 11d7dee commit 983d811
Show file tree
Hide file tree
Showing 119 changed files with 13,947 additions and 251 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Many thanks to...
- @akshayr-mecha
- @dtzxporter

Many thanks to...
- @jackpot51
- @wash2

## [0.10.0] - 2023-07-28
### Added
- Text shaping, font fallback, and `iced_wgpu` overhaul. [#1697](https://github.com/iced-rs/iced/pull/1697)
Expand Down
19 changes: 12 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ all-features = true
maintenance = { status = "actively-developed" }

[features]
default = ["wgpu", "winit", "a11y", "multi-window"]
# Enable the `wgpu` GPU-accelerated renderer backend
wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"]
# Enables the `Image` widget
Expand All @@ -32,7 +31,7 @@ qr_code = ["iced_widget/qr_code"]
# Enables lazy widgets
lazy = ["iced_widget/lazy"]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]
debug = ["iced_winit?/debug", "iced_sctk?/debug"]
# Enables `tokio` as the `executor::Default` on native platforms
tokio = ["iced_futures/tokio"]
# Enables `async-std` as the `executor::Default` on native platforms
Expand All @@ -41,22 +40,22 @@ async-std = ["iced_futures/async-std"]
smol = ["iced_futures/smol"]
# Enables advanced color conversion via `palette`
palette = ["iced_core/palette"]
# Enables querying system information
system = ["iced_winit/system"]
# Enables broken "sRGB linear" blending to reproduce color management of the Web
web-colors = ["iced_renderer/web-colors"]
# Enables the WebGL backend, replacing WebGPU
webgl = ["iced_renderer/webgl"]
# Enables the syntax `highlighter` module
highlighter = ["iced_highlighter"]
# Enables experimental multi-window support.
multi-window = ["iced_winit/multi-window"]
multi-window = ["iced_winit?/multi-window"]
# Enables the advanced module
advanced = []
# Enables the `accesskit` accessibility library
a11y = ["iced_accessibility", "iced_core/a11y", "iced_widget/a11y", "iced_winit?/a11y"]
a11y = ["iced_accessibility", "iced_core/a11y", "iced_widget/a11y", "iced_winit?/a11y", "iced_sctk?/a11y"]
# Enables the winit shell. Conflicts with `wayland` and `glutin`.
winit = ["iced_winit", "iced_accessibility?/accesskit_winit"]
# Enables the sctk shell. COnflicts with `winit` and `glutin`.
wayland = ["iced_sctk", "iced_widget/wayland", "iced_accessibility?/accesskit_unix", "iced_core/wayland", "multi-window"]

[dependencies]
iced_core.workspace = true
Expand All @@ -66,6 +65,8 @@ iced_widget.workspace = true
iced_winit.features = ["application"]
iced_winit.workspace = true
iced_winit.optional = true
iced_sctk.workspace = true
iced_sctk.optional = true
iced_highlighter.workspace = true
iced_highlighter.optional = true
iced_accessibility.workspace = true
Expand All @@ -90,6 +91,7 @@ members = [
"winit",
"examples/*",
"accessibility",
"sctk"
]

[profile.release-opt]
Expand Down Expand Up @@ -125,6 +127,7 @@ iced_tiny_skia = { version = "0.12", path = "tiny_skia" }
iced_wgpu = { version = "0.12", path = "wgpu" }
iced_widget = { version = "0.12", path = "widget" }
iced_winit = { version = "0.12", path = "winit", features = ["application"] }
iced_sctk = { version = "0.1", path = "sctk" }
iced_accessibility = { version = "0.1", path = "accessibility" }

async-std = "1.0"
Expand All @@ -151,8 +154,9 @@ qrcode = { version = "0.12", default-features = false }
raw-window-handle = "0.5"
resvg = "0.36"
rustc-hash = "1.0"
sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "2e9bf9f" }
smol = "1.0"
softbuffer = "0.2"
softbuffer = { git = "https://github.com/pop-os/softbuffer", tag = "cosmic-2.0-old" }
syntect = "5.1"
sysinfo = "0.28"
thiserror = "1.0"
Expand All @@ -163,6 +167,7 @@ xxhash-rust = { version = "0.8", features = ["xxh3"] }
unicode-segmentation = "1.0"
wasm-bindgen-futures = "0.4"
wasm-timer = "0.2"
wayland-protocols = { version = "0.31.0", features = [ "staging"]}
web-sys = "0.3"
wgpu = "0.18"
winapi = "0.3"
Expand Down
4 changes: 3 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ keywords.workspace = true

[features]
a11y = ["iced_accessibility"]
wayland = ["iced_accessibility?/accesskit_unix", "sctk"]

[dependencies]
bitflags.workspace = true
log.workspace = true
thiserror.workspace = true
xxhash-rust.workspace = true
num-traits.workspace = true

sctk.workspace = true
sctk.optional = true
palette.workspace = true
palette.optional = true

Expand Down
6 changes: 3 additions & 3 deletions core/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ where

fn layout(
&self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
_tree: &mut Tree,
_renderer: &Renderer,
_limits: &layout::Limits,
) -> layout::Node {
todo!()
}
Expand Down
6 changes: 4 additions & 2 deletions core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use crate::keyboard;
use crate::mouse;
use crate::touch;
use crate::window;

#[cfg(feature = "wayland")]
/// A platform specific event for wayland
pub mod wayland;
/// A user interface event.
///
/// _**Note:** This type is largely incomplete! If you need to track
Expand Down Expand Up @@ -36,7 +38,7 @@ pub enum Event {
}

/// A platform specific event
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq)]
pub enum PlatformSpecific {
/// A Wayland specific event
#[cfg(feature = "wayland")]
Expand Down
141 changes: 141 additions & 0 deletions core/src/event/wayland/data_device.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
use sctk::{
data_device_manager::{data_offer::DragOffer, ReadPipe},
reexports::client::protocol::wl_data_device_manager::DndAction,
};
use std::{
os::fd::{AsRawFd, OwnedFd, RawFd},
sync::{Arc, Mutex},
};

/// Dnd Offer events
#[derive(Debug, Clone, PartialEq)]
pub enum DndOfferEvent {
/// A DnD offer has been introduced with the given mime types.
Enter {
/// x coordinate of the offer
x: f64,
/// y coordinate of the offer
y: f64,
/// The offered mime types
mime_types: Vec<String>,
},
/// The DnD device has left.
Leave,
/// Drag and Drop Motion event.
Motion {
/// x coordinate of the pointer
x: f64,
/// y coordinate of the pointer
y: f64,
},
/// The selected DnD action
SelectedAction(DndAction),
/// The offered actions for the current DnD offer
SourceActions(DndAction),
/// Dnd Drop event
DropPerformed,
/// Raw DnD Data
DndData {
/// The data
data: Vec<u8>,
/// The mime type of the data
mime_type: String,
},
/// Raw Selection Data
SelectionData {
/// The data
data: Vec<u8>,
/// The mime type of the data
mime_type: String,
},
/// Selection Offer
/// a selection offer has been introduced with the given mime types.
SelectionOffer(Vec<String>),
}

/// Selection Offer events
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SelectionOfferEvent {
/// a selection offer has been introduced with the given mime types.
Offer(Vec<String>),
/// Read the Selection data
Data {
/// The mime type that the selection should be converted to.
mime_type: String,
/// The data
data: Vec<u8>,
},
}

/// A ReadPipe and the mime type of the data.
#[derive(Debug, Clone)]
pub struct ReadData {
/// mime type of the data
pub mime_type: String,
/// The pipe to read the data from
pub fd: Arc<Mutex<ReadPipe>>,
}

impl ReadData {
/// Create a new ReadData
pub fn new(mime_type: String, fd: Arc<Mutex<ReadPipe>>) -> Self {
Self { mime_type, fd }
}
}

/// Data Source events
/// Includes drag and drop events and clipboard events
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataSourceEvent {
/// A Dnd action was selected by the compositor for your source.
DndActionAccepted(DndAction),
/// A mime type was accepted by a client for your source.
MimeAccepted(Option<String>),
/// Some client has requested the DnD data.
/// This is used to send the data to the client.
SendDndData(String),
/// Some client has requested the selection data.
/// This is used to send the data to the client.
SendSelectionData(String),
/// The data source has been cancelled and is no longer valid.
/// This may be sent for multiple reasons
Cancelled,
/// Dnd Finished
DndFinished,
/// Dnd Drop event
DndDropPerformed,
}

/// A WriteData and the mime type of the data to be written.
#[derive(Debug, Clone)]
pub struct WriteData {
/// mime type of the data
pub mime_type: String,
/// The fd to write the data to
pub fd: Arc<Mutex<OwnedFd>>,
}

impl WriteData {
/// Create a new WriteData
pub fn new(mime_type: String, fd: Arc<Mutex<OwnedFd>>) -> Self {
Self { mime_type, fd }
}
}

impl PartialEq for WriteData {
fn eq(&self, other: &Self) -> bool {
self.fd.lock().unwrap().as_raw_fd()
== other.fd.lock().unwrap().as_raw_fd()
}
}

impl Eq for WriteData {}

impl PartialEq for ReadData {
fn eq(&self, other: &Self) -> bool {
self.fd.lock().unwrap().as_raw_fd()
== other.fd.lock().unwrap().as_raw_fd()
}
}

impl Eq for ReadData {}
10 changes: 10 additions & 0 deletions core/src/event/wayland/layer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// layer surface events
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LayerEvent {
/// layer surface Done
Done,
/// layer surface focused
Focused,
/// layer_surface unfocused
Unfocused,
}
45 changes: 45 additions & 0 deletions core/src/event/wayland/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
mod data_device;
mod layer;
mod output;
mod popup;
mod seat;
mod session_lock;
mod window;

use crate::{time::Instant, window::Id};
use sctk::reexports::client::protocol::{
wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface,
};

pub use data_device::*;
pub use layer::*;
pub use output::*;
pub use popup::*;
pub use seat::*;
pub use session_lock::*;
pub use window::*;

/// wayland events
#[derive(Debug, Clone, PartialEq)]
pub enum Event {
/// layer surface event
Layer(LayerEvent, WlSurface, Id),
/// popup event
Popup(PopupEvent, WlSurface, Id),
/// output event
Output(OutputEvent, WlOutput),
/// window event
Window(WindowEvent, WlSurface, Id),
/// Seat Event
Seat(SeatEvent, WlSeat),
/// Data Device event
DataSource(DataSourceEvent),
/// Dnd Offer events
DndOffer(DndOfferEvent),
/// Selection Offer events
SelectionOffer(SelectionOfferEvent),
/// Session lock events
SessionLock(SessionLockEvent),
/// Frame events
Frame(Instant, WlSurface, Id),
}
34 changes: 34 additions & 0 deletions core/src/event/wayland/output.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use sctk::output::OutputInfo;

/// output events
#[derive(Debug, Clone)]
pub enum OutputEvent {
/// created output
Created(Option<OutputInfo>),
/// removed output
Removed,
/// Output Info
InfoUpdate(OutputInfo),
}

impl Eq for OutputEvent {}

impl PartialEq for OutputEvent {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Created(l0), Self::Created(r0)) => {
if let Some((l0, r0)) = l0.as_ref().zip(r0.as_ref()) {
l0.id == r0.id && l0.make == r0.make && l0.model == r0.model
} else {
l0.is_none() && r0.is_none()
}
}
(Self::InfoUpdate(l0), Self::InfoUpdate(r0)) => {
l0.id == r0.id && l0.make == r0.make && l0.model == r0.model
}
_ => {
core::mem::discriminant(self) == core::mem::discriminant(other)
}
}
}
}
Loading

0 comments on commit 983d811

Please sign in to comment.