chore: Update deps

This commit is contained in:
Victoria Brekenfeld 2023-09-29 21:33:16 +02:00
parent 4f3a682564
commit 4e12957169
39 changed files with 1146 additions and 1001 deletions

View file

@ -3,13 +3,13 @@
use smithay::{
reexports::{
calloop::{generic::Generic, EventLoop, Interest, Mode, PostAction},
wayland_server::Display,
wayland_server::{Display, DisplayHandle},
},
wayland::socket::ListeningSocketSource,
};
use anyhow::{Context, Result};
use std::{ffi::OsString, os::unix::prelude::AsRawFd, sync::Arc};
use std::{ffi::OsString, sync::Arc};
use tracing::{error, info, warn};
use crate::wayland::handlers::compositor::client_compositor_state;
@ -35,19 +35,18 @@ fn main() -> Result<()> {
info!("Cosmic starting up!");
// init event loop
let mut event_loop =
EventLoop::try_new_high_precision().with_context(|| "Failed to initialize event loop")?;
let mut event_loop = EventLoop::try_new().with_context(|| "Failed to initialize event loop")?;
// init wayland
let (display, socket) = init_wayland_display(&mut event_loop)?;
// init state
let mut state = state::State::new(
&display.handle(),
&display,
socket,
event_loop.handle(),
event_loop.get_signal(),
);
// init backend
backend::init_backend_auto(&display.handle(), &mut event_loop, &mut state)?;
backend::init_backend_auto(&display, &mut event_loop, &mut state)?;
// potentially tell systemd we are setup now
#[cfg(feature = "systemd")]
if let state::BackendData::Kms(_) = &state.backend {
@ -56,43 +55,43 @@ fn main() -> Result<()> {
// potentially tell the session we are setup now
session::setup_socket(event_loop.handle(), &state)?;
let mut data = state::Data { display, state };
// run the event loop
event_loop.run(None, &mut data, |data| {
event_loop.run(None, &mut state, |state| {
// shall we shut down?
if data.state.common.shell.outputs().next().is_none() || data.state.common.should_stop {
if state.common.shell.outputs().next().is_none() || state.common.should_stop {
info!("Shutting down");
data.state.common.event_loop_signal.stop();
data.state.common.event_loop_signal.wakeup();
state.common.event_loop_signal.stop();
state.common.event_loop_signal.wakeup();
return;
}
// trigger routines
let clients = data.state.common.shell.update_animations();
let clients = state.common.shell.update_animations();
{
let dh = data.display.handle();
let dh = state.common.display_handle.clone();
for client in clients.values() {
client_compositor_state(&client).blocker_cleared(&mut data.state, &dh);
client_compositor_state(&client).blocker_cleared(state, &dh);
}
}
data.state.common.shell.refresh();
state::Common::refresh_focus(&mut data.state);
state.common.shell.refresh();
state::Common::refresh_focus(state);
// send out events
let _ = data.display.flush_clients();
let _ = state.common.display_handle.flush_clients();
})?;
// drop eventloop & state before logger
std::mem::drop(event_loop);
std::mem::drop(data);
std::mem::drop(state);
Ok(())
}
fn init_wayland_display(
event_loop: &mut EventLoop<state::Data>,
) -> Result<(Display<state::State>, OsString)> {
let mut display = Display::new().unwrap();
event_loop: &mut EventLoop<state::State>,
) -> Result<(DisplayHandle, OsString)> {
let display = Display::new().unwrap();
let handle = display.handle();
let source = ListeningSocketSource::new_auto().unwrap();
let socket_name = source.socket_name().to_os_string();
@ -100,13 +99,13 @@ fn init_wayland_display(
event_loop
.handle()
.insert_source(source, |client_stream, _, data| {
if let Err(err) = data.display.handle().insert_client(
.insert_source(source, |client_stream, _, state| {
if let Err(err) = state.common.display_handle.insert_client(
client_stream,
Arc::new(if cfg!(debug_assertions) {
data.state.new_privileged_client_state()
state.new_privileged_client_state()
} else {
data.state.new_client_state()
state.new_client_state()
}),
) {
warn!(?err, "Error adding wayland client");
@ -116,22 +115,20 @@ fn init_wayland_display(
event_loop
.handle()
.insert_source(
Generic::new(
display.backend().poll_fd().as_raw_fd(),
Interest::READ,
Mode::Level,
),
move |_, _, data: &mut state::Data| match data.display.dispatch_clients(&mut data.state)
{
Ok(_) => Ok(PostAction::Continue),
Err(err) => {
error!(?err, "I/O error on the Wayland display");
data.state.common.should_stop = true;
Err(err)
Generic::new(display, Interest::READ, Mode::Level),
move |_, display, state| {
// SAFETY: We don't drop the display
match unsafe { display.get_mut().dispatch_clients(state) } {
Ok(_) => Ok(PostAction::Continue),
Err(err) => {
error!(?err, "I/O error on the Wayland display");
state.common.should_stop = true;
Err(err)
}
}
},
)
.with_context(|| "Failed to init the wayland event source.")?;
Ok((display, socket_name))
Ok((handle, socket_name))
}