mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-18 22:26:12 +01:00
Project restructure to prepare for config API
This commit is contained in:
parent
748dadae01
commit
32db3bc238
29 changed files with 166 additions and 86 deletions
37
Cargo.toml
37
Cargo.toml
|
@ -1,34 +1,5 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "pinnacle"
|
members = [
|
||||||
version = "0.1.0"
|
"pinnacle",
|
||||||
edition = "2021"
|
"pinnacle_api"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tracing = "0.1.37"
|
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
|
||||||
smithay = { git = "https://github.com/Smithay/smithay" }
|
|
||||||
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", optional = true }
|
|
||||||
thiserror = "1.0.40"
|
|
||||||
xcursor = {version = "0.3.4", optional = true }
|
|
||||||
image = {version = "0.24.0", default-features = false, optional = true}
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["egl", "winit", "udev"]
|
|
||||||
egl = ["smithay/use_system_lib", "smithay/backend_egl"]
|
|
||||||
udev = [
|
|
||||||
"smithay-drm-extras",
|
|
||||||
"smithay/backend_libinput",
|
|
||||||
"smithay/backend_udev",
|
|
||||||
"smithay/backend_drm",
|
|
||||||
"smithay/backend_gbm",
|
|
||||||
"smithay/backend_vulkan",
|
|
||||||
"smithay/backend_egl",
|
|
||||||
"smithay/backend_session_libseat",
|
|
||||||
"image",
|
|
||||||
"smithay/renderer_gl",
|
|
||||||
"smithay/renderer_multi",
|
|
||||||
"xcursor",
|
|
||||||
]
|
]
|
||||||
winit = ["smithay/backend_winit", "smithay/backend_drm"]
|
|
||||||
|
|
35
pinnacle/Cargo.toml
Normal file
35
pinnacle/Cargo.toml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[package]
|
||||||
|
name = "pinnacle"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
pinnacle_api = { path = "../pinnacle_api" }
|
||||||
|
tracing = "0.1.37"
|
||||||
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||||
|
smithay = { git = "https://github.com/Smithay/smithay" }
|
||||||
|
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", optional = true }
|
||||||
|
thiserror = "1.0.40"
|
||||||
|
xcursor = {version = "0.3.4", optional = true }
|
||||||
|
image = {version = "0.24.0", default-features = false, optional = true}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["egl", "winit", "udev"]
|
||||||
|
egl = ["smithay/use_system_lib", "smithay/backend_egl"]
|
||||||
|
udev = [
|
||||||
|
"smithay-drm-extras",
|
||||||
|
"smithay/backend_libinput",
|
||||||
|
"smithay/backend_udev",
|
||||||
|
"smithay/backend_drm",
|
||||||
|
"smithay/backend_gbm",
|
||||||
|
"smithay/backend_vulkan",
|
||||||
|
"smithay/backend_egl",
|
||||||
|
"smithay/backend_session_libseat",
|
||||||
|
"image",
|
||||||
|
"smithay/renderer_gl",
|
||||||
|
"smithay/renderer_multi",
|
||||||
|
"xcursor",
|
||||||
|
]
|
||||||
|
winit = ["smithay/backend_winit", "smithay/backend_drm"]
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
@ -3,13 +3,14 @@ use smithay::{
|
||||||
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
|
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
|
||||||
KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
|
KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
|
||||||
},
|
},
|
||||||
desktop::WindowSurfaceType,
|
desktop::{Window, WindowSurfaceType},
|
||||||
input::{
|
input::{
|
||||||
keyboard::{keysyms, FilterResult},
|
keyboard::{keysyms, FilterResult},
|
||||||
pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent},
|
pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent},
|
||||||
},
|
},
|
||||||
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::ResizeEdge,
|
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::ResizeEdge,
|
||||||
utils::{Logical, Point, SERIAL_COUNTER},
|
utils::{Logical, Point, SERIAL_COUNTER},
|
||||||
|
wayland::seat::WaylandFocus,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -18,6 +19,16 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<B: Backend> State<B> {
|
impl<B: Backend> State<B> {
|
||||||
|
pub fn surface_under<P>(&self, point: P) -> Option<(Window, Point<i32, Logical>)>
|
||||||
|
where
|
||||||
|
P: Into<Point<f64, Logical>>,
|
||||||
|
{
|
||||||
|
// TODO: layer map, popups, fullscreen
|
||||||
|
self.space
|
||||||
|
.element_under(point)
|
||||||
|
.map(|(window, loc)| (window.clone(), loc))
|
||||||
|
}
|
||||||
|
|
||||||
fn pointer_button<I: InputBackend>(&mut self, event: I::PointerButtonEvent) {
|
fn pointer_button<I: InputBackend>(&mut self, event: I::PointerButtonEvent) {
|
||||||
let pointer = self.seat.get_pointer().unwrap();
|
let pointer = self.seat.get_pointer().unwrap();
|
||||||
let keyboard = self.seat.get_keyboard().unwrap();
|
let keyboard = self.seat.get_keyboard().unwrap();
|
||||||
|
@ -39,11 +50,7 @@ impl<B: Backend> State<B> {
|
||||||
// If the button was clicked, focus on the window below if exists, else
|
// If the button was clicked, focus on the window below if exists, else
|
||||||
// unfocus on windows.
|
// unfocus on windows.
|
||||||
if ButtonState::Pressed == button_state {
|
if ButtonState::Pressed == button_state {
|
||||||
if let Some((window, window_loc)) = self
|
if let Some((window, window_loc)) = self.surface_under(pointer_loc) {
|
||||||
.space
|
|
||||||
.element_under(pointer_loc)
|
|
||||||
.map(|(w, l)| (w.clone(), l))
|
|
||||||
{
|
|
||||||
const BUTTON_LEFT: u32 = 0x110;
|
const BUTTON_LEFT: u32 = 0x110;
|
||||||
const BUTTON_RIGHT: u32 = 0x111;
|
const BUTTON_RIGHT: u32 = 0x111;
|
||||||
if self.move_mode {
|
if self.move_mode {
|
||||||
|
@ -305,11 +312,15 @@ impl State<UdevData> {
|
||||||
// this event is never generated by winit
|
// this event is never generated by winit
|
||||||
self.pointer_location = self.clamp_coords(self.pointer_location);
|
self.pointer_location = self.clamp_coords(self.pointer_location);
|
||||||
|
|
||||||
|
let surface_under = self
|
||||||
|
.surface_under(self.pointer_location)
|
||||||
|
.and_then(|(window, loc)| window.wl_surface().map(|surface| (surface, loc)));
|
||||||
|
|
||||||
// tracing::info!("{:?}", self.pointer_location);
|
// tracing::info!("{:?}", self.pointer_location);
|
||||||
if let Some(ptr) = self.seat.get_pointer() {
|
if let Some(ptr) = self.seat.get_pointer() {
|
||||||
ptr.motion(
|
ptr.motion(
|
||||||
self,
|
self,
|
||||||
None,
|
surface_under,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: self.pointer_location,
|
location: self.pointer_location,
|
||||||
serial,
|
serial,
|
||||||
|
@ -347,16 +358,16 @@ impl State<UdevData> {
|
||||||
self.pointer_location.x = event.x_transformed(max_x);
|
self.pointer_location.x = event.x_transformed(max_x);
|
||||||
self.pointer_location.y = event.y_transformed(max_y);
|
self.pointer_location.y = event.y_transformed(max_y);
|
||||||
|
|
||||||
// clamp to screen limits
|
|
||||||
self.pointer_location = self.clamp_coords(self.pointer_location);
|
self.pointer_location = self.clamp_coords(self.pointer_location);
|
||||||
|
|
||||||
// tracing::info!("{:?}", self.pointer_location);
|
let surface_under = self
|
||||||
|
.surface_under(self.pointer_location)
|
||||||
|
.and_then(|(window, loc)| window.wl_surface().map(|surface| (surface, loc)));
|
||||||
|
|
||||||
// let under = self.surface_under();
|
|
||||||
if let Some(ptr) = self.seat.get_pointer() {
|
if let Some(ptr) = self.seat.get_pointer() {
|
||||||
ptr.motion(
|
ptr.motion(
|
||||||
self,
|
self,
|
||||||
None,
|
surface_under,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: self.pointer_location,
|
location: self.pointer_location,
|
||||||
serial,
|
serial,
|
34
pinnacle/src/main.rs
Normal file
34
pinnacle/src/main.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
mod backend;
|
||||||
|
mod cursor;
|
||||||
|
mod grab;
|
||||||
|
mod handlers;
|
||||||
|
mod input;
|
||||||
|
mod layout;
|
||||||
|
mod pointer;
|
||||||
|
mod render;
|
||||||
|
mod state;
|
||||||
|
mod window;
|
||||||
|
mod xdg;
|
||||||
|
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
pinnacle_api::start();
|
||||||
|
|
||||||
|
// match tracing_subscriber::EnvFilter::try_from_default_env() {
|
||||||
|
// Ok(env_filter) => {
|
||||||
|
// tracing_subscriber::fmt()
|
||||||
|
// .compact()
|
||||||
|
// .with_env_filter(env_filter)
|
||||||
|
// .init();
|
||||||
|
// }
|
||||||
|
// Err(_) => {
|
||||||
|
// tracing_subscriber::fmt().compact().init();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// tracing::info!("Starting winit backend");
|
||||||
|
// // crate::backend::winit::run_winit()?;
|
||||||
|
// crate::backend::udev::run_udev()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -181,16 +181,16 @@ pub fn take_presentation_feedback(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let map = smithay::desktop::layer_map_for_output(output);
|
// let map = smithay::desktop::layer_map_for_output(output);
|
||||||
for layer_surface in map.layers() {
|
// for layer_surface in map.layers() {
|
||||||
layer_surface.take_presentation_feedback(
|
// layer_surface.take_presentation_feedback(
|
||||||
&mut output_presentation_feedback,
|
// &mut output_presentation_feedback,
|
||||||
surface_primary_scanout_output,
|
// surface_primary_scanout_output,
|
||||||
|surface, _| {
|
// |surface, _| {
|
||||||
surface_presentation_feedback_flags_from_states(surface, render_element_states)
|
// surface_presentation_feedback_flags_from_states(surface, render_element_states)
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
output_presentation_feedback
|
output_presentation_feedback
|
||||||
}
|
}
|
9
pinnacle_api/Cargo.toml
Normal file
9
pinnacle_api/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "pinnacle_api"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tracing = "0.1.37"
|
||||||
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||||
|
rkyv = { version = "0.7.42", features = ["validation", "strict"] }
|
51
pinnacle_api/src/lib.rs
Normal file
51
pinnacle_api/src/lib.rs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
use std::{
|
||||||
|
io::Read,
|
||||||
|
mem::size_of,
|
||||||
|
os::unix::net::{UnixDatagram, UnixListener, UnixStream},
|
||||||
|
};
|
||||||
|
|
||||||
|
const SOCKET_PATH: &str = "/tmp/pinnacle_socket";
|
||||||
|
|
||||||
|
pub fn new_socket() {
|
||||||
|
let socket = UnixDatagram::bind("/something/other").unwrap();
|
||||||
|
let socket2 = UnixStream::connect("/fsalkfhgtew").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start() {
|
||||||
|
let listener = match UnixListener::bind(SOCKET_PATH) {
|
||||||
|
Ok(socket) => socket,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Failed to create UnixListener: {}", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for stream in listener.incoming() {
|
||||||
|
match stream {
|
||||||
|
Ok(stream) => {
|
||||||
|
std::thread::spawn(|| handle_client(stream));
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Incoming stream error: {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_client(mut stream: UnixStream) {
|
||||||
|
let mut buf = [0u8; size_of::<Message>()];
|
||||||
|
stream.read_exact(&mut buf).unwrap();
|
||||||
|
|
||||||
|
let thing = rkyv::check_archived_root::<Message>(&buf).unwrap();
|
||||||
|
println!("{}", thing.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(rkyv::Archive)]
|
||||||
|
#[archive(check_bytes)]
|
||||||
|
struct Message {
|
||||||
|
number: u32,
|
||||||
|
msg: String,
|
||||||
|
num2: u64,
|
||||||
|
num3: u8,
|
||||||
|
}
|
1
pinnacle_api_lua/init.lua
Normal file
1
pinnacle_api_lua/init.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
32
src/main.rs
32
src/main.rs
|
@ -1,32 +0,0 @@
|
||||||
mod backend;
|
|
||||||
mod cursor;
|
|
||||||
mod grab;
|
|
||||||
mod handlers;
|
|
||||||
mod input;
|
|
||||||
mod layout;
|
|
||||||
mod pointer;
|
|
||||||
mod render;
|
|
||||||
mod state;
|
|
||||||
mod window;
|
|
||||||
mod xdg;
|
|
||||||
|
|
||||||
use std::error::Error;
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
|
||||||
match tracing_subscriber::EnvFilter::try_from_default_env() {
|
|
||||||
Ok(env_filter) => {
|
|
||||||
tracing_subscriber::fmt()
|
|
||||||
.compact()
|
|
||||||
.with_env_filter(env_filter)
|
|
||||||
.init();
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
tracing_subscriber::fmt().compact().init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!("Starting winit backend");
|
|
||||||
// crate::backend::winit::run_winit()?;
|
|
||||||
crate::backend::udev::run_udev()?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
Loading…
Reference in a new issue