examples: Update sctk_subsurface_gst to compile again
This commit is contained in:
parent
29b41e9776
commit
e702c43f71
3 changed files with 30 additions and 27 deletions
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
||||||
sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "828b1eb" }
|
sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "828b1eb" }
|
||||||
iced = { path = "../..", default-features = false, features = [
|
iced = { path = "../..", default-features = false, features = [
|
||||||
"wayland",
|
"wayland",
|
||||||
|
"winit",
|
||||||
"debug",
|
"debug",
|
||||||
"a11y",
|
"a11y",
|
||||||
] }
|
] }
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,32 @@
|
||||||
// Shows a subsurface with a 1x1 px red buffer, stretch to window size
|
// Shows a subsurface with a 1x1 px red buffer, stretch to window size
|
||||||
|
|
||||||
use iced::{
|
use iced::{
|
||||||
wayland::InitialSurface, widget::text, window, Application, Command,
|
platform_specific::shell::subsurface_widget::{self, SubsurfaceBuffer},
|
||||||
Element, Length, Subscription, Theme,
|
widget::text,
|
||||||
|
window, Element, Length, Subscription, Task,
|
||||||
};
|
};
|
||||||
use iced_sctk::subsurface_widget::SubsurfaceBuffer;
|
|
||||||
use std::{env, path::Path};
|
use std::{env, path::Path};
|
||||||
|
|
||||||
mod pipewire;
|
mod pipewire;
|
||||||
|
|
||||||
fn main() {
|
fn main() -> iced::Result {
|
||||||
let args = env::args();
|
let args = env::args();
|
||||||
if args.len() != 2 {
|
if args.len() != 2 {
|
||||||
eprintln!("usage: sctk_subsurface_gst [h264 mp4 path]");
|
eprintln!("usage: sctk_subsurface_gst [h264 mp4 path]");
|
||||||
return;
|
return Ok(());
|
||||||
}
|
}
|
||||||
let path = args.skip(1).next().unwrap();
|
let path = args.skip(1).next().unwrap();
|
||||||
if !Path::new(&path).exists() {
|
if !Path::new(&path).exists() {
|
||||||
eprintln!("File `{path}` not found.");
|
eprintln!("File `{path}` not found.");
|
||||||
return;
|
return Ok(());
|
||||||
}
|
}
|
||||||
let mut settings = iced::Settings::with_flags(path);
|
iced::daemon(
|
||||||
settings.initial_surface = InitialSurface::XdgWindow(Default::default());
|
SubsurfaceApp::title,
|
||||||
SubsurfaceApp::run(settings).unwrap();
|
SubsurfaceApp::update,
|
||||||
|
SubsurfaceApp::view,
|
||||||
|
)
|
||||||
|
.subscription(SubsurfaceApp::subscription)
|
||||||
|
.run_with(|| SubsurfaceApp::new(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
|
@ -36,19 +40,14 @@ pub enum Message {
|
||||||
Pipewire(pipewire::Event),
|
Pipewire(pipewire::Event),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Application for SubsurfaceApp {
|
impl SubsurfaceApp {
|
||||||
type Executor = iced::executor::Default;
|
fn new(flags: String) -> (SubsurfaceApp, Task<Message>) {
|
||||||
type Message = Message;
|
|
||||||
type Flags = String;
|
|
||||||
type Theme = Theme;
|
|
||||||
|
|
||||||
fn new(flags: String) -> (SubsurfaceApp, Command<Self::Message>) {
|
|
||||||
(
|
(
|
||||||
SubsurfaceApp {
|
SubsurfaceApp {
|
||||||
path: flags,
|
path: flags,
|
||||||
..SubsurfaceApp::default()
|
..SubsurfaceApp::default()
|
||||||
},
|
},
|
||||||
Command::none(),
|
Task::none(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +55,7 @@ impl Application for SubsurfaceApp {
|
||||||
String::from("SubsurfaceApp")
|
String::from("SubsurfaceApp")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
|
fn update(&mut self, message: Message) -> Task<Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::Pipewire(evt) => match evt {
|
Message::Pipewire(evt) => match evt {
|
||||||
pipewire::Event::Frame(subsurface_buffer) => {
|
pipewire::Event::Frame(subsurface_buffer) => {
|
||||||
|
|
@ -64,12 +63,12 @@ impl Application for SubsurfaceApp {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Command::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self, _id: window::Id) -> Element<Self::Message> {
|
fn view(&self, _id: window::Id) -> Element<Message> {
|
||||||
if let Some(buffer) = &self.buffer {
|
if let Some(buffer) = &self.buffer {
|
||||||
iced_sctk::subsurface_widget::Subsurface::new(1, 1, buffer)
|
subsurface_widget::Subsurface::new(buffer.clone())
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.into()
|
.into()
|
||||||
|
|
@ -78,7 +77,7 @@ impl Application for SubsurfaceApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> Subscription<Self::Message> {
|
fn subscription(&self) -> Subscription<Message> {
|
||||||
pipewire::subscription(&self.path).map(Message::Pipewire)
|
pipewire::subscription(&self.path).map(Message::Pipewire)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use drm_fourcc::{DrmFourcc, DrmModifier};
|
||||||
use gst::glib::{self, translate::IntoGlib};
|
use gst::glib::{self, translate::IntoGlib};
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use iced::futures::{executor::block_on, SinkExt};
|
use iced::futures::{executor::block_on, SinkExt};
|
||||||
use iced_sctk::subsurface_widget::{
|
use iced::platform_specific::shell::subsurface_widget::{
|
||||||
BufferSource, Dmabuf, Plane, SubsurfaceBuffer,
|
BufferSource, Dmabuf, Plane, SubsurfaceBuffer,
|
||||||
};
|
};
|
||||||
use std::{ffi::c_void, os::unix::io::BorrowedFd, sync::Arc, thread};
|
use std::{ffi::c_void, os::unix::io::BorrowedFd, sync::Arc, thread};
|
||||||
|
|
@ -53,10 +53,13 @@ pub enum Event {
|
||||||
|
|
||||||
pub fn subscription(path: &str) -> iced::Subscription<Event> {
|
pub fn subscription(path: &str) -> iced::Subscription<Event> {
|
||||||
let path = path.to_string();
|
let path = path.to_string();
|
||||||
iced::subscription::channel("pw", 16, |sender| async {
|
iced::Subscription::run_with_id(
|
||||||
thread::spawn(move || pipewire_thread(&path, sender));
|
"pw",
|
||||||
std::future::pending().await
|
iced::stream::channel(16, |sender| async {
|
||||||
})
|
thread::spawn(move || pipewire_thread(&path, sender));
|
||||||
|
std::future::pending().await
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pipewire_thread(
|
fn pipewire_thread(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue