chore: Update deps
This commit is contained in:
parent
4f3a682564
commit
4e12957169
39 changed files with 1146 additions and 1001 deletions
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
backend::render::{workspace_elements, CLEAR_COLOR},
|
||||
config::OutputConfig,
|
||||
shell::Shell,
|
||||
state::{BackendData, ClientState, Common, Data, Fps, SurfaceDmabufFeedback},
|
||||
state::{BackendData, ClientState, Common, Fps, SurfaceDmabufFeedback},
|
||||
utils::prelude::*,
|
||||
wayland::{
|
||||
handlers::screencopy::{render_session, UserdataExt},
|
||||
|
|
@ -157,7 +157,7 @@ pub type GbmDrmCompositor = DrmCompositor<
|
|||
|
||||
pub fn init_backend(
|
||||
dh: &DisplayHandle,
|
||||
event_loop: &mut EventLoop<'static, Data>,
|
||||
event_loop: &mut EventLoop<'static, State>,
|
||||
state: &mut State,
|
||||
) -> Result<()> {
|
||||
let (session, notifier) = LibSeatSession::new().context("Failed to acquire session")?;
|
||||
|
|
@ -172,21 +172,21 @@ pub fn init_backend(
|
|||
|
||||
let libinput_event_source = event_loop
|
||||
.handle()
|
||||
.insert_source(libinput_backend, move |mut event, _, data| {
|
||||
.insert_source(libinput_backend, move |mut event, _, state| {
|
||||
if let InputEvent::DeviceAdded { ref mut device } = &mut event {
|
||||
data.state.common.config.read_device(device);
|
||||
data.state
|
||||
state.common.config.read_device(device);
|
||||
state
|
||||
.backend
|
||||
.kms()
|
||||
.input_devices
|
||||
.insert(device.name().into(), device.clone());
|
||||
} else if let InputEvent::DeviceRemoved { device } = &event {
|
||||
data.state.backend.kms().input_devices.remove(device.name());
|
||||
state.backend.kms().input_devices.remove(device.name());
|
||||
}
|
||||
data.state.process_input_event(event, true);
|
||||
for output in data.state.common.shell.outputs() {
|
||||
if let Err(err) = data.state.backend.kms().schedule_render(
|
||||
&data.state.common.event_loop_handle,
|
||||
state.process_input_event(event, true);
|
||||
for output in state.common.shell.outputs() {
|
||||
if let Err(err) = state.backend.kms().schedule_render(
|
||||
&state.common.event_loop_handle,
|
||||
output,
|
||||
None,
|
||||
None,
|
||||
|
|
@ -236,19 +236,17 @@ pub fn init_backend(
|
|||
};
|
||||
info!("Using {} as primary gpu for rendering.", primary);
|
||||
|
||||
let udev_dispatcher = Dispatcher::new(udev_backend, move |event, _, data: &mut Data| {
|
||||
let udev_dispatcher = Dispatcher::new(udev_backend, move |event, _, state: &mut State| {
|
||||
let dh = state.common.display_handle.clone();
|
||||
match match event {
|
||||
UdevEvent::Added { device_id, path } => data
|
||||
.state
|
||||
.device_added(device_id, path, &data.display.handle(), true)
|
||||
UdevEvent::Added { device_id, path } => state
|
||||
.device_added(device_id, path, &dh, true)
|
||||
.with_context(|| format!("Failed to add drm device: {}", device_id)),
|
||||
UdevEvent::Changed { device_id } => data
|
||||
.state
|
||||
UdevEvent::Changed { device_id } => state
|
||||
.device_changed(device_id)
|
||||
.with_context(|| format!("Failed to update drm device: {}", device_id)),
|
||||
UdevEvent::Removed { device_id } => data
|
||||
.state
|
||||
.device_removed(device_id, &data.display.handle())
|
||||
UdevEvent::Removed { device_id } => state
|
||||
.device_removed(device_id, &dh)
|
||||
.with_context(|| format!("Failed to remove drm device: {}", device_id)),
|
||||
} {
|
||||
Ok(()) => {
|
||||
|
|
@ -269,16 +267,16 @@ pub fn init_backend(
|
|||
let dispatcher = udev_dispatcher.clone();
|
||||
let session_event_source = event_loop
|
||||
.handle()
|
||||
.insert_source(notifier, move |event, &mut (), data| match event {
|
||||
.insert_source(notifier, move |event, &mut (), state| match event {
|
||||
SessionEvent::ActivateSession => {
|
||||
if let Err(err) = libinput_context.resume() {
|
||||
error!(?err, "Failed to resume libinput context.");
|
||||
}
|
||||
for device in data.state.backend.kms().devices.values() {
|
||||
for device in state.backend.kms().devices.values() {
|
||||
device.drm.activate();
|
||||
}
|
||||
let dispatcher = dispatcher.clone();
|
||||
handle.insert_idle(move |data| {
|
||||
handle.insert_idle(move |state| {
|
||||
for (dev, path) in dispatcher.as_source_ref().device_list() {
|
||||
let drm_node = match DrmNode::from_dev_id(dev) {
|
||||
Ok(node) => node,
|
||||
|
|
@ -287,32 +285,27 @@ pub fn init_backend(
|
|||
continue;
|
||||
}
|
||||
};
|
||||
if data.state.backend.kms().devices.contains_key(&drm_node) {
|
||||
if let Err(err) = data.state.device_changed(dev) {
|
||||
if state.backend.kms().devices.contains_key(&drm_node) {
|
||||
if let Err(err) = state.device_changed(dev) {
|
||||
error!(?err, "Failed to update drm device {}.", path.display(),);
|
||||
}
|
||||
} else {
|
||||
if let Err(err) = data.state.device_added(
|
||||
dev,
|
||||
path.into(),
|
||||
&data.display.handle(),
|
||||
true,
|
||||
) {
|
||||
let dh = state.common.display_handle.clone();
|
||||
if let Err(err) = state.device_added(dev, path.into(), &dh, true) {
|
||||
error!(?err, "Failed to add drm device {}.", path.display(),);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let seats = data.state.common.seats().cloned().collect::<Vec<_>>();
|
||||
data.state.common.config.read_outputs(
|
||||
&mut data.state.common.output_configuration_state,
|
||||
&mut data.state.backend,
|
||||
&mut data.state.common.shell,
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state.common.config.read_outputs(
|
||||
&mut state.common.output_configuration_state,
|
||||
&mut state.backend,
|
||||
&mut state.common.shell,
|
||||
seats.into_iter(),
|
||||
&data.state.common.event_loop_handle,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
for surface in data
|
||||
.state
|
||||
for surface in state
|
||||
.backend
|
||||
.kms()
|
||||
.devices
|
||||
|
|
@ -322,10 +315,10 @@ pub fn init_backend(
|
|||
surface.scheduled = false;
|
||||
surface.pending = false;
|
||||
}
|
||||
for output in data.state.common.shell.outputs() {
|
||||
for output in state.common.shell.outputs() {
|
||||
let sessions = output.pending_buffers().collect::<Vec<_>>();
|
||||
if let Err(err) = data.state.backend.kms().schedule_render(
|
||||
&data.state.common.event_loop_handle,
|
||||
if let Err(err) = state.backend.kms().schedule_render(
|
||||
&state.common.event_loop_handle,
|
||||
output,
|
||||
None,
|
||||
if !sessions.is_empty() {
|
||||
|
|
@ -346,12 +339,12 @@ pub fn init_backend(
|
|||
}
|
||||
SessionEvent::PauseSession => {
|
||||
libinput_context.suspend();
|
||||
for device in data.state.backend.kms().devices.values_mut() {
|
||||
for device in state.backend.kms().devices.values_mut() {
|
||||
device.drm.pause();
|
||||
for surface in device.surfaces.values_mut() {
|
||||
surface.surface = None;
|
||||
if let Some(token) = surface.render_timer_token.take() {
|
||||
data.state.common.event_loop_handle.remove(token);
|
||||
state.common.event_loop_handle.remove(token);
|
||||
}
|
||||
surface.scheduled = false;
|
||||
}
|
||||
|
|
@ -466,10 +459,10 @@ impl State {
|
|||
.event_loop_handle
|
||||
.insert_source(
|
||||
notifier,
|
||||
move |event, metadata, data: &mut Data| match event {
|
||||
move |event, metadata, state: &mut State| match event {
|
||||
DrmEvent::VBlank(crtc) => {
|
||||
let rescheduled = if let Some(device) =
|
||||
data.state.backend.kms().devices.get_mut(&drm_node)
|
||||
state.backend.kms().devices.get_mut(&drm_node)
|
||||
{
|
||||
if let Some(surface) = device.surfaces.get_mut(&crtc) {
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -497,7 +490,7 @@ impl State {
|
|||
)
|
||||
} else {
|
||||
(
|
||||
data.state.common.clock.now(),
|
||||
state.common.clock.now(),
|
||||
wp_presentation_feedback::Kind::Vsync,
|
||||
)
|
||||
};
|
||||
|
|
@ -520,7 +513,7 @@ impl State {
|
|||
|
||||
surface.pending = false;
|
||||
let animations_going =
|
||||
data.state.common.shell.animations_going();
|
||||
state.common.shell.animations_going();
|
||||
let animation_diff = std::mem::replace(
|
||||
&mut surface.last_animation_state,
|
||||
animations_going,
|
||||
|
|
@ -549,7 +542,7 @@ impl State {
|
|||
|
||||
if let Some((output, avg_rendertime)) = rescheduled {
|
||||
let mut scheduled_sessions =
|
||||
data.state.workspace_session_for_output(&output);
|
||||
state.workspace_session_for_output(&output);
|
||||
let mut output_sessions = output.pending_buffers().peekable();
|
||||
if output_sessions.peek().is_some() {
|
||||
scheduled_sessions
|
||||
|
|
@ -559,8 +552,8 @@ impl State {
|
|||
|
||||
let estimated_rendertime =
|
||||
std::cmp::max(avg_rendertime, MIN_RENDER_TIME);
|
||||
if let Err(err) = data.state.backend.kms().schedule_render(
|
||||
&data.state.common.event_loop_handle,
|
||||
if let Err(err) = state.backend.kms().schedule_render(
|
||||
&state.common.event_loop_handle,
|
||||
&output,
|
||||
Some(estimated_rendertime),
|
||||
scheduled_sessions,
|
||||
|
|
@ -1255,7 +1248,7 @@ impl KmsState {
|
|||
seats: impl Iterator<Item = Seat<State>>,
|
||||
shell: &mut Shell,
|
||||
test_only: bool,
|
||||
loop_handle: &LoopHandle<'_, Data>,
|
||||
loop_handle: &LoopHandle<'_, State>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let recreated = if let Some(device) = self
|
||||
.devices
|
||||
|
|
@ -1464,7 +1457,7 @@ impl KmsState {
|
|||
|
||||
pub fn schedule_render(
|
||||
&mut self,
|
||||
loop_handle: &LoopHandle<'_, Data>,
|
||||
loop_handle: &LoopHandle<'_, State>,
|
||||
output: &Output,
|
||||
estimated_rendertime: Option<Duration>,
|
||||
mut screencopy_sessions: Option<Vec<(ScreencopySession, BufferParams)>>,
|
||||
|
|
@ -1477,9 +1470,9 @@ impl KmsState {
|
|||
{
|
||||
if surface.surface.is_none() {
|
||||
if let Some(sessions) = screencopy_sessions {
|
||||
loop_handle.insert_idle(move |data| {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
for (session, params) in sessions.into_iter() {
|
||||
data.state.common.still_pending(session, params);
|
||||
state.common.still_pending(session, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1500,8 +1493,8 @@ impl KmsState {
|
|||
.saturating_sub(estimated_rendertime.unwrap()),
|
||||
)
|
||||
},
|
||||
move |_time, _, data| {
|
||||
let backend = data.state.backend.kms();
|
||||
move |_time, _, state| {
|
||||
let backend = state.backend.kms();
|
||||
let (mut device, mut other) = backend
|
||||
.devices
|
||||
.iter_mut()
|
||||
|
|
@ -1511,12 +1504,12 @@ impl KmsState {
|
|||
if let Some(surface) = target_device.surfaces.get_mut(&crtc) {
|
||||
let target_node = target_device.render_node;
|
||||
let render_node = render_node_for_output(
|
||||
&data.display.handle(),
|
||||
&state.common.display_handle,
|
||||
&surface.output,
|
||||
target_node,
|
||||
&data.state.common.shell,
|
||||
&state.common.shell,
|
||||
);
|
||||
let state = &mut data.state.common;
|
||||
let common = &mut state.common;
|
||||
|
||||
let result = if render_node != target_node {
|
||||
let render_device = &mut other
|
||||
|
|
@ -1531,7 +1524,7 @@ impl KmsState {
|
|||
render_device.allocator.as_mut(),
|
||||
)),
|
||||
&target_node,
|
||||
state,
|
||||
common,
|
||||
screencopy_sessions.as_deref(),
|
||||
)
|
||||
} else {
|
||||
|
|
@ -1539,7 +1532,7 @@ impl KmsState {
|
|||
&mut backend.api,
|
||||
None,
|
||||
&target_node,
|
||||
state,
|
||||
common,
|
||||
screencopy_sessions.as_deref(),
|
||||
)
|
||||
};
|
||||
|
|
@ -1564,7 +1557,7 @@ impl KmsState {
|
|||
|
||||
if let Some(sessions) = screencopy_sessions.as_mut() {
|
||||
for (session, params) in sessions.drain(..) {
|
||||
data.state.common.still_pending(session, params);
|
||||
state.common.still_pending(session, params);
|
||||
}
|
||||
}
|
||||
TimeoutAction::Drop
|
||||
|
|
@ -1573,9 +1566,9 @@ impl KmsState {
|
|||
surface.scheduled = true;
|
||||
} else {
|
||||
if let Some(sessions) = screencopy_sessions {
|
||||
loop_handle.insert_idle(|data| {
|
||||
loop_handle.insert_idle(|state| {
|
||||
for (session, params) in sessions.into_iter() {
|
||||
data.state.common.still_pending(session, params);
|
||||
state.common.still_pending(session, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@ use smithay::{
|
|||
use std::sync::Arc;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::{
|
||||
state::{ClientState, Data},
|
||||
utils::prelude::*,
|
||||
};
|
||||
use crate::state::{ClientState, State};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Socket {
|
||||
|
|
@ -96,10 +93,10 @@ impl State {
|
|||
let token = self
|
||||
.common
|
||||
.event_loop_handle
|
||||
.insert_source(listener, move |client_stream, _, data: &mut Data| {
|
||||
if let Err(err) = data.display.handle().insert_client(
|
||||
.insert_source(listener, move |client_stream, _, state: &mut State| {
|
||||
if let Err(err) = state.common.display_handle.insert_client(
|
||||
client_stream,
|
||||
Arc::new(data.state.new_client_state_with_node(render_node)),
|
||||
Arc::new(state.new_client_state_with_node(render_node)),
|
||||
) {
|
||||
warn!(
|
||||
socket_name = socket_name_clone,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::state::{Data, State};
|
||||
use crate::state::State;
|
||||
use anyhow::{Context, Result};
|
||||
use smithay::reexports::{calloop::EventLoop, wayland_server::DisplayHandle};
|
||||
use tracing::{info, warn};
|
||||
|
|
@ -15,7 +15,7 @@ pub mod x11;
|
|||
|
||||
pub fn init_backend_auto(
|
||||
dh: &DisplayHandle,
|
||||
event_loop: &mut EventLoop<'static, Data>,
|
||||
event_loop: &mut EventLoop<'static, State>,
|
||||
state: &mut State,
|
||||
) -> Result<()> {
|
||||
let res = match std::env::var("COSMIC_BACKEND") {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
backend::render,
|
||||
config::OutputConfig,
|
||||
input::Devices,
|
||||
state::{BackendData, Common, Data},
|
||||
state::{BackendData, Common},
|
||||
utils::prelude::*,
|
||||
wayland::protocols::screencopy::{BufferParams, Session as ScreencopySession},
|
||||
};
|
||||
|
|
@ -147,7 +147,7 @@ impl WinitState {
|
|||
|
||||
pub fn init_backend(
|
||||
dh: &DisplayHandle,
|
||||
event_loop: &mut EventLoop<Data>,
|
||||
event_loop: &mut EventLoop<State>,
|
||||
state: &mut State,
|
||||
) -> Result<()> {
|
||||
let (mut backend, mut input) =
|
||||
|
|
@ -197,13 +197,8 @@ pub fn init_backend(
|
|||
let mut token = Some(
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(render_source, move |_, _, data| {
|
||||
if let Err(err) = data
|
||||
.state
|
||||
.backend
|
||||
.winit()
|
||||
.render_output(&mut data.state.common)
|
||||
{
|
||||
.insert_source(render_source, move |_, _, state| {
|
||||
if let Err(err) = state.backend.winit().render_output(&mut state.common) {
|
||||
error!(?err, "Failed to render frame.");
|
||||
render_ping.ping();
|
||||
}
|
||||
|
|
@ -213,21 +208,18 @@ pub fn init_backend(
|
|||
let event_loop_handle = event_loop.handle();
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(event_source, move |_, _, data| {
|
||||
match input.dispatch_new_events(|event| {
|
||||
data.state.process_winit_event(event, &render_ping_handle)
|
||||
}) {
|
||||
.insert_source(event_source, move |_, _, state| {
|
||||
match input
|
||||
.dispatch_new_events(|event| state.process_winit_event(event, &render_ping_handle))
|
||||
{
|
||||
Ok(_) => {
|
||||
event_ping_handle.ping();
|
||||
render_ping_handle.ping();
|
||||
}
|
||||
Err(winit::WinitError::WindowClosed) => {
|
||||
let output = data.state.backend.winit().output.clone();
|
||||
let seats = data.state.common.seats().cloned().collect::<Vec<_>>();
|
||||
data.state
|
||||
.common
|
||||
.shell
|
||||
.remove_output(&output, seats.into_iter());
|
||||
let output = state.backend.winit().output.clone();
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state.common.shell.remove_output(&output, seats.into_iter());
|
||||
if let Some(token) = token.take() {
|
||||
event_loop_handle.remove(token);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
backend::render,
|
||||
config::OutputConfig,
|
||||
input::Devices,
|
||||
state::{BackendData, Common, Data},
|
||||
state::{BackendData, Common},
|
||||
utils::prelude::*,
|
||||
wayland::protocols::screencopy::{BufferParams, Session as ScreencopySession},
|
||||
};
|
||||
|
|
@ -63,7 +63,7 @@ pub struct X11State {
|
|||
}
|
||||
|
||||
impl X11State {
|
||||
pub fn add_window(&mut self, handle: LoopHandle<'_, Data>) -> Result<Output> {
|
||||
pub fn add_window(&mut self, handle: LoopHandle<'_, State>) -> Result<Output> {
|
||||
let window = WindowBuilder::new()
|
||||
.title("COSMIC")
|
||||
.build(&self.handle)
|
||||
|
|
@ -124,15 +124,15 @@ impl X11State {
|
|||
let (ping, source) =
|
||||
ping::make_ping().with_context(|| "Failed to create output event loop source")?;
|
||||
let _token = handle
|
||||
.insert_source(source, move |_, _, data| {
|
||||
let x11_state = data.state.backend.x11();
|
||||
.insert_source(source, move |_, _, state| {
|
||||
let x11_state = state.backend.x11();
|
||||
if let Some(surface) = x11_state
|
||||
.surfaces
|
||||
.iter_mut()
|
||||
.find(|s| s.output == output_ref)
|
||||
{
|
||||
if let Err(err) =
|
||||
surface.render_output(&mut x11_state.renderer, &mut data.state.common)
|
||||
surface.render_output(&mut x11_state.renderer, &mut state.common)
|
||||
{
|
||||
error!(?err, "Error rendering.");
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ fn try_gbm_allocator(fd: OwnedFd) -> Option<Allocator> {
|
|||
|
||||
pub fn init_backend(
|
||||
dh: &DisplayHandle,
|
||||
event_loop: &mut EventLoop<Data>,
|
||||
event_loop: &mut EventLoop<State>,
|
||||
state: &mut State,
|
||||
) -> Result<()> {
|
||||
let backend = X11Backend::new().with_context(|| "Failed to initilize X11 backend")?;
|
||||
|
|
@ -391,12 +391,11 @@ pub fn init_backend(
|
|||
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(backend, move |event, _, data| match event {
|
||||
.insert_source(backend, move |event, _, state| match event {
|
||||
X11Event::CloseRequested { window_id } => {
|
||||
// TODO: drain_filter
|
||||
let mut outputs_removed = Vec::new();
|
||||
for surface in data
|
||||
.state
|
||||
for surface in state
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
|
|
@ -406,13 +405,13 @@ pub fn init_backend(
|
|||
surface.window.unmap();
|
||||
outputs_removed.push(surface.output.clone());
|
||||
}
|
||||
data.state
|
||||
state
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
.retain(|s| s.window.id() != window_id);
|
||||
for output in outputs_removed.into_iter() {
|
||||
data.state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.remove_output(&output, seats.iter().cloned());
|
||||
|
|
@ -427,8 +426,7 @@ pub fn init_backend(
|
|||
size,
|
||||
refresh: 60_000,
|
||||
};
|
||||
if let Some(surface) = data
|
||||
.state
|
||||
if let Some(surface) = state
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
|
|
@ -449,8 +447,8 @@ pub fn init_backend(
|
|||
output.change_current_state(Some(mode), None, None, None);
|
||||
output.set_preferred(mode);
|
||||
layer_map_for_output(output).arrange();
|
||||
data.state.common.output_configuration_state.update();
|
||||
data.state.common.shell.refresh_outputs();
|
||||
state.common.output_configuration_state.update();
|
||||
state.common.shell.refresh_outputs();
|
||||
surface.dirty = true;
|
||||
if !surface.pending {
|
||||
surface.render.ping();
|
||||
|
|
@ -458,8 +456,7 @@ pub fn init_backend(
|
|||
}
|
||||
}
|
||||
X11Event::Refresh { window_id } | X11Event::PresentCompleted { window_id } => {
|
||||
if let Some(surface) = data
|
||||
.state
|
||||
if let Some(surface) = state
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
|
|
@ -473,7 +470,7 @@ pub fn init_backend(
|
|||
}
|
||||
}
|
||||
}
|
||||
X11Event::Input(event) => data.state.process_x11_event(event),
|
||||
X11Event::Input(event) => state.process_x11_event(event),
|
||||
})
|
||||
.map_err(|_| anyhow::anyhow!("Failed to insert X11 Backend into event loop"))?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue