first commit
This commit is contained in:
commit
39c0b97dee
8 changed files with 1887 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/../test_wayland_server/.idea/test_wayland_server.iml" filepath="$PROJECT_DIR$/../test_wayland_server/.idea/test_wayland_server.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
11
.idea/test_wayland_server.iml
Normal file
11
.idea/test_wayland_server.iml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="EMPTY_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
1759
Cargo.lock
generated
Normal file
1759
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
16
Cargo.toml
Normal file
16
Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[package]
|
||||||
|
name = "test_wayland_server"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
smithay = "0.3.0"
|
||||||
|
wayland-protocols = { version = "0.31.0", features = ["unstable", "staging", "server"] }
|
||||||
|
wayland-protocols-wlr = { version = "0.2.0", features = ["server"] }
|
||||||
|
wayland-protocols-misc = { version = "0.2.0", features = ["server"] }
|
||||||
|
wayland-server = "0.31.0"
|
||||||
|
wayland-sys = "0.31.1"
|
||||||
|
wayland-backend = "0.3.2"
|
||||||
|
tempfile = "3.8.1"
|
78
src/main.rs
Normal file
78
src/main.rs
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use smithay::delegate_compositor;
|
||||||
|
use smithay::reexports::wayland_server::Display;
|
||||||
|
|
||||||
|
use smithay::wayland::compositor::{CompositorClientState, CompositorHandler, CompositorState};
|
||||||
|
|
||||||
|
use wayland_server::backend::{ClientData, ClientId, DisconnectReason};
|
||||||
|
use wayland_server::protocol::wl_surface::WlSurface;
|
||||||
|
use wayland_server::{Client, ListeningSocket};
|
||||||
|
|
||||||
|
struct App {
|
||||||
|
compositor_state: CompositorState,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CompositorHandler for App {
|
||||||
|
fn compositor_state(&mut self) -> &mut CompositorState {
|
||||||
|
&mut self.compositor_state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState {
|
||||||
|
&client.get_data::<ClientState>().unwrap().compositor_state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn commit(&mut self, surface: &WlSurface) {
|
||||||
|
dbg!("Commit", surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let mut display: Display<App> = Display::new()?;
|
||||||
|
let dh = display.handle();
|
||||||
|
|
||||||
|
let compositor_state = CompositorState::new::<App>(&dh);
|
||||||
|
|
||||||
|
let mut state = App { compositor_state };
|
||||||
|
|
||||||
|
let listener = ListeningSocket::bind("wayland-5").unwrap();
|
||||||
|
|
||||||
|
let mut clients = Vec::new();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if let Some(stream) = listener.accept().unwrap() {
|
||||||
|
println!("Got a client: {:?}", stream);
|
||||||
|
|
||||||
|
let client = display
|
||||||
|
.handle()
|
||||||
|
.insert_client(stream, Arc::new(ClientState::default()))
|
||||||
|
.unwrap();
|
||||||
|
clients.push(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
display.dispatch_clients(&mut state)?;
|
||||||
|
display.flush_clients()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct ClientState {
|
||||||
|
compositor_state: CompositorClientState,
|
||||||
|
}
|
||||||
|
impl ClientData for ClientState {
|
||||||
|
fn initialized(&self, _client_id: ClientId) {
|
||||||
|
println!("initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn disconnected(&self, _client_id: ClientId, _reason: DisconnectReason) {
|
||||||
|
println!("disconnected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsMut<CompositorState> for App {
|
||||||
|
fn as_mut(&mut self) -> &mut CompositorState {
|
||||||
|
&mut self.compositor_state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate_compositor!(App);
|
Loading…
Reference in a new issue