Fix building mock backend

This commit is contained in:
Ian Douglas Scott 2025-01-24 14:33:04 -08:00
parent 3dc82789f5
commit 207e7b2ff3
2 changed files with 17 additions and 11 deletions

View file

@ -25,7 +25,7 @@ use std::{
fs,
io::{self, Write},
sync::{
atomic::{AtomicUsize, Ordering},
atomic::{AtomicU32, Ordering},
Arc,
},
thread,
@ -35,7 +35,13 @@ use super::{CaptureImage, Cmd, Event};
use crate::utils;
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
struct MockObjectId(usize);
pub struct MockObjectId(u32);
impl MockObjectId {
pub fn protocol_id(&self) -> u32 {
self.0
}
}
fn create_solid_capture_image(r: u8, g: u8, b: u8) -> CaptureImage {
let file = fs::File::from(utils::create_memfile().unwrap());
@ -68,7 +74,7 @@ fn create_solid_capture_image(r: u8, g: u8, b: u8) -> CaptureImage {
impl MockObjectId {
fn new() -> Self {
static NEXT_MOCK_ID: AtomicUsize = AtomicUsize::new(0);
static NEXT_MOCK_ID: AtomicU32 = AtomicU32::new(0);
Self(NEXT_MOCK_ID.fetch_add(1, Ordering::SeqCst))
}
}
@ -76,6 +82,12 @@ impl MockObjectId {
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
pub struct ZcosmicWorkspaceHandleV1(MockObjectId);
impl ZcosmicWorkspaceHandleV1 {
pub fn id(&self) -> MockObjectId {
self.0.clone()
}
}
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
pub struct ZcosmicToplevelHandleV1(MockObjectId);

View file

@ -1,10 +1,7 @@
//! Types related to drag-and-drop
use cosmic::{
cctk::{
cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1,
wayland_client::{protocol::wl_output, Proxy},
},
cctk::wayland_client::{protocol::wl_output, Proxy},
iced::clipboard::mime::AsMimeTypes,
};
use std::{borrow::Cow, sync::LazyLock};
@ -71,10 +68,7 @@ impl TryFrom<(Vec<u8>, std::string::String)> for DragToplevel {
#[derive(Clone, Debug, PartialEq)]
#[repr(u8)]
pub enum DropTarget {
WorkspaceSidebarEntry(
zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
wl_output::WlOutput,
),
WorkspaceSidebarEntry(ZcosmicWorkspaceHandleV1, wl_output::WlOutput),
}
impl DropTarget {