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

1329
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -11,11 +11,10 @@ members = [
]
[dependencies]
apply = "0.3.0"
anyhow = { version = "1.0.51", features = ["backtrace"] }
bitflags = "1.3.2"
bitflags = "2.4"
bytemuck = "1.12"
calloop = { version = "0.10.1", features = ["executor"] }
calloop = { version = "0.12.2", features = ["executor"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sendfd = "0.4.1"
@ -28,19 +27,19 @@ log-panics = { version = "2", features = ["with-backtrace"] }
thiserror = "1.0.26"
regex = "1"
xcursor = "0.3.3"
xkbcommon = "0.4"
indexmap = "1.8.0"
xkbcommon = "0.6"
indexmap = "2.0"
xdg = "^2.1"
ron = "0.7"
libsystemd = { version = "0.5", optional = true }
wayland-backend = "0.1.0"
wayland-scanner = "0.30.0"
wayland-backend = "0.3.0"
wayland-scanner = "0.31.0"
cosmic-comp-config = { path = "cosmic-comp-config" }
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c", features = ["calloop"] }
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", rev = "188b7c2b", features = ["calloop"] }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c" }
tiny-skia = "0.9"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "188b7c2b", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "188b7c2b" }
tiny-skia = "0.10"
ordered-float = "3.0"
glow = "0.11.2"
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "tracing-log"] }
@ -61,13 +60,13 @@ branch = "feature/copy_clone"
[dependencies.smithay]
version = "0.3"
git = "https://github.com/smithay/smithay.git"
rev = "58d5bdc"
rev = "74ef59a3f"
default-features = false
features = ["backend_drm", "backend_gbm", "backend_egl", "backend_libinput", "backend_session_libseat", "backend_udev", "backend_winit", "backend_vulkan", "backend_x11", "desktop", "use_system_lib", "renderer_glow", "renderer_multi", "wayland_frontend", "xwayland"]
[dependencies.smithay-egui]
git = "https://github.com/Smithay/smithay-egui.git"
rev = "dab5c1b"
rev = "114d8db6"
features = ["svg"]
optional = true
@ -87,4 +86,4 @@ debug = true
lto = "fat"
[patch."https://github.com/Smithay/smithay.git"]
smithay = { git = "https://github.com/smithay//smithay", rev = "d3e1ef9" }
smithay = { git = "https://github.com/smithay//smithay", rev = "74ef59a3f" }

View file

@ -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);
}
});
}

View file

@ -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,

View file

@ -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") {

View file

@ -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);
}

View file

@ -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"))?;

View file

