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 std::sync::atomic::Ordering;
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
sync::atomic::Ordering,
|
||||
};
|
||||
|
||||
pub mod backend;
|
||||
pub mod input;
|
||||
|
|
@ -26,9 +29,9 @@ fn main() -> Result<()> {
|
|||
// init event loop
|
||||
let mut event_loop = EventLoop::try_new().with_context(|| "Failed to initialize event loop")?;
|
||||
// init wayland
|
||||
let display = init_wayland_display(&mut event_loop)?;
|
||||
let (display, socket) = init_wayland_display(&mut event_loop)?;
|
||||
// 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
|
||||
backend::init_backend_auto(&mut event_loop, &mut state)?;
|
||||
|
||||
|
|
@ -60,7 +63,7 @@ fn main() -> Result<()> {
|
|||
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 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.")?;
|
||||
|
||||
Ok(display)
|
||||
Ok((display, socket_name))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use smithay::{
|
|||
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
ffi::OsString,
|
||||
rc::Rc,
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
time::Instant,
|
||||
|
|
@ -35,6 +36,7 @@ pub struct State {
|
|||
|
||||
pub struct Common {
|
||||
pub display: Rc<RefCell<Display>>,
|
||||
pub socket: OsString,
|
||||
pub event_loop_handle: LoopHandle<'static, State>,
|
||||
|
||||
pub spaces: Workspaces,
|
||||
|
|
@ -125,7 +127,7 @@ pub fn get_dnd_icon(seat: &Seat) -> Option<WlSurface> {
|
|||
}
|
||||
|
||||
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_xdg_output_manager(&mut display, None);
|
||||
let shell_handles = init_shell(&mut display);
|
||||
|
|
@ -162,6 +164,7 @@ impl State {
|
|||
State {
|
||||
common: Common {
|
||||
display: Rc::new(RefCell::new(display)),
|
||||
socket,
|
||||
event_loop_handle: handle,
|
||||
|
||||
spaces: Workspaces::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue