trying to get a basic wayland setup

This commit is contained in:
Chris Cochrun 2023-10-09 09:13:48 -05:00
parent 1af939a901
commit c8a4642827
5 changed files with 103 additions and 13 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/target
.direnv

25
Cargo.lock generated
View file

@ -1138,6 +1138,7 @@ dependencies = [
"iced_style",
"log",
"raw-window-handle",
"sysinfo",
"thiserror",
"web-sys",
"winapi",
@ -1626,6 +1627,15 @@ dependencies = [
"minimal-lexical",
]
[[package]]
name = "ntapi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
dependencies = [
"winapi",
]
[[package]]
name = "num-integer"
version = "0.1.45"
@ -2387,6 +2397,21 @@ dependencies = [
"libc",
]
[[package]]
name = "sysinfo"
version = "0.28.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c2f3ca6693feb29a89724516f016488e9aafc7f37264f898593ee4b942f31b"
dependencies = [
"cfg-if",
"core-foundation-sys",
"libc",
"ntapi",
"once_cell",
"rayon",
"winapi",
]
[[package]]
name = "termcolor"
version = "1.3.0"

View file

@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
iced = { version = "0.10.0", features = ["image", "debug"] }
iced = { version = "0.10.0", features = ["image", "debug", "system"] }
iced_aw = "0.7.0"
iced_winit = "0.10.0"

View file

@ -6,6 +6,11 @@ mkShell rec {
nativeBuildInputs = [
gtk-layer-shell
gtk3
vulkan-loader
wayland
wayland-protocols
libxkbcommon
pkg-config
];
buildInputs = [
@ -13,13 +18,12 @@ mkShell rec {
stdenv
gnumake
gdb
pkg-config
makeWrapper
vulkan-headers
vulkan-loader
wayland
wayland-protocols
libxkbcommon
vulkan-tools
libGL
# podofo
mpv
ffmpeg_5-full

View file

@ -1,31 +1,91 @@
use iced::executor;
use iced::widget::{button, column, row, Button, Column, Container, Row, Text};
use iced::{executor, Alignment, Length, Rectangle, Renderer};
use iced::{Application, Command, Element, Settings, Theme};
use iced_aw::native::TabBar;
use iced_aw::split::Axis;
use iced_aw::{split, Split};
fn main() -> iced::Result {
std::env::set_var("WINIT_UNIX_BACKEND", "wayland");
App::run(Settings::default())
}
struct App;
struct App {
divider_position: Option<u16>,
}
#[derive(Debug, Clone)]
enum Message {
OnVerResize(u16),
}
impl Application for App {
type Executor = executor::Default;
type Flags = ();
type Message = ();
type Message = Message;
type Theme = Theme;
fn new(_flags: ()) -> (App, Command<Self::Message>) {
(App, Command::none())
(
App {
divider_position: None,
},
Command::none(),
)
}
fn title(&self) -> String {
String::from("A cool application")
}
fn update(&mut self, _message: Self::Message) -> Command<Self::Message> {
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::OnVerResize(position) => self.divider_position = Some(position),
};
Command::none()
}
fn view(&self) -> Element<Self::Message> {
"Hello, world!".into()
fn view(&self) -> Element<Message> {
let top: _ = Container::new(
row(vec![
Button::<Message, Renderer>::new("Edit")
.height(Length::Fill)
.padding(10)
.into(),
Button::new("Present")
.height(Length::Fill)
.padding(10)
.into(),
Button::new("Close Library")
.height(Length::Fill)
.padding(10)
.into(),
])
.width(Length::Fill)
.height(Length::Fill)
.align_items(Alignment::End),
);
let first = Container::new(Text::new("First"))
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y();
let second = Container::new(Text::new("Second"))
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y();
Split::new(
first,
second,
self.divider_position,
Axis::Vertical,
Message::OnVerResize,
)
.into()
}
fn theme(&self) -> Self::Theme {
Theme::Dark
}
}