@ -4,7 +4,7 @@ use crate::shell::{focus::FocusDirection, grabs::ResizeEdge, Direction, ResizeDi
use serde::Deserialize;
use smithay::{
backend::input::KeyState,
input::keyboard::{keysyms as KeySyms, xkb::keysym_get_name, ModifiersState},
input::keyboard::{xkb::keysym_get_name, ModifiersState},
};
use std::collections::HashMap;
@ -90,11 +90,11 @@ pub struct KeyPattern {
pub modifiers: KeyModifiers,
/// The actual key, that was pressed
#[serde(deserialize_with = "deserialize_Keysym", default)]
pub key: Option<u32>,
pub key: Option<Keysym>,
}
impl KeyPattern {
pub fn new(modifiers: impl Into<KeyModifiers>, key: Option<u32>) -> KeyPattern {
pub fn new(modifiers: impl Into<KeyModifiers>, key: Option<Keysym>) -> KeyPattern {
KeyPattern {
modifiers: modifiers.into(),
key,
@ -174,7 +174,7 @@ pub enum Action {
fn insert_binding(
key_bindings: &mut HashMap<KeyPattern, Action>,
modifiers: KeyModifiers,
keys: impl Iterator<Item = u32>,
keys: impl Iterator<Item = Keysym>,
action: Action,
) {
if !key_bindings.values().any(|a| a == &action) {
@ -197,16 +197,16 @@ pub fn add_default_bindings(
let (workspace_previous, workspace_next, output_previous, output_next) = match workspace_layout
{
WorkspaceLayout::Horizontal => (
[KeySyms::KEY_Left, KeySyms::KEY_h],
[KeySyms::KEY_Right, KeySyms::KEY_l],
[KeySyms::KEY_Up, KeySyms::KEY_k],
[KeySyms::KEY_Down, KeySyms::KEY_j],
[Keysym::Left, Keysym::h],
[Keysym::Right, Keysym::l],
[Keysym::Up, Keysym::k],
[Keysym::Down, Keysym::j],
),
WorkspaceLayout::Vertical => (
[KeySyms::KEY_Up, KeySyms::KEY_k],
[KeySyms::KEY_Down, KeySyms::KEY_j],
[KeySyms::KEY_Left, KeySyms::KEY_h],
[KeySyms::KEY_Right, KeySyms::KEY_l],
[Keysym::Up, Keysym::k],
[Keysym::Down, Keysym::j],
[Keysym::Left, Keysym::h],
[Keysym::Right, Keysym::l],
),
};

View file

@ -2,7 +2,7 @@
use crate::{
shell::{Shell, WorkspaceAmount},
state::{BackendData, Data, State},
state::{BackendData, State},
wayland::protocols::output_configuration::OutputConfigurationState,
};
use cosmic_config::ConfigGet;
@ -158,12 +158,12 @@ impl OutputConfig {
}
impl Config {
pub fn load(loop_handle: &LoopHandle<'_, Data>) -> Config {
pub fn load(loop_handle: &LoopHandle<'_, State>) -> Config {
let config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
let source = cosmic_config::calloop::ConfigWatchSource::new(&config).unwrap();
loop_handle
.insert_source(source, |(config, keys), (), shared_data| {
config_changed(config, keys, &mut shared_data.state);
.insert_source(source, |(config, keys), (), state| {
config_changed(config, keys, state);
})
.expect("Failed to add cosmic-config to the event loop");
let xdg = xdg::BaseDirectories::new().ok();
@ -260,7 +260,7 @@ impl Config {
backend: &mut BackendData,
shell: &mut Shell,
seats: impl Iterator<Item = Seat<State>>,
loop_handle: &LoopHandle<'_, Data>,
loop_handle: &LoopHandle<'_, State>,
) {
let seats = seats.collect::<Vec<_>>();
let outputs = output_state.outputs().collect::<Vec<_>>();

View file

@ -3,6 +3,7 @@
use super::{KeyModifier, KeyModifiers};
use serde::{Deserialize, Serialize};
use smithay::reexports::x11rb::NO_SYMBOL;
pub use smithay::{
backend::input::KeyState,
input::keyboard::{keysyms as KeySyms, Keysym, XkbConfig as WlXkbConfig},
@ -65,8 +66,9 @@ where
let name = String::deserialize(deserializer)?;
//let name = format!("KEY_{}", code);
match xkb::keysym_from_name(&name, xkb::KEYSYM_NO_FLAGS) {
KeySyms::KEY_NoSymbol => match xkb::keysym_from_name(&name, xkb::KEYSYM_CASE_INSENSITIVE) {
KeySyms::KEY_NoSymbol => Err(<D::Error as Error>::invalid_value(
x if x.raw() == NO_SYMBOL => {
match xkb::keysym_from_name(&name, xkb::KEYSYM_CASE_INSENSITIVE) {
x if x.raw() == NO_SYMBOL => Err(<D::Error as Error>::invalid_value(
Unexpected::Str(&name),
&"One of the keysym names of xkbcommon.h without the 'KEY_' prefix",
)),
@ -78,7 +80,8 @@ where
);
Ok(Some(x))
}
},
}
}
x => Ok(Some(x)),
}
}

View file

@ -25,7 +25,7 @@ use smithay::{
},
desktop::{layer_map_for_output, space::SpaceElement, WindowSurfaceType},
input::{
keyboard::{keysyms, FilterResult, KeysymHandle, XkbConfig},
keyboard::{FilterResult, KeysymHandle, XkbConfig},
pointer::{
AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
@ -51,6 +51,7 @@ use smithay::{
#[cfg(not(feature = "debug"))]
use tracing::info;
use tracing::{error, trace, warn};
use xkbcommon::xkb::{Keycode, Keysym};
use std::{
any::Any,
@ -58,7 +59,6 @@ use std::{
collections::HashMap,
time::{Duration, Instant},
};
use xkbcommon::xkb::KEY_XF86Switch_VT_12;
crate::utils::id_gen!(next_seat_id, SEAT_ID, SEAT_IDS);
@ -66,7 +66,7 @@ crate::utils::id_gen!(next_seat_id, SEAT_ID, SEAT_IDS);
pub struct SeatId(pub usize);
pub struct ActiveOutput(pub RefCell<Output>);
#[derive(Default)]
pub struct SupressedKeys(RefCell<Vec<(u32, Option<RegistrationToken>)>>);
pub struct SupressedKeys(RefCell<Vec<(Keycode, Option<RegistrationToken>)>>);
#[derive(Default, Debug)]
pub struct ModifiersShortcutQueue(RefCell<Option<KeyPattern>>);
#[derive(Default)]
@ -321,8 +321,8 @@ impl State {
if let Some(new_workspace) = other_w.iter_mut().find(|w| w.handle == new_descriptor.handle) {
if let Some(focus) = TilingLayout::swap_trees(&mut old_workspace.tiling_layer, Some(&mut new_workspace.tiling_layer), &old_descriptor, &new_descriptor, &mut data.common.shell.toplevel_info_state) {
let seat = seat.clone();
data.common.event_loop_handle.insert_idle(move |data| {
Common::set_focus(&mut data.state, Some(&focus), &seat, None);
data.common.event_loop_handle.insert_idle(move |state| {
Common::set_focus(state, Some(&focus), &seat, None);
});
}
old_workspace.refresh_focus_stack();
@ -334,8 +334,8 @@ impl State {
if let Some(focus) = TilingLayout::swap_trees(&mut workspace.tiling_layer, None, &old_descriptor, &new_descriptor, &mut data.common.shell.toplevel_info_state) {
std::mem::drop(spaces);
let seat = seat.clone();
data.common.event_loop_handle.insert_idle(move |data| {
Common::set_focus(&mut data.state, Some(&focus), &seat, None);
data.common.event_loop_handle.insert_idle(move |state| {
Common::set_focus(state, Some(&focus), &seat, None);
});
}
workspace.refresh_focus_stack();
@ -352,8 +352,8 @@ impl State {
if new_workspace.tiling_layer.windows().next().is_none() {
if let Some(focus) = TilingLayout::move_tree(&mut old_workspace.tiling_layer, &mut new_workspace.tiling_layer, &current_output, &new_workspace.handle, &seat, new_workspace.focus_stack.get(&seat).iter(), old_descriptor, &mut data.common.shell.toplevel_info_state) {
let seat = seat.clone();
data.common.event_loop_handle.insert_idle(move |data| {
Common::set_focus(&mut data.state, Some(&focus), &seat, None);
data.common.event_loop_handle.insert_idle(move |state| {
Common::set_focus(state, Some(&focus), &seat, None);
});
}
old_workspace.refresh_focus_stack();
@ -401,10 +401,10 @@ impl State {
data.common.shell.resize_mode()
{
let resize_edge = match handle.modified_sym() {
keysyms::KEY_Left | keysyms::KEY_h | keysyms::KEY_H => Some(ResizeEdge::LEFT),
keysyms::KEY_Down | keysyms::KEY_j | keysyms::KEY_J => Some(ResizeEdge::BOTTOM),
keysyms::KEY_Up | keysyms::KEY_k | keysyms::KEY_K => Some(ResizeEdge::TOP),
keysyms::KEY_Right | keysyms::KEY_l | keysyms::KEY_L => Some(ResizeEdge::RIGHT),
Keysym::Left | Keysym::h | Keysym::H => Some(ResizeEdge::LEFT),
Keysym::Down | Keysym::j | Keysym::J => Some(ResizeEdge::BOTTOM),
Keysym::Up | Keysym::k | Keysym::K => Some(ResizeEdge::TOP),
Keysym::Right | Keysym::l | Keysym::L => Some(ResizeEdge::RIGHT),
_ => None,
};
@ -415,7 +415,7 @@ impl State {
let action = Action::_ResizingInternal(direction, edge, state);
let key_pattern = KeyPattern {
modifiers: modifiers.clone().into(),
key: Some(handle.raw_code()),
key: Some(Keysym::new(handle.raw_code().raw())),
};
if state == KeyState::Released {
@ -430,9 +430,9 @@ impl State {
let action_clone = action.clone();
let key_pattern_clone = key_pattern.clone();
let start = Instant::now();
loop_handle.insert_source(Timer::from_duration(Duration::from_millis(200)), move |current, _, data| {
loop_handle.insert_source(Timer::from_duration(Duration::from_millis(200)), move |current, _, state| {
let duration = current.duration_since(start).as_millis();
data.state.handle_action(action_clone.clone(), &seat_clone, serial, time.overflowing_add(duration as u32).0, key_pattern_clone.clone(), None);
state.handle_action(action_clone.clone(), &seat_clone, serial, time.overflowing_add(duration as u32).0, key_pattern_clone.clone(), None);
calloop::timer::TimeoutAction::ToDuration(Duration::from_millis(25))
}).ok()
} else { None };
@ -482,11 +482,11 @@ impl State {
// Handle VT switches
if state == KeyState::Pressed
&& (keysyms::KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12)
.contains(&handle.modified_sym())
&& (Keysym::XF86_Switch_VT_1.raw() ..= Keysym::XF86_Switch_VT_12.raw())
.contains(&handle.modified_sym().raw())
{
if let Err(err) = data.backend.kms().switch_vt(
(handle.modified_sym() - keysyms::KEY_XF86Switch_VT_1
(handle.modified_sym().raw() - Keysym::XF86_Switch_VT_1.raw()
+ 1)
as i32,
) {

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)
{
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");
data.state.common.should_stop = true;
state.common.should_stop = true;
Err(err)
}
}
},
)
.with_context(|| "Failed to init the wayland event source.")?;
Ok((display, socket_name))
Ok((handle, socket_name))
}

View file

@ -12,14 +12,14 @@ use std::{
collections::HashMap,
io::{Read, Write},
os::unix::{
io::{AsRawFd, FromRawFd, RawFd},
io::{AsFd, BorrowedFd, FromRawFd, RawFd},
net::UnixStream,
},
sync::Arc,
};
use tracing::{error, warn};
use crate::state::{Data, State};
use crate::state::State;
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "message")]
@ -34,9 +34,9 @@ struct StreamWrapper {
size: u16,
read_bytes: usize,
}
impl AsRawFd for StreamWrapper {
fn as_raw_fd(&self) -> RawFd {
self.stream.as_raw_fd()
impl AsFd for StreamWrapper {
fn as_fd(&self) -> BorrowedFd<'_> {
self.stream.as_fd()
}
}
impl From<UnixStream> for StreamWrapper {
@ -50,7 +50,7 @@ impl From<UnixStream> for StreamWrapper {
}
}
pub fn setup_socket(handle: LoopHandle<Data>, state: &State) -> Result<()> {
pub fn setup_socket(handle: LoopHandle<State>, state: &State) -> Result<()> {
if let Ok(fd_num) = std::env::var("COSMIC_SESSION_SOCK") {
if let Ok(fd) = fd_num.parse::<RawFd>() {
// set CLOEXEC
@ -94,7 +94,10 @@ pub fn setup_socket(handle: LoopHandle<Data>, state: &State) -> Result<()> {
handle.insert_source(
Generic::new(StreamWrapper::from(session_socket), Interest::READ, Mode::Level),
move |_, stream, data: &mut crate::state::Data| {
move |_, stream, state| {
// SAFETY: We don't drop the stream!
let stream = unsafe { stream.get_mut() };
if stream.size == 0 {
let mut len = [0u8; 2];
match stream.stream.read_exact(&mut len) {
@ -131,7 +134,7 @@ pub fn setup_socket(handle: LoopHandle<Data>, state: &State) -> Result<()> {
assert_eq!(received_count, count);
for fd in fds.into_iter().take(received_count) {
let stream = unsafe { UnixStream::from_raw_fd(fd) };
if let Err(err) = data.display.handle().insert_client(stream, Arc::new(data.state.new_privileged_client_state())) {
if let Err(err) = state.common.display_handle.insert_client(stream, Arc::new(state.new_privileged_client_state())) {
warn!(?err, "Failed to add privileged client to display");
}
}

View file

@ -539,7 +539,7 @@ impl CosmicMapped {
self.element = CosmicMappedInternal::Window(window);
}
pub(super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::Data> {
pub(super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::State> {
match &self.element {
CosmicMappedInternal::Stack(stack) => stack.loop_handle(),
CosmicMappedInternal::Window(window) => window.loop_handle(),

View file

@ -22,7 +22,7 @@ pub type ResizeIndicator = IcedElement<ResizeIndicatorInternal>;
pub fn resize_indicator(
direction: ResizeDirection,
config: &Config,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) -> ResizeIndicator {
ResizeIndicator::new(
ResizeIndicatorInternal {

View file

@ -122,14 +122,14 @@ pub enum Focus {
pub enum MoveResult {
Handled,
MoveOut(CosmicSurface, LoopHandle<'static, crate::state::Data>),
MoveOut(CosmicSurface, LoopHandle<'static, crate::state::State>),
Default,
}
impl CosmicStack {
pub fn new<I: Into<CosmicSurface>>(
windows: impl Iterator<Item = I>,
handle: LoopHandle<'static, crate::state::Data>,
handle: LoopHandle<'static, crate::state::State>,
) -> CosmicStack {
let windows = windows.map(Into::into).collect::<Vec<_>>();
assert!(!windows.is_empty());
@ -498,7 +498,7 @@ impl CosmicStack {
.with_program(|p| p.group_focused.store(true, Ordering::SeqCst));
}
pub(in super::super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::Data> {
pub(in super::super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::State> {
self.0.loop_handle()
}
@ -603,7 +603,7 @@ impl Program for CosmicStackInternal {
fn update(
&mut self,
message: Self::Message,
loop_handle: &LoopHandle<'static, crate::state::Data>,
loop_handle: &LoopHandle<'static, crate::state::State>,
) -> Command<Self::Message> {
match message {
Message::DragStart => {
@ -612,8 +612,8 @@ impl Program for CosmicStackInternal {
[self.active.load(Ordering::SeqCst)]
.wl_surface()
{
loop_handle.insert_idle(move |data| {
Shell::move_request(&mut data.state, &surface, &seat, serial);
loop_handle.insert_idle(move |state| {
Shell::move_request(state, &surface, &seat, serial);
});
}
}
@ -1080,9 +1080,9 @@ impl PointerTarget<State> for CosmicStack {
}
let seat = seat.clone();
data.common.event_loop_handle.insert_idle(move |data| {
data.common.event_loop_handle.insert_idle(move |state| {
seat.get_pointer().unwrap().set_grab(
&mut data.state,
state,
grab,
event.serial,
smithay::input::pointer::Focus::Clear,

View file

@ -16,7 +16,7 @@ use smithay::utils::{Logical, Size};
pub type StackHover = IcedElement<StackHoverInternal>;
pub fn stack_hover(
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
size: Size<i32, Logical>,
) -> StackHover {
StackHover::new(StackHoverInternal, size, evlh)

View file

@ -15,7 +15,7 @@ use smithay::utils::Size;
pub type SwapIndicator = IcedElement<SwapIndicatorInternal>;
pub fn swap_indicator(evlh: LoopHandle<'static, crate::state::Data>) -> SwapIndicator {
pub fn swap_indicator(evlh: LoopHandle<'static, crate::state::State>) -> SwapIndicator {
SwapIndicator::new(SwapIndicatorInternal, Size::from((1, 1)), evlh)
}

View file

@ -113,7 +113,7 @@ impl CosmicWindowInternal {
impl CosmicWindow {
pub fn new(
window: impl Into<CosmicSurface>,
handle: LoopHandle<'static, crate::state::Data>,
handle: LoopHandle<'static, crate::state::State>,
) -> CosmicWindow {
let window = window.into();
let width = window.geometry().size.w;
@ -166,7 +166,7 @@ impl CosmicWindow {
}
}
pub(super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::Data> {
pub(super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::State> {
self.0.loop_handle()
}
@ -228,14 +228,14 @@ impl Program for CosmicWindowInternal {
fn update(
&mut self,
message: Self::Message,
loop_handle: &LoopHandle<'static, crate::state::Data>,
loop_handle: &LoopHandle<'static, crate::state::State>,
) -> Command<Self::Message> {
match message {
Message::DragStart => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
if let Some(surface) = self.window.wl_surface() {
loop_handle.insert_idle(move |data| {
Shell::move_request(&mut data.state, &surface, &seat, serial);
loop_handle.insert_idle(move |state| {
Shell::move_request(state, &surface, &seat, serial);
});
}
}
@ -243,17 +243,11 @@ impl Program for CosmicWindowInternal {
Message::Maximize => {
if let Some((seat, _serial)) = self.last_seat.lock().unwrap().clone() {
if let Some(surface) = self.window.wl_surface() {
loop_handle.insert_idle(move |data| {
if let Some(mapped) = data
.state
.common
.shell
.element_for_wl_surface(&surface)
.cloned()
{
if let Some(workspace) =
data.state.common.shell.space_for_mut(&mapped)
loop_handle.insert_idle(move |state| {
if let Some(mapped) =
state.common.shell.element_for_wl_surface(&surface).cloned()
{
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
let output = seat.active_output();
let (window, _) = mapped
.windows()
@ -262,7 +256,7 @@ impl Program for CosmicWindowInternal {
workspace.maximize_toggle(
&window,
&output,
data.state.common.event_loop_handle.clone(),
state.common.event_loop_handle.clone(),
)
}
}

View file

@ -21,17 +21,18 @@ mod moving;
pub use self::moving::*;
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ResizeEdge: u32 {
const TOP = 0b0001;
const BOTTOM = 0b0010;
const LEFT = 0b0100;
const RIGHT = 0b1000;
const TOP_LEFT = Self::TOP.bits | Self::LEFT.bits;
const BOTTOM_LEFT = Self::BOTTOM.bits | Self::LEFT.bits;
const TOP_LEFT = Self::TOP.bits() | Self::LEFT.bits();
const BOTTOM_LEFT = Self::BOTTOM.bits() | Self::LEFT.bits();
const TOP_RIGHT = Self::TOP.bits | Self::RIGHT.bits;
const BOTTOM_RIGHT = Self::BOTTOM.bits | Self::RIGHT.bits;
const TOP_RIGHT = Self::TOP.bits() | Self::RIGHT.bits();
const BOTTOM_RIGHT = Self::BOTTOM.bits() | Self::RIGHT.bits();
}
}

View file

@ -366,6 +366,7 @@ impl FloatingLayout {
KeyboardFocusTarget::Popup(popup) => {
let Some(toplevel_surface) = (match popup {
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
PopupKind::InputMethod(_) => unreachable!(),
}) else {
return FocusResult::None
};
@ -436,6 +437,7 @@ impl FloatingLayout {
KeyboardFocusTarget::Popup(popup) => {
let Some(toplevel_surface) = (match popup {
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
PopupKind::InputMethod(_) => unreachable!(),
}) else {
return MoveResult::None
};

View file

@ -69,11 +69,11 @@ impl PointerTarget<State> for ResizeForkTarget {
let orientation = self.orientation;
let serial = event.serial;
let button = event.button;
data.common.event_loop_handle.insert_idle(move |data| {
data.common.event_loop_handle.insert_idle(move |state| {
let pointer = seat.get_pointer().unwrap();
let location = pointer.current_location();
pointer.set_grab(
&mut data.state,
state,
ResizeForkGrab {
start_data: PointerGrabStartData {
focus: None,

View file

@ -9,6 +9,7 @@ use smithay::{
},
utils::Serial,
};
use xkbcommon::xkb::Keysym;
use crate::{
config::{Action, KeyPattern},
@ -71,7 +72,7 @@ impl KeyboardGrab<State> for SwapWindowGrab {
time,
KeyPattern {
modifiers: modifiers.map(Into::into).unwrap_or_default(),
key: Some(keycode),
key: Some(Keysym::new(keycode)),
},
None,
);

View file

@ -2660,6 +2660,7 @@ impl TilingLayout {
if let KeyboardFocusTarget::Popup(popup) = target {
let toplevel_surface = match popup {
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
PopupKind::InputMethod(_) => unreachable!(),
}?;
let root_id = tree.root_node_id()?;
let node =

View file

@ -1219,7 +1219,7 @@ impl Shell {
pub fn set_overview_mode(
&mut self,
enabled: Option<Trigger>,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) {
if let Some(trigger) = enabled {
if !matches!(self.overview_mode, OverviewMode::Started(_, _)) {
@ -1261,7 +1261,7 @@ impl Shell {
&mut self,
enabled: Option<(KeyPattern, ResizeDirection)>,
config: &Config,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) {
if let Some((pattern, direction)) = enabled {
if let ResizeMode::Started(old_pattern, _, old_direction) = &mut self.resize_mode {

View file

@ -430,7 +430,7 @@ impl Workspace {
&mut self,
window: &CosmicSurface,
output: &Output,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) {
if self.fullscreen.contains_key(output) {
return;
@ -459,7 +459,7 @@ impl Workspace {
&mut self,
window: &CosmicSurface,
output: &Output,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) {
if self
.fullscreen
@ -484,7 +484,7 @@ impl Workspace {
window: &'a CosmicSurface,
output: &Output,
exclusive: bool,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) {
if let Some(mapped) = self
.mapped()
@ -635,7 +635,7 @@ impl Workspace {
&mut self,
window: &CosmicSurface,
output: &Output,
evlh: LoopHandle<'static, crate::state::Data>,
evlh: LoopHandle<'static, crate::state::State>,
) {
if self.fullscreen.contains_key(output) {
self.unmaximize_request(window);

View file

@ -54,7 +54,7 @@ use smithay::{
wayland_server::{
backend::{ClientData, ClientId, DisconnectReason},
protocol::wl_shm,
Client, Display, DisplayHandle,
Client, DisplayHandle,
},
},
utils::{Clock, IsAlive, Monotonic},
@ -114,11 +114,6 @@ impl ClientData for ClientState {
}
}
pub struct Data {
pub display: Display<State>,
pub state: State,
}
#[derive(Debug)]
pub struct State {
pub backend: BackendData,
@ -131,7 +126,7 @@ pub struct Common {
pub socket: OsString,
pub display_handle: DisplayHandle,
pub event_loop_handle: LoopHandle<'static, Data>,
pub event_loop_handle: LoopHandle<'static, State>,
pub event_loop_signal: LoopSignal,
//pub output_conf: ConfigurationManager,
@ -212,7 +207,7 @@ impl BackendData {
test_only: bool,
shell: &mut Shell,
seats: impl Iterator<Item = Seat<State>>,
loop_handle: &LoopHandle<'_, Data>,
loop_handle: &LoopHandle<'_, State>,
) -> Result<(), anyhow::Error> {
let result = match self {
BackendData::Kms(ref mut state) => {
@ -252,7 +247,7 @@ impl BackendData {
pub fn schedule_render(
&mut self,
loop_handle: &LoopHandle<'_, Data>,
loop_handle: &LoopHandle<'_, State>,
output: &Output,
screencopy: Option<Vec<(ScreencopySession, BufferParams)>>,
) {
@ -281,7 +276,7 @@ impl State {
pub fn new(
dh: &DisplayHandle,
socket: OsString,
handle: LoopHandle<'static, Data>,
handle: LoopHandle<'static, State>,
signal: LoopSignal,
) -> State {
let requested_languages = DesktopLanguageRequester::requested_languages();

View file

@ -98,7 +98,7 @@ pub trait Program {
fn update(
&mut self,
message: Self::Message,
loop_handle: &LoopHandle<'static, crate::state::Data>,
loop_handle: &LoopHandle<'static, crate::state::State>,
) -> Command<Self::Message> {
let _ = (message, loop_handle);
Command::none()
@ -119,7 +119,7 @@ pub trait Program {
}
}
struct ProgramWrapper<P: Program>(P, LoopHandle<'static, crate::state::Data>);
struct ProgramWrapper<P: Program>(P, LoopHandle<'static, crate::state::State>);
impl<P: Program> IcedProgram for ProgramWrapper<P> {
type Message = <P as Program>::Message;
type Renderer = IcedRenderer;
@ -150,7 +150,7 @@ struct IcedElementInternal<P: Program + Send + 'static> {
debug: Debug,
// futures
handle: LoopHandle<'static, crate::state::Data>,
handle: LoopHandle<'static, crate::state::State>,
scheduler: Scheduler<<P as Program>::Message>,
executor_token: Option<RegistrationToken>,
rx: Receiver<<P as Program>::Message>,
@ -228,7 +228,7 @@ impl<P: Program + Send + 'static> IcedElement<P> {
pub fn new(
program: P,
size: impl Into<Size<i32, Logical>>,
handle: LoopHandle<'static, crate::state::Data>,
handle: LoopHandle<'static, crate::state::State>,
) -> IcedElement<P> {
let size = size.into();
let mut renderer =
@ -276,7 +276,7 @@ impl<P: Program + Send + 'static> IcedElement<P> {
func(&internal.state.program().0)
}
pub fn loop_handle(&self) -> LoopHandle<'static, crate::state::Data> {
pub fn loop_handle(&self) -> LoopHandle<'static, crate::state::State> {
self.0.lock().unwrap().handle.clone()
}

View file

@ -2,7 +2,7 @@
use crate::{
shell::CosmicSurface,
state::{BackendData, ClientState, Data},
state::{BackendData, ClientState},
utils::prelude::*,
wayland::protocols::screencopy::SessionType,
};
@ -73,7 +73,7 @@ impl State {
}
fn xdg_popup_ensure_initial_configure(&mut self, popup: &PopupKind) {
let PopupKind::Xdg(ref popup) = popup;
if let PopupKind::Xdg(ref popup) = popup {
let initial_configure_sent = with_states(popup.wl_surface(), |states| {
states
.data_map
@ -89,6 +89,7 @@ impl State {
popup.send_configure().expect("initial configure failed");
}
}
}
fn layer_surface_ensure_inital_configure(&mut self, surface: &LayerSurface) -> bool {
// send the initial configure if relevant
@ -149,10 +150,11 @@ impl CompositorHandler for State {
state
.common
.event_loop_handle
.insert_source(source, move |_, _, data| {
data.state
.insert_source(source, move |_, _, state| {
let dh = state.common.display_handle.clone();
state
.client_compositor_state(&client)
.blocker_cleared(&mut data.state, &data.display.handle());
.blocker_cleared(state, &dh);
Ok(())
});
if res.is_ok() {
@ -164,7 +166,7 @@ impl CompositorHandler for State {
}
fn commit(&mut self, surface: &WlSurface) {
X11Wm::commit_hook::<Data>(surface);
X11Wm::commit_hook::<State>(surface);
// first load the buffer for various smithay helper functions
on_commit_buffer_handler::<Self>(surface);

View file

@ -137,8 +137,8 @@ impl State {
self.common
.config
.write_outputs(self.common.output_configuration_state.outputs());
self.common.event_loop_handle.insert_idle(move |data| {
data.state.common.output_configuration_state.update();
self.common.event_loop_handle.insert_idle(move |state| {
state.common.output_configuration_state.update();
});
true

View file

@ -46,7 +46,7 @@ use crate::{
render_output, render_workspace, CursorMode, CLEAR_COLOR,
},
shell::{CosmicMappedRenderElement, CosmicSurface, WorkspaceRenderElement},
state::{BackendData, ClientState, Common, Data, State},
state::{BackendData, ClientState, Common, State},
utils::prelude::OutputExt,
wayland::protocols::{
screencopy::{
@ -1173,19 +1173,14 @@ impl State {
if active.wl_surface().as_ref() == Some(surface) {
for (session, params) in active.pending_buffers() {
let window = active.clone();
self.common.event_loop_handle.insert_idle(move |data| {
self.common.event_loop_handle.insert_idle(move |state| {
if !session.alive() {
return;
}
match render_window_to_buffer(
&mut data.state,
&session,
params.clone(),
&window,
) {
match render_window_to_buffer(state, &session, params.clone(), &window) {
// rendering yielded no damage, buffer is still pending
Ok(false) => data.state.common.still_pending(session, params),
Ok(false) => state.common.still_pending(session, params),
Ok(true) => {} // success
Err((reason, err)) => {
warn!(?err, "Screencopy session failed");
@ -1291,21 +1286,21 @@ impl State {
}
pub fn schedule_offscreen_workspace_session(
event_loop_handle: &LoopHandle<'static, Data>,
event_loop_handle: &LoopHandle<'static, State>,
session: Session,
params: BufferParams,
output: Output,
handle: WorkspaceHandle,
) {
event_loop_handle.insert_idle(move |data| {
event_loop_handle.insert_idle(move |state| {
if !session.alive() {
return;
}
if !data.state.common.shell.outputs.contains(&output) {
if !state.common.shell.outputs.contains(&output) {
return;
}
match render_workspace_to_buffer(
&mut data.state,
state,
&session,
params.clone(),
&output,
@ -1313,7 +1308,7 @@ pub fn schedule_offscreen_workspace_session(
) {
Ok(false) => {
// rendering yielded no new damage, buffer still pending
data.state.common.still_pending(session, params);
state.common.still_pending(session, params);
}
Ok(true) => {}
Err((reason, err)) => {

View file

@ -16,12 +16,12 @@ impl SecurityContextHandler for State {
) {
self.common
.event_loop_handle
.insert_source(source, move |client_stream, _, data| {
if let Err(err) = data.display.handle().insert_client(
.insert_source(source, move |client_stream, _, state| {
if let Err(err) = state.common.display_handle.insert_client(
client_stream,
Arc::new(ClientState {
security_context: Some(security_context.clone()),
..data.state.new_client_state()
..state.new_client_state()
}),
) {
warn!(?err, "Error adding wayland client");

View file

@ -95,6 +95,7 @@ pub fn update_reactive_popups<'a>(
}
}
}
PopupKind::InputMethod(_) => {}
}
}
}

View file

@ -11,7 +11,7 @@ use smithay::{
zwlr_output_mode_v1::{self, ZwlrOutputModeV1},
},
wayland_server::{
backend::{ClientId, GlobalId, ObjectId},
backend::{ClientId, GlobalId},
protocol::wl_output::WlOutput,
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
},
@ -247,9 +247,9 @@ where
}
}
fn destroyed(state: &mut D, _client: ClientId, resource: ObjectId, _data: &Output) {
fn destroyed(state: &mut D, _client: ClientId, resource: &ZwlrOutputHeadV1, _data: &Output) {
for instance in &mut state.output_configuration_state().instances {
instance.heads.retain(|h| h.head.id() != resource);
instance.heads.retain(|h| &h.head != resource);
}
}
}

View file

@ -883,18 +883,18 @@ where
fn destroyed(
state: &mut D,
_client: wayland_backend::server::ClientId,
resource: wayland_backend::server::ObjectId,
resource: &ZcosmicScreencopySessionV1,
data: &SessionData,
) {
if data.inner.lock().unwrap().is_cursor() {
let session = CursorSession {
obj: SessionResource::Destroyed(resource),
obj: SessionResource::Destroyed(resource.id()),
data: data.clone(),
};
state.cursor_session_destroyed(session)
} else {
let session = Session {
obj: SessionResource::Destroyed(resource),
obj: SessionResource::Destroyed(resource.id()),
data: data.clone(),
};
state.session_destroyed(session)

View file

@ -5,7 +5,7 @@ use std::{collections::HashMap, sync::Mutex};
use smithay::{
output::Output,
reexports::wayland_server::{
backend::{ClientId, GlobalId, ObjectId},
backend::{ClientId, GlobalId},
protocol::wl_surface::WlSurface,
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
},
@ -139,11 +139,11 @@ where
}
}
fn destroyed(state: &mut D, _client: ClientId, resource: ObjectId, _data: &()) {
fn destroyed(state: &mut D, _client: ClientId, resource: &ZcosmicToplevelInfoV1, _data: &()) {
state
.toplevel_info_state_mut()
.instances
.retain(|i| i.id() != resource);
.retain(|i| i != resource);
}
}
@ -174,16 +174,12 @@ where
fn destroyed(
state: &mut D,
_client: ClientId,
resource: ObjectId,
resource: &ZcosmicToplevelHandleV1,
_data: &ToplevelHandleState<W>,
) {
for toplevel in &state.toplevel_info_state_mut().toplevels {
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
state
.lock()
.unwrap()
.instances
.retain(|i| i.id() != resource);
state.lock().unwrap().instances.retain(|i| i != resource);
}
}
}

View file

@ -4,7 +4,7 @@ use smithay::{
input::{Seat, SeatHandler},
output::Output,
reexports::wayland_server::{
backend::{ClientId, GlobalId, ObjectId},
backend::{ClientId, GlobalId},
protocol::wl_surface::WlSurface,
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
},
@ -225,9 +225,9 @@ where
}
}
fn destroyed(state: &mut D, client: ClientId, resource: ObjectId, _data: &()) {
fn destroyed(state: &mut D, client: ClientId, resource: &ZcosmicToplevelManagerV1, _data: &()) {
let mng_state = state.toplevel_management_state();
mng_state.instances.retain(|i| i.id() != resource);
mng_state.instances.retain(|i| i != resource);
if !mng_state
.instances
.iter()

View file

@ -211,11 +211,16 @@ where
}
}
fn destroyed(state: &mut D, _client: ClientId, resource: ObjectId, _data: &()) {
fn destroyed(
state: &mut D,
_client: ClientId,
resource: &ZcosmicWorkspaceManagerV1,
_data: &(),
) {
state
.workspace_state_mut()
.instances
.retain(|i| i.id() != resource);
.retain(|i| i != resource);
}
}
@ -268,9 +273,14 @@ where
}
}
fn destroyed(state: &mut D, _client: ClientId, resource: ObjectId, _data: &WorkspaceGroupData) {
fn destroyed(
state: &mut D,
_client: ClientId,
resource: &ZcosmicWorkspaceGroupHandleV1,
_data: &WorkspaceGroupData,
) {
for group in &mut state.workspace_state_mut().groups {
group.instances.retain(|i| i.id() != resource)
group.instances.retain(|i| i != resource)
}
}
}
@ -361,10 +371,15 @@ where
}
}
fn destroyed(state: &mut D, _client: ClientId, resource: ObjectId, _data: &WorkspaceData) {
fn destroyed(
state: &mut D,
_client: ClientId,
resource: &ZcosmicWorkspaceHandleV1,
_data: &WorkspaceData,
) {
for group in &mut state.workspace_state_mut().groups {
for workspace in &mut group.workspaces {
workspace.instances.retain(|i| i.id() != resource)
workspace.instances.retain(|i| i != resource)
}
}
}

View file

@ -3,7 +3,7 @@ use std::{ffi::OsString, os::unix::io::OwnedFd};
use crate::{
backend::render::cursor::{load_cursor_theme, Cursor, CursorShape},
shell::{focus::target::KeyboardFocusTarget, CosmicSurface, Shell},
state::{Data, State},
state::State,
utils::prelude::*,
wayland::{handlers::screencopy::PendingScreencopyBuffers, protocols::screencopy::SessionType},
};
@ -56,8 +56,8 @@ impl State {
display: _,
} => {
let mut wm = match X11Wm::start_wm(
data.state.common.event_loop_handle.clone(),
data.state.common.display_handle.clone(),
data.common.event_loop_handle.clone(),
data.common.display_handle.clone(),
connection,
client,
) {
@ -83,11 +83,11 @@ impl State {
);
}
let xwayland_state = data.state.common.xwayland_state.as_mut().unwrap();
let xwayland_state = data.common.xwayland_state.as_mut().unwrap();
xwayland_state.xwm = Some(wm);
}
XWaylandEvent::Exited => {
if let Some(mut xwayland_state) = data.state.common.xwayland_state.take() {
if let Some(mut xwayland_state) = data.common.xwayland_state.take() {
xwayland_state.xwm = None;
}
}
@ -126,10 +126,9 @@ impl State {
}
}
impl XwmHandler for Data {
impl XwmHandler for State {
fn xwm_state(&mut self, _xwm: XwmId) -> &mut X11Wm {
self.state
.common
self.common
.xwayland_state
.as_mut()
.and_then(|state| state.xwm.as_mut())
@ -146,27 +145,16 @@ impl XwmHandler for Data {
}
let surface = CosmicSurface::X11(window.clone());
if self
.state
.common
.shell
.element_for_surface(&surface)
.is_some()
{
if self.common.shell.element_for_surface(&surface).is_some() {
return;
}
let seat = self.state.common.last_active_seat().clone();
self.state
.common
.shell
.pending_windows
.push((surface, seat));
let seat = self.common.last_active_seat().clone();
self.common.shell.pending_windows.push((surface, seat));
}
fn map_window_notify(&mut self, _xwm: XwmId, surface: X11Surface) {
if let Some((window, seat)) = self
.state
.common
.shell
.pending_windows
@ -181,13 +169,12 @@ impl XwmHandler for Data {
.cloned()
{
let output = seat.active_output();
Shell::map_window(&mut self.state, &window, &output);
Shell::map_window(self, &window, &output);
}
}
fn mapped_override_redirect_window(&mut self, _xwm: XwmId, window: X11Surface) {
if self
.state
.common
.shell
.override_redirect_windows
@ -196,26 +183,23 @@ impl XwmHandler for Data {
{
return;
}
Shell::map_override_redirect(&mut self.state, window)
Shell::map_override_redirect(self, window)
}
fn unmapped_window(&mut self, _xwm: XwmId, window: X11Surface) {
let surface = CosmicSurface::X11(window.clone());
if window.is_override_redirect() {
self.state
.common
self.common
.shell
.override_redirect_windows
.retain(|or| or != &window);
} else if let Some((element, space)) = self
.state
.common
.shell
.element_for_surface(&surface)
.cloned()
.and_then(|element| {
self.state
.common
self.common
.shell
.space_for_mut(&element)
.map(|space| (element, space))
@ -229,27 +213,21 @@ impl XwmHandler for Data {
}
let outputs = if let Some(wl_surface) = window.wl_surface() {
self.state
.common
self.common
.shell
.visible_outputs_for_surface(&wl_surface)
.collect::<Vec<_>>()
} else {
self.state
.common
.shell
.outputs()
.cloned()
.collect::<Vec<_>>()
self.common.shell.outputs().cloned().collect::<Vec<_>>()
};
for output in outputs.iter() {
self.state.common.shell.active_space_mut(output).refresh();
self.common.shell.active_space_mut(output).refresh();
}
// screencopy
let mut scheduled_sessions = window
.wl_surface()
.map(|wl_surface| self.state.schedule_workspace_sessions(&wl_surface))
.map(|wl_surface| self.schedule_workspace_sessions(&wl_surface))
.unwrap_or_default();
for output in outputs.into_iter() {
@ -258,8 +236,8 @@ impl XwmHandler for Data {
.get_or_insert_with(Vec::new)
.extend(sessions.borrow_mut().drain(..));
}
self.state.backend.schedule_render(
&self.state.common.event_loop_handle,
self.backend.schedule_render(
&self.common.event_loop_handle,
&output,
scheduled_sessions.as_ref().map(|sessions| {
sessions
@ -292,12 +270,11 @@ impl XwmHandler for Data {
// We only allow floating X11 windows to resize themselves. Nothing else
let mut current_geo = window.geometry();
if let Some(mapped) = self
.state
.common
.shell
.element_for_surface(&CosmicSurface::X11(window.clone()))
{
let space = self.state.common.shell.space_for(mapped).unwrap();
let space = self.common.shell.space_for(mapped).unwrap();
if space.is_floating(mapped) {
mapped.set_geometry(Rectangle::from_loc_and_size(
current_geo.loc,
@ -334,7 +311,7 @@ impl XwmHandler for Data {
) {
if window.is_override_redirect() {
if let Some(id) = above {
let or_windows = &mut self.state.common.shell.override_redirect_windows;
let or_windows = &mut self.common.shell.override_redirect_windows;
if let Some(own_pos) = or_windows.iter().position(|or| or == &window) {
let compare_pos = or_windows
.iter()
@ -348,7 +325,7 @@ impl XwmHandler for Data {
}
let geo = window.geometry();
for (output, overlap) in self.state.common.shell.outputs().cloned().map(|o| {
for (output, overlap) in self.common.shell.outputs().cloned().map(|o| {
let intersection = o.geometry().intersection(geo);
(o, intersection)
}) {
@ -369,57 +346,35 @@ impl XwmHandler for Data {
resize_edge: smithay::xwayland::xwm::ResizeEdge,
) {
if let Some(wl_surface) = window.wl_surface() {
let seat = self.state.common.last_active_seat().clone();
Shell::resize_request(
&mut self.state,
&wl_surface,
&seat,
None,
resize_edge.into(),
)
let seat = self.common.last_active_seat().clone();
Shell::resize_request(self, &wl_surface, &seat, None, resize_edge.into())
}
}
fn move_request(&mut self, _xwm: XwmId, window: X11Surface, _button: u32) {
if let Some(wl_surface) = window.wl_surface() {
let seat = self.state.common.last_active_seat().clone();
Shell::move_request(&mut self.state, &wl_surface, &seat, None)
let seat = self.common.last_active_seat().clone();
Shell::move_request(self, &wl_surface, &seat, None)
}
}
fn maximize_request(&mut self, _xwm: XwmId, window: X11Surface) {
let seat = self.state.common.last_active_seat();
let seat = self.common.last_active_seat();
let output = seat.active_output();
let surface = CosmicSurface::X11(window);
if let Some(mapped) = self
.state
.common
.shell
.element_for_surface(&surface)
.cloned()
{
if let Some(workspace) = self.state.common.shell.space_for_mut(&mapped) {
if let Some(mapped) = self.common.shell.element_for_surface(&surface).cloned() {
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
let (window, _) = mapped.windows().find(|(w, _)| w == &surface).unwrap();
workspace.maximize_request(
&window,
&output,
self.state.common.event_loop_handle.clone(),
)
workspace.maximize_request(&window, &output, self.common.event_loop_handle.clone())
}
}
}
fn unmaximize_request(&mut self, _xwm: XwmId, window: X11Surface) {
let surface = CosmicSurface::X11(window);
if let Some(mapped) = self
.state
.common
.shell
.element_for_surface(&surface)
.cloned()
{
if let Some(workspace) = self.state.common.shell.space_for_mut(&mapped) {
if let Some(mapped) = self.common.shell.element_for_surface(&surface).cloned() {
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
let (window, _) = mapped.windows().find(|(w, _)| w == &surface).unwrap();
workspace.unmaximize_request(&window);
}
@ -427,23 +382,17 @@ impl XwmHandler for Data {
}
fn fullscreen_request(&mut self, _xwm: XwmId, window: X11Surface) {
let seat = self.state.common.last_active_seat();
let seat = self.common.last_active_seat();
let output = seat.active_output();
let surface = CosmicSurface::X11(window);
if let Some(mapped) = self
.state
.common
.shell
.element_for_surface(&surface)
.cloned()
{
if let Some(workspace) = self.state.common.shell.space_for_mut(&mapped) {
if let Some(mapped) = self.common.shell.element_for_surface(&surface).cloned() {
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
let (window, _) = mapped.windows().find(|(w, _)| w == &surface).unwrap();
workspace.fullscreen_request(
&window,
&output,
self.state.common.event_loop_handle.clone(),
self.common.event_loop_handle.clone(),
)
}
}
@ -451,14 +400,8 @@ impl XwmHandler for Data {
fn unfullscreen_request(&mut self, _xwm: XwmId, window: X11Surface) {
let surface = CosmicSurface::X11(window);
if let Some(mapped) = self
.state
.common
.shell
.element_for_surface(&surface)
.cloned()
{
if let Some(workspace) = self.state.common.shell.space_for_mut(&mapped) {
if let Some(mapped) = self.common.shell.element_for_surface(&surface).cloned() {
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
let (window, _) = mapped.windows().find(|(w, _)| w == &surface).unwrap();
workspace.unfullscreen_request(&window);
}
@ -472,7 +415,7 @@ impl XwmHandler for Data {
mime_type: String,
fd: OwnedFd,
) {
let seat = self.state.common.last_active_seat();
let seat = self.common.last_active_seat();
match selection {
SelectionType::Clipboard => {
if let Err(err) = request_data_device_client_selection(seat, mime_type, fd) {
@ -494,39 +437,36 @@ impl XwmHandler for Data {
}
fn allow_selection_access(&mut self, xwm: XwmId, _selection: SelectionType) -> bool {
self.state.common.is_x_focused(xwm)
self.common.is_x_focused(xwm)
}
fn new_selection(&mut self, xwm: XwmId, selection: SelectionType, mime_types: Vec<String>) {
trace!(?selection, ?mime_types, "Got Selection from Xwayland",);
if self.state.common.is_x_focused(xwm) {
let seat = self.state.common.last_active_seat();
if self.common.is_x_focused(xwm) {
let seat = self.common.last_active_seat();
match selection {
SelectionType::Clipboard => set_data_device_selection(
&self.state.common.display_handle,
&seat,
mime_types,
xwm,
),
SelectionType::Clipboard => {
set_data_device_selection(&self.common.display_handle, &seat, mime_types, xwm)
}
SelectionType::Primary => {
set_primary_selection(&self.state.common.display_handle, &seat, mime_types, xwm)
set_primary_selection(&self.common.display_handle, &seat, mime_types, xwm)
}
}
}
}
fn cleared_selection(&mut self, xwm: XwmId, selection: SelectionType) {
for seat in self.state.common.seats() {
for seat in self.common.seats() {
match selection {
SelectionType::Clipboard => {
if current_data_device_selection_userdata(seat).as_deref() == Some(&xwm) {
clear_data_device_selection(&self.state.common.display_handle, seat)
clear_data_device_selection(&self.common.display_handle, seat)
}
}
SelectionType::Primary => {
if current_primary_selection_userdata(seat).as_deref() == Some(&xwm) {
clear_primary_selection(&self.state.common.display_handle, seat)
clear_primary_selection(&self.common.display_handle, seat)
}
}
}