Compare commits
2 commits
ce6f2066a1
...
454b14bf3a
| Author | SHA1 | Date | |
|---|---|---|---|
| 454b14bf3a | |||
| 4e2fbca7e6 |
7 changed files with 80 additions and 45 deletions
|
|
@ -5,7 +5,7 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parking_lot = "0.12.5"
|
parking_lot = "0.12.5"
|
||||||
smithay = { path = "./smithay", features = ["desktop", "wayland-backend", "xwayland"] }
|
smithay = { path = "./smithay", features = ["desktop", "wayland-backend", "wayland_frontend", "xwayland"] }
|
||||||
wayland-protocols = { version = "0.32.13", features = ["wayland-server", "server"] }
|
wayland-protocols = { version = "0.32.13", features = ["wayland-server", "server"] }
|
||||||
wayland-server = { version = "0.31.13", features = ["dlopen"] }
|
wayland-server = { version = "0.31.13", features = ["dlopen"] }
|
||||||
winit = "0.30.13"
|
winit = "0.30.13"
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,11 @@ use wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1
|
||||||
|
|
||||||
impl XdgDecorationHandler for State {
|
impl XdgDecorationHandler for State {
|
||||||
fn new_decoration(&mut self, toplevel: smithay::wayland::shell::xdg::ToplevelSurface) {
|
fn new_decoration(&mut self, toplevel: smithay::wayland::shell::xdg::ToplevelSurface) {
|
||||||
println!("new_decoration");
|
toplevel.with_pending_state(|state| {
|
||||||
// todo!()
|
state.decoration_mode = Some(Mode::ClientSide);
|
||||||
|
// state.decoration_mode = Some(Mode::ServerSide);
|
||||||
|
});
|
||||||
|
toplevel.send_configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_mode(
|
fn request_mode(
|
||||||
|
|
@ -13,12 +16,18 @@ impl XdgDecorationHandler for State {
|
||||||
toplevel: smithay::wayland::shell::xdg::ToplevelSurface,
|
toplevel: smithay::wayland::shell::xdg::ToplevelSurface,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
) {
|
) {
|
||||||
println!("request_mode");
|
toplevel.with_pending_state(|state| {
|
||||||
// todo!()
|
state.decoration_mode = Some(Mode::ClientSide);
|
||||||
|
// state.decoration_mode = Some(mode);
|
||||||
|
});
|
||||||
|
toplevel.send_configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unset_mode(&mut self, toplevel: smithay::wayland::shell::xdg::ToplevelSurface) {
|
fn unset_mode(&mut self, toplevel: smithay::wayland::shell::xdg::ToplevelSurface) {
|
||||||
println!("unset_mode");
|
toplevel.with_pending_state(|state| {
|
||||||
// todo!()
|
state.decoration_mode = Some(Mode::ClientSide);
|
||||||
|
// state.decoration_mode = Some(Mode::ServerSide);
|
||||||
|
});
|
||||||
|
toplevel.send_configure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
src/main.rs
19
src/main.rs
|
|
@ -5,6 +5,7 @@ mod handlers;
|
||||||
mod audio;
|
mod audio;
|
||||||
mod grabs;
|
mod grabs;
|
||||||
mod input;
|
mod input;
|
||||||
|
pub mod render;
|
||||||
mod state;
|
mod state;
|
||||||
mod winit;
|
mod winit;
|
||||||
mod xwayland;
|
mod xwayland;
|
||||||
|
|
@ -27,7 +28,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// than the host compositor
|
// than the host compositor
|
||||||
unsafe { std::env::set_var("WAYLAND_DISPLAY", &state.socket_name) };
|
unsafe { std::env::set_var("WAYLAND_DISPLAY", &state.socket_name) };
|
||||||
|
|
||||||
spawn_client();
|
// spawn_clients();
|
||||||
|
|
||||||
if let Some(sysaudioplayer) = &state.sysaudioplayer {
|
if let Some(sysaudioplayer) = &state.sysaudioplayer {
|
||||||
sysaudioplayer.blink4();
|
sysaudioplayer.blink4();
|
||||||
|
|
@ -47,19 +48,3 @@ fn init_logging() {
|
||||||
tracing_subscriber::fmt().init();
|
tracing_subscriber::fmt().init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_client() {
|
|
||||||
let mut args = std::env::args().skip(1);
|
|
||||||
let flag = args.next();
|
|
||||||
let arg = args.next();
|
|
||||||
|
|
||||||
match (flag.as_deref(), arg) {
|
|
||||||
// (Some("-c") | Some("--command"), Some(command)) => {
|
|
||||||
// std::process::Command::new(command).spawn().ok();
|
|
||||||
// }
|
|
||||||
_ => {
|
|
||||||
std::process::Command::new("startmde").spawn().ok();
|
|
||||||
std::process::Command::new("konsole").spawn().ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
46
src/render.rs
Normal file
46
src/render.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
use smithay::{
|
||||||
|
backend::renderer::{
|
||||||
|
damage::OutputDamageTracker,
|
||||||
|
element::{
|
||||||
|
memory::MemoryRenderBufferRenderElement, solid::SolidColorRenderElement,
|
||||||
|
surface::WaylandSurfaceRenderElement,
|
||||||
|
},
|
||||||
|
gles::{GlesRenderer, GlesTarget},
|
||||||
|
ImportMem,
|
||||||
|
},
|
||||||
|
output::Output,
|
||||||
|
render_elements,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::State;
|
||||||
|
|
||||||
|
render_elements! {
|
||||||
|
DecorationElement<R> where R: ImportMem;
|
||||||
|
Chrome=SolidColorRenderElement,
|
||||||
|
Label=MemoryRenderBufferRenderElement<R>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl State {
|
||||||
|
pub fn render(
|
||||||
|
&self,
|
||||||
|
output: &Output,
|
||||||
|
renderer: &mut GlesRenderer,
|
||||||
|
framebuffer: &mut GlesTarget,
|
||||||
|
damage_tracker: &mut OutputDamageTracker,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
// let elem = DecorationElement::
|
||||||
|
|
||||||
|
smithay::desktop::space::render_output::<_, WaylandSurfaceRenderElement<GlesRenderer>, _, _>(
|
||||||
|
output,
|
||||||
|
renderer,
|
||||||
|
framebuffer,
|
||||||
|
1.0,
|
||||||
|
0,
|
||||||
|
[&self.space],
|
||||||
|
&[],
|
||||||
|
damage_tracker,
|
||||||
|
[0.07, 0.16, 0.286, 1.0],
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -118,7 +118,7 @@ impl State {
|
||||||
// Windows get a position and stacking order through mapping.
|
// Windows get a position and stacking order through mapping.
|
||||||
// Outputs become views of a part of the Space and can be rendered via Space::render_output.
|
// Outputs become views of a part of the Space and can be rendered via Space::render_output.
|
||||||
let space = Space::default();
|
let space = Space::default();
|
||||||
Self::setup_xwayland(display.handle(), handle.clone())?;
|
Self::start_programs(display.handle(), handle.clone())?;
|
||||||
|
|
||||||
let socket_name = Self::init_wayland_listener(display, handle.clone());
|
let socket_name = Self::init_wayland_listener(display, handle.clone());
|
||||||
|
|
||||||
|
|
@ -218,7 +218,11 @@ impl State {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&mut self) {}
|
pub fn spawn_clients() {
|
||||||
|
/* todo: read from shit */
|
||||||
|
std::process::Command::new("startmde").spawn().ok();
|
||||||
|
std::process::Command::new("konsole").spawn().ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data associated with a wayland client that connects to Smallvil.
|
/// Data associated with a wayland client that connects to Smallvil.
|
||||||
|
|
|
||||||
18
src/winit.rs
18
src/winit.rs
|
|
@ -65,22 +65,8 @@ pub fn init_winit(state: &mut State) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
{
|
{
|
||||||
let (renderer, mut framebuffer) = backend.bind().unwrap();
|
let (renderer, mut framebuffer) = backend.bind().unwrap();
|
||||||
smithay::desktop::space::render_output::<
|
state
|
||||||
_,
|
.render(&output, renderer, &mut framebuffer, &mut damage_tracker)
|
||||||
WaylandSurfaceRenderElement<GlesRenderer>,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
>(
|
|
||||||
&output,
|
|
||||||
renderer,
|
|
||||||
&mut framebuffer,
|
|
||||||
1.0,
|
|
||||||
0,
|
|
||||||
[&state.space],
|
|
||||||
&[],
|
|
||||||
&mut damage_tracker,
|
|
||||||
[0.07, 0.16, 0.286, 1.0],
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
backend.submit(Some(&[damage])).unwrap();
|
backend.submit(Some(&[damage])).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,11 @@ impl XWaylandShellHandler for State {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn setup_xwayland(
|
pub fn start_programs(
|
||||||
dh: DisplayHandle,
|
dh: DisplayHandle,
|
||||||
loop_handle: LoopHandle<'static, Self>,
|
loop_handle: LoopHandle<'static, Self>,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
/* try to spawn xwayland first */
|
||||||
let (xwayland, client) = XWayland::spawn(
|
let (xwayland, client) = XWayland::spawn(
|
||||||
&dh,
|
&dh,
|
||||||
None,
|
None,
|
||||||
|
|
@ -116,9 +117,13 @@ impl State {
|
||||||
|
|
||||||
println!("XWayland started on display :{display_number}");
|
println!("XWayland started on display :{display_number}");
|
||||||
unsafe { std::env::set_var("DISPLAY", format!(":{display_number}")) };
|
unsafe { std::env::set_var("DISPLAY", format!(":{display_number}")) };
|
||||||
|
|
||||||
|
/* now launch the clients */
|
||||||
|
State::spawn_clients();
|
||||||
}
|
}
|
||||||
XWaylandEvent::Error => {
|
XWaylandEvent::Error => {
|
||||||
// warn!("XWayland crashed on startup");
|
println!("XWayland crashed on startup");
|
||||||
|
State::spawn_clients();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue