chore: clippy

This commit is contained in:
Vukašin Vojinović 2025-10-16 13:50:32 +02:00 committed by Victoria Brekenfeld
parent 3b70bc0265
commit 0847247c33
77 changed files with 865 additions and 1029 deletions

View file

@ -14,7 +14,7 @@ use smithay::{
};
use std::{
collections::{HashMap, HashSet},
ffi::{CStr, CString},
ffi::CString,
mem,
os::unix::{io::AsFd, net::UnixStream},
};
@ -49,7 +49,7 @@ impl AtspiClient {
modifiers: &ModifiersState,
) {
let keymap_text = keymap.get_as_string(xkb::KEYMAP_FORMAT_TEXT_V1);
let name = CStr::from_bytes_with_nul(b"eis-keymap\0").unwrap();
let name = c"eis-keymap";
let file = SealedFile::with_content(name, &CString::new(keymap_text).unwrap()).unwrap();
let device = seat.add_device(
@ -260,7 +260,7 @@ fn handle_event(
}
Ok(EisRequestSourceEvent::Request(EisRequest::Bind(request))) => {
if connection.has_interface("ei_keyboard")
&& request.capabilities & 2 << DeviceCapability::Keyboard as u64 != 0
&& request.capabilities & (2 << DeviceCapability::Keyboard as u64) != 0
{
let keymap = keymap_or_default(state.common.config.xkb_config());
client.add_keyboard(

View file

@ -11,16 +11,13 @@ impl BufferHandler for State {
fn buffer_destroyed(&mut self, buffer: &WlBuffer) {
if let BackendData::Kms(kms_state) = &mut self.backend {
for device in kms_state.drm_devices.values_mut() {
if device.inner.active_buffers.remove(&buffer.downgrade()) {
if !device
if device.inner.active_buffers.remove(&buffer.downgrade()) && !device
.inner
.in_use(kms_state.primary_node.read().unwrap().as_ref())
{
if let Err(err) = kms_state.refresh_used_devices() {
warn!(?err, "Failed to init devices.");
};
break;
}
.in_use(kms_state.primary_node.read().unwrap().as_ref()) {
if let Err(err) = kms_state.refresh_used_devices() {
warn!(?err, "Failed to init devices.");
};
break;
}
}
}

View file

@ -122,7 +122,7 @@ pub fn frame_time_estimation(clock: &Clock<Monotonic>, states: &SurfaceData) ->
if let Some(ref last) = data.last_commit {
// if the time since the last commit is already higher than our estimation,
// there is no reason to not use that as a better "guess"
let diff = Time::elapsed(&last, clock.now());
let diff = Time::elapsed(last, clock.now());
Some(diff.max(data.estimation))
} else {
Some(data.estimation)
@ -275,7 +275,7 @@ impl CompositorHandler for State {
// schedule a new render
if let Some(output) = shell.visible_output_for_surface(surface) {
self.backend.schedule_render(&output);
self.backend.schedule_render(output);
}
if mapped {
@ -349,7 +349,7 @@ impl CompositorHandler for State {
if let Some(element) = shell.element_for_surface(surface).cloned() {
crate::shell::layout::floating::ResizeSurfaceGrab::apply_resize_to_location(
element.clone(),
&mut *shell,
&mut shell,
);
}
}
@ -392,8 +392,8 @@ impl State {
} else {
None
};
if toplevel_ensure_initial_configure(&toplevel, initial_size)
&& with_renderer_surface_state(&surface, |state| state.buffer().is_some())
if toplevel_ensure_initial_configure(toplevel, initial_size)
&& with_renderer_surface_state(surface, |state| state.buffer().is_some())
.unwrap_or(false)
{
let window = pending.surface.clone();

View file

@ -68,7 +68,7 @@ impl ClientDndGrabHandler for State {
seat: Seat<Self>,
) {
let user_data = seat.user_data();
user_data.insert_if_missing_threadsafe::<Mutex<Option<DnDIcon>>, _>(|| Default::default());
user_data.insert_if_missing_threadsafe::<Mutex<Option<DnDIcon>>, _>(Default::default);
let offset = if let CursorImageStatus::Surface(ref surface) = seat.cursor_image_status() {
compositor::with_states(surface, |states| {

View file

@ -36,12 +36,11 @@ impl PreferredDecorationMode {
pub fn mode(window: &Window) -> Option<XdgMode> {
let user_data = window.user_data();
user_data.insert_if_missing(|| PreferredDecorationMode(RefCell::new(None)));
user_data
*user_data
.get::<PreferredDecorationMode>()
.unwrap()
.0
.borrow()
.clone()
}
pub fn update(window: &Window, update: Option<XdgMode>) {
@ -56,21 +55,12 @@ impl PreferredDecorationMode {
}
pub type KdeDecorationData = Mutex<KdeDecorationSurfaceState>;
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct KdeDecorationSurfaceState {
pub mode: Option<KdeMode>,
pub objs: Vec<OrgKdeKwinServerDecoration>,
}
impl Default for KdeDecorationSurfaceState {
fn default() -> Self {
KdeDecorationSurfaceState {
mode: None,
objs: Vec::new(),
}
}
}
impl XdgDecorationHandler for State {
fn new_decoration(&mut self, toplevel: ToplevelSurface) {
let shell = self.common.shell.read();

View file

@ -46,7 +46,7 @@ fn kms_surfaces_for_output<'a>(
output: &'a Output,
) -> impl Iterator<Item = &'a mut Surface> + 'a {
kms_surfaces(state).filter(move |surface| {
surface.output == *output || surface.output.mirroring().as_ref() == Some(&output)
surface.output == *output || surface.output.mirroring().as_ref() == Some(output)
})
}

View file

@ -16,8 +16,7 @@ impl PointerConstraintsHandler for State {
fn new_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle<Self>) {
// XXX region
if pointer
.current_focus()
.map_or(false, |x| x.wl_surface().as_deref() == Some(surface))
.current_focus().is_some_and(|x| x.wl_surface().as_deref() == Some(surface))
{
with_pointer_constraint(surface, pointer, |constraint| {
constraint.unwrap().activate();

View file

@ -52,7 +52,7 @@ impl ScreencopyHandler for State {
.and_then(|output| constraints_for_output(&output, &mut self.backend)),
ImageCaptureSourceData::Workspace(handle) => {
let shell = self.common.shell.read();
let output = shell.workspaces.space_for_handle(&handle)?.output();
let output = shell.workspaces.space_for_handle(handle)?.output();
constraints_for_output(output, &mut self.backend)
}
ImageCaptureSourceData::Toplevel(window) => {
@ -339,7 +339,7 @@ fn constraints_for_output(output: &Output, backend: &mut BackendData) -> Option<
let mut renderer = backend
.offscreen_renderer(|kms| {
kms.target_node_for_output(&output)
kms.target_node_for_output(output)
.or(*kms.primary_node.read().unwrap())
})
.unwrap();
@ -357,7 +357,7 @@ fn constraints_for_toplevel(
.offscreen_renderer(|kms| {
let dma_node = with_renderer_surface_state(&wl_surface, |state| {
let buffer = state.buffer()?;
let dmabuf = get_dmabuf(&*buffer).ok()?;
let dmabuf = get_dmabuf(buffer).ok()?;
dmabuf.node()
})
.flatten();

View file

@ -173,7 +173,7 @@ where
Ok(Some(PendingImageCopyData {
frame,
damage: damage
.into_iter()
.iter()
.map(|rect| {
let logical = rect.to_logical(1);
logical.to_buffer(1, transform.invert(), &buffer_size.to_logical(1, transform))
@ -354,7 +354,7 @@ pub fn render_workspace_to_buffer(
&common.shell,
None,
common.clock.now(),
&output,
output,
None,
handle,
cursor_mode,
@ -373,7 +373,7 @@ pub fn render_workspace_to_buffer(
&common.shell,
None,
common.clock.now(),
&output,
output,
None,
handle,
cursor_mode,
@ -655,7 +655,7 @@ pub fn render_window_to_buffer(
.and_then(|wl_surface| {
with_renderer_surface_state(&wl_surface, |state| {
let buffer = state.buffer()?;
let dmabuf = get_dmabuf(&*buffer).ok()?;
let dmabuf = get_dmabuf(buffer).ok()?;
dmabuf.node()
})
})
@ -783,7 +783,7 @@ pub fn render_cursor_to_buffer(
{
let mut elements = cursor::draw_cursor(
renderer,
&seat,
seat,
Point::from((0.0, 0.0)),
1.0.into(),
1.0,

View file

@ -37,14 +37,14 @@ impl SecurityContextHandler for State {
let drm_node = client_data
.as_ref()
.and_then(|data| data.downcast_ref::<ClientState>())
.and_then(|data| data.advertised_drm_node.clone())
.and_then(|data| data.advertised_drm_node)
.or_else(|| {
client_data
.as_ref()
.and_then(|data| data.downcast_ref::<XWaylandClientData>())
.and_then(|data| data.user_data().get::<DrmNode>().cloned())
})
.or_else(|| new_state.advertised_drm_node.clone());
.or(new_state.advertised_drm_node);
if let Err(err) = state.common.display_handle.insert_client(
client_stream,

View file

@ -40,7 +40,7 @@ impl SessionLockHandler for State {
});
for output in shell.outputs() {
self.backend.schedule_render(&output);
self.backend.schedule_render(output);
}
}
@ -49,7 +49,7 @@ impl SessionLockHandler for State {
shell.session_lock = None;
for output in shell.outputs() {
self.backend.schedule_render(&output);
self.backend.schedule_render(output);
}
}

View file

@ -52,7 +52,7 @@ impl ToplevelManagementHandler for State {
let (target, new_pos) = if let Some((idx, workspace)) = maybe {
let handle = workspace.handle;
let new_pos = shell.activate(
&output,
output,
idx,
WorkspaceDelta::new_shortcut(),
&mut self.common.workspace_state.update(),
@ -112,7 +112,7 @@ impl ToplevelManagementHandler for State {
if seat.active_output() != *output {
if let Some(new_pos) = new_pos {
seat.set_active_output(&output);
seat.set_active_output(output);
if let Some(ptr) = seat.get_pointer() {
let serial = SERIAL_COUNTER.next_serial();
ptr.motion(
@ -150,7 +150,7 @@ impl ToplevelManagementHandler for State {
let Some(surface) = window.wl_surface() else {
return;
};
let Some((from_workspace, _)) = shell.workspace_for_surface(&*surface) else {
let Some((from_workspace, _)) = shell.workspace_for_surface(&surface) else {
return;
};
@ -182,7 +182,7 @@ impl ToplevelManagementHandler for State {
.or_else(|| {
window
.wl_surface()
.and_then(|surface| shell.visible_output_for_surface(&*surface).cloned())
.and_then(|surface| shell.visible_output_for_surface(&surface).cloned())
})
.unwrap_or_else(|| seat.focused_or_active_output());
if let Some(target) =

View file

@ -126,7 +126,7 @@ impl XdgActivationHandler for State {
let Some((element_output, element_workspace)) = shell
.space_for(&element)
.map(|w| (w.output.clone(), w.handle.clone()))
.map(|w| (w.output.clone(), w.handle))
else {
return;
};
@ -227,7 +227,7 @@ impl XdgActivationHandler for State {
} else {
shell
.pending_activations
.insert(ActivationKey::Wayland(surface), context.clone());
.insert(ActivationKey::Wayland(surface), *context);
};
}
}

View file

@ -99,7 +99,7 @@ impl XdgShellHandler for State {
});
if let Some(root) = maybe_root {
let target = root.into();
let target = root;
let ret = self.common.popups.grab_popup(target, kind, &seat, serial);
match ret {
Ok(mut grab) => {
@ -304,12 +304,10 @@ impl XdgShellHandler for State {
if should_focus {
Shell::set_focus(self, Some(&target), &seat, None, true);
}
} else {
if let Some(pending) = shell.pending_windows.iter_mut().find(|pending| {
pending.surface.wl_surface().as_deref() == Some(surface.wl_surface())
}) {
pending.fullscreen.take();
}
} else if let Some(pending) = shell.pending_windows.iter_mut().find(|pending| {
pending.surface.wl_surface().as_deref() == Some(surface.wl_surface())
}) {
pending.fullscreen.take();
}
}
@ -337,12 +335,12 @@ impl XdgShellHandler for State {
{
let dh = self.common.display_handle.clone();
for client in clients.values() {
client_compositor_state(&client).blocker_cleared(self, &dh);
client_compositor_state(client).blocker_cleared(self, &dh);
}
}
if let Some(output) = output.as_ref() {
self.backend.schedule_render(&output);
self.backend.schedule_render(output);
}
}

View file

@ -22,7 +22,7 @@ use tracing::warn;
impl Shell {
pub fn unconstrain_popup(&self, surface: &PopupSurface) {
if let Some(parent) = get_popup_toplevel(&surface) {
if let Some(parent) = get_popup_toplevel(surface) {
if let Some(elem) = self.element_for_surface(&parent) {
let (mut element_geo, output, is_tiled) =
if let Some(workspace) = self.space_for(elem) {
@ -87,14 +87,14 @@ pub fn update_reactive_popups<'a>(
for (popup, _) in PopupManager::popups_for_surface(toplevel.wl_surface()) {
match popup {
PopupKind::Xdg(surface) => {
let positioner = with_states(&surface.wl_surface(), |states| {
let positioner = with_states(surface.wl_surface(), |states| {
let attributes = states
.data_map
.get::<XdgPopupSurfaceData>()
.unwrap()
.lock()
.unwrap();
attributes.current.positioner.clone()
attributes.current.positioner
});
if positioner.reactive {
let anchor_point = loc + positioner.get_anchor_point().as_global();

View file

@ -141,11 +141,10 @@ where
surface.wl_surface(),
move |_, _dh, surface| {
let corner_radii_too_big = with_states(surface, |surface_data| {
let corners = surface_data
let corners = *surface_data
.cached_state
.get::<CacheableCorners>()
.pending()
.clone();
.pending();
surface_data
.cached_state
.get::<SurfaceCachedState>()

View file

@ -87,7 +87,7 @@ where
) {
let data = DrmInstanceData {
formats: global_data.formats.clone(),
dmabuf_global: global_data.dmabuf_global.clone(),
dmabuf_global: global_data.dmabuf_global,
};
let drm_instance = data_init.init(resource, data);
@ -266,7 +266,7 @@ impl<R: 'static> WlDrmState<R> {
filter: Box::new(client_filter),
formats,
device_path,
dmabuf_global: dmabuf_global.clone(),
dmabuf_global: *dmabuf_global,
};
display.create_global::<D, wl_drm::WlDrm, _>(2, data)

View file

@ -219,15 +219,12 @@ where
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
OutputSourceRequest::CreateSource { source, output } => {
let data = match Output::from_resource(&output) {
Some(output) => ImageCaptureSourceData::Output(output.downgrade()),
None => ImageCaptureSourceData::Destroyed,
};
data_init.init(source, data);
}
_ => {}
if let OutputSourceRequest::CreateSource { source, output } = request {
let data = match Output::from_resource(&output) {
Some(output) => ImageCaptureSourceData::Output(output.downgrade()),
None => ImageCaptureSourceData::Destroyed,
};
data_init.init(source, data);
}
}
@ -256,15 +253,12 @@ where
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
CosmicWorkspaceSourceRequest::CreateSource { source, output } => {
let data = match state.workspace_state().get_ext_workspace_handle(&output) {
Some(workspace) => ImageCaptureSourceData::Workspace(workspace),
None => ImageCaptureSourceData::Destroyed,
};
data_init.init(source, data);
}
_ => {}
if let CosmicWorkspaceSourceRequest::CreateSource { source, output } = request {
let data = match state.workspace_state().get_ext_workspace_handle(&output) {
Some(workspace) => ImageCaptureSourceData::Workspace(workspace),
None => ImageCaptureSourceData::Destroyed,
};
data_init.init(source, data);
}
}
@ -293,18 +287,15 @@ where
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
ToplevelSourceRequest::CreateSource {
if let ToplevelSourceRequest::CreateSource {
source,
toplevel_handle,
} => {
let data = match window_from_ext_handle(state, &toplevel_handle) {
Some(toplevel) => ImageCaptureSourceData::Toplevel(toplevel.clone()),
None => ImageCaptureSourceData::Destroyed,
};
data_init.init(source, data);
}
_ => {}
} = request {
let data = match window_from_ext_handle(state, &toplevel_handle) {
Some(toplevel) => ImageCaptureSourceData::Toplevel(toplevel.clone()),
None => ImageCaptureSourceData::Destroyed,
};
data_init.init(source, data);
}
}
@ -330,9 +321,7 @@ where
_dhandle: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
match request {
_ => {}
}
{}
}
fn destroyed(

View file

@ -148,19 +148,16 @@ where
_dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
match request {
zcosmic_output_head_v1::Request::Release => {
let inner = state.output_configuration_state();
if let Some(head) = inner
.instances
.iter_mut()
.flat_map(|instance| instance.heads.iter_mut())
.find(|head| head.extension_obj.as_ref().is_some_and(|o| o == obj))
{
head.extension_obj.take();
}
if let zcosmic_output_head_v1::Request::Release = request {
let inner = state.output_configuration_state();
if let Some(head) = inner
.instances
.iter_mut()
.flat_map(|instance| instance.heads.iter_mut())
.find(|head| head.extension_obj.as_ref().is_some_and(|o| o == obj))
{
head.extension_obj.take();
}
_ => {}
}
}
}

View file

@ -136,13 +136,10 @@ where
_dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
match request {
zwlr_output_head_v1::Request::Release => {
for instance in &mut state.output_configuration_state().instances {
instance.heads.retain(|h| &h.obj != obj);
}
if let zwlr_output_head_v1::Request::Release = request {
for instance in &mut state.output_configuration_state().instances {
instance.heads.retain(|h| &h.obj != obj);
}
_ => {}
}
}
@ -173,16 +170,13 @@ where
_dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
match request {
zwlr_output_mode_v1::Request::Release => {
let state = state.output_configuration_state();
for instance in &mut state.instances {
for head in &mut instance.heads {
head.modes.retain(|mode| mode != obj)
}
if let zwlr_output_mode_v1::Request::Release = request {
let state = state.output_configuration_state();
for instance in &mut state.instances {
for head in &mut instance.heads {
head.modes.retain(|mode| mode != obj)
}
}
_ => {}
}
}
}
@ -281,13 +275,11 @@ where
.heads
.iter_mut()
.map(|(head, conf)| {
let output = match {
inner
.instances
.iter()
.find_map(|instance| instance.heads.iter().find(|h| h.obj == *head))
.map(|i| i.output.clone())
} {
let output = match inner
.instances
.iter()
.find_map(|instance| instance.heads.iter().find(|h| h.obj == *head))
.map(|i| i.output.clone()) {
Some(o) => o,
None => {
return Err(zwlr_output_configuration_head_v1::Error::InvalidMode);

View file

@ -37,8 +37,7 @@ mod handlers;
pub fn head_is_enabled(output: &Output) -> bool {
output
.user_data()
.get::<OutputState>()
.map_or(false, |inner| inner.lock().unwrap().enabled)
.get::<OutputState>().is_some_and(|inner| inner.lock().unwrap().enabled)
}
#[derive(Debug)]
@ -135,7 +134,7 @@ impl<'a> TryFrom<&'a mut PendingOutputConfigurationInner> for OutputConfiguratio
wlr_mode
.data::<Mode>()
.cloned()
.ok_or_else(|| zwlr_output_configuration_head_v1::Error::InvalidMode)?,
.ok_or(zwlr_output_configuration_head_v1::Error::InvalidMode)?,
)),
Some(ModeConfiguration::Custom { size, refresh }) => {
Some(ModeConfiguration::Custom { size, refresh })
@ -283,7 +282,7 @@ where
for instance in &mut self.instances {
let mut removed_heads = Vec::new();
for head in &mut instance.heads {
if &head.output == &output {
if head.output == output {
if head.obj.version() < zwlr_output_head_v1::REQ_RELEASE_SINCE {
removed_heads.push(head.obj.clone());
}
@ -435,7 +434,7 @@ where
.map(|c| c == output_mode)
.unwrap_or(false)
{
instance.obj.current_mode(&*mode);
instance.obj.current_mode(mode);
}
}
}

View file

@ -120,7 +120,7 @@ impl OverlapNotifyState {
w.is_sticky()
|| active_workspaces.iter().any(|active_workspace| {
state.in_workspace(&active_workspace)
state.in_workspace(active_workspace)
})
})
{
@ -208,8 +208,8 @@ impl LayerOverlapNotificationDataInternal {
}
}
}
for (_, (identifier, namespace, exclusive, layer, overlap)) in
&self.last_snapshot.layer_overlaps
for (identifier, namespace, exclusive, layer, overlap) in
self.last_snapshot.layer_overlaps.values()
{
new_notification.layer_enter(
identifier.clone(),
@ -414,22 +414,19 @@ where
_dhandle: &DisplayHandle,
data_init: &mut smithay::reexports::wayland_server::DataInit<'_, D>,
) {
match request {
zcosmic_overlap_notify_v1::Request::NotifyOnOverlap {
if let zcosmic_overlap_notify_v1::Request::NotifyOnOverlap {
overlap_notification,
layer_surface,
} => {
let notification = data_init.init(overlap_notification, ());
if let Some(surface) = state.layer_surface_from_resource(layer_surface) {
let mut data = surface
.user_data()
.get_or_insert_threadsafe(LayerOverlapNotificationData::default)
.lock()
.unwrap();
data.add_notification(notification);
}
} = request {
let notification = data_init.init(overlap_notification, ());
if let Some(surface) = state.layer_surface_from_resource(layer_surface) {
let mut data = surface
.user_data()
.get_or_insert_threadsafe(LayerOverlapNotificationData::default)
.lock()
.unwrap();
data.add_notification(notification);
}
_ => {}
}
}
@ -461,9 +458,7 @@ where
_dhandle: &DisplayHandle,
_data_init: &mut smithay::reexports::wayland_server::DataInit<'_, D>,
) {
match request {
_ => {}
}
{}
}
}

View file

@ -167,7 +167,7 @@ impl SessionRef {
}
pub fn user_data(&self) -> &UserDataMap {
&*self.user_data
&self.user_data
}
}
@ -346,7 +346,7 @@ impl CursorSessionRef {
}
pub fn user_data(&self) -> &UserDataMap {
&*self.user_data
&self.user_data
}
}
@ -746,25 +746,22 @@ where
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
ext_image_copy_capture_session_v1::Request::CreateFrame { frame } => {
let inner = Arc::new(Mutex::new(FrameInner::new(
resource.clone(),
data.inner.lock().unwrap().constraints.clone(),
)));
let obj = data_init.init(
frame,
FrameData {
inner: inner.clone(),
},
);
data.inner
.lock()
.unwrap()
.active_frames
.push(FrameRef { obj, inner });
}
_ => {}
if let ext_image_copy_capture_session_v1::Request::CreateFrame { frame } = request {
let inner = Arc::new(Mutex::new(FrameInner::new(
resource.clone(),
data.inner.lock().unwrap().constraints.clone(),
)));
let obj = data_init.init(
frame,
FrameData {
inner: inner.clone(),
},
);
data.inner
.lock()
.unwrap()
.active_frames
.push(FrameRef { obj, inner });
}
}
@ -803,45 +800,42 @@ where
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
ext_image_copy_capture_cursor_session_v1::Request::GetCaptureSession { session } => {
let new_data = CursorSessionData {
inner: data.inner.clone(),
};
let session = data_init.init(session, new_data);
if let ext_image_copy_capture_cursor_session_v1::Request::GetCaptureSession { session } = request {
let new_data = CursorSessionData {
inner: data.inner.clone(),
};
let session = data_init.init(session, new_data);
let mut inner = data.inner.lock().unwrap();
if inner.session.is_some() {
resource.post_error(
ext_image_copy_capture_cursor_session_v1::Error::DuplicateSession,
"Duplicate session",
);
return;
}
if inner.stopped {
session.stopped();
} else if let Some(constraints) = inner.constraints.as_ref() {
session.buffer_size(constraints.size.w as u32, constraints.size.h as u32);
for fmt in &constraints.shm {
session.shm_format(*fmt);
}
if let Some(dma) = constraints.dma.as_ref() {
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
session.dmabuf_device(node);
for (fmt, modifiers) in &dma.formats {
let modifiers = modifiers
.iter()
.flat_map(|modifier| u64::from(*modifier).to_ne_bytes())
.collect::<Vec<u8>>();
session.dmabuf_format(*fmt as u32, modifiers);
}
}
session.done();
}
inner.session = Some(session);
let mut inner = data.inner.lock().unwrap();
if inner.session.is_some() {
resource.post_error(
ext_image_copy_capture_cursor_session_v1::Error::DuplicateSession,
"Duplicate session",
);
return;
}
_ => {}
if inner.stopped {
session.stopped();
} else if let Some(constraints) = inner.constraints.as_ref() {
session.buffer_size(constraints.size.w as u32, constraints.size.h as u32);
for fmt in &constraints.shm {
session.shm_format(*fmt);
}
if let Some(dma) = constraints.dma.as_ref() {
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
session.dmabuf_device(node);
for (fmt, modifiers) in &dma.formats {
let modifiers = modifiers
.iter()
.flat_map(|modifier| u64::from(*modifier).to_ne_bytes())
.collect::<Vec<u8>>();
session.dmabuf_format(*fmt as u32, modifiers);
}
}
session.done();
}
inner.session = Some(session);
}
}
@ -879,25 +873,22 @@ where
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
match request {
ext_image_copy_capture_session_v1::Request::CreateFrame { frame } => {
let inner = Arc::new(Mutex::new(FrameInner::new(
resource.clone(),
data.inner.lock().unwrap().constraints.clone(),
)));
let obj = data_init.init(
frame,
FrameData {
inner: inner.clone(),
},
);
data.inner
.lock()
.unwrap()
.active_frames
.push(FrameRef { obj, inner });
}
_ => {}
if let ext_image_copy_capture_session_v1::Request::CreateFrame { frame } = request {
let inner = Arc::new(Mutex::new(FrameInner::new(
resource.clone(),
data.inner.lock().unwrap().constraints.clone(),
)));
let obj = data_init.init(
frame,
FrameData {
inner: inner.clone(),
},
);
data.inner
.lock()
.unwrap()
.active_frames
.push(FrameRef { obj, inner });
}
}

View file

@ -252,10 +252,7 @@ where
_dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
match request {
zcosmic_toplevel_handle_v1::Request::Destroy => {}
_ => {}
}
if let zcosmic_toplevel_handle_v1::Request::Destroy = request {}
}
fn destroyed(
@ -290,7 +287,7 @@ pub fn toplevel_leave_output(toplevel: &impl Window, output: &Output) {
pub fn toplevel_enter_workspace(toplevel: &impl Window, workspace: &WorkspaceHandle) {
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
state.lock().unwrap().workspaces.push(workspace.clone());
state.lock().unwrap().workspaces.push(*workspace);
}
}
@ -509,7 +506,7 @@ where
changed = true;
}
if handle_state.states.as_ref().map_or(true, |states| {
if handle_state.states.as_ref().is_none_or(|states| {
(states.contains(&States::Maximized) != window.is_maximized())
|| (states.contains(&States::Fullscreen) != window.is_fullscreen())
|| (states.contains(&States::Activated) != window.is_activated())
@ -562,7 +559,7 @@ where
.geometry
.filter(|_| instance.version() >= zcosmic_toplevel_handle_v1::EVT_GEOMETRY_SINCE)
.filter(|geo| output.geometry().intersection(*geo).is_some())
.map(|geo| geo.to_local(&output));
.map(|geo| geo.to_local(output));
for wl_output in output.client_outputs(&client) {
if handle_state.wl_outputs.insert(wl_output.clone()) {
instance.output_enter(&wl_output);
@ -584,7 +581,7 @@ where
.iter()
.any(|output| output.owns(wl_output));
if !retain {
instance.output_leave(&wl_output);
instance.output_leave(wl_output);
changed = true;
}
retain
@ -596,8 +593,8 @@ where
.iter()
.filter(|w| !handle_state.workspaces.contains(w))
{
for handle in workspace_state.raw_ext_workspace_handles(&new_workspace, &instance.id()) {
instance.ext_workspace_enter(&handle);
for handle in workspace_state.raw_ext_workspace_handles(new_workspace, &instance.id()) {
instance.ext_workspace_enter(handle);
changed = true;
}
}
@ -606,8 +603,8 @@ where
.iter()
.filter(|w| !state.workspaces.contains(w))
{
for handle in workspace_state.raw_ext_workspace_handles(&old_workspace, &instance.id()) {
instance.ext_workspace_leave(&handle);
for handle in workspace_state.raw_ext_workspace_handles(old_workspace, &instance.id()) {
instance.ext_workspace_leave(handle);
changed = true;
}
}

View file

@ -350,7 +350,7 @@ where
let retain =
wl_output.is_alive() && group.outputs.iter().any(|output| output.owns(wl_output));
if !retain {
instance.output_leave(&wl_output);
instance.output_leave(wl_output);
changed = true;
}
retain
@ -361,7 +361,7 @@ where
if handle_state.capabilities != Some(group.capabilities) {
instance.capabilities(group.capabilities);
handle_state.capabilities = Some(group.capabilities.clone());
handle_state.capabilities = Some(group.capabilities);
changed = true;
}

View file

@ -305,8 +305,8 @@ where
fn done(&mut self) {
let mut changed = false;
for instance in &self.ext_instances {
for mut group in &mut self.groups {
if ext::send_group_to_client::<D>(&self.dh, instance, &mut group) {
for group in &mut self.groups {
if ext::send_group_to_client::<D>(&self.dh, instance, group) {
changed = true;
}
}
@ -338,7 +338,7 @@ where
}
}
impl<'a, D> WorkspaceUpdateGuard<'a, D>
impl<D> WorkspaceUpdateGuard<'_, D>
where
D: WorkspaceHandler,
{
@ -617,7 +617,7 @@ where
}
}
impl<'a, D> Drop for WorkspaceUpdateGuard<'a, D>
impl<D> Drop for WorkspaceUpdateGuard<'_, D>
where
D: WorkspaceHandler,
{