state: add socket name
This commit is contained in:
parent
ab912e24c0
commit
c562955c80
2 changed files with 12 additions and 6 deletions
13
src/main.rs
13
src/main.rs
|
|
@ -6,7 +6,10 @@ use smithay::reexports::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use std::sync::atomic::Ordering;
|
use std::{
|
||||||
|
ffi::OsString,
|
||||||
|
sync::atomic::Ordering,
|
||||||
|
};
|
||||||
|
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
|
@ -26,9 +29,9 @@ fn main() -> Result<()> {
|
||||||
// init event loop
|
// init event loop
|
||||||
let mut event_loop = EventLoop::try_new().with_context(|| "Failed to initialize event loop")?;
|
let mut event_loop = EventLoop::try_new().with_context(|| "Failed to initialize event loop")?;
|
||||||
// init wayland
|
// init wayland
|
||||||
let display = init_wayland_display(&mut event_loop)?;
|
let (display, socket) = init_wayland_display(&mut event_loop)?;
|
||||||
// init state
|
// init state
|
||||||
let mut state = state::State::new(display, event_loop.handle(), log);
|
let mut state = state::State::new(display, socket, event_loop.handle(), log);
|
||||||
// init backend
|
// init backend
|
||||||
backend::init_backend_auto(&mut event_loop, &mut state)?;
|
backend::init_backend_auto(&mut event_loop, &mut state)?;
|
||||||
|
|
||||||
|
|
@ -60,7 +63,7 @@ fn main() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_wayland_display(event_loop: &mut EventLoop<state::State>) -> Result<Display> {
|
fn init_wayland_display(event_loop: &mut EventLoop<state::State>) -> Result<(Display, OsString)> {
|
||||||
let mut display = Display::new();
|
let mut display = Display::new();
|
||||||
let socket_name = display.add_socket_auto()?;
|
let socket_name = display.add_socket_auto()?;
|
||||||
|
|
||||||
|
|
@ -84,5 +87,5 @@ fn init_wayland_display(event_loop: &mut EventLoop<state::State>) -> Result<Disp
|
||||||
)
|
)
|
||||||
.with_context(|| "Failed to init the wayland event source.")?;
|
.with_context(|| "Failed to init the wayland event source.")?;
|
||||||
|
|
||||||
Ok(display)
|
Ok((display, socket_name))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use smithay::{
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
|
ffi::OsString,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
|
|
@ -35,6 +36,7 @@ pub struct State {
|
||||||
|
|
||||||
pub struct Common {
|
pub struct Common {
|
||||||
pub display: Rc<RefCell<Display>>,
|
pub display: Rc<RefCell<Display>>,
|
||||||
|
pub socket: OsString,
|
||||||
pub event_loop_handle: LoopHandle<'static, State>,
|
pub event_loop_handle: LoopHandle<'static, State>,
|
||||||
|
|
||||||
pub spaces: Workspaces,
|
pub spaces: Workspaces,
|
||||||
|
|
@ -125,7 +127,7 @@ pub fn get_dnd_icon(seat: &Seat) -> Option<WlSurface> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn new(mut display: Display, handle: LoopHandle<'static, State>, log: LogState) -> State {
|
pub fn new(mut display: Display, socket: OsString, handle: LoopHandle<'static, State>, log: LogState) -> State {
|
||||||
init_shm_global(&mut display, vec![], None);
|
init_shm_global(&mut display, vec![], None);
|
||||||
init_xdg_output_manager(&mut display, None);
|
init_xdg_output_manager(&mut display, None);
|
||||||
let shell_handles = init_shell(&mut display);
|
let shell_handles = init_shell(&mut display);
|
||||||
|
|
@ -162,6 +164,7 @@ impl State {
|
||||||
State {
|
State {
|
||||||
common: Common {
|
common: Common {
|
||||||
display: Rc::new(RefCell::new(display)),
|
display: Rc::new(RefCell::new(display)),
|
||||||
|
socket,
|
||||||
event_loop_handle: handle,
|
event_loop_handle: handle,
|
||||||
|
|
||||||
spaces: Workspaces::new(),
|
spaces: Workspaces::new(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue