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

@ -2,10 +2,9 @@
use std::process::Command; use std::process::Command;
fn main() { fn main() {
if let Some(output) = Command::new("git") if let Ok(output) = Command::new("git")
.args(&["rev-parse", "HEAD"]) .args(["rev-parse", "HEAD"])
.output() .output()
.ok()
{ {
let git_hash = String::from_utf8(output.stdout).unwrap(); let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash); println!("cargo:rustc-env=GIT_HASH={}", git_hash);

View file

@ -186,8 +186,7 @@ impl State {
if let Ok(node) = DrmNode::from_dev_id(dev) { if let Ok(node) = DrmNode::from_dev_id(dev) {
let node = node let node = node
.node_with_type(NodeType::Render) .node_with_type(NodeType::Render)
.map(|res| res.ok()) .and_then(|res| res.ok())
.flatten()
.unwrap_or(node); .unwrap_or(node);
for ident in allowlist { for ident in allowlist {
if ident.matches(&node) { if ident.matches(&node) {
@ -208,8 +207,7 @@ impl State {
if let Ok(node) = DrmNode::from_dev_id(dev) { if let Ok(node) = DrmNode::from_dev_id(dev) {
let node = node let node = node
.node_with_type(NodeType::Render) .node_with_type(NodeType::Render)
.map(|res| res.ok()) .and_then(|res| res.ok())
.flatten()
.unwrap_or(node); .unwrap_or(node);
for ident in blocklist { for ident in blocklist {
if ident.matches(&node) { if ident.matches(&node) {
@ -228,7 +226,7 @@ impl State {
.kms() .kms()
.session .session
.open( .open(
&path, path,
OFlags::RDWR | OFlags::CLOEXEC | OFlags::NOCTTY | OFlags::NONBLOCK, OFlags::RDWR | OFlags::CLOEXEC | OFlags::NOCTTY | OFlags::NONBLOCK,
) )
.with_context(|| { .with_context(|| {
@ -595,7 +593,7 @@ impl Device {
let added = config let added = config
.iter() .iter()
.filter(|(conn, maybe)| match (surfaces.get(&conn), maybe) { .filter(|(conn, maybe)| match (surfaces.get(conn), maybe) {
(Some(current_crtc), Some(new_crtc)) => current_crtc != new_crtc, (Some(current_crtc), Some(new_crtc)) => current_crtc != new_crtc,
// see `removed` // see `removed`
(Some(_), None) => true, (Some(_), None) => true,
@ -610,10 +608,10 @@ impl Device {
.outputs .outputs
.iter() .iter()
.filter(|(conn, _)| match config.get(conn) { .filter(|(conn, _)| match config.get(conn) {
Some(Some(c)) => surfaces.get(&conn).is_some_and(|crtc| c != crtc), Some(Some(c)) => surfaces.get(conn).is_some_and(|crtc| c != crtc),
// if don't have a crtc, we need to drop the surface if it exists. // if don't have a crtc, we need to drop the surface if it exists.
// so it needs to be in both `removed` AND `added`. // so it needs to be in both `removed` AND `added`.
Some(None) => surfaces.get(&conn).is_some(), Some(None) => surfaces.get(conn).is_some(),
_ => true, _ => true,
}) })
.map(|(conn, _)| *conn) .map(|(conn, _)| *conn)
@ -630,7 +628,7 @@ impl Device {
} }
} }
impl<'a> LockedDevice<'a> { impl LockedDevice<'_> {
fn allow_frame_flags( fn allow_frame_flags(
&mut self, &mut self,
flag: bool, flag: bool,
@ -660,7 +658,7 @@ impl<'a> LockedDevice<'a> {
renderer, renderer,
shell, shell,
now, now,
&output, output,
CursorMode::All, CursorMode::All,
None, None,
) )
@ -759,7 +757,7 @@ impl InnerDevice {
.outputs .outputs
.get(&conn) .get(&conn)
.cloned() .cloned()
.map(|output| Ok(output)) .map(Ok)
.unwrap_or_else(|| create_output_for_conn(drm, conn)) .unwrap_or_else(|| create_output_for_conn(drm, conn))
.context("Failed to create `Output`")?; .context("Failed to create `Output`")?;
@ -895,7 +893,7 @@ impl InnerDevice {
{ {
for surface in self.surfaces.values_mut() { for surface in self.surfaces.values_mut() {
let known_nodes = surface.known_nodes().clone(); let known_nodes = surface.known_nodes().clone();
for gone_device in known_nodes.difference(&used_devices) { for gone_device in known_nodes.difference(used_devices) {
surface.remove_node(*gone_device); surface.remove_node(*gone_device);
} }
for new_device in used_devices.difference(&known_nodes) { for new_device in used_devices.difference(&known_nodes) {
@ -993,7 +991,7 @@ fn populate_modes(
.iter() .iter()
.find(|mode| mode.mode_type().contains(ModeTypeFlags::PREFERRED)) .find(|mode| mode.mode_type().contains(ModeTypeFlags::PREFERRED))
.copied() .copied()
.or(conn_info.modes().get(0).copied()) .or(conn_info.modes().first().copied())
else { else {
anyhow::bail!("No mode found"); anyhow::bail!("No mode found");
}; };
@ -1011,13 +1009,13 @@ fn populate_modes(
size: (mode.size().0 as i32, mode.size().1 as i32).into(), size: (mode.size().0 as i32, mode.size().1 as i32).into(),
refresh: refresh_rate as i32, refresh: refresh_rate as i32,
}; };
modes.push(mode.clone()); modes.push(mode);
output.add_mode(mode); output.add_mode(mode);
} }
for mode in output for mode in output
.modes() .modes()
.into_iter() .into_iter()
.filter(|mode| !modes.contains(&mode)) .filter(|mode| !modes.contains(mode))
{ {
output.delete_mode(mode); output.delete_mode(mode);
} }

View file

@ -82,7 +82,7 @@ pub fn display_configuration(
.flat_map(|conn| device.get_connector(*conn, false).ok()) .flat_map(|conn| device.get_connector(*conn, false).ok())
.filter(|conn| { .filter(|conn| {
if let Some(enc) = conn.current_encoder() { if let Some(enc) = conn.current_encoder() {
if let Some(enc) = device.get_encoder(enc).ok() { if let Ok(enc) = device.get_encoder(enc) {
if let Some(crtc) = enc.crtc() { if let Some(crtc) = enc.crtc() {
return cleanup.contains(&crtc); return cleanup.contains(&crtc);
} }

View file

@ -135,7 +135,7 @@ pub fn init_backend(
// manually add already present gpus // manually add already present gpus
let mut outputs = Vec::new(); let mut outputs = Vec::new();
for (dev, path) in udev_dispatcher.as_source_ref().device_list() { for (dev, path) in udev_dispatcher.as_source_ref().device_list() {
match state.device_added(dev, path.into(), dh) { match state.device_added(dev, path, dh) {
Ok(added) => outputs.extend(added), Ok(added) => outputs.extend(added),
Err(err) => warn!("Failed to add device {}: {:?}", path.display(), err), Err(err) => warn!("Failed to add device {}: {:?}", path.display(), err),
} }
@ -169,7 +169,7 @@ pub fn init_backend(
} }
// start x11 // start x11
let primary = state.backend.kms().primary_node.read().unwrap().clone(); let primary = *state.backend.kms().primary_node.read().unwrap();
state.launch_xwayland(primary); state.launch_xwayland(primary);
Ok(()) Ok(())
@ -209,7 +209,7 @@ fn init_libinput(
.context("Failed to initialize libinput event source")?; .context("Failed to initialize libinput event source")?;
// Create relative pointer global // Create relative pointer global
RelativePointerManagerState::new::<State>(&dh); RelativePointerManagerState::new::<State>(dh);
Ok(libinput_context) Ok(libinput_context)
} }
@ -239,7 +239,7 @@ fn determine_primary_gpu(
// try to find builtin display // try to find builtin display
for dev in drm_devices.values() { for dev in drm_devices.values() {
if dev.inner.surfaces.values().any(|s| { if dev.inner.surfaces.values().any(|s| {
if let Some(conn_info) = dev.drm.device().get_connector(s.connector, false).ok() { if let Ok(conn_info) = dev.drm.device().get_connector(s.connector, false) {
let i = conn_info.interface(); let i = conn_info.interface();
i == Interface::EmbeddedDisplayPort || i == Interface::LVDS || i == Interface::DSI i == Interface::EmbeddedDisplayPort || i == Interface::LVDS || i == Interface::DSI
} else { } else {
@ -392,7 +392,7 @@ impl State {
} }
} else { } else {
let dh = state.common.display_handle.clone(); let dh = state.common.display_handle.clone();
match state.device_added(dev, path.into(), &dh) { match state.device_added(dev, path, &dh) {
Ok(outputs) => added.extend(outputs), Ok(outputs) => added.extend(outputs),
Err(err) => error!(?err, "Failed to add drm device {}.", path.display(),), Err(err) => error!(?err, "Failed to add drm device {}.", path.display(),),
} }
@ -465,7 +465,7 @@ impl KmsState {
if let Some(state) = self.syncobj_state.as_mut() { if let Some(state) = self.syncobj_state.as_mut() {
state.update_device(import_device); state.update_device(import_device);
} else { } else {
let syncobj_state = DrmSyncobjState::new::<State>(&dh, import_device); let syncobj_state = DrmSyncobjState::new::<State>(dh, import_device);
self.syncobj_state = Some(syncobj_state); self.syncobj_state = Some(syncobj_state);
} }
return Ok(()); return Ok(());
@ -646,7 +646,7 @@ impl KmsState {
} }
} }
impl<'a> KmsGuard<'a> { impl KmsGuard<'_> {
pub fn schedule_render(&mut self, output: &Output) { pub fn schedule_render(&mut self, output: &Output) {
for surface in self for surface in self
.drm_devices .drm_devices
@ -755,7 +755,7 @@ impl<'a> KmsGuard<'a> {
.crtcs() .crtcs()
.iter() .iter()
.filter(|crtc| { .filter(|crtc| {
!device.inner.surfaces.get(crtc).is_some() device.inner.surfaces.get(crtc).is_none()
// TODO: We can't do this. See https://github.com/Smithay/smithay/pull/1820 // TODO: We can't do this. See https://github.com/Smithay/smithay/pull/1820
//.is_some_and(|surface| surface.output.is_enabled()) //.is_some_and(|surface| surface.output.is_enabled())
}) })
@ -915,7 +915,7 @@ impl<'a> KmsGuard<'a> {
&mut renderer, &mut renderer,
&shell, &shell,
now, now,
&output, output,
CursorMode::All, CursorMode::All,
None, None,
) )
@ -1024,7 +1024,7 @@ impl<'a> KmsGuard<'a> {
&mut renderer, &mut renderer,
&shell, &shell,
now, now,
&output, output,
CursorMode::All, CursorMode::All,
None, None,
) )
@ -1068,7 +1068,7 @@ impl<'a> KmsGuard<'a> {
&mut renderer, &mut renderer,
&shell, &shell,
now, now,
&output, output,
CursorMode::All, CursorMode::All,
None, None,
) )
@ -1103,10 +1103,8 @@ impl<'a> KmsGuard<'a> {
None None
}; };
if !test_only { if !test_only && mirrored_output != surface.output.mirroring() {
if mirrored_output != surface.output.mirroring() { surface.set_mirroring(mirrored_output.clone());
surface.set_mirroring(mirrored_output.clone());
}
} }
} }
} }

View file

@ -42,6 +42,12 @@ impl fmt::Debug for GbmPixmanDevice {
} }
} }
impl<A: AsFd + 'static> Default for GbmPixmanBackend<A> {
fn default() -> Self {
Self::new()
}
}
impl<A: AsFd + 'static> GbmPixmanBackend<A> { impl<A: AsFd + 'static> GbmPixmanBackend<A> {
pub fn new() -> Self { pub fn new() -> Self {
GbmPixmanBackend { GbmPixmanBackend {

View file

@ -181,15 +181,14 @@ pub type GbmDrmOutput = DrmOutput<
DrmDeviceFd, DrmDeviceFd,
>; >;
#[derive(Debug)] #[derive(Debug, Default)]
pub enum QueueState { pub enum QueueState {
#[default]
Idle, Idle,
/// A redraw is queued. /// A redraw is queued.
Queued(RegistrationToken), Queued(RegistrationToken),
/// We submitted a frame to the KMS and waiting for it to be presented. /// We submitted a frame to the KMS and waiting for it to be presented.
WaitingForVBlank { WaitingForVBlank { redraw_needed: bool },
redraw_needed: bool,
},
/// We did not submit anything to KMS and made a timer to fire at the estimated VBlank. /// We did not submit anything to KMS and made a timer to fire at the estimated VBlank.
WaitingForEstimatedVBlank(RegistrationToken), WaitingForEstimatedVBlank(RegistrationToken),
/// A redraw is queued on top of the above. /// A redraw is queued on top of the above.
@ -199,12 +198,6 @@ pub enum QueueState {
}, },
} }
impl Default for QueueState {
fn default() -> Self {
QueueState::Idle
}
}
#[derive(Debug)] #[derive(Debug)]
pub enum ThreadCommand { pub enum ThreadCommand {
Suspend(SyncSender<()>), Suspend(SyncSender<()>),
@ -760,7 +753,7 @@ impl SurfaceThreadState {
let now = self.clock.now(); let now = self.clock.now();
let presentation_time = match metadata.as_ref().map(|data| &data.time) { let presentation_time = match metadata.as_ref().map(|data| &data.time) {
Some(DrmEventTime::Monotonic(tp)) => Some(tp.clone()), Some(DrmEventTime::Monotonic(tp)) => Some(*tp),
_ => None, _ => None,
}; };
let sequence = metadata.as_ref().map(|data| data.sequence).unwrap_or(0); let sequence = metadata.as_ref().map(|data| data.sequence).unwrap_or(0);
@ -944,7 +937,7 @@ impl SurfaceThreadState {
warn!(?name, "Failed to submit rendering: {:?}", err); warn!(?name, "Failed to submit rendering: {:?}", err);
state.queue_redraw(true); state.queue_redraw(true);
} }
return TimeoutAction::Drop; TimeoutAction::Drop
}) })
.expect("Failed to schedule render"); .expect("Failed to schedule render");
@ -954,7 +947,7 @@ impl SurfaceThreadState {
} }
QueueState::WaitingForEstimatedVBlank(estimated_vblank) => { QueueState::WaitingForEstimatedVBlank(estimated_vblank) => {
self.state = QueueState::WaitingForEstimatedVBlankAndQueued { self.state = QueueState::WaitingForEstimatedVBlankAndQueued {
estimated_vblank: estimated_vblank.clone(), estimated_vblank: *estimated_vblank,
queued_render: token, queued_render: token,
}; };
} }
@ -968,7 +961,7 @@ impl SurfaceThreadState {
} if force => { } if force => {
self.loop_handle.remove(*queued_render); self.loop_handle.remove(*queued_render);
self.state = QueueState::WaitingForEstimatedVBlankAndQueued { self.state = QueueState::WaitingForEstimatedVBlankAndQueued {
estimated_vblank: estimated_vblank.clone(), estimated_vblank: *estimated_vblank,
queued_render: token, queued_render: token,
}; };
} }
@ -990,7 +983,7 @@ impl SurfaceThreadState {
.as_ref() .as_ref()
.unwrap_or(&self.target_node), .unwrap_or(&self.target_node),
&self.target_node, &self.target_node,
&*self.shell.read(), &self.shell.read(),
); );
let mut renderer = if render_node != self.target_node { let mut renderer = if render_node != self.target_node {
@ -1016,7 +1009,7 @@ impl SurfaceThreadState {
( (
true, true,
fullscreen_surface.wl_surface().is_some_and(|surface| { fullscreen_surface.wl_surface().is_some_and(|surface| {
recursive_frame_time_estimation(&self.clock, &*surface) recursive_frame_time_estimation(&self.clock, &surface)
.is_some_and(|dur| dur <= _30_FPS) .is_some_and(|dur| dur <= _30_FPS)
}), }),
animations_going, animations_going,
@ -1079,7 +1072,7 @@ impl SurfaceThreadState {
let source_output = self let source_output = self
.mirroring .mirroring
.as_ref() .as_ref()
.or((!self.screen_filter.is_noop()).then(|| &self.output)) .or((!self.screen_filter.is_noop()).then_some(&self.output))
.filter(|output| { .filter(|output| {
PostprocessOutputConfig::for_output_untransformed(output) PostprocessOutputConfig::for_output_untransformed(output)
!= PostprocessOutputConfig::for_output(&self.output) != PostprocessOutputConfig::for_output(&self.output)
@ -1258,7 +1251,7 @@ impl SurfaceThreadState {
&mut renderer, &mut renderer,
&self.output, &self.output,
&pre_postprocess_data, &pre_postprocess_data,
&postprocess_state, postprocess_state,
&self.screen_filter, &self.screen_filter,
); );
@ -1507,7 +1500,7 @@ fn render_node_for_output(
.flat_map(|w| w.wl_surface().and_then(|s| source_node_for_surface(&s))) .flat_map(|w| w.wl_surface().and_then(|s| source_node_for_surface(&s)))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if nodes.contains(&target_node) || nodes.is_empty() { if nodes.contains(target_node) || nodes.is_empty() {
*target_node *target_node
} else { } else {
*primary_node *primary_node
@ -1575,7 +1568,7 @@ fn get_surface_dmabuf_feedback(
FormatSet::from_iter( FormatSet::from_iter(
primary_plane_formats primary_plane_formats
.into_iter() .into_iter()
.chain(overlay_plane_formats.into_iter()), .chain(overlay_plane_formats),
), ),
) )
.build() .build()
@ -1648,7 +1641,7 @@ fn take_screencopy_frames(
} else { } else {
damage_tracking.age_for_buffer(&buffer) damage_tracking.age_for_buffer(&buffer)
}; };
let res = damage_tracking.dt.damage_output(age, &elements); let res = damage_tracking.dt.damage_output(age, elements);
if let Some(old_len) = old_len { if let Some(old_len) = old_len {
elements.truncate(old_len); elements.truncate(old_len);
@ -1708,7 +1701,7 @@ fn send_screencopy_result<'a>(
.texture .texture
.as_ref() .as_ref()
.is_some_and(|tex| tex.format() == Some(format)) .is_some_and(|tex| tex.format() == Some(format))
&& (session.draw_cursor() == false || pre_postprocess_data.cursor_texture.is_none()) && (!session.draw_cursor() || pre_postprocess_data.cursor_texture.is_none())
{ {
None None
} else { } else {

View file

@ -143,7 +143,6 @@ impl Timings {
Time::elapsed(&frame.render_start, clock.now()) Time::elapsed(&frame.render_start, clock.now())
- frame - frame
.render_duration_elements .render_duration_elements
.clone()
.unwrap_or(Duration::ZERO), .unwrap_or(Duration::ZERO),
); );
} }
@ -271,7 +270,7 @@ impl Timings {
} }
let secs = match (self.previous_frames.front(), self.previous_frames.back()) { let secs = match (self.previous_frames.front(), self.previous_frames.back()) {
(Some(Frame { render_start, .. }), Some(end_frame)) => { (Some(Frame { render_start, .. }), Some(end_frame)) => {
Time::elapsed(render_start, end_frame.render_start.clone()) + end_frame.frame_time() Time::elapsed(render_start, end_frame.render_start) + end_frame.frame_time()
} }
_ => { _ => {
return 0.0; return 0.0;

View file

@ -155,7 +155,7 @@ pub fn init_backend_auto(
.startup_done .startup_done
.store(true, std::sync::atomic::Ordering::SeqCst); .store(true, std::sync::atomic::Ordering::SeqCst);
for output in state.common.shell.read().outputs() { for output in state.common.shell.read().outputs() {
state.backend.schedule_render(&output); state.backend.schedule_render(output);
} }
} }
} }

View file

@ -134,7 +134,7 @@ where
R::TextureId: Clone + 'static, R::TextureId: Clone + 'static,
{ {
let scale = scale.into(); let scale = scale.into();
let h = with_states(&surface, |states| { let h = with_states(surface, |states| {
states states
.data_map .data_map
.get::<Mutex<CursorImageAttributes>>() .get::<Mutex<CursorImageAttributes>>()
@ -169,7 +169,7 @@ where
R: Renderer + ImportAll, R: Renderer + ImportAll,
R::TextureId: Clone + 'static, R::TextureId: Clone + 'static,
{ {
if get_role(&surface) != Some("dnd_icon") { if get_role(surface) != Some("dnd_icon") {
warn!( warn!(
?surface, ?surface,
"Trying to display as a dnd icon a surface that does not have the DndIcon role." "Trying to display as a dnd icon a surface that does not have the DndIcon role."
@ -320,7 +320,7 @@ where
MemoryRenderBufferRenderElement::from_buffer( MemoryRenderBufferRenderElement::from_buffer(
renderer, renderer,
location.to_physical(scale), location.to_physical(scale),
&pointer_image, pointer_image,
None, None,
None, None,
None, None,

View file

@ -348,7 +348,7 @@ impl AsGlowRenderer for GlowRenderer {
} }
} }
impl<'a> AsGlowRenderer for GlMultiRenderer<'a> { impl AsGlowRenderer for GlMultiRenderer<'_> {
fn glow_renderer(&self) -> &GlowRenderer { fn glow_renderer(&self) -> &GlowRenderer {
self.as_ref() self.as_ref()
} }
@ -403,7 +403,7 @@ impl Element for DamageElement {
scale: Scale<f64>, scale: Scale<f64>,
_commit: Option<CommitCounter>, _commit: Option<CommitCounter>,
) -> DamageSet<i32, Physical> { ) -> DamageSet<i32, Physical> {
DamageSet::from_slice(&[Rectangle::from_size(self.geometry(scale).size).into()]) DamageSet::from_slice(&[Rectangle::from_size(self.geometry(scale).size)])
} }
} }

View file

@ -93,7 +93,7 @@ pub enum RendererRef<'a> {
GlMulti(GlMultiRenderer<'a>), GlMulti(GlMultiRenderer<'a>),
} }
impl<'a> AsRef<GlowRenderer> for RendererRef<'a> { impl AsRef<GlowRenderer> for RendererRef<'_> {
fn as_ref(&self) -> &GlowRenderer { fn as_ref(&self) -> &GlowRenderer {
match self { match self {
Self::Glow(renderer) => renderer, Self::Glow(renderer) => renderer,
@ -102,7 +102,7 @@ impl<'a> AsRef<GlowRenderer> for RendererRef<'a> {
} }
} }
impl<'a> AsMut<GlowRenderer> for RendererRef<'a> { impl AsMut<GlowRenderer> for RendererRef<'_> {
fn as_mut(&mut self) -> &mut GlowRenderer { fn as_mut(&mut self) -> &mut GlowRenderer {
match self { match self {
Self::Glow(renderer) => renderer, Self::Glow(renderer) => renderer,
@ -442,8 +442,8 @@ where
let (focal_point, zoom_scale) = zoom_state let (focal_point, zoom_scale) = zoom_state
.map(|state| { .map(|state| {
( (
state.animating_focal_point(Some(&output)).to_local(&output), state.animating_focal_point(Some(output)).to_local(output),
state.animating_level(&output), state.animating_level(output),
) )
}) })
.unwrap_or_else(|| ((0., 0.).into(), 1.)); .unwrap_or_else(|| ((0., 0.).into(), 1.));
@ -460,7 +460,7 @@ where
elements.extend( elements.extend(
cursor::draw_cursor( cursor::draw_cursor(
renderer, renderer,
&seat, seat,
location, location,
scale.into(), scale.into(),
zoom_scale, zoom_scale,
@ -486,7 +486,7 @@ where
} }
if !exclude_dnd_icon { if !exclude_dnd_icon {
if let Some(dnd_icon) = get_dnd_icon(&seat) { if let Some(dnd_icon) = get_dnd_icon(seat) {
elements.extend( elements.extend(
cursor::draw_dnd_icon( cursor::draw_dnd_icon(
renderer, renderer,
@ -620,7 +620,7 @@ where
return Ok(debug_elements); return Ok(debug_elements);
}; };
let (previous_idx, idx) = shell_guard.workspaces.active_num(&output); let (previous_idx, idx) = shell_guard.workspaces.active_num(output);
let previous_workspace = previous_workspace let previous_workspace = previous_workspace
.zip(previous_idx) .zip(previous_idx)
.map(|((w, start), idx)| (w.handle, idx, start)); .map(|((w, start), idx)| (w.handle, idx, start));
@ -694,7 +694,7 @@ where
elements.extend(cursor_elements( elements.extend(cursor_elements(
renderer, renderer,
seats.iter(), seats.iter(),
zoom_level.clone(), zoom_level,
&theme, &theme,
now, now,
output, output,
@ -752,8 +752,8 @@ where
let (focal_point, zoom_scale) = zoom_level let (focal_point, zoom_scale) = zoom_level
.map(|state| { .map(|state| {
( (
state.animating_focal_point(Some(&output)).to_local(&output), state.animating_focal_point(Some(output)).to_local(output),
state.animating_level(&output), state.animating_level(output),
) )
}) })
.unwrap_or_else(|| ((0., 0.).into(), 1.)); .unwrap_or_else(|| ((0., 0.).into(), 1.));
@ -761,7 +761,7 @@ where
let crop_to_output = |element: WorkspaceRenderElement<R>| { let crop_to_output = |element: WorkspaceRenderElement<R>| {
CropRenderElement::from_element( CropRenderElement::from_element(
RescaleRenderElement::from_element( RescaleRenderElement::from_element(
element.into(), element,
focal_point focal_point
.as_logical() .as_logical()
.to_physical(output.current_scale().fractional_scale()) .to_physical(output.current_scale().fractional_scale())
@ -774,7 +774,7 @@ where
}; };
render_input_order::<()>( render_input_order::<()>(
&*shell, &shell,
output, output,
previous, previous,
current, current,
@ -817,7 +817,7 @@ where
elements.extend( elements.extend(
render_elements_from_surface_tree::<_, WorkspaceRenderElement<_>>( render_elements_from_surface_tree::<_, WorkspaceRenderElement<_>>(
renderer, renderer,
&layer.wl_surface(), layer.wl_surface(),
location location
.to_local(output) .to_local(output)
.as_logical() .as_logical()
@ -917,7 +917,7 @@ where
resize_indicator.clone(), resize_indicator.clone(),
active_hint, active_hint,
alpha, alpha,
&theme.cosmic(), theme.cosmic(),
) )
.into_iter() .into_iter()
.map(Into::into) .map(Into::into)
@ -932,7 +932,7 @@ where
last_active_seat, last_active_seat,
!move_active && is_active_space, !move_active && is_active_space,
overview.clone(), overview.clone(),
&theme.cosmic(), theme.cosmic(),
) { ) {
Ok(elements) => { Ok(elements) => {
elements elements
@ -963,7 +963,7 @@ where
overview.clone(), overview.clone(),
resize_indicator.clone(), resize_indicator.clone(),
active_hint, active_hint,
&theme.cosmic(), theme.cosmic(),
) { ) {
Ok(elements) => { Ok(elements) => {
elements elements
@ -1344,7 +1344,7 @@ where
for (session, frame) in output.take_pending_frames() { for (session, frame) in output.take_pending_frames() {
if let Some(pending_image_copy_data) = render_session::<_, _, GlesTexture>( if let Some(pending_image_copy_data) = render_session::<_, _, GlesTexture>(
renderer, renderer,
&session.user_data().get::<SessionData>().unwrap(), session.user_data().get::<SessionData>().unwrap(),
frame, frame,
output.current_transform(), output.current_transform(),
|buffer, renderer, offscreen, dt, age, additional_damage| { |buffer, renderer, offscreen, dt, age, additional_damage| {
@ -1496,7 +1496,7 @@ where
)?; )?;
if let Some(additional_damage) = additional_damage { if let Some(additional_damage) = additional_damage {
let output_geo = output.geometry().to_local(&output).as_logical(); let output_geo = output.geometry().to_local(output).as_logical();
elements.extend( elements.extend(
additional_damage additional_damage
.into_iter() .into_iter()

View file

@ -143,7 +143,7 @@ pub fn init_backend(
init_egl_client_side(dh, state, &mut backend)?; init_egl_client_side(dh, state, &mut backend)?;
let name = format!("WINIT-0"); let name = "WINIT-0".to_string();
let size = backend.window_size(); let size = backend.window_size();
let props = PhysicalProperties { let props = PhysicalProperties {
size: (0, 0).into(), size: (0, 0).into(),

View file

@ -512,29 +512,26 @@ where
impl State { impl State {
pub fn process_x11_event(&mut self, event: InputEvent<X11Input>) { pub fn process_x11_event(&mut self, event: InputEvent<X11Input>) {
// here we can handle special cases for x11 inputs, like mapping them to windows // here we can handle special cases for x11 inputs, like mapping them to windows
match &event { if let InputEvent::PointerMotionAbsolute { event } = &event {
InputEvent::PointerMotionAbsolute { event } => { if let Some(window) = event.window() {
if let Some(window) = event.window() { let output = self
let output = self .backend
.backend .x11()
.x11() .surfaces
.surfaces .iter()
.iter() .find(|surface| &surface.window == window.as_ref())
.find(|surface| &surface.window == window.as_ref()) .map(|surface| surface.output.clone())
.map(|surface| surface.output.clone()) .unwrap();
.unwrap();
let device = event.device(); let device = event.device();
for seat in self.common.shell.read().seats.iter() { for seat in self.common.shell.read().seats.iter() {
let devices = seat.user_data().get::<Devices>().unwrap(); let devices = seat.user_data().get::<Devices>().unwrap();
if devices.has_device(&device) { if devices.has_device(&device) {
seat.set_active_output(&output); seat.set_active_output(&output);
break; break;
}
} }
} }
} }
_ => {}
}; };
self.process_input_event(event); self.process_input_event(event);

View file

@ -92,11 +92,7 @@ pub fn get_config<'a, T: 'a, F: Fn(&'a InputConfig) -> Option<T>>(
) -> Option<(T, bool)> { ) -> Option<(T, bool)> {
if let Some(setting) = device_config.and_then(&f) { if let Some(setting) = device_config.and_then(&f) {
Some((setting, false)) Some((setting, false))
} else if let Some(setting) = f(default_config) { } else { f(default_config).map(|setting| (setting, true)) }
Some((setting, true))
} else {
None
}
} }
fn config_set_error<T: std::fmt::Debug>( fn config_set_error<T: std::fmt::Debug>(

View file

@ -86,7 +86,7 @@ pub struct NumlockStateConfig {
pub struct CompOutputConfig<'a>(pub Ref<'a, OutputConfig>); pub struct CompOutputConfig<'a>(pub Ref<'a, OutputConfig>);
impl<'a> CompOutputConfig<'a> { impl CompOutputConfig<'_> {
pub fn mode_size(&self) -> Size<i32, Physical> { pub fn mode_size(&self) -> Size<i32, Physical> {
self.0.mode.0.into() self.0.mode.0.into()
} }
@ -153,7 +153,7 @@ pub struct ScreenFilter {
impl ScreenFilter { impl ScreenFilter {
pub fn is_noop(&self) -> bool { pub fn is_noop(&self) -> bool {
self.inverted == false && self.color_filter.is_none() !self.inverted && self.color_filter.is_none()
} }
} }
@ -582,7 +582,7 @@ impl Config {
) )
}) })
.collect::<Vec<(OutputInfo, OutputConfig)>>(); .collect::<Vec<(OutputInfo, OutputConfig)>>();
infos.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b)); infos.sort_by(|(a, _), (b, _)| a.cmp(b));
let (infos, configs) = infos.into_iter().unzip(); let (infos, configs) = infos.into_iter().unzip();
self.dynamic_conf self.dynamic_conf
.outputs_mut() .outputs_mut()
@ -642,20 +642,20 @@ impl Config {
pub struct PersistenceGuard<'a, T: Serialize>(Option<PathBuf>, &'a mut T); pub struct PersistenceGuard<'a, T: Serialize>(Option<PathBuf>, &'a mut T);
impl<'a, T: Serialize> std::ops::Deref for PersistenceGuard<'a, T> { impl<T: Serialize> std::ops::Deref for PersistenceGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &T { fn deref(&self) -> &T {
&self.1 self.1
} }
} }
impl<'a, T: Serialize> std::ops::DerefMut for PersistenceGuard<'a, T> { impl<T: Serialize> std::ops::DerefMut for PersistenceGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T { fn deref_mut(&mut self) -> &mut T {
&mut self.1 self.1
} }
} }
impl<'a, T: Serialize> Drop for PersistenceGuard<'a, T> { impl<T: Serialize> Drop for PersistenceGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
if let Some(path) = self.0.as_ref() { if let Some(path) = self.0.as_ref() {
let content = match ron::ser::to_string_pretty(&self.1, Default::default()) { let content = match ron::ser::to_string_pretty(&self.1, Default::default()) {

View file

@ -50,7 +50,7 @@ pub fn init(evlh: &LoopHandle<'static, State>) -> Result<Vec<RegistrationToken>>
} }
} }
()
} }
calloop::channel::Event::Closed => (), calloop::channel::Event::Closed => (),
}) })
@ -61,8 +61,8 @@ pub fn init(evlh: &LoopHandle<'static, State>) -> Result<Vec<RegistrationToken>>
let result = std::thread::Builder::new() let result = std::thread::Builder::new()
.name("system76-power-hotplug".to_string()) .name("system76-power-hotplug".to_string())
.spawn(move || { .spawn(move || {
if let Ok(mut msg_iter) = power_daemon.receive_hot_plug_detect() { if let Ok(msg_iter) = power_daemon.receive_hot_plug_detect() {
while let Some(msg) = msg_iter.next() { for msg in msg_iter {
if tx.send(msg).is_err() { if tx.send(msg).is_err() {
break; break;
} }
@ -104,7 +104,7 @@ pub fn ready(common: &Common) -> Result<()> {
.xwayland_state .xwayland_state
.as_ref() .as_ref()
.map(|s| format!(":{}", s.display)) .map(|s| format!(":{}", s.display))
.unwrap_or(String::new()), .unwrap_or_default(),
), ),
]))?; ]))?;

View file

@ -106,16 +106,16 @@ impl State {
match action { match action {
SwipeAction::NextWorkspace => { SwipeAction::NextWorkspace => {
let _ = to_next_workspace( let _ = to_next_workspace(
&mut *self.common.shell.write(), &mut self.common.shell.write(),
&seat, seat,
true, true,
&mut self.common.workspace_state.update(), &mut self.common.workspace_state.update(),
); );
} }
SwipeAction::PrevWorkspace => { SwipeAction::PrevWorkspace => {
let _ = to_previous_workspace( let _ = to_previous_workspace(
&mut *self.common.shell.write(), &mut self.common.shell.write(),
&seat, seat,
true, true,
&mut self.common.workspace_state.update(), &mut self.common.workspace_state.update(),
); );
@ -201,7 +201,7 @@ impl State {
} }
let next = to_next_workspace( let next = to_next_workspace(
&mut *self.common.shell.write(), &mut self.common.shell.write(),
seat, seat,
false, false,
&mut self.common.workspace_state.update(), &mut self.common.workspace_state.update(),
@ -247,7 +247,7 @@ impl State {
} }
let previous = to_previous_workspace( let previous = to_previous_workspace(
&mut *self.common.shell.write(), &mut self.common.shell.write(),
seat, seat,
false, false,
&mut self.common.workspace_state.update(), &mut self.common.workspace_state.update(),
@ -543,7 +543,7 @@ impl State {
let workspace = shell.workspaces.active(&next_output).unwrap().1; let workspace = shell.workspaces.active(&next_output).unwrap().1;
let new_target = workspace let new_target = workspace
.focus_stack .focus_stack
.get(&seat) .get(seat)
.last() .last()
.cloned() .cloned()
.map(Into::<KeyboardFocusTarget>::into); .map(Into::<KeyboardFocusTarget>::into);
@ -940,7 +940,7 @@ impl State {
let output = seat.active_output(); let output = seat.active_output();
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();
let workspace = shell.active_space_mut(&output).unwrap(); let workspace = shell.active_space_mut(&output).unwrap();
workspace.tiling_layer.update_orientation(None, &seat); workspace.tiling_layer.update_orientation(None, seat);
} }
Action::Orientation(orientation) => { Action::Orientation(orientation) => {
@ -949,7 +949,7 @@ impl State {
let workspace = shell.active_space_mut(&output).unwrap(); let workspace = shell.active_space_mut(&output).unwrap();
workspace workspace
.tiling_layer .tiling_layer
.update_orientation(Some(orientation), &seat); .update_orientation(Some(orientation), seat);
} }
Action::ToggleStacking => { Action::ToggleStacking => {
@ -1066,7 +1066,10 @@ impl State {
.env("XDG_ACTIVATION_TOKEN", &*token) .env("XDG_ACTIVATION_TOKEN", &*token)
.env("DESKTOP_STARTUP_ID", &*token) .env("DESKTOP_STARTUP_ID", &*token)
.env_remove("COSMIC_SESSION_SOCK"); .env_remove("COSMIC_SESSION_SOCK");
unsafe { cmd.pre_exec(|| Ok(crate::utils::rlimit::restore_nofile_limit())) }; unsafe { cmd.pre_exec(|| {
crate::utils::rlimit::restore_nofile_limit();
Ok(())
}) };
std::thread::spawn(move || match cmd.spawn() { std::thread::spawn(move || match cmd.spawn() {
Ok(mut child) => { Ok(mut child) => {
@ -1093,7 +1096,7 @@ impl State {
if zoom_seat == *seat { if zoom_seat == *seat {
let new_level = (current_level + change).max(1.0); let new_level = (current_level + change).max(1.0);
shell.trigger_zoom( shell.trigger_zoom(
&seat, seat,
Some(&output), Some(&output),
new_level, new_level,
&self.common.config.cosmic_conf.accessibility_zoom, &self.common.config.cosmic_conf.accessibility_zoom,

View file

@ -50,12 +50,10 @@ impl GestureState {
} else { } else {
Some(Direction::Left) Some(Direction::Left)
} }
} else if movement.y > 0.0 {
Some(Direction::Down)
} else { } else {
if movement.y > 0.0 { Some(Direction::Up)
Some(Direction::Down)
} else {
Some(Direction::Up)
}
} }
} }

View file

@ -121,8 +121,7 @@ impl SupressedKeys {
Some( Some(
removed removed
.into_iter() .into_iter()
.map(|(_, token)| token) .filter_map(|(_, token)| token)
.flatten()
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
) )
} }
@ -314,7 +313,7 @@ impl State {
let mut position = seat.get_pointer().unwrap().current_location().as_global(); let mut position = seat.get_pointer().unwrap().current_location().as_global();
let under = State::surface_under(position, &current_output, &mut *shell) let under = State::surface_under(position, &current_output, &mut shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
let ptr = seat.get_pointer().unwrap(); let ptr = seat.get_pointer().unwrap();
@ -329,7 +328,7 @@ impl State {
with_pointer_constraint(&surface, &ptr, |constraint| match constraint { with_pointer_constraint(&surface, &ptr, |constraint| match constraint {
Some(constraint) if constraint.is_active() => { Some(constraint) if constraint.is_active() => {
// Constraint does not apply if not within region // Constraint does not apply if not within region
if !constraint.region().map_or(true, |x| { if !constraint.region().is_none_or(|x| {
x.contains( x.contains(
(ptr.current_location() - *surface_loc).to_i32_round(), (ptr.current_location() - *surface_loc).to_i32_round(),
) )
@ -358,7 +357,7 @@ impl State {
.cloned() .cloned()
.unwrap_or(current_output.clone()); .unwrap_or(current_output.clone());
let new_under = State::surface_under(position, &output, &mut *shell) let new_under = State::surface_under(position, &output, &mut shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
std::mem::drop(shell); std::mem::drop(shell);
@ -382,12 +381,9 @@ impl State {
.user_data() .user_data()
.get::<ResizeGrabMarker>() .get::<ResizeGrabMarker>()
.map(|marker| marker.get()) .map(|marker| marker.get())
.unwrap_or(false) .unwrap_or(false) && output != current_output {
{ ptr.frame(self);
if output != current_output { return;
ptr.frame(self);
return;
}
} }
//If the pointer isn't grabbed, we should check if the focused element should be updated //If the pointer isn't grabbed, we should check if the focused element should be updated
} else if self.common.config.cosmic_conf.focus_follows_cursor { } else if self.common.config.cosmic_conf.focus_follows_cursor {
@ -395,11 +391,11 @@ impl State {
let old_keyboard_target = State::element_under( let old_keyboard_target = State::element_under(
original_position, original_position,
&current_output, &current_output,
&*shell, &shell,
&seat, &seat,
); );
let new_keyboard_target = let new_keyboard_target =
State::element_under(position, &output, &*shell, &seat); State::element_under(position, &output, &shell, &seat);
if old_keyboard_target != new_keyboard_target if old_keyboard_target != new_keyboard_target
&& new_keyboard_target.is_some() && new_keyboard_target.is_some()
@ -557,7 +553,7 @@ impl State {
}; };
let point = let point =
(ptr.current_location() - surface_location).to_i32_round(); (ptr.current_location() - surface_location).to_i32_round();
if region.map_or(true, |region| region.contains(point)) { if region.is_none_or(|region| region.contains(point)) {
constraint.activate(); constraint.activate();
} }
} }
@ -574,7 +570,7 @@ impl State {
); );
if output != current_output { if output != current_output {
for session in cursor_sessions_for_output(&*shell, &current_output) { for session in cursor_sessions_for_output(&shell, &current_output) {
session.set_cursor_pos(None); session.set_cursor_pos(None);
} }
seat.set_active_output(&output); seat.set_active_output(&output);
@ -626,7 +622,7 @@ impl State {
.as_global(); .as_global();
let serial = SERIAL_COUNTER.next_serial(); let serial = SERIAL_COUNTER.next_serial();
let under = let under =
State::surface_under(position, &output, &mut *self.common.shell.write()) State::surface_under(position, &output, &mut self.common.shell.write())
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
let ptr = seat.get_pointer().unwrap(); let ptr = seat.get_pointer().unwrap();
@ -642,7 +638,7 @@ impl State {
ptr.frame(self); ptr.frame(self);
let shell = self.common.shell.read(); let shell = self.common.shell.read();
for session in cursor_sessions_for_output(&*shell, &output) { for session in cursor_sessions_for_output(&shell, &output) {
if let Some((geometry, offset)) = seat.cursor_geometry( if let Some((geometry, offset)) = seat.cursor_geometry(
position.as_logical().to_buffer( position.as_logical().to_buffer(
output.current_scale().fractional_scale(), output.current_scale().fractional_scale(),
@ -922,7 +918,7 @@ impl State {
percentage *= 5.; percentage *= 5.;
} }
let change = -(percentage as f64 / 100.); let change = -(percentage / 100.);
self.update_zoom(&seat, change, event.source() == AxisSource::Wheel); self.update_zoom(&seat, change, event.source() == AxisSource::Wheel);
} }
} else { } else {
@ -1249,7 +1245,7 @@ impl State {
if let Some(seat) = shell.seats.for_device(&event.device()).cloned() { if let Some(seat) = shell.seats.for_device(&event.device()).cloned() {
self.common.idle_notifier_state.notify_activity(&seat); self.common.idle_notifier_state.notify_activity(&seat);
let Some(output) = let Some(output) =
mapped_output_for_device(&self.common.config, &*shell, &event.device()) mapped_output_for_device(&self.common.config, &shell, &event.device())
.cloned() .cloned()
else { else {
return; return;
@ -1257,7 +1253,7 @@ impl State {
let position = let position =
transform_output_mapped_position(&output, &event, shell.zoom_state()); transform_output_mapped_position(&output, &event, shell.zoom_state());
let under = State::surface_under(position, &output, &mut *shell) let under = State::surface_under(position, &output, &mut shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
std::mem::drop(shell); std::mem::drop(shell);
@ -1281,7 +1277,7 @@ impl State {
if let Some(seat) = shell.seats.for_device(&event.device()).cloned() { if let Some(seat) = shell.seats.for_device(&event.device()).cloned() {
self.common.idle_notifier_state.notify_activity(&seat); self.common.idle_notifier_state.notify_activity(&seat);
let Some(output) = let Some(output) =
mapped_output_for_device(&self.common.config, &*shell, &event.device()) mapped_output_for_device(&self.common.config, &shell, &event.device())
.cloned() .cloned()
else { else {
return; return;
@ -1289,7 +1285,7 @@ impl State {
let position = let position =
transform_output_mapped_position(&output, &event, shell.zoom_state()); transform_output_mapped_position(&output, &event, shell.zoom_state());
let under = State::surface_under(position, &output, &mut *shell) let under = State::surface_under(position, &output, &mut shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
std::mem::drop(shell); std::mem::drop(shell);
@ -1372,7 +1368,7 @@ impl State {
let position = let position =
transform_output_mapped_position(&output, &event, shell.zoom_state()); transform_output_mapped_position(&output, &event, shell.zoom_state());
let under = State::surface_under(position, &output, &mut *shell) let under = State::surface_under(position, &output, &mut shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
std::mem::drop(shell); std::mem::drop(shell);
@ -1437,7 +1433,7 @@ impl State {
let position = let position =
transform_output_mapped_position(&output, &event, shell.zoom_state()); transform_output_mapped_position(&output, &event, shell.zoom_state());
let under = State::surface_under(position, &output, &mut *shell) let under = State::surface_under(position, &output, &mut shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
std::mem::drop(shell); std::mem::drop(shell);
@ -1602,7 +1598,7 @@ impl State {
modifiers, modifiers,
&handle, &handle,
event.state(), event.state(),
event.time() as u64 * 1000, event.time() * 1000,
); );
// Leave move overview mode, if any modifier was released // Leave move overview mode, if any modifier was released
@ -1654,7 +1650,7 @@ impl State {
); );
} else if !cosmic_modifiers_eq_smithay(&action_pattern.modifiers, modifiers) { } else if !cosmic_modifiers_eq_smithay(&action_pattern.modifiers, modifiers) {
let mut new_pattern = action_pattern.clone(); let mut new_pattern = action_pattern.clone();
new_pattern.modifiers = cosmic_modifiers_from_smithay(modifiers.clone()); new_pattern.modifiers = cosmic_modifiers_from_smithay(*modifiers);
let enabled = let enabled =
self.common self.common
.config .config
@ -1700,7 +1696,7 @@ impl State {
cosmic_keystate_from_smithay(event.state()), cosmic_keystate_from_smithay(event.state()),
)); ));
let key_pattern = shortcuts::Binding { let key_pattern = shortcuts::Binding {
modifiers: cosmic_modifiers_from_smithay(modifiers.clone()), modifiers: cosmic_modifiers_from_smithay(*modifiers),
keycode: None, keycode: None,
key: Some(handle.modified_sym()), key: Some(handle.modified_sym()),
description: None, description: None,
@ -1774,28 +1770,26 @@ impl State {
.active_virtual_mods .active_virtual_mods
.remove(&event.key_code()); .remove(&event.key_code());
// If `Caps_Lock` is a virtual modifier, and is in locked state, clear it // If `Caps_Lock` is a virtual modifier, and is in locked state, clear it
if removed && handle.modified_sym() == Keysym::Caps_Lock { if removed && handle.modified_sym() == Keysym::Caps_Lock && (modifiers.serialized.locked & 2) != 0 {
if (modifiers.serialized.locked & 2) != 0 { let serial = SERIAL_COUNTER.next_serial();
let serial = SERIAL_COUNTER.next_serial(); let time = self.common.clock.now().as_millis();
let time = self.common.clock.now().as_millis(); keyboard.input(
keyboard.input( self,
self, event.key_code(),
event.key_code(), KeyState::Pressed,
KeyState::Pressed, serial,
serial, time,
time, |_, _, _| FilterResult::<()>::Forward,
|_, _, _| FilterResult::<()>::Forward, );
); let serial = SERIAL_COUNTER.next_serial();
let serial = SERIAL_COUNTER.next_serial(); keyboard.input(
keyboard.input( self,
self, event.key_code(),
event.key_code(), KeyState::Released,
KeyState::Released, serial,
serial, time,
time, |_, _, _| FilterResult::<()>::Forward,
|_, _, _| FilterResult::<()>::Forward, );
);
}
} }
} else if event.state() == KeyState::Pressed } else if event.state() == KeyState::Pressed
&& self && self
@ -1918,7 +1912,7 @@ impl State {
if let Some(focus) = current_focus { if let Some(focus) = current_focus {
if let Some(new_descriptor) = shell if let Some(new_descriptor) = shell
.workspaces .workspaces
.active(&focused_output) .active(focused_output)
.unwrap() .unwrap()
.1 .1
.node_desc(focus) .node_desc(focus)
@ -1933,7 +1927,7 @@ impl State {
.find(|w| w.handle == new_descriptor.handle) .find(|w| w.handle == new_descriptor.handle)
{ {
{ {
let mut stack = new_workspace.focus_stack.get_mut(&seat); let mut stack = new_workspace.focus_stack.get_mut(seat);
for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| { for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| {
old_workspace.tiling_layer.element_for_node(node_id) old_workspace.tiling_layer.element_for_node(node_id)
}) { }) {
@ -1941,7 +1935,7 @@ impl State {
} }
} }
{ {
let mut stack = old_workspace.focus_stack.get_mut(&seat); let mut stack = old_workspace.focus_stack.get_mut(seat);
for elem in new_descriptor.focus_stack.iter().flat_map(|node_id| { for elem in new_descriptor.focus_stack.iter().flat_map(|node_id| {
new_workspace.tiling_layer.element_for_node(node_id) new_workspace.tiling_layer.element_for_node(node_id)
}) { }) {
@ -1951,7 +1945,7 @@ impl State {
if let Some(focus) = TilingLayout::swap_trees( if let Some(focus) = TilingLayout::swap_trees(
&mut old_workspace.tiling_layer, &mut old_workspace.tiling_layer,
Some(&mut new_workspace.tiling_layer), Some(&mut new_workspace.tiling_layer),
&old_descriptor, old_descriptor,
&new_descriptor, &new_descriptor,
) { ) {
let seat = seat.clone(); let seat = seat.clone();
@ -1963,26 +1957,24 @@ impl State {
new_workspace.refresh_focus_stack(); new_workspace.refresh_focus_stack();
} }
} }
} else { } else if let Some(workspace) = spaces.find(|w| w.handle == new_descriptor.handle) {
if let Some(workspace) = spaces.find(|w| w.handle == new_descriptor.handle) { if let Some(focus) = TilingLayout::swap_trees(
if let Some(focus) = TilingLayout::swap_trees( &mut workspace.tiling_layer,
&mut workspace.tiling_layer, None,
None, old_descriptor,
&old_descriptor, &new_descriptor,
&new_descriptor, ) {
) { std::mem::drop(spaces);
std::mem::drop(spaces); let seat = seat.clone();
let seat = seat.clone(); self.common.event_loop_handle.insert_idle(move |state| {
self.common.event_loop_handle.insert_idle(move |state| { Shell::set_focus(state, Some(&focus), &seat, None, true);
Shell::set_focus(state, Some(&focus), &seat, None, true); });
});
}
workspace.refresh_focus_stack();
} }
workspace.refresh_focus_stack();
} }
} }
} else { } else {
let new_workspace = shell.workspaces.active(&focused_output).unwrap().1.handle; let new_workspace = shell.workspaces.active(focused_output).unwrap().1.handle;
if new_workspace != old_descriptor.handle { if new_workspace != old_descriptor.handle {
let spaces = shell.workspaces.spaces_mut(); let spaces = shell.workspaces.spaces_mut();
let (mut old_w, mut other_w) = let (mut old_w, mut other_w) =
@ -1993,7 +1985,7 @@ impl State {
{ {
if new_workspace.tiling_layer.windows().next().is_none() { if new_workspace.tiling_layer.windows().next().is_none() {
{ {
let mut stack = new_workspace.focus_stack.get_mut(&seat); let mut stack = new_workspace.focus_stack.get_mut(seat);
for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| { for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| {
old_workspace.tiling_layer.element_for_node(node_id) old_workspace.tiling_layer.element_for_node(node_id)
}) { }) {
@ -2004,8 +1996,8 @@ impl State {
&mut old_workspace.tiling_layer, &mut old_workspace.tiling_layer,
&mut new_workspace.tiling_layer, &mut new_workspace.tiling_layer,
&new_workspace.handle, &new_workspace.handle,
&seat, seat,
new_workspace.focus_stack.get(&seat).iter(), new_workspace.focus_stack.get(seat).iter(),
old_descriptor.clone(), old_descriptor.clone(),
None, None,
) { ) {
@ -2314,7 +2306,7 @@ fn cursor_sessions_for_output<'a>(
output: &'a Output, output: &'a Output,
) -> impl Iterator<Item = CursorSessionRef> + 'a { ) -> impl Iterator<Item = CursorSessionRef> + 'a {
shell shell
.active_space(&output) .active_space(output)
.into_iter() .into_iter()
.flat_map(|workspace| { .flat_map(|workspace| {
let maybe_fullscreen = workspace.get_fullscreen(); let maybe_fullscreen = workspace.get_fullscreen();
@ -2327,7 +2319,7 @@ fn cursor_sessions_for_output<'a>(
.into_iter() .into_iter()
.flatten(), .flatten(),
) )
.chain(output.cursor_sessions().into_iter()) .chain(output.cursor_sessions())
}) })
} }

View file

@ -80,7 +80,10 @@ impl State {
command.envs( command.envs(
session::get_env(&self.common).expect("WAYLAND_DISPLAY should be valid UTF-8"), session::get_env(&self.common).expect("WAYLAND_DISPLAY should be valid UTF-8"),
); );
unsafe { command.pre_exec(|| Ok(utils::rlimit::restore_nofile_limit())) }; unsafe { command.pre_exec(|| {
utils::rlimit::restore_nofile_limit();
Ok(())
}) };
info!("Running {:?}", exec); info!("Running {:?}", exec);
command command
@ -172,7 +175,7 @@ fn main_inner() -> Result<(), Box<dyn Error>> {
{ {
let dh = state.common.display_handle.clone(); let dh = state.common.display_handle.clone();
for client in clients.values() { for client in clients.values() {
client_compositor_state(&client).blocker_cleared(state, &dh); client_compositor_state(client).blocker_cleared(state, &dh);
} }
} }

View file

@ -133,11 +133,11 @@ pub fn setup_socket(handle: LoopHandle<State>, common: &Common) -> Result<()> {
stream.read_bytes = 0; stream.read_bytes = 0;
match std::str::from_utf8(&stream.buffer) { match std::str::from_utf8(&stream.buffer) {
Ok(message) => { Ok(message) => {
match serde_json::from_str::<'_, Message>(&message) { match serde_json::from_str::<'_, Message>(message) {
Ok(Message::NewPrivilegedClient { count }) => { Ok(Message::NewPrivilegedClient { count }) => {
let mut buffer = [0; 1]; let mut buffer = [0; 1];
let mut fds = vec![0; count]; let mut fds = vec![0; count];
match stream.stream.recv_with_fd(&mut buffer, &mut *fds) { match stream.stream.recv_with_fd(&mut buffer, &mut fds) {
Ok((_, received_count)) => { Ok((_, received_count)) => {
assert_eq!(received_count, count); assert_eq!(received_count, count);
for fd in fds.into_iter().take(received_count) { for fd in fds.into_iter().take(received_count) {

View file

@ -241,10 +241,7 @@ impl CosmicMapped {
} }
pub fn focus_window(&self, window: &CosmicSurface) { pub fn focus_window(&self, window: &CosmicSurface) {
match &self.element { if let CosmicMappedInternal::Stack(stack) = &self.element { stack.set_active(window) }
CosmicMappedInternal::Stack(stack) => stack.set_active(window),
_ => {}
}
} }
pub fn has_surface(&self, surface: &WlSurface, surface_type: WindowSurfaceType) -> bool { pub fn has_surface(&self, surface: &WlSurface, surface_type: WindowSurfaceType) -> bool {
@ -446,7 +443,7 @@ impl CosmicMapped {
pub fn set_bounds(&self, size: impl Into<Option<Size<i32, Logical>>>) { pub fn set_bounds(&self, size: impl Into<Option<Size<i32, Logical>>>) {
let size = size.into(); let size = size.into();
for (surface, _) in self.windows() { for (surface, _) in self.windows() {
surface.set_bounds(size.clone()) surface.set_bounds(size)
} }
} }
@ -508,24 +505,21 @@ impl CosmicMapped {
(output, overlap): (&Output, Rectangle<i32, Logical>), (output, overlap): (&Output, Rectangle<i32, Logical>),
theme: cosmic::Theme, theme: cosmic::Theme,
) { ) {
match &self.element { if let CosmicMappedInternal::Window(window) = &self.element {
CosmicMappedInternal::Window(window) => { let surface = window.surface();
let surface = window.surface(); let activated = surface.is_activated(true);
let activated = surface.is_activated(true); let handle = window.loop_handle();
let handle = window.loop_handle();
let stack = CosmicStack::new(std::iter::once(surface), handle, theme); let stack = CosmicStack::new(std::iter::once(surface), handle, theme);
if let Some(geo) = self.last_geometry.lock().unwrap().clone() { if let Some(geo) = *self.last_geometry.lock().unwrap() {
stack.set_geometry(geo.to_global(&output)); stack.set_geometry(geo.to_global(output));
}
stack.output_enter(output, overlap);
stack.set_activate(activated);
stack.active().send_configure();
stack.refresh();
self.element = CosmicMappedInternal::Stack(stack);
} }
_ => {} stack.output_enter(output, overlap);
stack.set_activate(activated);
stack.active().send_configure();
stack.refresh();
self.element = CosmicMappedInternal::Stack(stack);
} }
} }
@ -540,8 +534,8 @@ impl CosmicMapped {
surface.set_tiled(false); surface.set_tiled(false);
let window = CosmicWindow::new(surface, handle, theme); let window = CosmicWindow::new(surface, handle, theme);
if let Some(geo) = self.last_geometry.lock().unwrap().clone() { if let Some(geo) = *self.last_geometry.lock().unwrap() {
window.set_geometry(geo.to_global(&output)); window.set_geometry(geo.to_global(output));
} }
window.output_enter(output, overlap); window.output_enter(output, overlap);
window.set_activate(self.is_activated(true)); window.set_activate(self.is_activated(true));
@ -843,7 +837,7 @@ impl CosmicMapped {
pub fn ssd_height(&self, pending: bool) -> Option<i32> { pub fn ssd_height(&self, pending: bool) -> Option<i32> {
match &self.element { match &self.element {
CosmicMappedInternal::Window(w) => (!w.surface().is_decorated(pending)) CosmicMappedInternal::Window(w) => (!w.surface().is_decorated(pending))
.then(|| crate::shell::element::window::SSD_HEIGHT), .then_some(crate::shell::element::window::SSD_HEIGHT),
CosmicMappedInternal::Stack(_) => Some(crate::shell::element::stack::TAB_HEIGHT), CosmicMappedInternal::Stack(_) => Some(crate::shell::element::stack::TAB_HEIGHT),
_ => unreachable!(), _ => unreachable!(),
} }

View file

@ -180,7 +180,7 @@ impl CosmicStack {
*prev_idx = last_mod_serial.map(|s| (s, p.active.load(Ordering::SeqCst))); *prev_idx = last_mod_serial.map(|s| (s, p.active.load(Ordering::SeqCst)));
} }
if let Some(mut geo) = p.geometry.lock().unwrap().clone() { if let Some(mut geo) = *p.geometry.lock().unwrap() {
geo.loc.y += TAB_HEIGHT; geo.loc.y += TAB_HEIGHT;
geo.size.h -= TAB_HEIGHT; geo.size.h -= TAB_HEIGHT;
window.set_geometry(geo, TAB_HEIGHT as u32); window.set_geometry(geo, TAB_HEIGHT as u32);
@ -210,7 +210,7 @@ impl CosmicStack {
let mut windows = p.windows.lock().unwrap(); let mut windows = p.windows.lock().unwrap();
if windows.len() == 1 { if windows.len() == 1 {
p.override_alive.store(false, Ordering::SeqCst); p.override_alive.store(false, Ordering::SeqCst);
let window = windows.get(0).unwrap(); let window = windows.first().unwrap();
window.try_force_undecorated(false); window.try_force_undecorated(false);
window.set_tiled(false); window.set_tiled(false);
return; return;
@ -238,7 +238,7 @@ impl CosmicStack {
let mut windows = p.windows.lock().unwrap(); let mut windows = p.windows.lock().unwrap();
if windows.len() == 1 { if windows.len() == 1 {
p.override_alive.store(false, Ordering::SeqCst); p.override_alive.store(false, Ordering::SeqCst);
let window = windows.get(0).unwrap(); let window = windows.first().unwrap();
window.try_force_undecorated(false); window.try_force_undecorated(false);
window.set_tiled(false); window.set_tiled(false);
return Some(window.clone()); return Some(window.clone());
@ -545,10 +545,9 @@ impl CosmicStack {
pub fn pending_size(&self) -> Option<Size<i32, Logical>> { pub fn pending_size(&self) -> Option<Size<i32, Logical>> {
self.0.with_program(|p| { self.0.with_program(|p| {
p.geometry (*p.geometry
.lock() .lock()
.unwrap() .unwrap())
.clone()
.map(|geo| geo.size.as_logical()) .map(|geo| geo.size.as_logical())
}) })
} }
@ -1466,17 +1465,11 @@ impl PointerTarget<State> for CosmicStack {
} }
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) { fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
match self.0.with_program(|p| p.current_focus()) { if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::axis(&self.0, seat, data, frame) }
Some(Focus::Header) => PointerTarget::axis(&self.0, seat, data, frame),
_ => {}
}
} }
fn frame(&self, seat: &Seat<State>, data: &mut State) { fn frame(&self, seat: &Seat<State>, data: &mut State) {
match self.0.with_program(|p| p.current_focus()) { if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::frame(&self.0, seat, data) }
Some(Focus::Header) => PointerTarget::frame(&self.0, seat, data),
_ => {}
}
} }
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) { fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
@ -1607,7 +1600,7 @@ impl TouchTarget<State> for CosmicStack {
} }
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent, seq: Serial) { fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent, seq: Serial) {
TouchTarget::up(&self.0, seat, data, &event, seq) TouchTarget::up(&self.0, seat, data, event, seq)
} }
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &TouchMotionEvent, seq: Serial) { fn motion(&self, seat: &Seat<State>, data: &mut State, event: &TouchMotionEvent, seq: Serial) {

View file

@ -239,7 +239,7 @@ pub(super) struct TabInternal<'a, Message: TabMessage> {
right_click_message: Option<Message>, right_click_message: Option<Message>,
} }
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabInternal<'a, Message> impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabInternal<'_, Message>
where where
Message: TabMessage, Message: TabMessage,
{ {

View file

@ -125,7 +125,7 @@ impl Offset {
const SCROLL_ANIMATION_DURATION: Duration = Duration::from_millis(200); const SCROLL_ANIMATION_DURATION: Duration = Duration::from_millis(200);
const TAB_ANIMATION_DURATION: Duration = Duration::from_millis(150); const TAB_ANIMATION_DURATION: Duration = Duration::from_millis(150);
impl<'a, Message> Tabs<'a, Message> impl<Message> Tabs<'_, Message>
where where
Message: TabMessage + 'static, Message: TabMessage + 'static,
{ {
@ -308,7 +308,7 @@ impl State {
} }
} }
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for Tabs<'a, Message> impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for Tabs<'_, Message>
where where
Message: TabMessage, Message: TabMessage,
{ {

View file

@ -81,14 +81,13 @@ impl From<X11Surface> for CosmicSurface {
impl PartialEq<WlSurface> for CosmicSurface { impl PartialEq<WlSurface> for CosmicSurface {
fn eq(&self, other: &WlSurface) -> bool { fn eq(&self, other: &WlSurface) -> bool {
self.wl_surface().map_or(false, |s| &*s == other) self.wl_surface().is_some_and(|s| &*s == other)
} }
} }
impl PartialEq<ToplevelSurface> for CosmicSurface { impl PartialEq<ToplevelSurface> for CosmicSurface {
fn eq(&self, other: &ToplevelSurface) -> bool { fn eq(&self, other: &ToplevelSurface) -> bool {
self.wl_surface() self.wl_surface().is_some_and(|s| &*s == other.wl_surface())
.map_or(false, |s| &*s == other.wl_surface())
} }
} }
@ -280,7 +279,7 @@ impl CosmicSurface {
WindowSurface::Wayland(toplevel) => { WindowSurface::Wayland(toplevel) => {
if enable { if enable {
let previous_decoration_state = let previous_decoration_state =
toplevel.current_state().decoration_mode.clone(); toplevel.current_state().decoration_mode;
if PreferredDecorationMode::is_unset(&self.0) { if PreferredDecorationMode::is_unset(&self.0) {
PreferredDecorationMode::update(&self.0, previous_decoration_state); PreferredDecorationMode::update(&self.0, previous_decoration_state);
} }
@ -639,10 +638,8 @@ impl CosmicSurface {
return false; return false;
}; };
if surface_type.contains(WindowSurfaceType::TOPLEVEL) { if surface_type.contains(WindowSurfaceType::TOPLEVEL) && *toplevel == *surface {
if *toplevel == *surface { return true;
return true;
}
} }
if surface_type.contains(WindowSurfaceType::SUBSURFACE) { if surface_type.contains(WindowSurfaceType::SUBSURFACE) {

View file

@ -252,7 +252,7 @@ impl CosmicWindow {
let geo = p.window.geometry(); let geo = p.window.geometry();
let point_i32 = relative_pos.to_i32_round::<i32>(); let point_i32 = relative_pos.to_i32_round::<i32>();
let ssd_height = has_ssd.then_some(SSD_HEIGHT).unwrap_or(0); let ssd_height = if has_ssd { SSD_HEIGHT } else { 0 };
if (point_i32.x - geo.loc.x >= -RESIZE_BORDER && point_i32.x - geo.loc.x < 0) if (point_i32.x - geo.loc.x >= -RESIZE_BORDER && point_i32.x - geo.loc.x < 0)
|| (point_i32.y - geo.loc.y >= -RESIZE_BORDER && point_i32.y - geo.loc.y < 0) || (point_i32.y - geo.loc.y >= -RESIZE_BORDER && point_i32.y - geo.loc.y < 0)
@ -708,7 +708,7 @@ impl PointerTarget<State> for CosmicWindow {
if has_ssd || p.is_tiled(false) { if has_ssd || p.is_tiled(false) {
let Some(next) = Focus::under( let Some(next) = Focus::under(
&p.window, &p.window,
has_ssd.then_some(SSD_HEIGHT).unwrap_or(0), if has_ssd { SSD_HEIGHT } else { 0 },
event.location, event.location,
) else { ) else {
return; return;
@ -734,7 +734,7 @@ impl PointerTarget<State> for CosmicWindow {
if has_ssd || p.is_tiled(false) { if has_ssd || p.is_tiled(false) {
let Some(next) = Focus::under( let Some(next) = Focus::under(
&p.window, &p.window,
has_ssd.then_some(SSD_HEIGHT).unwrap_or(0), if has_ssd { SSD_HEIGHT } else { 0 },
event.location, event.location,
) else { ) else {
return; return;
@ -804,17 +804,11 @@ impl PointerTarget<State> for CosmicWindow {
} }
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) { fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
match self.0.with_program(|p| p.current_focus()) { if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::axis(&self.0, seat, data, frame) }
Some(Focus::Header) => PointerTarget::axis(&self.0, seat, data, frame),
_ => {}
}
} }
fn frame(&self, seat: &Seat<State>, data: &mut State) { fn frame(&self, seat: &Seat<State>, data: &mut State) {
match self.0.with_program(|p| p.current_focus()) { if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::frame(&self.0, seat, data) }
Some(Focus::Header) => PointerTarget::frame(&self.0, seat, data),
_ => {}
}
} }
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) { fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
@ -901,7 +895,7 @@ impl TouchTarget<State> for CosmicWindow {
} }
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent, seq: Serial) { fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent, seq: Serial) {
TouchTarget::up(&self.0, seat, data, &event, seq) TouchTarget::up(&self.0, seat, data, event, seq)
} }
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &TouchMotionEvent, seq: Serial) { fn motion(&self, seat: &Seat<State>, data: &mut State, event: &TouchMotionEvent, seq: Serial) {

View file

@ -59,9 +59,9 @@ impl From<CosmicSurface> for FocusTarget {
} }
} }
impl Into<KeyboardFocusTarget> for FocusTarget { impl From<FocusTarget> for KeyboardFocusTarget {
fn into(self) -> KeyboardFocusTarget { fn from(val: FocusTarget) -> Self {
match self { match val {
FocusTarget::Window(mapped) => KeyboardFocusTarget::Element(mapped), FocusTarget::Window(mapped) => KeyboardFocusTarget::Element(mapped),
FocusTarget::Fullscreen(surface) => KeyboardFocusTarget::Fullscreen(surface), FocusTarget::Fullscreen(surface) => KeyboardFocusTarget::Fullscreen(surface),
} }
@ -94,7 +94,7 @@ impl FocusTarget {
pub struct FocusStack<'a>(pub(super) Option<&'a IndexSet<FocusTarget>>); pub struct FocusStack<'a>(pub(super) Option<&'a IndexSet<FocusTarget>>);
pub struct FocusStackMut<'a>(pub(super) &'a mut IndexSet<FocusTarget>); pub struct FocusStackMut<'a>(pub(super) &'a mut IndexSet<FocusTarget>);
impl<'a> FocusStack<'a> { impl FocusStack<'_> {
/// returns the last unminimized window in the focus stack that is still alive /// returns the last unminimized window in the focus stack that is still alive
pub fn last(&self) -> Option<&FocusTarget> { pub fn last(&self) -> Option<&FocusTarget> {
self.0 self.0
@ -109,7 +109,7 @@ impl<'a> FocusStack<'a> {
} }
} }
impl<'a> FocusStackMut<'a> { impl FocusStackMut<'_> {
pub fn append(&mut self, target: impl Into<FocusTarget>) { pub fn append(&mut self, target: impl Into<FocusTarget>) {
let target = target.into(); let target = target.into();
self.0.retain(|w| w.alive()); self.0.retain(|w| w.alive());
@ -232,7 +232,7 @@ impl Shell {
let focused_windows = self let focused_windows = self
.seats .seats
.iter() .iter()
.map(|seat| { .filter_map(|seat| {
if matches!( if matches!(
seat.get_keyboard().unwrap().current_focus(), seat.get_keyboard().unwrap().current_focus(),
Some(KeyboardFocusTarget::Group(_)) | Some(KeyboardFocusTarget::LockSurface(_)) Some(KeyboardFocusTarget::Group(_)) | Some(KeyboardFocusTarget::LockSurface(_))
@ -248,7 +248,6 @@ impl Shell {
FocusTarget::Fullscreen(_) => None, FocusTarget::Fullscreen(_) => None,
}) })
}) })
.flatten()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for output in self.outputs().cloned().collect::<Vec<_>>().into_iter() { for output in self.outputs().cloned().collect::<Vec<_>>().into_iter() {
@ -257,7 +256,7 @@ impl Shell {
raise_with_children(&mut set.sticky_layer, focused); raise_with_children(&mut set.sticky_layer, focused);
} }
for window in set.sticky_layer.mapped() { for window in set.sticky_layer.mapped() {
window.set_activated(focused_windows.contains(&window)); window.set_activated(focused_windows.contains(window));
window.configure(); window.configure();
} }
for window in set for window in set
@ -291,7 +290,7 @@ impl Shell {
raise_with_children(&mut workspace.floating_layer, focused); raise_with_children(&mut workspace.floating_layer, focused);
} }
for window in workspace.mapped() { for window in workspace.mapped() {
window.set_activated(focused_windows.contains(&window)); window.set_activated(focused_windows.contains(window));
window.configure(); window.configure();
} }
for m in workspace.minimized_windows.iter() { for m in workspace.minimized_windows.iter() {
@ -330,38 +329,36 @@ fn update_focus_state(
) { ) {
// update keyboard focus // update keyboard focus
if let Some(keyboard) = seat.get_keyboard() { if let Some(keyboard) = seat.get_keyboard() {
if should_update_cursor && state.common.config.cosmic_conf.cursor_follows_focus { if should_update_cursor && state.common.config.cosmic_conf.cursor_follows_focus && target.is_some() {
if target.is_some() { //need to borrow mutably for surface under
//need to borrow mutably for surface under let shell = state.common.shell.read();
let shell = state.common.shell.read(); // get the top left corner of the target element
// get the top left corner of the target element let geometry = shell.focused_geometry(target.unwrap());
let geometry = shell.focused_geometry(target.unwrap()); if let Some(geometry) = geometry {
if let Some(geometry) = geometry { // get the center of the target element
// get the center of the target element let window_center = Point::from((geometry.size.w / 2, geometry.size.h / 2));
let window_center = Point::from((geometry.size.w / 2, geometry.size.h / 2)); let new_pos = (geometry.loc + window_center).to_f64();
let new_pos = (geometry.loc + window_center).to_f64();
// create a pointer target from the target element // create a pointer target from the target element
let output = shell let output = shell
.outputs() .outputs()
.find(|output| output.geometry().to_f64().contains(new_pos)) .find(|output| output.geometry().to_f64().contains(new_pos))
.cloned() .cloned()
.unwrap_or(seat.active_output()); .unwrap_or(seat.active_output());
let focus = State::surface_under(new_pos, &output, &*shell) let focus = State::surface_under(new_pos, &output, &shell)
.map(|(focus, loc)| (focus, loc.as_logical())); .map(|(focus, loc)| (focus, loc.as_logical()));
//drop here to avoid multiple borrows //drop here to avoid multiple borrows
mem::drop(shell); mem::drop(shell);
seat.get_pointer().unwrap().motion( seat.get_pointer().unwrap().motion(
state, state,
focus, focus,
&MotionEvent { &MotionEvent {
location: new_pos.as_logical(), location: new_pos.as_logical(),
serial: SERIAL_COUNTER.next_serial(), serial: SERIAL_COUNTER.next_serial(),
time: 0, time: 0,
}, },
); );
}
} }
} }
@ -460,15 +457,15 @@ impl Common {
} }
} }
update_pointer_focus(state, &seat); update_pointer_focus(state, seat);
let output = seat.focused_or_active_output(); let output = seat.focused_or_active_output();
let mut shell = state.common.shell.write(); let mut shell = state.common.shell.write();
let last_known_focus = ActiveFocus::get(&seat); let last_known_focus = ActiveFocus::get(seat);
if let Some(target) = last_known_focus { if let Some(target) = last_known_focus {
if target.alive() { if target.alive() {
if focus_target_is_valid(&mut *shell, &seat, &output, target) { if focus_target_is_valid(&mut shell, seat, &output, target) {
continue; // Focus is valid continue; // Focus is valid
} else { } else {
trace!("Wrong Window, focus fixup"); trace!("Wrong Window, focus fixup");
@ -504,7 +501,7 @@ impl Common {
} }
} else { } else {
let workspace = shell.active_space(&output).unwrap(); let workspace = shell.active_space(&output).unwrap();
let focus_stack = workspace.focus_stack.get(&seat); let focus_stack = workspace.focus_stack.get(seat);
if focus_stack.last().is_none() { if focus_stack.last().is_none() {
continue; // Focus is valid continue; // Focus is valid
@ -527,7 +524,7 @@ impl Common {
} }
// update keyboard focus // update keyboard focus
let target = update_focus_target(&*shell, &seat, &output); let target = update_focus_target(&shell, seat, &output);
std::mem::drop(shell); std::mem::drop(shell);
//I can probably feature gate this condition //I can probably feature gate this condition
debug!("Restoring focus to {:?}", target.as_ref()); debug!("Restoring focus to {:?}", target.as_ref());
@ -547,8 +544,8 @@ impl Common {
.as_ref() .as_ref()
.and_then(|t| t.wl_surface()) .and_then(|t| t.wl_surface())
.and_then(|s| state.common.display_handle.get_client(s.id()).ok()); .and_then(|s| state.common.display_handle.get_client(s.id()).ok());
set_data_device_focus(&state.common.display_handle, &seat, client.clone()); set_data_device_focus(&state.common.display_handle, seat, client.clone());
set_primary_focus(&state.common.display_handle, &seat, client); set_primary_focus(&state.common.display_handle, seat, client);
} }
} }
@ -603,8 +600,8 @@ fn focus_target_is_valid(
.mapped() .mapped()
.any(|m| m == &mapped); .any(|m| m == &mapped);
let workspace = shell.active_space(&output).unwrap(); let workspace = shell.active_space(output).unwrap();
let focus_stack = workspace.focus_stack.get(&seat); let focus_stack = workspace.focus_stack.get(seat);
let is_in_focus_stack = focus_stack.last().map(|m| m == &mapped).unwrap_or(false); let is_in_focus_stack = focus_stack.last().map(|m| m == &mapped).unwrap_or(false);
if is_sticky && !is_in_focus_stack { if is_sticky && !is_in_focus_stack {
shell.append_focus_stack(mapped, seat); shell.append_focus_stack(mapped, seat);
@ -613,17 +610,17 @@ fn focus_target_is_valid(
is_sticky || is_in_focus_stack is_sticky || is_in_focus_stack
} }
KeyboardFocusTarget::LayerSurface(layer) => { KeyboardFocusTarget::LayerSurface(layer) => {
layer_map_for_output(&output).layers().any(|l| l == &layer) layer_map_for_output(output).layers().any(|l| l == &layer)
} }
KeyboardFocusTarget::Group(WindowGroup { node, .. }) => shell KeyboardFocusTarget::Group(WindowGroup { node, .. }) => shell
.workspaces .workspaces
.active(&output) .active(output)
.unwrap() .unwrap()
.1 .1
.tiling_layer .tiling_layer
.has_node(&node), .has_node(&node),
KeyboardFocusTarget::Fullscreen(window) => { KeyboardFocusTarget::Fullscreen(window) => {
let workspace = shell.active_space(&output).unwrap(); let workspace = shell.active_space(output).unwrap();
workspace.get_fullscreen().is_some_and(|w| w == &window) workspace.get_fullscreen().is_some_and(|w| w == &window)
} }
KeyboardFocusTarget::Popup(_) => true, KeyboardFocusTarget::Popup(_) => true,
@ -654,15 +651,15 @@ fn update_focus_target(
.map(KeyboardFocusTarget::from) .map(KeyboardFocusTarget::from)
} else { } else {
shell shell
.active_space(&output) .active_space(output)
.unwrap() .unwrap()
.focus_stack .focus_stack
.get(&seat) .get(seat)
.last() .last()
.cloned() .cloned()
.map(Into::<KeyboardFocusTarget>::into) .map(Into::<KeyboardFocusTarget>::into)
.or_else(|| { .or_else(|| {
let workspace = shell.active_space(&output).unwrap(); let workspace = shell.active_space(output).unwrap();
workspace workspace
.mapped() .mapped()
@ -710,10 +707,8 @@ fn exclusive_layer_surface_layer(shell: &Shell) -> Option<Layer> {
for output in shell.outputs() { for output in shell.outputs() {
for layer_surface in layer_map_for_output(output).layers() { for layer_surface in layer_map_for_output(output).layers() {
let data = layer_surface.cached_state(); let data = layer_surface.cached_state();
if data.keyboard_interactivity == KeyboardInteractivity::Exclusive { if data.keyboard_interactivity == KeyboardInteractivity::Exclusive && data.layer as u32 >= layer.unwrap_or(Layer::Top) as u32 {
if data.layer as u32 >= layer.unwrap_or(Layer::Top) as u32 { layer = Some(data.layer);
layer = Some(data.layer);
}
} }
} }
} }

View file

@ -125,13 +125,13 @@ fn render_input_order_internal<R: 'static>(
.last() .last()
.zip(fullscreen) .zip(fullscreen)
.is_some_and(|(target, fullscreen)| target == &fullscreen.surface); .is_some_and(|(target, fullscreen)| target == &fullscreen.surface);
let overview_is_open = workspace_overview_is_open(&output); let overview_is_open = workspace_overview_is_open(output);
let has_focused_fullscreen = if is_active_workspace { let has_focused_fullscreen = if is_active_workspace {
let current_focus = seat.get_keyboard().unwrap().current_focus(); let current_focus = seat.get_keyboard().unwrap().current_focus();
matches!(current_focus, Some(KeyboardFocusTarget::Fullscreen(_))) matches!(current_focus, Some(KeyboardFocusTarget::Fullscreen(_)))
|| (current_focus.is_none() || (current_focus.is_none()
&& focus_stack_is_valid_fullscreen && focus_stack_is_valid_fullscreen
&& !workspace_overview_is_open(&output)) && !workspace_overview_is_open(output))
} else { } else {
focus_stack_is_valid_fullscreen && !overview_is_open focus_stack_is_valid_fullscreen && !overview_is_open
}; };
@ -141,7 +141,7 @@ fn render_input_order_internal<R: 'static>(
Some((previous, previous_idx, start)) => { Some((previous, previous_idx, start)) => {
let layout = shell.workspaces.layout; let layout = shell.workspaces.layout;
let Some(workspace) = shell.workspaces.space_for_handle(&previous) else { let Some(workspace) = shell.workspaces.space_for_handle(previous) else {
return ControlFlow::Break(Err(OutputNoMode)); return ControlFlow::Break(Err(OutputNoMode));
}; };
let has_fullscreen = workspace.fullscreen.is_some(); let has_fullscreen = workspace.fullscreen.is_some();
@ -368,13 +368,13 @@ fn render_input_order_internal<R: 'static>(
ControlFlow::Continue(()) ControlFlow::Continue(())
} }
fn layer_popups<'a>( fn layer_popups(
output: &'a Output, output: &Output,
layer: Layer, layer: Layer,
element_filter: ElementFilter, element_filter: ElementFilter,
) -> impl Iterator<Item = (LayerSurface, PopupKind, Point<i32, Global>)> + 'a { ) -> impl Iterator<Item = (LayerSurface, PopupKind, Point<i32, Global>)> + '_ {
layer_surfaces(output, layer, element_filter).flat_map(move |(surface, location)| { layer_surfaces(output, layer, element_filter).flat_map(move |(surface, location)| {
let location_clone = location.clone(); let location_clone = location;
let surface_clone = surface.clone(); let surface_clone = surface.clone();
PopupManager::popups_for_surface(surface.wl_surface()).map(move |(popup, popup_offset)| { PopupManager::popups_for_surface(surface.wl_surface()).map(move |(popup, popup_offset)| {
let offset = (popup_offset - popup.geometry().loc).as_global(); let offset = (popup_offset - popup.geometry().loc).as_global();
@ -383,11 +383,11 @@ fn layer_popups<'a>(
}) })
} }
fn layer_surfaces<'a>( fn layer_surfaces(
output: &'a Output, output: &Output,
layer: Layer, layer: Layer,
element_filter: ElementFilter, element_filter: ElementFilter,
) -> impl Iterator<Item = (LayerSurface, Point<i32, Global>)> + 'a { ) -> impl Iterator<Item = (LayerSurface, Point<i32, Global>)> + '_ {
// we want to avoid deadlocks on the layer-map in callbacks, so we need to clone the layer surfaces // we want to avoid deadlocks on the layer-map in callbacks, so we need to clone the layer surfaces
let layers = { let layers = {
let layer_map = layer_map_for_output(output); let layer_map = layer_map_for_output(output);

View file

@ -205,7 +205,7 @@ impl KeyboardFocusTarget {
match self { match self {
KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(), KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(),
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => { KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => {
get_popup_toplevel(&xdg).map(Cow::Owned) get_popup_toplevel(xdg).map(Cow::Owned)
} }
_ => None, _ => None,
} }
@ -278,7 +278,7 @@ impl IsAlive for KeyboardFocusTarget {
impl PointerTarget<State> for PointerFocusTarget { impl PointerTarget<State> for PointerFocusTarget {
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) { fn enter(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
let toplevel = self.toplevel(&*data.common.shell.read()); let toplevel = self.toplevel(&data.common.shell.read());
if let Some(element) = toplevel { if let Some(element) = toplevel {
for session in element.cursor_sessions() { for session in element.cursor_sessions() {
session.set_cursor_pos(Some( session.set_cursor_pos(Some(
@ -300,7 +300,7 @@ impl PointerTarget<State> for PointerFocusTarget {
self.inner_pointer_target().enter(seat, data, event); self.inner_pointer_target().enter(seat, data, event);
} }
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) { fn motion(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
let toplevel = self.toplevel(&*data.common.shell.read()); let toplevel = self.toplevel(&data.common.shell.read());
if let Some(element) = toplevel { if let Some(element) = toplevel {
for session in element.cursor_sessions() { for session in element.cursor_sessions() {
session.set_cursor_pos(Some( session.set_cursor_pos(Some(
@ -335,7 +335,7 @@ impl PointerTarget<State> for PointerFocusTarget {
self.inner_pointer_target().frame(seat, data); self.inner_pointer_target().frame(seat, data);
} }
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) { fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
let toplevel = self.toplevel(&*data.common.shell.read()); let toplevel = self.toplevel(&data.common.shell.read());
if let Some(element) = toplevel { if let Some(element) = toplevel {
for session in element.cursor_sessions() { for session in element.cursor_sessions() {
session.set_cursor_pos(None); session.set_cursor_pos(None);

View file

@ -51,9 +51,7 @@ fn next_workspace(
shell shell
.workspaces .workspaces
.spaces_for_output(&output) .spaces_for_output(&output)
.skip_while(|space| space.handle != current_handle) .skip_while(|space| space.handle != current_handle).nth(1)
.skip(1)
.next()
.map(|space| (current_handle, space.handle)) .map(|space| (current_handle, space.handle))
} }
@ -62,7 +60,7 @@ fn move_fullscreen_prev_workspace(state: &mut State, surface: &CosmicSurface) {
let Some(wl_surface) = surface.wl_surface() else { let Some(wl_surface) = surface.wl_surface() else {
return; return;
}; };
let Some((from, to)) = prev_workspace(&shell, &*wl_surface) else { let Some((from, to)) = prev_workspace(&shell, &wl_surface) else {
return; return;
}; };
@ -88,7 +86,7 @@ fn move_fullscreen_next_workspace(state: &mut State, surface: &CosmicSurface) {
let Some(wl_surface) = surface.wl_surface() else { let Some(wl_surface) = surface.wl_surface() else {
return; return;
}; };
let Some((from, to)) = next_workspace(&shell, &*wl_surface) else { let Some((from, to)) = next_workspace(&shell, &wl_surface) else {
return; return;
}; };
@ -115,7 +113,7 @@ fn move_element_prev_workspace(state: &mut State, mapped: &CosmicMapped) {
let Some(wl_surface) = window.wl_surface() else { let Some(wl_surface) = window.wl_surface() else {
return; return;
}; };
let Some((from, to)) = prev_workspace(&shell, &*wl_surface) else { let Some((from, to)) = prev_workspace(&shell, &wl_surface) else {
return; return;
}; };
@ -141,7 +139,7 @@ fn move_element_next_workspace(state: &mut State, mapped: &CosmicMapped) {
let Some(wl_surface) = window.wl_surface() else { let Some(wl_surface) = window.wl_surface() else {
return; return;
}; };
let Some((from, to)) = next_workspace(&shell, &*wl_surface) else { let Some((from, to)) = next_workspace(&shell, &wl_surface) else {
return; return;
}; };

View file

@ -40,7 +40,7 @@ struct State {
cursor_over: bool, cursor_over: bool,
} }
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for SubmenuItem<'a, Message> impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for SubmenuItem<'_, Message>
where where
Message: CursorEvents, Message: CursorEvents,
{ {
@ -216,11 +216,11 @@ where
} }
} }
impl<'a, Message> Into<cosmic::Element<'a, Message>> for SubmenuItem<'a, Message> impl<'a, Message> From<SubmenuItem<'a, Message>> for cosmic::Element<'a, Message>
where where
Message: CursorEvents + 'a, Message: CursorEvents + 'a,
{ {
fn into(self) -> cosmic::Element<'a, Message> { fn from(val: SubmenuItem<'a, Message>) -> Self {
Element::new(self) Element::new(val)
} }
} }

View file

@ -381,7 +381,7 @@ impl Program for ContextMenu {
.row_width .row_width
.lock() .lock()
.unwrap() .unwrap()
.map(|size| Length::Fixed(size)) .map(Length::Fixed)
.unwrap_or(Length::Shrink); .unwrap_or(Length::Shrink);
let mode = match width { let mode = match width {
Length::Shrink => Length::Shrink, Length::Shrink => Length::Shrink,
@ -968,8 +968,7 @@ impl MenuAlignment {
size, size,
AxisAlignment::Centered, AxisAlignment::Centered,
AxisAlignment::Corner(0), AxisAlignment::Corner(0),
) ),
.into_iter(),
) )
.chain( .chain(
for_alignment( for_alignment(
@ -977,8 +976,7 @@ impl MenuAlignment {
size, size,
AxisAlignment::Corner(0), AxisAlignment::Corner(0),
AxisAlignment::Centered, AxisAlignment::Centered,
) ),
.into_iter(),
) )
.chain( .chain(
for_alignment( for_alignment(
@ -986,15 +984,14 @@ impl MenuAlignment {
size, size,
AxisAlignment::Corner(0), AxisAlignment::Corner(0),
AxisAlignment::Corner(0), AxisAlignment::Corner(0),
) ),
.into_iter(),
) )
.collect(), .collect(),
(AxisAlignment::PreferCentered, y) => { (AxisAlignment::PreferCentered, y) => {
for_alignment(position, size, AxisAlignment::Centered, y) for_alignment(position, size, AxisAlignment::Centered, y)
.into_iter() .into_iter()
.chain( .chain(
for_alignment(position, size, AxisAlignment::Corner(0), y).into_iter(), for_alignment(position, size, AxisAlignment::Corner(0), y),
) )
.collect() .collect()
} }
@ -1002,7 +999,7 @@ impl MenuAlignment {
for_alignment(position, size, x, AxisAlignment::Centered) for_alignment(position, size, x, AxisAlignment::Centered)
.into_iter() .into_iter()
.chain( .chain(
for_alignment(position, size, x, AxisAlignment::Corner(0)).into_iter(), for_alignment(position, size, x, AxisAlignment::Corner(0)),
) )
.collect() .collect()
} }

View file

@ -122,9 +122,9 @@ impl From<shortcuts::action::ResizeEdge> for ResizeEdge {
} }
} }
impl Into<shortcuts::action::ResizeEdge> for ResizeEdge { impl From<ResizeEdge> for shortcuts::action::ResizeEdge {
fn into(self) -> shortcuts::action::ResizeEdge { fn from(val: ResizeEdge) -> Self {
match self { match val {
ResizeEdge::BOTTOM => shortcuts::action::ResizeEdge::Bottom, ResizeEdge::BOTTOM => shortcuts::action::ResizeEdge::Bottom,
ResizeEdge::BOTTOM_LEFT => shortcuts::action::ResizeEdge::BottomLeft, ResizeEdge::BOTTOM_LEFT => shortcuts::action::ResizeEdge::BottomLeft,
ResizeEdge::BOTTOM_RIGHT => shortcuts::action::ResizeEdge::BottomRight, ResizeEdge::BOTTOM_RIGHT => shortcuts::action::ResizeEdge::BottomRight,

View file

@ -92,11 +92,10 @@ impl MoveGrabState {
let mut window_geo = self.window.geometry(); let mut window_geo = self.window.geometry();
window_geo.loc += self.location.to_i32_round() + self.window_offset; window_geo.loc += self.location.to_i32_round() + self.window_offset;
if !output if output
.geometry() .geometry()
.as_logical() .as_logical()
.intersection(window_geo) .intersection(window_geo).is_none()
.is_some()
{ {
return Vec::new(); return Vec::new();
} }
@ -136,15 +135,14 @@ impl MoveGrabState {
active_window_hint.green, active_window_hint.green,
active_window_hint.blue, active_window_hint.blue,
], ],
)) )),
.into(),
) )
} else { } else {
None None
}; };
let non_exclusive_geometry = { let non_exclusive_geometry = {
let layers = layer_map_for_output(&output); let layers = layer_map_for_output(output);
layers.non_exclusive_zone() layers.non_exclusive_zone()
}; };
@ -173,8 +171,7 @@ impl MoveGrabState {
active_window_hint.green, active_window_hint.green,
active_window_hint.blue, active_window_hint.blue,
], ],
)) )),
.into(),
CosmicMappedRenderElement::from(BackdropShader::element( CosmicMappedRenderElement::from(BackdropShader::element(
renderer, renderer,
Key::Window(Usage::SnappingIndicator, self.window.key()), Key::Window(Usage::SnappingIndicator, self.window.key()),
@ -182,8 +179,7 @@ impl MoveGrabState {
theme.radius_s()[0], // TODO: Fix once shaders support 4 corner radii customization theme.radius_s()[0], // TODO: Fix once shaders support 4 corner radii customization
0.4, 0.4,
[base_color.red, base_color.green, base_color.blue], [base_color.red, base_color.green, base_color.blue],
)) )),
.into(),
] ]
} }
_ => vec![], _ => vec![],
@ -431,7 +427,7 @@ impl MoveGrab {
indicator.output_enter(output, overlap); indicator.output_enter(output, overlap);
} }
} }
} else if self.window_outputs.remove(&output) { } else if self.window_outputs.remove(output) {
self.window.output_leave(output); self.window.output_leave(output);
if let Some(indicator) = grab_state.stacking_indicator.as_ref().map(|x| &x.0) { if let Some(indicator) = grab_state.stacking_indicator.as_ref().map(|x| &x.0) {
indicator.output_leave(output); indicator.output_leave(output);
@ -440,7 +436,7 @@ impl MoveGrab {
} }
let indicator_location = let indicator_location =
shell.stacking_indicator(&current_output, self.previous.clone()); shell.stacking_indicator(&current_output, self.previous);
if indicator_location.is_some() != grab_state.stacking_indicator.is_some() { if indicator_location.is_some() != grab_state.stacking_indicator.is_some() {
grab_state.stacking_indicator = indicator_location.map(|geo| { grab_state.stacking_indicator = indicator_location.map(|geo| {
let element = stack_hover( let element = stack_hover(
@ -739,7 +735,7 @@ impl MoveGrab {
start: Instant::now(), start: Instant::now(),
stacking_indicator: None, stacking_indicator: None,
snapping_zone: None, snapping_zone: None,
previous: previous_layer.clone(), previous: previous_layer,
location: start_data.location(), location: start_data.location(),
cursor_output: cursor_output.clone(), cursor_output: cursor_output.clone(),
}; };
@ -787,7 +783,7 @@ impl Drop for MoveGrab {
let output = self.cursor_output.clone(); let output = self.cursor_output.clone();
let seat = self.seat.clone(); let seat = self.seat.clone();
let window_outputs = self.window_outputs.drain().collect::<HashSet<_>>(); let window_outputs = self.window_outputs.drain().collect::<HashSet<_>>();
let previous = self.previous.clone(); let previous = self.previous;
let window = self.window.clone(); let window = self.window.clone();
let is_touch_grab = matches!(self.start_data, GrabStartData::Touch(_)); let is_touch_grab = matches!(self.start_data, GrabStartData::Touch(_));

View file

@ -101,22 +101,18 @@ impl ResizeSurfaceGrab {
// If the resizing vertical edge is close to our output's edge in the same direction, snap to it. // If the resizing vertical edge is close to our output's edge in the same direction, snap to it.
let output_geom = self.output.geometry().to_local(&self.output); let output_geom = self.output.geometry().to_local(&self.output);
if self.edges.intersects(ResizeEdge::LEFT) { if self.edges.intersects(ResizeEdge::LEFT) {
if ((self.initial_window_location.x - dx as i32 - output_geom.loc.x).abs() as u32) if (self.initial_window_location.x - dx as i32 - output_geom.loc.x).unsigned_abs()
< self.edge_snap_threshold < self.edge_snap_threshold
{ {
new_window_width = self.initial_window_size.w - output_geom.loc.x new_window_width = self.initial_window_size.w - output_geom.loc.x
+ self.initial_window_location.x; + self.initial_window_location.x;
} }
} else { } else if (self.initial_window_location.x + self.initial_window_size.w + dx as i32
if ((self.initial_window_location.x + self.initial_window_size.w + dx as i32 - output_geom.loc.x - output_geom.size.w).unsigned_abs()
- output_geom.loc.x < self.edge_snap_threshold
- output_geom.size.w) {
.abs() as u32) new_window_width =
< self.edge_snap_threshold output_geom.loc.x - self.initial_window_location.x + output_geom.size.w;
{
new_window_width =
output_geom.loc.x - self.initial_window_location.x + output_geom.size.w;
}
} }
} }
@ -131,22 +127,18 @@ impl ResizeSurfaceGrab {
// If the resizing horizontal edge is close to our output's edge in the same direction, snap to it. // If the resizing horizontal edge is close to our output's edge in the same direction, snap to it.
let output_geom = self.output.geometry().to_local(&self.output); let output_geom = self.output.geometry().to_local(&self.output);
if self.edges.intersects(ResizeEdge::TOP) { if self.edges.intersects(ResizeEdge::TOP) {
if ((self.initial_window_location.y - dy as i32 - output_geom.loc.y).abs() as u32) if (self.initial_window_location.y - dy as i32 - output_geom.loc.y).unsigned_abs()
< self.edge_snap_threshold < self.edge_snap_threshold
{ {
new_window_height = self.initial_window_size.h - output_geom.loc.y new_window_height = self.initial_window_size.h - output_geom.loc.y
+ self.initial_window_location.y; + self.initial_window_location.y;
} }
} else { } else if (self.initial_window_location.y + self.initial_window_size.h + dy as i32
if ((self.initial_window_location.y + self.initial_window_size.h + dy as i32 - output_geom.loc.y - output_geom.size.h).unsigned_abs()
- output_geom.loc.y < self.edge_snap_threshold
- output_geom.size.h) {
.abs() as u32) new_window_height =
< self.edge_snap_threshold output_geom.loc.y - self.initial_window_location.y + output_geom.size.h;
{
new_window_height =
output_geom.loc.y - self.initial_window_location.y + output_geom.size.h;
}
} }
} }
@ -361,10 +353,8 @@ impl TouchGrab<State> for ResizeSurfaceGrab {
event: &TouchMotionEvent, event: &TouchMotionEvent,
seq: Serial, seq: Serial,
) { ) {
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot { if event.slot == <Self as TouchGrab<State>>::start_data(self).slot && self.update_location(event.location.as_global()) {
if self.update_location(event.location.as_global()) { handle.unset_grab(self, data);
handle.unset_grab(self, data);
}
} }
handle.motion(data, None, event, seq); handle.motion(data, None, event, seq);
@ -514,7 +504,7 @@ impl ResizeSurfaceGrab {
if edges.intersects(ResizeEdge::TOP_LEFT) { if edges.intersects(ResizeEdge::TOP_LEFT) {
let size = window.geometry().size; let size = window.geometry().size;
let mut new = location.clone(); let mut new = location;
if edges.intersects(ResizeEdge::LEFT) { if edges.intersects(ResizeEdge::LEFT) {
new.x = initial_window_location.x + (initial_window_size.w - size.w); new.x = initial_window_location.x + (initial_window_size.w - size.w);
} }
@ -555,7 +545,7 @@ impl ResizeSurfaceGrab {
} }
floating_layer.space.map_element( floating_layer.space.map_element(
window, window,
new_location.to_local(&output).as_logical(), new_location.to_local(output).as_logical(),
false, false,
); );
} }

View file

@ -137,7 +137,7 @@ impl Animation {
} }
| Animation::Unminimize { | Animation::Unminimize {
target_geometry, .. target_geometry, ..
} => (MINIMIZE_ANIMATION_DURATION, target_geometry.clone()), } => (MINIMIZE_ANIMATION_DURATION, *target_geometry),
Animation::Tiled { .. } => { Animation::Tiled { .. } => {
let target_geometry = if let Some(target_rect) = let target_geometry = if let Some(target_rect) =
tiled_state.map(|state| state.relative_geometry(output_geometry, gaps)) tiled_state.map(|state| state.relative_geometry(output_geometry, gaps))
@ -149,7 +149,7 @@ impl Animation {
(ANIMATION_DURATION, target_geometry) (ANIMATION_DURATION, target_geometry)
} }
}; };
let previous_rect = self.previous_geometry().clone(); let previous_rect = *self.previous_geometry();
let start = *self.start(); let start = *self.start();
let now = Instant::now(); let now = Instant::now();
let progress = let progress =
@ -284,7 +284,7 @@ impl FloatingLayout {
} }
.to_f64(); .to_f64();
let output_geometry = { let output_geometry = {
let layers = layer_map_for_output(&output); let layers = layer_map_for_output(output);
layers.non_exclusive_zone() layers.non_exclusive_zone()
}; };
@ -295,7 +295,7 @@ impl FloatingLayout {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_iter() .into_iter()
{ {
let tiled_state = mapped.floating_tiled.lock().unwrap().clone(); let tiled_state = *mapped.floating_tiled.lock().unwrap();
if let Some(tiled_state) = tiled_state { if let Some(tiled_state) = tiled_state {
let geometry = tiled_state.relative_geometry(output_geometry, self.gaps()); let geometry = tiled_state.relative_geometry(output_geometry, self.gaps());
self.map_internal( self.map_internal(
@ -383,7 +383,7 @@ impl FloatingLayout {
} }
if mapped.floating_tiled.lock().unwrap().take().is_some() { if mapped.floating_tiled.lock().unwrap().take().is_some() {
if let Some(state) = mapped.maximized_state.lock().unwrap().as_mut() { if let Some(state) = mapped.maximized_state.lock().unwrap().as_mut() {
if let Some(real_old_geo) = mapped.last_geometry.lock().unwrap().clone() { if let Some(real_old_geo) = *mapped.last_geometry.lock().unwrap() {
state.original_geometry = real_old_geo; state.original_geometry = real_old_geo;
} }
}; };
@ -407,7 +407,7 @@ impl FloatingLayout {
let layers = layer_map_for_output(&output); let layers = layer_map_for_output(&output);
let output_geometry = layers.non_exclusive_zone(); let output_geometry = layers.non_exclusive_zone();
mapped.set_bounds(output_geometry.size); mapped.set_bounds(output_geometry.size);
let last_geometry = mapped.last_geometry.lock().unwrap().clone(); let last_geometry = *mapped.last_geometry.lock().unwrap();
let min_size = mapped.min_size().unwrap_or((320, 240).into()); let min_size = mapped.min_size().unwrap_or((320, 240).into());
if let Some(size) = size if let Some(size) = size
@ -688,7 +688,7 @@ impl FloatingLayout {
*window.last_geometry.lock().unwrap() = Some(mapped_geometry); *window.last_geometry.lock().unwrap() = Some(mapped_geometry);
} }
self.space.unmap_elem(&window); self.space.unmap_elem(window);
if let Some(pos) = self.spawn_order.iter().position(|w| w == window) { if let Some(pos) = self.spawn_order.iter().position(|w| w == window) {
self.spawn_order.truncate(pos); self.spawn_order.truncate(pos);
} }
@ -877,7 +877,7 @@ impl FloatingLayout {
} }
pub fn stacking_indicator(&self) -> Option<Rectangle<i32, Local>> { pub fn stacking_indicator(&self) -> Option<Rectangle<i32, Local>> {
self.hovered_stack.as_ref().map(|(_, geo)| geo.clone()) self.hovered_stack.as_ref().map(|(_, geo)| *geo)
} }
pub fn resize_request( pub fn resize_request(
@ -890,7 +890,7 @@ impl FloatingLayout {
release: ReleaseMode, release: ReleaseMode,
) -> Option<ResizeSurfaceGrab> { ) -> Option<ResizeSurfaceGrab> {
if seat.get_pointer().is_some() { if seat.get_pointer().is_some() {
let location = self.space.element_location(&mapped)?.as_local(); let location = self.space.element_location(mapped)?.as_local();
let size = mapped.geometry().size; let size = mapped.geometry().size;
mapped.moved_since_mapped.store(true, Ordering::SeqCst); mapped.moved_since_mapped.store(true, Ordering::SeqCst);
@ -934,7 +934,7 @@ impl FloatingLayout {
let Some(original_geo) = self.space.element_geometry(mapped) else { let Some(original_geo) = self.space.element_geometry(mapped) else {
return false; // we don't have that window return false; // we don't have that window
}; };
let mut geo = original_geo.clone(); let mut geo = original_geo;
if edge.contains(ResizeEdge::RIGHT) || edge.contains(ResizeEdge::LEFT) { if edge.contains(ResizeEdge::RIGHT) || edge.contains(ResizeEdge::LEFT) {
if direction == ResizeDirection::Inwards { if direction == ResizeDirection::Inwards {
@ -1313,7 +1313,7 @@ impl FloatingLayout {
let window_geometry = if mapped.is_maximized(false) { let window_geometry = if mapped.is_maximized(false) {
geometry geometry
} else { } else {
prev.clone() prev
.map(|mut rect| { .map(|mut rect| {
if let Some(old_size) = old_output_size { if let Some(old_size) = old_output_size {
rect = Rectangle::new( rect = Rectangle::new(
@ -1529,14 +1529,14 @@ impl FloatingLayout {
.to_physical_precise_round(output_scale), .to_physical_precise_round(output_scale),
scale, scale,
); );
let relocated = RelocateRenderElement::from_element(
RelocateRenderElement::from_element(
rescaled, rescaled,
(geometry.loc - original_geo.loc) (geometry.loc - original_geo.loc)
.as_logical() .as_logical()
.to_physical_precise_round(output_scale), .to_physical_precise_round(output_scale),
Relocate::Relative, Relocate::Relative,
); )
relocated
}) })
} }
CosmicMappedRenderElement::Window(elem) => { CosmicMappedRenderElement::Window(elem) => {
@ -1549,14 +1549,14 @@ impl FloatingLayout {
.to_physical_precise_round(output_scale), .to_physical_precise_round(output_scale),
scale, scale,
); );
let relocated = RelocateRenderElement::from_element(
RelocateRenderElement::from_element(
rescaled, rescaled,
(geometry.loc - original_geo.loc) (geometry.loc - original_geo.loc)
.as_logical() .as_logical()
.to_physical_precise_round(output_scale), .to_physical_precise_round(output_scale),
Relocate::Relative, Relocate::Relative,
); )
relocated
}) })
} }
x => x, x => x,
@ -1566,7 +1566,7 @@ impl FloatingLayout {
if focused == Some(elem) && !elem.is_maximized(false) { if focused == Some(elem) && !elem.is_maximized(false) {
if let Some((mode, resize)) = resize_indicator.as_mut() { if let Some((mode, resize)) = resize_indicator.as_mut() {
let mut resize_geometry = geometry.clone(); let mut resize_geometry = geometry;
resize_geometry.loc -= (18, 18).into(); resize_geometry.loc -= (18, 18).into();
resize_geometry.size += (36, 36).into(); resize_geometry.size += (36, 36).into();

View file

@ -535,10 +535,8 @@ impl TouchGrab<State> for ResizeForkGrab {
event: &TouchMotionEvent, event: &TouchMotionEvent,
seq: Serial, seq: Serial,
) { ) {
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot { if event.slot == <Self as TouchGrab<State>>::start_data(self).slot && self.update_location(data, event.location, false) {
if self.update_location(data, event.location, false) { handle.unset_grab(self, data);
handle.unset_grab(self, data);
}
} }
handle.motion(data, None, event, seq); handle.motion(data, None, event, seq);

View file

@ -49,7 +49,7 @@ impl KeyboardGrab<State> for SwapWindowGrab {
return; return;
} }
let syms = Vec::from(handle.keysym_handle(keycode).raw_syms()); let syms = handle.keysym_handle(keycode).raw_syms();
let focus_bindings = &data let focus_bindings = &data
.common .common
.config .config

View file

@ -500,7 +500,7 @@ impl TilingLayout {
if sibling if sibling
.as_ref() .as_ref()
.is_some_and(|sibling| tree.get(&sibling).is_ok()) .is_some_and(|sibling| tree.get(sibling).is_ok())
{ {
let sibling_id = sibling.unwrap(); let sibling_id = sibling.unwrap();
let new_node = Node::new(Data::Mapped { let new_node = Node::new(Data::Mapped {
@ -542,7 +542,7 @@ impl TilingLayout {
} }
fn map_to_tree( fn map_to_tree(
mut tree: &mut Tree<Data>, tree: &mut Tree<Data>,
window: impl Into<CosmicMapped>, window: impl Into<CosmicMapped>,
output: &Output, output: &Output,
node: Option<NodeId>, node: Option<NodeId>,
@ -564,7 +564,7 @@ impl TilingLayout {
}; };
let new_id = tree.insert(new_window, InsertBehavior::AsRoot).unwrap(); let new_id = tree.insert(new_window, InsertBehavior::AsRoot).unwrap();
TilingLayout::new_group(&mut tree, &root_id, &new_id, orientation).unwrap(); TilingLayout::new_group(tree, &root_id, &new_id, orientation).unwrap();
tree.make_nth_sibling( tree.make_nth_sibling(
&new_id, &new_id,
match direction { match direction {
@ -577,36 +577,34 @@ impl TilingLayout {
} else { } else {
tree.insert(new_window, InsertBehavior::AsRoot).unwrap() tree.insert(new_window, InsertBehavior::AsRoot).unwrap()
} }
} else if let Some(ref node_id) = node {
let orientation = {
let window_size = tree.get(node_id).unwrap().data().geometry().size;
if window_size.w > window_size.h {
Orientation::Vertical
} else {
Orientation::Horizontal
}
};
let new_id = tree.insert(new_window, InsertBehavior::AsRoot).unwrap();
TilingLayout::new_group(tree, node_id, &new_id, orientation).unwrap();
new_id
} else { } else {
if let Some(ref node_id) = node { // nothing? then we add to the root
if let Some(root_id) = tree.root_node_id().cloned() {
let orientation = { let orientation = {
let window_size = tree.get(node_id).unwrap().data().geometry().size; let output_size = output.geometry().size;
if window_size.w > window_size.h { if output_size.w > output_size.h {
Orientation::Vertical Orientation::Vertical
} else { } else {
Orientation::Horizontal Orientation::Horizontal
} }
}; };
let new_id = tree.insert(new_window, InsertBehavior::AsRoot).unwrap(); let new_id = tree.insert(new_window, InsertBehavior::AsRoot).unwrap();
TilingLayout::new_group(&mut tree, &node_id, &new_id, orientation).unwrap(); TilingLayout::new_group(tree, &root_id, &new_id, orientation).unwrap();
new_id new_id
} else { } else {
// nothing? then we add to the root tree.insert(new_window, InsertBehavior::AsRoot).unwrap()
if let Some(root_id) = tree.root_node_id().cloned() {
let orientation = {
let output_size = output.geometry().size;
if output_size.w > output_size.h {
Orientation::Vertical
} else {
Orientation::Horizontal
}
};
let new_id = tree.insert(new_window, InsertBehavior::AsRoot).unwrap();
TilingLayout::new_group(&mut tree, &root_id, &new_id, orientation).unwrap();
new_id
} else {
tree.insert(new_window, InsertBehavior::AsRoot).unwrap()
}
} }
}; };
@ -666,7 +664,7 @@ impl TilingLayout {
let this_stack = this_mapped.stack_ref()?; let this_stack = this_mapped.stack_ref()?;
this_stack.remove_window(&stack_surface); this_stack.remove_window(&stack_surface);
if !this_stack.alive() { if !this_stack.alive() {
let _ = this.unmap(&this_mapped, None); let _ = this.unmap(this_mapped, None);
} }
let mapped: CosmicMapped = let mapped: CosmicMapped =
@ -687,13 +685,13 @@ impl TilingLayout {
mapped.set_tiled(true); mapped.set_tiled(true);
other.map(mapped.clone(), Some(focus_stack), direction); other.map(mapped.clone(), Some(focus_stack), direction);
return Some(KeyboardFocusTarget::Element(mapped)); Some(KeyboardFocusTarget::Element(mapped))
} }
None => { None => {
let node = this_tree.get(&desc.node).ok()?; let node = this_tree.get(&desc.node).ok()?;
let mut children = node let mut children = node
.children() .children()
.into_iter() .iter()
.map(|child_id| (desc.node.clone(), child_id.clone())) .map(|child_id| (desc.node.clone(), child_id.clone()))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let node = Node::new(node.data().clone()); let node = Node::new(node.data().clone());
@ -819,7 +817,7 @@ impl TilingLayout {
.push_tree(other_tree, ANIMATION_DURATION, blocker); .push_tree(other_tree, ANIMATION_DURATION, blocker);
other.node_desc_to_focus(&NodeDesc { other.node_desc_to_focus(&NodeDesc {
handle: other_handle.clone(), handle: *other_handle,
node: id.clone(), node: id.clone(),
stack_window: None, stack_window: None,
focus_stack: Vec::new(), // node_desc_to_focus doesn't use this focus_stack: Vec::new(), // node_desc_to_focus doesn't use this
@ -915,12 +913,12 @@ impl TilingLayout {
// swap children // swap children
let mut this_children = this_node let mut this_children = this_node
.children() .children()
.into_iter() .iter()
.map(|child_id| (other_desc.node.clone(), child_id.clone())) .map(|child_id| (other_desc.node.clone(), child_id.clone()))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let mut other_children = other_node let mut other_children = other_node
.children() .children()
.into_iter() .iter()
.map(|child_id| (this_desc.node.clone(), child_id.clone())) .map(|child_id| (this_desc.node.clone(), child_id.clone()))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -1070,7 +1068,7 @@ impl TilingLayout {
toplevel_leave_workspace(this_surface, &this_desc.handle); toplevel_leave_workspace(this_surface, &this_desc.handle);
toplevel_enter_workspace(this_surface, &other_desc.handle); toplevel_enter_workspace(this_surface, &other_desc.handle);
} }
this_stack.remove_window(&this_surface); this_stack.remove_window(this_surface);
let mapped: CosmicMapped = CosmicWindow::new( let mapped: CosmicMapped = CosmicWindow::new(
this_surface.clone(), this_surface.clone(),
@ -1157,7 +1155,7 @@ impl TilingLayout {
toplevel_leave_workspace(other_surface, &other_desc.handle); toplevel_leave_workspace(other_surface, &other_desc.handle);
toplevel_enter_workspace(other_surface, &this_desc.handle); toplevel_enter_workspace(other_surface, &this_desc.handle);
} }
other_stack.remove_window(&other_surface); other_stack.remove_window(other_surface);
let mapped: CosmicMapped = CosmicWindow::new( let mapped: CosmicMapped = CosmicWindow::new(
other_surface.clone(), other_surface.clone(),
@ -1266,12 +1264,12 @@ impl TilingLayout {
} }
match (&this_desc.stack_window, &other_desc.stack_window) { match (&this_desc.stack_window, &other_desc.stack_window) {
(None, None) if !has_other_tree => this.node_desc_to_focus(&this_desc), (None, None) if !has_other_tree => this.node_desc_to_focus(this_desc),
//(None, Some(_)) => None, //(None, Some(_)) => None,
_ => other _ => other
.as_ref() .as_ref()
.unwrap_or(&this) .unwrap_or(&this)
.node_desc_to_focus(&other_desc), .node_desc_to_focus(other_desc),
} }
} }
@ -1311,7 +1309,7 @@ impl TilingLayout {
let state = { let state = {
let tree = &self.queue.trees.back().unwrap().0; let tree = &self.queue.trees.back().unwrap().0;
tree.get(&node_id).unwrap().parent().and_then(|parent_id| { tree.get(&node_id).unwrap().parent().and_then(|parent_id| {
let parent = tree.get(&parent_id).unwrap(); let parent = tree.get(parent_id).unwrap();
let idx = parent let idx = parent
.children() .children()
.iter() .iter()
@ -1325,7 +1323,7 @@ impl TilingLayout {
// this group will be flattened // this group will be flattened
Some(RestoreTilingState { Some(RestoreTilingState {
parent: None, parent: None,
sibling: parent.children().iter().cloned().find(|id| id != &node_id), sibling: parent.children().iter().find(|&id| id != &node_id).cloned(),
orientation: *orientation, orientation: *orientation,
idx, idx,
sizes: sizes.clone(), sizes: sizes.clone(),
@ -1390,7 +1388,7 @@ impl TilingLayout {
.data_mut(); .data_mut();
*data = Data::Placeholder { *data = Data::Placeholder {
id: Id::new(), id: Id::new(),
last_geometry: data.geometry().clone(), last_geometry: *data.geometry(),
type_, type_,
}; };
@ -1435,7 +1433,7 @@ impl TilingLayout {
fn unmap_internal(tree: &mut Tree<Data>, node: &NodeId) { fn unmap_internal(tree: &mut Tree<Data>, node: &NodeId) {
let parent_id = tree.get(node).ok().and_then(|node| node.parent()).cloned(); let parent_id = tree.get(node).ok().and_then(|node| node.parent()).cloned();
let position = parent_id.as_ref().and_then(|parent_id| { let position = parent_id.as_ref().and_then(|parent_id| {
tree.children_ids(&parent_id) tree.children_ids(parent_id)
.unwrap() .unwrap()
.position(|id| id == node) .position(|id| id == node)
}); });
@ -1470,7 +1468,7 @@ impl TilingLayout {
&other_child, &other_child,
parent_parent_id parent_parent_id
.as_ref() .as_ref()
.map(|parent_id| MoveBehavior::ToParent(parent_id)) .map(MoveBehavior::ToParent)
.unwrap_or(MoveBehavior::ToRoot), .unwrap_or(MoveBehavior::ToRoot),
) )
.unwrap(); .unwrap();
@ -1736,9 +1734,7 @@ impl TilingLayout {
// we move again by making a new fork // we move again by making a new fork
let old_id = tree let old_id = tree
.children_ids(&next_child_id) .children_ids(&next_child_id)
.unwrap() .unwrap().nth(group_len / 2)
.skip(group_len / 2)
.next()
.unwrap() .unwrap()
.clone(); .clone();
TilingLayout::new_group( TilingLayout::new_group(
@ -1887,7 +1883,7 @@ impl TilingLayout {
let mut node_id = last_node_id.clone(); let mut node_id = last_node_id.clone();
while let Some(group) = tree.get(&node_id).unwrap().parent() { while let Some(group) = tree.get(&node_id).unwrap().parent() {
let child = node_id.clone(); let child = node_id.clone();
let group_data = tree.get(&group).unwrap().data(); let group_data = tree.get(group).unwrap().data();
let main_orientation = group_data.orientation(); let main_orientation = group_data.orientation();
assert!(group_data.is_group()); assert!(group_data.is_group());
@ -1908,7 +1904,7 @@ impl TilingLayout {
WindowGroup { WindowGroup {
node: group.clone(), node: group.clone(),
alive: match group_data { alive: match group_data {
&Data::Group { ref alive, .. } => Arc::downgrade(alive), Data::Group { alive, .. } => Arc::downgrade(alive),
_ => unreachable!(), _ => unreachable!(),
}, },
focus_stack: match data { focus_stack: match data {
@ -1925,7 +1921,7 @@ impl TilingLayout {
// which child are we? // which child are we?
let idx = tree let idx = tree
.children_ids(&group) .children_ids(group)
.unwrap() .unwrap()
.position(|id| id == &child) .position(|id| id == &child)
.unwrap(); .unwrap();
@ -1936,13 +1932,13 @@ impl TilingLayout {
| (Orientation::Vertical, FocusDirection::Right) | (Orientation::Vertical, FocusDirection::Right)
if idx < (len - 1) => if idx < (len - 1) =>
{ {
tree.children_ids(&group).unwrap().skip(idx + 1).next() tree.children_ids(group).unwrap().nth(idx + 1)
} }
(Orientation::Horizontal, FocusDirection::Up) (Orientation::Horizontal, FocusDirection::Up)
| (Orientation::Vertical, FocusDirection::Left) | (Orientation::Vertical, FocusDirection::Left)
if idx > 0 => if idx > 0 =>
{ {
tree.children_ids(&group).unwrap().skip(idx - 1).next() tree.children_ids(group).unwrap().nth(idx - 1)
} }
_ => None, // continue iterating _ => None, // continue iterating
}; };
@ -1965,7 +1961,7 @@ impl TilingLayout {
Data::Group { alive, .. } => { Data::Group { alive, .. } => {
FocusResult::Some(KeyboardFocusTarget::Group(WindowGroup { FocusResult::Some(KeyboardFocusTarget::Group(WindowGroup {
node: replacement_id.clone(), node: replacement_id.clone(),
alive: Arc::downgrade(&alive), alive: Arc::downgrade(alive),
focus_stack: tree focus_stack: tree
.children_ids(replacement_id) .children_ids(replacement_id)
.unwrap() .unwrap()
@ -2653,7 +2649,7 @@ impl TilingLayout {
} }
let mapped = match self.last_overview_hover.as_ref().map(|x| &x.1) { let mapped = match self.last_overview_hover.as_ref().map(|x| &x.1) {
Some(TargetZone::GroupEdge(group_id, direction)) if tree.get(&group_id).is_ok() => { Some(TargetZone::GroupEdge(group_id, direction)) if tree.get(group_id).is_ok() => {
let new_id = tree let new_id = tree
.insert( .insert(
Node::new(Data::Mapped { Node::new(Data::Mapped {
@ -2671,7 +2667,7 @@ impl TilingLayout {
Orientation::Horizontal Orientation::Horizontal
}; };
if tree.get(group_id).unwrap().data().orientation() != orientation { if tree.get(group_id).unwrap().data().orientation() != orientation {
TilingLayout::new_group(&mut tree, &group_id, &new_id, orientation).unwrap(); TilingLayout::new_group(&mut tree, group_id, &new_id, orientation).unwrap();
} else { } else {
let data = tree.get_mut(group_id).unwrap().data_mut(); let data = tree.get_mut(group_id).unwrap().data_mut();
let len = data.len(); let len = data.len();
@ -2689,7 +2685,7 @@ impl TilingLayout {
*window.tiling_node_id.lock().unwrap() = Some(new_id); *window.tiling_node_id.lock().unwrap() = Some(new_id);
window window
} }
Some(TargetZone::GroupInterior(group_id, idx)) if tree.get(&group_id).is_ok() => { Some(TargetZone::GroupInterior(group_id, idx)) if tree.get(group_id).is_ok() => {
let new_id = tree let new_id = tree
.insert( .insert(
Node::new(Data::Mapped { Node::new(Data::Mapped {
@ -2710,9 +2706,9 @@ impl TilingLayout {
*window.tiling_node_id.lock().unwrap() = Some(new_id); *window.tiling_node_id.lock().unwrap() = Some(new_id);
window window
} }
Some(TargetZone::InitialPlaceholder(node_id)) if tree.get(&node_id).is_ok() => { Some(TargetZone::InitialPlaceholder(node_id)) if tree.get(node_id).is_ok() => {
let data = tree.get_mut(&node_id).unwrap().data_mut(); let data = tree.get_mut(node_id).unwrap().data_mut();
let geo = data.geometry().clone(); let geo = *data.geometry();
*data = Data::Mapped { *data = Data::Mapped {
mapped: window.clone(), mapped: window.clone(),
@ -2722,7 +2718,7 @@ impl TilingLayout {
*window.tiling_node_id.lock().unwrap() = Some(node_id.clone()); *window.tiling_node_id.lock().unwrap() = Some(node_id.clone());
window window
} }
Some(TargetZone::WindowSplit(window_id, direction)) if tree.get(&window_id).is_ok() => { Some(TargetZone::WindowSplit(window_id, direction)) if tree.get(window_id).is_ok() => {
let new_id = tree let new_id = tree
.insert( .insert(
Node::new(Data::Mapped { Node::new(Data::Mapped {
@ -2730,7 +2726,7 @@ impl TilingLayout {
last_geometry: Rectangle::from_size((100, 100).into()), last_geometry: Rectangle::from_size((100, 100).into()),
minimize_rect: None, minimize_rect: None,
}), }),
InsertBehavior::UnderNode(&window_id), InsertBehavior::UnderNode(window_id),
) )
.unwrap(); .unwrap();
let orientation = if matches!(direction, Direction::Left | Direction::Right) { let orientation = if matches!(direction, Direction::Left | Direction::Right) {
@ -2738,14 +2734,14 @@ impl TilingLayout {
} else { } else {
Orientation::Horizontal Orientation::Horizontal
}; };
TilingLayout::new_group(&mut tree, &window_id, &new_id, orientation).unwrap(); TilingLayout::new_group(&mut tree, window_id, &new_id, orientation).unwrap();
if matches!(direction, Direction::Left | Direction::Up) { if matches!(direction, Direction::Left | Direction::Up) {
tree.make_first_sibling(&new_id).unwrap(); tree.make_first_sibling(&new_id).unwrap();
} }
*window.tiling_node_id.lock().unwrap() = Some(new_id.clone()); *window.tiling_node_id.lock().unwrap() = Some(new_id.clone());
window window
} }
Some(TargetZone::WindowStack(window_id, _)) if tree.get(&window_id).is_ok() => { Some(TargetZone::WindowStack(window_id, _)) if tree.get(window_id).is_ok() => {
match tree.get_mut(window_id).unwrap().data_mut() { match tree.get_mut(window_id).unwrap().data_mut() {
Data::Mapped { mapped, .. } => { Data::Mapped { mapped, .. } => {
mapped.convert_to_stack((&self.output, mapped.bbox()), self.theme.clone()); mapped.convert_to_stack((&self.output, mapped.bbox()), self.theme.clone());
@ -2978,7 +2974,7 @@ impl TilingLayout {
let mut configures = Vec::new(); let mut configures = Vec::new();
let (outer, inner) = gaps; let (outer, inner) = gaps;
let mut geo = layer_map_for_output(&output) let mut geo = layer_map_for_output(output)
.non_exclusive_zone() .non_exclusive_zone()
.as_local(); .as_local();
geo.loc.x += outer; geo.loc.x += outer;
@ -3095,7 +3091,7 @@ impl TilingLayout {
Data::Mapped { mapped, .. } => { Data::Mapped { mapped, .. } => {
if !(mapped.is_fullscreen(true) || mapped.is_maximized(true)) { if !(mapped.is_fullscreen(true) || mapped.is_maximized(true)) {
mapped.set_tiled(true); mapped.set_tiled(true);
let internal_geometry = geo.to_global(&output); let internal_geometry = geo.to_global(output);
mapped.set_geometry(internal_geometry); mapped.set_geometry(internal_geometry);
if let Some(serial) = mapped.configure() { if let Some(serial) = mapped.configure() {
configures.push((mapped.active_window(), serial)); configures.push((mapped.active_window(), serial));
@ -3312,9 +3308,7 @@ impl TilingLayout {
(last_geometry.loc (last_geometry.loc
+ tree + tree
.children(&id) .children(&id)
.unwrap() .unwrap().nth(idx)
.skip(idx)
.next()
.map(|node| { .map(|node| {
let geo = node.data().geometry(); let geo = node.data().geometry();
geo.loc + geo.size geo.loc + geo.size
@ -3647,7 +3641,7 @@ impl TilingLayout {
} => true, } => true,
_ => false, _ => false,
}) })
.map(|node_id| TargetZone::InitialPlaceholder(node_id)) .map(TargetZone::InitialPlaceholder)
.unwrap_or(TargetZone::Initial), .unwrap_or(TargetZone::Initial),
)); ));
} }
@ -3684,14 +3678,14 @@ impl TilingLayout {
let removed = if let TargetZone::InitialPlaceholder(node_id) = let removed = if let TargetZone::InitialPlaceholder(node_id) =
old_target_zone old_target_zone
{ {
if tree.get(&node_id).is_ok() { if tree.get(node_id).is_ok() {
TilingLayout::unmap_internal(&mut tree, &node_id); TilingLayout::unmap_internal(&mut tree, node_id);
} }
true true
} else if let TargetZone::WindowSplit(node_id, _) = old_target_zone } else if let TargetZone::WindowSplit(node_id, _) = old_target_zone
{ {
if let Some(children) = tree if let Some(children) = tree
.get(&node_id) .get(node_id)
.ok() .ok()
.and_then(|node| node.parent()) .and_then(|node| node.parent())
.and_then(|parent_id| tree.get(parent_id).ok()) .and_then(|parent_id| tree.get(parent_id).ok())
@ -3714,7 +3708,7 @@ impl TilingLayout {
} }
true true
} else if let TargetZone::GroupEdge(node_id, _) = old_target_zone { } else if let TargetZone::GroupEdge(node_id, _) = old_target_zone {
if let Ok(node) = tree.get_mut(&node_id) { if let Ok(node) = tree.get_mut(node_id) {
match node.data_mut() { match node.data_mut() {
Data::Group { pill_indicator, .. } => { Data::Group { pill_indicator, .. } => {
*pill_indicator = None; *pill_indicator = None;
@ -3726,7 +3720,7 @@ impl TilingLayout {
} else if let TargetZone::GroupInterior(node_id, _) = } else if let TargetZone::GroupInterior(node_id, _) =
old_target_zone old_target_zone
{ {
if let Ok(node) = tree.get_mut(&node_id) { if let Ok(node) = tree.get_mut(node_id) {
match node.data_mut() { match node.data_mut() {
Data::Group { pill_indicator, .. } => { Data::Group { pill_indicator, .. } => {
*pill_indicator = None; *pill_indicator = None;
@ -3761,7 +3755,7 @@ impl TilingLayout {
} else { } else {
Orientation::Horizontal Orientation::Horizontal
}; };
TilingLayout::new_group(&mut tree, &node_id, &id, orientation) TilingLayout::new_group(&mut tree, node_id, &id, orientation)
.unwrap(); .unwrap();
if matches!(dir, Direction::Left | Direction::Up) { if matches!(dir, Direction::Left | Direction::Up) {
tree.make_first_sibling(&id).unwrap(); tree.make_first_sibling(&id).unwrap();
@ -3771,7 +3765,7 @@ impl TilingLayout {
} else if let TargetZone::GroupEdge(node_id, direction) = } else if let TargetZone::GroupEdge(node_id, direction) =
&target_zone &target_zone
{ {
if let Ok(node) = tree.get_mut(&node_id) { if let Ok(node) = tree.get_mut(node_id) {
match node.data_mut() { match node.data_mut() {
Data::Group { pill_indicator, .. } => { Data::Group { pill_indicator, .. } => {
*pill_indicator = *pill_indicator =
@ -3785,7 +3779,7 @@ impl TilingLayout {
} }
} else if let TargetZone::GroupInterior(node_id, idx) = &target_zone } else if let TargetZone::GroupInterior(node_id, idx) = &target_zone
{ {
if let Ok(node) = tree.get_mut(&node_id) { if let Ok(node) = tree.get_mut(node_id) {
match node.data_mut() { match node.data_mut() {
Data::Group { pill_indicator, .. } => { Data::Group { pill_indicator, .. } => {
*pill_indicator = Some(PillIndicator::Inner(*idx)); *pill_indicator = Some(PillIndicator::Inner(*idx));
@ -3823,9 +3817,7 @@ impl TilingLayout {
pub fn mapped(&self) -> impl Iterator<Item = (&CosmicMapped, Rectangle<i32, Local>)> { pub fn mapped(&self) -> impl Iterator<Item = (&CosmicMapped, Rectangle<i32, Local>)> {
let tree = &self.queue.trees.back().unwrap().0; let tree = &self.queue.trees.back().unwrap().0;
let iter = if let Some(root) = tree.root_node_id() { let iter = tree.root_node_id().map(|root| tree.traverse_pre_order(root)
Some(
tree.traverse_pre_order(root)
.unwrap() .unwrap()
.filter(|node| node.data().is_mapped(None)) .filter(|node| node.data().is_mapped(None))
.filter(|node| match node.data() { .filter(|node| match node.data() {
@ -3837,7 +3829,7 @@ impl TilingLayout {
mapped, mapped,
last_geometry, last_geometry,
.. ..
} => (mapped, last_geometry.clone()), } => (mapped, *last_geometry),
_ => unreachable!(), _ => unreachable!(),
}) })
.chain( .chain(
@ -3853,14 +3845,10 @@ impl TilingLayout {
mapped, mapped,
last_geometry, last_geometry,
.. ..
} => (mapped, last_geometry.clone()), } => (mapped, *last_geometry),
_ => unreachable!(), _ => unreachable!(),
}), }),
), ));
)
} else {
None
};
iter.into_iter().flatten() iter.into_iter().flatten()
} }
@ -3868,7 +3856,7 @@ impl TilingLayout {
self.mapped().flat_map(|(mapped, geo)| { self.mapped().flat_map(|(mapped, geo)| {
mapped.windows().map(move |(w, p)| { mapped.windows().map(move |(w, p)| {
(w, { (w, {
let mut geo = geo.clone(); let mut geo = geo;
geo.loc += p.as_local(); geo.loc += p.as_local();
geo.size -= p.to_size().as_local(); geo.size -= p.to_size().as_local();
geo geo
@ -3933,7 +3921,7 @@ impl TilingLayout {
while let Some((src_id, dst_id)) = stack.pop() { while let Some((src_id, dst_id)) = stack.pop() {
for child_id in src.children_ids(&src_id).unwrap() { for child_id in src.children_ids(&src_id).unwrap() {
let src_node = src.get(&child_id).unwrap(); let src_node = src.get(child_id).unwrap();
let new_node = Node::new(src_node.data().clone()); let new_node = Node::new(src_node.data().clone());
let new_child_id = dst let new_child_id = dst
.insert(new_node, InsertBehavior::UnderNode(&dst_id)) .insert(new_node, InsertBehavior::UnderNode(&dst_id))
@ -4027,7 +4015,7 @@ impl TilingLayout {
&self.backdrop_id, &self.backdrop_id,
is_mouse_tiling, is_mouse_tiling,
swap_desc.clone(), swap_desc.clone(),
overview.1.as_ref().and_then(|(_, tree)| tree.clone()), overview.1.as_ref().and_then(|(_, tree)| *tree),
theme, theme,
)) ))
} else { } else {
@ -4064,7 +4052,7 @@ impl TilingLayout {
&self.backdrop_id, &self.backdrop_id,
is_mouse_tiling, is_mouse_tiling,
swap_desc.clone(), swap_desc.clone(),
overview.1.as_ref().and_then(|(_, tree)| tree.clone()), overview.1.as_ref().and_then(|(_, tree)| *tree),
theme, theme,
)) ))
} else { } else {
@ -4176,7 +4164,7 @@ impl TilingLayout {
&self.backdrop_id, &self.backdrop_id,
is_mouse_tiling, is_mouse_tiling,
swap_desc.clone(), swap_desc.clone(),
overview.1.as_ref().and_then(|(_, tree)| tree.clone()), overview.1.as_ref().and_then(|(_, tree)| *tree),
theme, theme,
)) ))
} else { } else {
@ -4211,7 +4199,7 @@ impl TilingLayout {
&self.backdrop_id, &self.backdrop_id,
is_mouse_tiling, is_mouse_tiling,
swap_desc.clone(), swap_desc.clone(),
overview.1.as_ref().and_then(|(_, tree)| tree.clone()), overview.1.as_ref().and_then(|(_, tree)| *tree),
theme, theme,
)) ))
} else { } else {
@ -4326,14 +4314,10 @@ where
seat.get_keyboard() seat.get_keyboard()
.unwrap() .unwrap()
.current_focus() .current_focus()
.and_then(|target| TilingLayout::currently_focused_node(&tree, target)) .and_then(|target| TilingLayout::currently_focused_node(tree, target))
}) })
.map(|(id, _)| id); .map(|(id, _)| id);
let focused_geo = if let Some(focused_id) = focused.as_ref() { let focused_geo = focused.as_ref().map(|focused_id| *tree.get(focused_id).unwrap().data().geometry());
Some(*tree.get(focused_id).unwrap().data().geometry())
} else {
None
};
let has_potential_groups = if let Some(focused_id) = focused.as_ref() { let has_potential_groups = if let Some(focused_id) = focused.as_ref() {
let focused_node = tree.get(focused_id).unwrap(); let focused_node = tree.get(focused_id).unwrap();
@ -4510,7 +4494,7 @@ where
.parent() .parent()
.map(|parent_id| { .map(|parent_id| {
matches!( matches!(
tree.get(&parent_id).unwrap().data(), tree.get(parent_id).unwrap().data(),
Data::Group { Data::Group {
pill_indicator: Some(_), pill_indicator: Some(_),
.. ..
@ -4630,7 +4614,7 @@ where
}; };
} }
if matches!(swap_desc, Some(ref desc) if &desc.node == &node_id) { if matches!(swap_desc, Some(ref desc) if desc.node == node_id) {
if let Some(renderer) = renderer.as_mut() { if let Some(renderer) = renderer.as_mut() {
elements.push( elements.push(
BackdropShader::element( BackdropShader::element(
@ -4855,7 +4839,7 @@ where
geo.size -= (WINDOW_BACKDROP_GAP * 2, WINDOW_BACKDROP_GAP * 2).into(); geo.size -= (WINDOW_BACKDROP_GAP * 2, WINDOW_BACKDROP_GAP * 2).into();
} }
if matches!(swap_desc, Some(ref desc) if &desc.node == &node_id && desc.stack_window.is_none()) if matches!(swap_desc, Some(ref desc) if desc.node == node_id && desc.stack_window.is_none())
{ {
let swap_geo = swap_geometry( let swap_geo = swap_geometry(
geo.size.as_logical(), geo.size.as_logical(),
@ -5092,8 +5076,8 @@ fn render_old_tree(
} }
let (scale, offset) = scaled_geo let (scale, offset) = scaled_geo
.map(|adapted_geo| scale_to_center(&original_geo, &adapted_geo)) .map(|adapted_geo| scale_to_center(original_geo, &adapted_geo))
.unwrap_or_else(|| (1.0.into(), (0, 0).into())); .unwrap_or_else(|| (1.0, (0, 0).into()));
let geo = scaled_geo let geo = scaled_geo
.map(|adapted_geo| { .map(|adapted_geo| {
Rectangle::new( Rectangle::new(
@ -5206,7 +5190,7 @@ where
seat.get_keyboard() seat.get_keyboard()
.unwrap() .unwrap()
.current_focus() .current_focus()
.and_then(|target| TilingLayout::currently_focused_node(&target_tree, target)) .and_then(|target| TilingLayout::currently_focused_node(target_tree, target))
}) })
.map(|(id, _)| id); .map(|(id, _)| id);
let focused_geo = if let Some(focused) = focused.as_ref() { let focused_geo = if let Some(focused) = focused.as_ref() {
@ -5275,7 +5259,7 @@ where
let swap_geo = ease( let swap_geo = ease(
Linear, Linear,
EaseRectangle({ EaseRectangle({
let mut geo = focused_geo.clone(); let mut geo = focused_geo;
geo.loc.x += STACK_TAB_HEIGHT; geo.loc.x += STACK_TAB_HEIGHT;
geo.size.h -= STACK_TAB_HEIGHT; geo.size.h -= STACK_TAB_HEIGHT;
geo geo
@ -5344,7 +5328,7 @@ where
|| focused.as_ref() == Some(&node_id) || focused.as_ref() == Some(&node_id)
{ {
if indicator_thickness > 0 || data.is_group() { if indicator_thickness > 0 || data.is_group() {
let mut geo = geo.clone(); let mut geo = geo;
if data.is_group() { if data.is_group() {
let outer_gap: i32 = (if is_overview { GAP_KEYBOARD } else { 4 } as f32 let outer_gap: i32 = (if is_overview { GAP_KEYBOARD } else { 4 } as f32
@ -5437,7 +5421,7 @@ where
} }
if let Some((mode, resize)) = resize_indicator.as_mut() { if let Some((mode, resize)) = resize_indicator.as_mut() {
let mut geo = geo.clone(); let mut geo = geo;
geo.loc -= (18, 18).into(); geo.loc -= (18, 18).into();
geo.size += (36, 36).into(); geo.size += (36, 36).into();
@ -5572,7 +5556,7 @@ where
if swap_desc if swap_desc
.as_ref() .as_ref()
.map(|swap_desc| { .map(|swap_desc| {
(&swap_desc.node == &node_id (swap_desc.node == node_id
|| target_tree || target_tree
.ancestor_ids(&node_id) .ancestor_ids(&node_id)
.unwrap() .unwrap()
@ -5582,12 +5566,10 @@ where
.unwrap_or(false) .unwrap_or(false)
{ {
swap_elements.extend(elements); swap_elements.extend(elements);
} else if animating {
animating_window_elements.extend(elements);
} else { } else {
if animating { window_elements.extend(elements);
animating_window_elements.extend(elements);
} else {
window_elements.extend(elements);
}
} }
} }
}, },
@ -5666,7 +5648,7 @@ fn render_new_tree(
let (scale, offset) = old_scaled_geo let (scale, offset) = old_scaled_geo
.unwrap() .unwrap()
.map(|adapted_geo| scale_to_center(original_geo, adapted_geo)) .map(|adapted_geo| scale_to_center(original_geo, adapted_geo))
.unwrap_or_else(|| (1.0.into(), (0, 0).into())); .unwrap_or_else(|| (1.0, (0, 0).into()));
( (
old_scaled_geo old_scaled_geo
.unwrap() .unwrap()
@ -5694,7 +5676,7 @@ fn render_new_tree(
let (scale, offset) = scaled_geo let (scale, offset) = scaled_geo
.map(|adapted_geo| scale_to_center(original_geo, adapted_geo)) .map(|adapted_geo| scale_to_center(original_geo, adapted_geo))
.unwrap_or_else(|| (1.0.into(), (0, 0).into())); .unwrap_or_else(|| (1.0, (0, 0).into()));
let new_geo = scaled_geo let new_geo = scaled_geo
.map(|adapted_geo| { .map(|adapted_geo| {
Rectangle::new( Rectangle::new(

View file

@ -170,7 +170,7 @@ impl OverviewMode {
} }
pub fn trigger(&self) -> Option<&Trigger> { pub fn trigger(&self) -> Option<&Trigger> {
self.active_trigger().or_else(|| { self.active_trigger().or({
if let OverviewMode::Ended(trigger, _) = self { if let OverviewMode::Ended(trigger, _) = self {
trigger.as_ref() trigger.as_ref()
} else { } else {
@ -361,7 +361,7 @@ fn create_workspace(
) -> Workspace { ) -> Workspace {
let workspace_handle = state let workspace_handle = state
.create_workspace( .create_workspace(
&group_handle, group_handle,
if tiling { if tiling {
TilingState::TilingEnabled TilingState::TilingEnabled
} else { } else {
@ -394,7 +394,7 @@ fn create_workspace_from_pinned(
) -> Workspace { ) -> Workspace {
let workspace_handle = state let workspace_handle = state
.create_workspace( .create_workspace(
&group_handle, group_handle,
if pinned.tiling_enabled { if pinned.tiling_enabled {
TilingState::TilingEnabled TilingState::TilingEnabled
} else { } else {
@ -533,7 +533,7 @@ impl WorkspaceSet {
self.sticky_layer.set_output(new_output); self.sticky_layer.set_output(new_output);
for window in self.sticky_layer.windows() { for window in self.sticky_layer.windows() {
toplevel_leave_output(&window, &self.output); toplevel_leave_output(&window, &self.output);
toplevel_enter_output(&window, &new_output); toplevel_enter_output(&window, new_output);
} }
for workspace in &mut self.workspaces { for workspace in &mut self.workspaces {
workspace.set_output(new_output, explicit); workspace.set_output(new_output, explicit);
@ -591,8 +591,7 @@ impl WorkspaceSet {
// add empty at the end, if necessary // add empty at the end, if necessary
if self if self
.workspaces .workspaces
.last() .last().is_none_or(|last| !last.is_empty() || last.pinned)
.map_or(true, |last| !last.is_empty() || last.pinned)
{ {
self.add_empty_workspace(state); self.add_empty_workspace(state);
} }
@ -607,8 +606,7 @@ impl WorkspaceSet {
let previous_is_empty = i > 0 let previous_is_empty = i > 0
&& self && self
.workspaces .workspaces
.get(i - 1) .get(i - 1).is_some_and(|w| w.is_empty() && !w.pinned);
.map_or(false, |w| w.is_empty() && !w.pinned);
let keep = if workspace.can_auto_remove(xdg_activation_state) { let keep = if workspace.can_auto_remove(xdg_activation_state) {
// Keep empty workspace if it's active, or it's the last workspace, // Keep empty workspace if it's active, or it's the last workspace,
// and the previous worspace is not both active and empty. // and the previous worspace is not both active and empty.
@ -632,7 +630,7 @@ impl WorkspaceSet {
.filter(|kept| !**kept) .filter(|kept| !**kept)
.count(); .count();
if kept.iter().any(|val| *val == false) { if kept.iter().any(|val| !(*val)) {
self.update_workspace_idxs(state); self.update_workspace_idxs(state);
} }
} }
@ -736,9 +734,9 @@ impl Workspaces {
set set
}) })
.unwrap_or_else(|| { .unwrap_or_else(|| {
WorkspaceSet::new(workspace_state, &output, self.autotile, self.theme.clone()) WorkspaceSet::new(workspace_state, output, self.autotile, self.theme.clone())
}); });
workspace_state.add_group_output(&set.group, &output); workspace_state.add_group_output(&set.group, output);
// If this is the first output added, create workspaces for pinned workspaces from config // If this is the first output added, create workspaces for pinned workspaces from config
for pinned in std::mem::take(&mut self.persisted_workspaces) { for pinned in std::mem::take(&mut self.persisted_workspaces) {
@ -1152,7 +1150,7 @@ impl Workspaces {
s.active = active; s.active = active;
}); });
if keep.iter().any(|val| *val == false) { if keep.iter().any(|val| !(*val)) {
for set in self.sets.values_mut() { for set in self.sets.values_mut() {
set.update_workspace_idxs(workspace_state); set.update_workspace_idxs(workspace_state);
} }
@ -1751,7 +1749,7 @@ impl Shell {
KeyboardFocusTarget::Fullscreen(elem) => self KeyboardFocusTarget::Fullscreen(elem) => self
.outputs() .outputs()
.find(|output| { .find(|output| {
let workspace = self.active_space(&output).unwrap(); let workspace = self.active_space(output).unwrap();
workspace.get_fullscreen() == Some(&elem) workspace.get_fullscreen() == Some(&elem)
}) })
.cloned(), .cloned(),
@ -1759,7 +1757,7 @@ impl Shell {
.outputs() .outputs()
.find(|output| { .find(|output| {
self.workspaces self.workspaces
.active(&output) .active(output)
.unwrap() .unwrap()
.1 .1
.tiling_layer .tiling_layer
@ -1809,7 +1807,6 @@ impl Shell {
match focus_target { match focus_target {
KeyboardFocusTarget::Group(_group) => { KeyboardFocusTarget::Group(_group) => {
//TODO: decide if we want close actions to apply to groups //TODO: decide if we want close actions to apply to groups
return;
} }
KeyboardFocusTarget::Fullscreen(surface) => { KeyboardFocusTarget::Fullscreen(surface) => {
surface.close(); surface.close();
@ -1937,7 +1934,7 @@ impl Shell {
.workspaces .workspaces
.spaces() .spaces()
.find(move |workspace| workspace.output() == output) .find(move |workspace| workspace.output() == output)
.map(|w| (w.handle.clone(), output.clone())), .map(|w| (w.handle, output.clone())),
None => self None => self
.workspaces .workspaces
.spaces() .spaces()
@ -1951,7 +1948,7 @@ impl Shell {
.is_some_and(|m| m.has_surface(surface, WindowSurfaceType::ALL)) .is_some_and(|m| m.has_surface(surface, WindowSurfaceType::ALL))
}) })
}) })
.map(|w| (w.handle.clone(), w.output().clone())), .map(|w| (w.handle, w.output().clone())),
} }
} }
@ -2130,24 +2127,22 @@ impl Shell {
} }
self.overview_mode = OverviewMode::Started(trigger, Instant::now()); self.overview_mode = OverviewMode::Started(trigger, Instant::now());
} }
} else { } else if matches!(
if matches!( self.overview_mode,
self.overview_mode, OverviewMode::Started(_, _) | OverviewMode::Active(_)
OverviewMode::Started(_, _) | OverviewMode::Active(_) ) {
) { let (reverse_duration, trigger) =
let (reverse_duration, trigger) = if let OverviewMode::Started(trigger, start) = self.overview_mode.clone() {
if let OverviewMode::Started(trigger, start) = self.overview_mode.clone() { (
( ANIMATION_DURATION
ANIMATION_DURATION - Instant::now().duration_since(start).min(ANIMATION_DURATION),
- Instant::now().duration_since(start).min(ANIMATION_DURATION), Some(trigger),
Some(trigger), )
) } else {
} else { (Duration::ZERO, self.overview_mode.active_trigger().cloned())
(Duration::ZERO, self.overview_mode.active_trigger().cloned()) };
}; self.overview_mode =
self.overview_mode = OverviewMode::Ended(trigger, Instant::now() - reverse_duration);
OverviewMode::Ended(trigger, Instant::now() - reverse_duration);
}
} }
} }
@ -2188,12 +2183,10 @@ impl Shell {
evlh, evlh,
self.theme.clone(), self.theme.clone(),
)); ));
} else { } else if let Some(direction) = self.resize_mode.active_direction() {
if let Some(direction) = self.resize_mode.active_direction() { self.resize_mode = ResizeMode::Ended(Instant::now(), direction);
self.resize_mode = ResizeMode::Ended(Instant::now(), direction); if let Some((_, direction, edge, _, _, _)) = self.resize_state.as_ref() {
if let Some((_, direction, edge, _, _, _)) = self.resize_state.as_ref() { self.finish_resize(*direction, *edge);
self.finish_resize(*direction, *edge);
}
} }
} }
} }
@ -2449,7 +2442,7 @@ impl Shell {
.workspaces .workspaces
.sets .sets
.get_mut(&output) .get_mut(&output)
.or_else(|| self.workspaces.backup_set.as_mut()) .or(self.workspaces.backup_set.as_mut())
.unwrap(); .unwrap();
set.sticky_layer.map_internal( set.sticky_layer.map_internal(
window.clone(), window.clone(),
@ -2464,7 +2457,7 @@ impl Shell {
let workspace = match &state { let workspace = match &state {
Some(FullscreenRestoreState::Floating { workspace, .. }) Some(FullscreenRestoreState::Floating { workspace, .. })
| Some(FullscreenRestoreState::Tiling { workspace, .. }) => { | Some(FullscreenRestoreState::Tiling { workspace, .. }) => {
let workspace = self.workspaces.space_for_handle_mut(&workspace); let workspace = self.workspaces.space_for_handle_mut(workspace);
let workspace = match workspace { let workspace = match workspace {
Some(workspace) => workspace, Some(workspace) => workspace,
None => self.workspaces.active_mut(&seat.active_output()).unwrap(), None => self.workspaces.active_mut(&seat.active_output()).unwrap(),
@ -2936,12 +2929,12 @@ impl Shell {
node, focus_stack, .. node, focus_stack, ..
})) => { })) => {
let new_pos = if follow { let new_pos = if follow {
seat.set_active_output(&to_output); seat.set_active_output(to_output);
self.workspaces self.workspaces
.idx_for_handle(&to_output, &to) .idx_for_handle(to_output, &to)
.and_then(|to_idx| { .and_then(|to_idx| {
self.activate( self.activate(
&to_output, to_output,
to_idx, to_idx,
WorkspaceDelta::new_shortcut(), WorkspaceDelta::new_shortcut(),
workspace_state, workspace_state,
@ -2957,7 +2950,7 @@ impl Shell {
if let Some(from_workspace) = from_w.get_mut(0) { if let Some(from_workspace) = from_w.get_mut(0) {
if let Some(to_workspace) = other_w.iter_mut().find(|w| w.handle == to) { if let Some(to_workspace) = other_w.iter_mut().find(|w| w.handle == to) {
{ {
let mut stack = to_workspace.focus_stack.get_mut(&seat); let mut stack = to_workspace.focus_stack.get_mut(seat);
for elem in focus_stack.iter().flat_map(|node_id| { for elem in focus_stack.iter().flat_map(|node_id| {
from_workspace.tiling_layer.element_for_node(node_id) from_workspace.tiling_layer.element_for_node(node_id)
}) { }) {
@ -2982,7 +2975,7 @@ impl Shell {
&mut to_workspace.tiling_layer, &mut to_workspace.tiling_layer,
&to, &to,
seat, seat,
to_workspace.focus_stack.get(&seat).iter(), to_workspace.focus_stack.get(seat).iter(),
NodeDesc { NodeDesc {
handle: from, handle: from,
node, node,
@ -3003,7 +2996,7 @@ impl Shell {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_iter() .into_iter()
{ {
to_workspace.toggle_floating_window(&seat, &mapped); to_workspace.toggle_floating_window(seat, &mapped);
} }
to_workspace.tiling_enabled = false; to_workspace.tiling_enabled = false;
} }
@ -3145,7 +3138,7 @@ impl Shell {
{ {
to_workspace.unmaximize_request(&mapped); to_workspace.unmaximize_request(&mapped);
} }
let focus_stack = seat.map(|seat| to_workspace.focus_stack.get(&seat)); let focus_stack = seat.map(|seat| to_workspace.focus_stack.get(seat));
to_workspace.tiling_layer.map( to_workspace.tiling_layer.map(
mapped.clone(), mapped.clone(),
focus_stack.as_ref().map(|x| x.iter()), focus_stack.as_ref().map(|x| x.iter()),
@ -3239,7 +3232,7 @@ impl Shell {
{ {
to_workspace.unmaximize_request(&mapped); to_workspace.unmaximize_request(&mapped);
} }
let focus_stack = seat.map(|seat| to_workspace.focus_stack.get(&seat)); let focus_stack = seat.map(|seat| to_workspace.focus_stack.get(seat));
to_workspace.tiling_layer.map( to_workspace.tiling_layer.map(
mapped.clone(), mapped.clone(),
focus_stack.as_ref().map(|x| x.iter()), focus_stack.as_ref().map(|x| x.iter()),
@ -3301,7 +3294,7 @@ impl Shell {
) -> Option<(MenuGrab, Focus)> { ) -> Option<(MenuGrab, Focus)> {
let serial = serial.into(); let serial = serial.into();
let Some(GrabStartData::Pointer(start_data)) = let Some(GrabStartData::Pointer(start_data)) =
check_grab_preconditions(&seat, serial, Some(surface)) check_grab_preconditions(seat, serial, Some(surface))
else { else {
return None; // TODO: an application can send a menu request for a touch event return None; // TODO: an application can send a menu request for a touch event
}; };
@ -3316,7 +3309,7 @@ impl Shell {
if target_stack || !is_stacked { if target_stack || !is_stacked {
Box::new( Box::new(
window_items( window_items(
&mapped, mapped,
is_tiled, is_tiled,
is_stacked, is_stacked,
is_sticky, is_sticky,
@ -3333,7 +3326,7 @@ impl Shell {
.find(|(s, _)| s.wl_surface().as_deref() == Some(surface)) .find(|(s, _)| s.wl_surface().as_deref() == Some(surface))
.unwrap(); .unwrap();
Box::new( Box::new(
tab_items(&mapped, &tab, is_tiled, config) tab_items(mapped, &tab, is_tiled, config)
.collect::<Vec<Item>>() .collect::<Vec<Item>>()
.into_iter(), .into_iter(),
) as Box<dyn Iterator<Item = Item>> ) as Box<dyn Iterator<Item = Item>>
@ -3352,13 +3345,13 @@ impl Shell {
.map(|(mapped, relative_loc)| (set, mapped, relative_loc)) .map(|(mapped, relative_loc)| (set, mapped, relative_loc))
}) { }) {
let output = set.output.clone(); let output = set.output.clone();
let global_position = (set.sticky_layer.element_geometry(&mapped).unwrap().loc let global_position = (set.sticky_layer.element_geometry(mapped).unwrap().loc
+ relative_loc.as_local() + relative_loc.as_local()
+ location.as_local()) + location.as_local())
.to_global(&output); .to_global(&output);
( (
global_position, global_position,
items_for_element(&mapped, false, true, false, ResizeEdge::all()), items_for_element(mapped, false, true, false, ResizeEdge::all()),
) )
} else if let Some((workspace, output)) = self.workspace_for_surface(surface) { } else if let Some((workspace, output)) = self.workspace_for_surface(surface) {
let workspace = self.workspaces.space_for_handle(&workspace).unwrap(); let workspace = self.workspaces.space_for_handle(&workspace).unwrap();
@ -3396,7 +3389,7 @@ impl Shell {
( (
global_position, global_position,
items_for_element(&mapped, is_tiled, false, workspace.tiling_enabled, edge), items_for_element(mapped, is_tiled, false, workspace.tiling_enabled, edge),
) )
} }
} else { } else {
@ -3436,7 +3429,7 @@ impl Shell {
let mut element_geo = None; let mut element_geo = None;
let mut start_data = let mut start_data =
check_grab_preconditions(&seat, serial, client_initiated.then_some(surface))?; check_grab_preconditions(seat, serial, client_initiated.then_some(surface))?;
let maybe_fullscreen_workspace = self let maybe_fullscreen_workspace = self
.workspaces .workspaces
@ -3523,7 +3516,7 @@ impl Shell {
None None
}; };
let layer = if mapped == old_mapped { let layer = if if mapped == old_mapped {
let was_floating = workspace.floating_layer.unmap(&mapped, None); let was_floating = workspace.floating_layer.unmap(&mapped, None);
let was_tiled = workspace let was_tiled = workspace
.tiling_layer .tiling_layer
@ -3538,14 +3531,12 @@ impl Shell {
.tiling_layer .tiling_layer
.mapped() .mapped()
.any(|(m, _)| m == &old_mapped) .any(|(m, _)| m == &old_mapped)
} } { ManagedLayer::Tiling } else { ManagedLayer::Floating };
.then_some(ManagedLayer::Tiling)
.unwrap_or(ManagedLayer::Floating);
// if this changed the width, the window was tiled in floating mode // if this changed the width, the window was tiled in floating mode
if let Some(new_size) = new_size { if let Some(new_size) = new_size {
let output = workspace.output(); let output = workspace.output();
let ratio = pos.to_local(&output).x / (elem_geo.loc.x + elem_geo.size.w) as f64; let ratio = pos.to_local(output).x / (elem_geo.loc.x + elem_geo.size.w) as f64;
initial_window_location = Point::from(( initial_window_location = Point::from((
pos.x - (new_size.w as f64 * ratio), pos.x - (new_size.w as f64 * ratio),
@ -3650,7 +3641,7 @@ impl Shell {
KeyboardFocusTarget::Fullscreen(surface) => { KeyboardFocusTarget::Fullscreen(surface) => {
if let Some(workspace) = surface if let Some(workspace) = surface
.wl_surface() .wl_surface()
.and_then(|s| self.workspace_for_surface(&*s)) .and_then(|s| self.workspace_for_surface(&s))
.and_then(|(handle, _)| self.workspaces.space_for_handle(&handle)) .and_then(|(handle, _)| self.workspaces.space_for_handle(&handle))
{ {
workspace workspace
@ -3683,9 +3674,9 @@ impl Shell {
.unwrap() .unwrap()
.to_global(&set.output); .to_global(&set.output);
Some(geometry) Some(geometry)
} else if let Some(workspace) = self.space_for(&mapped) { } else if let Some(workspace) = self.space_for(mapped) {
let geometry = workspace let geometry = workspace
.element_geometry(&mapped) .element_geometry(mapped)
.unwrap() .unwrap()
.to_global(workspace.output()); .to_global(workspace.output());
Some(geometry) Some(geometry)
@ -3910,7 +3901,7 @@ impl Shell {
return None; return None;
} }
let mut start_data = check_grab_preconditions(&seat, None, None)?; let mut start_data = check_grab_preconditions(seat, None, None)?;
let (floating_layer, geometry) = if let Some(set) = self let (floating_layer, geometry) = if let Some(set) = self
.workspaces .workspaces
@ -3924,9 +3915,9 @@ impl Shell {
.unwrap() .unwrap()
.to_global(&set.output); .to_global(&set.output);
(&mut set.sticky_layer, geometry) (&mut set.sticky_layer, geometry)
} else if let Some(workspace) = self.space_for_mut(&mapped) { } else if let Some(workspace) = self.space_for_mut(mapped) {
let geometry = workspace let geometry = workspace
.element_geometry(&mapped) .element_geometry(mapped)
.unwrap() .unwrap()
.to_global(workspace.output()); .to_global(workspace.output());
(&mut workspace.floating_layer, geometry) (&mut workspace.floating_layer, geometry)
@ -3968,7 +3959,7 @@ impl Shell {
ReleaseMode::Click, ReleaseMode::Click,
) { ) {
grab.into() grab.into()
} else if let Some(ws) = self.space_for_mut(&mapped) { } else if let Some(ws) = self.space_for_mut(mapped) {
let node_id = mapped.tiling_node_id.lock().unwrap().clone()?; let node_id = mapped.tiling_node_id.lock().unwrap().clone()?;
let (node, left_up_idx, orientation) = ws.tiling_layer.resize_request(node_id, edge)?; let (node, left_up_idx, orientation) = ws.tiling_layer.resize_request(node_id, edge)?;
ResizeForkGrab::new( ResizeForkGrab::new(
@ -4026,22 +4017,20 @@ impl Shell {
was_maximized: false, was_maximized: false,
}, },
}); });
} else { } else if let Some((workspace, window)) = self.workspaces.sets.values_mut().find_map(|set| {
if let Some((workspace, window)) = self.workspaces.sets.values_mut().find_map(|set| { set.workspaces.iter_mut().find_map(|workspace| {
set.workspaces.iter_mut().find_map(|workspace| { let window = workspace
let window = workspace .get_fullscreen()
.get_fullscreen() .cloned()
.cloned() .into_iter()
.into_iter() .chain(workspace.mapped().map(|m| m.active_window()))
.chain(workspace.mapped().map(|m| m.active_window())) .find(|s| s == surface);
.find(|s| s == surface); window.map(|s| (workspace, s))
window.map(|s| (workspace, s)) })
}) }) {
}) { let to = minimize_rectangle(workspace.output(), &window);
let to = minimize_rectangle(workspace.output(), &window); if let Some(minimized) = workspace.minimize(surface, to) {
if let Some(minimized) = workspace.minimize(&surface, to) { workspace.minimized_windows.push(minimized);
workspace.minimized_windows.push(minimized);
}
} }
} }
} }
@ -4113,7 +4102,7 @@ impl Shell {
{ {
let geometry = set.sticky_layer.element_geometry(mapped).unwrap(); let geometry = set.sticky_layer.element_geometry(mapped).unwrap();
(ManagedLayer::Sticky, &mut set.sticky_layer, geometry) (ManagedLayer::Sticky, &mut set.sticky_layer, geometry)
} else if let Some(workspace) = self.space_for_mut(&mapped) { } else if let Some(workspace) = self.space_for_mut(mapped) {
let layer = if workspace.is_tiled(&mapped.active_window()) { let layer = if workspace.is_tiled(&mapped.active_window()) {
ManagedLayer::Tiling ManagedLayer::Tiling
} else { } else {
@ -4187,7 +4176,7 @@ impl Shell {
) -> Option<(ResizeGrab, Focus)> { ) -> Option<(ResizeGrab, Focus)> {
let serial = serial.into(); let serial = serial.into();
let start_data = let start_data =
check_grab_preconditions(&seat, serial, client_initiated.then_some(surface))?; check_grab_preconditions(seat, serial, client_initiated.then_some(surface))?;
let mapped = self.element_for_surface(surface).cloned()?; let mapped = self.element_for_surface(surface).cloned()?;
if mapped.is_maximized(true) { if mapped.is_maximized(true) {
return None; return None;
@ -4556,9 +4545,9 @@ impl Shell {
mapped.active_window() mapped.active_window()
}; };
toplevel_leave_output(&window, &old_output); toplevel_leave_output(&window, old_output);
let old_output = old_output.downgrade(); let old_output = old_output.downgrade();
let workspace_handle = self.active_space(&output).unwrap().handle.clone(); let workspace_handle = self.active_space(&output).unwrap().handle;
toplevel_enter_output(&window, &output); toplevel_enter_output(&window, &output);
toplevel_enter_workspace(&window, &workspace_handle); toplevel_enter_workspace(&window, &workspace_handle);
@ -4585,7 +4574,7 @@ impl Shell {
let from = workspace.element_geometry(&mapped).unwrap(); let from = workspace.element_geometry(&mapped).unwrap();
let (surface, state) = workspace.unmap_surface(surface).unwrap(); let (surface, state) = workspace.unmap_surface(surface).unwrap();
window = surface; window = surface;
let handle = workspace.handle.clone(); let handle = workspace.handle;
toplevel_leave_output(&window, &workspace.output); toplevel_leave_output(&window, &workspace.output);
toplevel_leave_workspace(&window, &workspace.handle); toplevel_leave_workspace(&window, &workspace.handle);
@ -4619,7 +4608,7 @@ impl Shell {
}; };
if let Some((old_fullscreen, restore, _)) = old_fullscreen { if let Some((old_fullscreen, restore, _)) = old_fullscreen {
self.remap_unfullscreened_window(old_fullscreen, restore, &loop_handle); self.remap_unfullscreened_window(old_fullscreen, restore, loop_handle);
} }
Some(KeyboardFocusTarget::Fullscreen(window)) Some(KeyboardFocusTarget::Fullscreen(window))
@ -4662,7 +4651,7 @@ impl Shell {
} }
let mut container = cosmic::config::COSMIC_TK.write().unwrap(); let mut container = cosmic::config::COSMIC_TK.write().unwrap();
if &*container != &toolkit { if *container != toolkit {
*container = toolkit; *container = toolkit;
drop(container); drop(container);
self.refresh(xdg_activation_state, workspace_state); self.refresh(xdg_activation_state, workspace_state);
@ -4777,7 +4766,7 @@ pub fn check_grab_preconditions(
let touch = seat.get_touch().unwrap(); let touch = seat.get_touch().unwrap();
let start_data = let start_data =
if serial.map_or(false, |serial| touch.has_grab(serial)) { if serial.is_some_and(|serial| touch.has_grab(serial)) {
GrabStartData::Touch(touch.grab_start_data().unwrap()) GrabStartData::Touch(touch.grab_start_data().unwrap())
} else { } else {
GrabStartData::Pointer(pointer.grab_start_data().unwrap_or_else(|| { GrabStartData::Pointer(pointer.grab_start_data().unwrap_or_else(|| {

View file

@ -37,6 +37,12 @@ pub struct Seats {
last_active: Option<Seat<State>>, last_active: Option<Seat<State>>,
} }
impl Default for Seats {
fn default() -> Self {
Self::new()
}
}
impl Seats { impl Seats {
pub fn new() -> Seats { pub fn new() -> Seats {
Seats { Seats {
@ -131,7 +137,7 @@ impl Devices {
let mut map = self.capabilities.borrow_mut(); let mut map = self.capabilities.borrow_mut();
map.remove(&id) map.remove(&id)
.unwrap_or(Vec::new()) .unwrap_or_default()
.into_iter() .into_iter()
.filter(|c| map.values().flatten().all(|has| *c != *has)) .filter(|c| map.values().flatten().all(|has| *c != *has))
.collect() .collect()

View file

@ -578,7 +578,7 @@ impl Workspace {
pub fn unmap_element(&mut self, mapped: &CosmicMapped) -> Option<WorkspaceRestoreData> { pub fn unmap_element(&mut self, mapped: &CosmicMapped) -> Option<WorkspaceRestoreData> {
let was_maximized = if mapped.maximized_state.lock().unwrap().is_some() { let was_maximized = if mapped.maximized_state.lock().unwrap().is_some() {
// If surface is maximized then unmaximize it, so it is assigned to only one layer // If surface is maximized then unmaximize it, so it is assigned to only one layer
self.unmaximize_request(&mapped) self.unmaximize_request(mapped)
} else { } else {
None None
}; };
@ -601,7 +601,7 @@ impl Workspace {
}); });
} }
if let Ok(state) = self.tiling_layer.unmap(&mapped, None) { if let Ok(state) = self.tiling_layer.unmap(mapped, None) {
return Some(WorkspaceRestoreData::Tiling(Some(TilingRestoreData { return Some(WorkspaceRestoreData::Tiling(Some(TilingRestoreData {
state, state,
was_maximized: was_maximized.is_some(), was_maximized: was_maximized.is_some(),
@ -610,7 +610,7 @@ impl Workspace {
// unmaximize_request might have triggered a `floating_layer.refresh()`, // unmaximize_request might have triggered a `floating_layer.refresh()`,
// which may have already removed a non-alive surface. // which may have already removed a non-alive surface.
if let Some(floating_geometry) = self.floating_layer.unmap(&mapped, None).or(was_maximized) if let Some(floating_geometry) = self.floating_layer.unmap(mapped, None).or(was_maximized)
{ {
return Some(WorkspaceRestoreData::Floating(Some(FloatingRestoreData { return Some(WorkspaceRestoreData::Floating(Some(FloatingRestoreData {
geometry: floating_geometry, geometry: floating_geometry,
@ -667,10 +667,8 @@ impl Workspace {
if let Some(stack) = maybe_stack { if let Some(stack) = maybe_stack {
if stack.len() > 1 { if stack.len() > 1 {
let idx = stack.surfaces().position(|s| &s == surface); let idx = stack.surfaces().position(|s| &s == surface);
let layer = self let layer = if self
.is_tiled(surface) .is_tiled(surface) { ManagedLayer::Tiling } else { ManagedLayer::Floating };
.then_some(ManagedLayer::Tiling)
.unwrap_or(ManagedLayer::Floating);
return idx return idx
.and_then(|idx| stack.remove_idx(idx)) .and_then(|idx| stack.remove_idx(idx))
.map(|s| (s, layer.into())); .map(|s| (s, layer.into()));
@ -856,14 +854,14 @@ impl Workspace {
self.fullscreen self.fullscreen
.as_ref() .as_ref()
.filter(|f| last_focused.is_some_and(|t| t == &f.surface)) .filter(|f| last_focused.is_some_and(|t| t == &f.surface))
.and_then(|f| check_fullscreen(f)) .and_then(check_fullscreen)
.or_else(|| self.floating_layer.popup_surface_under(location)) .or_else(|| self.floating_layer.popup_surface_under(location))
.or_else(|| self.tiling_layer.popup_surface_under(location, overview)) .or_else(|| self.tiling_layer.popup_surface_under(location, overview))
.or_else(|| { .or_else(|| {
self.fullscreen self.fullscreen
.as_ref() .as_ref()
.filter(|f| last_focused.is_none_or(|t| t != &f.surface)) .filter(|f| last_focused.is_none_or(|t| t != &f.surface))
.and_then(|f| check_fullscreen(f)) .and_then(check_fullscreen)
}) })
.map(|(m, p)| (m, p.to_global(&self.output))) .map(|(m, p)| (m, p.to_global(&self.output)))
} }
@ -909,14 +907,14 @@ impl Workspace {
self.fullscreen self.fullscreen
.as_ref() .as_ref()
.filter(|f| last_focused.is_some_and(|t| t == &f.surface)) .filter(|f| last_focused.is_some_and(|t| t == &f.surface))
.and_then(|f| check_fullscreen(f)) .and_then(check_fullscreen)
.or_else(|| self.floating_layer.toplevel_surface_under(location)) .or_else(|| self.floating_layer.toplevel_surface_under(location))
.or_else(|| self.tiling_layer.toplevel_surface_under(location, overview)) .or_else(|| self.tiling_layer.toplevel_surface_under(location, overview))
.or_else(|| { .or_else(|| {
self.fullscreen self.fullscreen
.as_ref() .as_ref()
.filter(|f| last_focused.is_none_or(|t| t != &f.surface)) .filter(|f| last_focused.is_none_or(|t| t != &f.surface))
.and_then(|f| check_fullscreen(f)) .and_then(check_fullscreen)
}) })
.map(|(m, p)| (m, p.to_global(&self.output))) .map(|(m, p)| (m, p.to_global(&self.output)))
} }
@ -952,8 +950,8 @@ impl Workspace {
match state.original_layer { match state.original_layer {
ManagedLayer::Tiling if self.tiling_enabled => { ManagedLayer::Tiling if self.tiling_enabled => {
// should still be mapped in tiling // should still be mapped in tiling
let geo = self.tiling_layer.element_geometry(&elem); let geo = self.tiling_layer.element_geometry(elem);
self.floating_layer.unmap(&elem, geo); self.floating_layer.unmap(elem, geo);
elem.output_enter(&self.output, elem.bbox()); elem.output_enter(&self.output, elem.bbox());
elem.set_maximized(false); elem.set_maximized(false);
elem.set_geometry(state.original_geometry.to_global(&self.output)); elem.set_geometry(state.original_geometry.to_global(&self.output));
@ -1252,7 +1250,7 @@ impl Workspace {
Some(( Some((
surface.surface.clone(), surface.surface.clone(),
surface.previous_state.clone(), surface.previous_state.clone(),
surface.previous_geometry.clone(), surface.previous_geometry,
)) ))
} else { } else {
None None
@ -1360,7 +1358,7 @@ impl Workspace {
self.floating_layer.map(window.clone(), None); self.floating_layer.map(window.clone(), None);
} else if self.floating_layer.mapped().any(|w| w == window) { } else if self.floating_layer.mapped().any(|w| w == window) {
let focus_stack = self.focus_stack.get(seat); let focus_stack = self.focus_stack.get(seat);
self.floating_layer.unmap(&window, None); self.floating_layer.unmap(window, None);
self.tiling_layer self.tiling_layer
.map(window.clone(), Some(focus_stack.iter()), None) .map(window.clone(), Some(focus_stack.iter()), None)
} }
@ -1446,7 +1444,7 @@ impl Workspace {
.unwrap() .unwrap()
.clone() .clone()
.map(|node_id| NodeDesc { .map(|node_id| NodeDesc {
handle: self.handle.clone(), handle: self.handle,
node: node_id.clone(), node: node_id.clone(),
stack_window: if mapped stack_window: if mapped
.stack_ref() .stack_ref()
@ -1467,7 +1465,7 @@ impl Workspace {
KeyboardFocusTarget::Group(WindowGroup { KeyboardFocusTarget::Group(WindowGroup {
node, focus_stack, .. node, focus_stack, ..
}) => Some(NodeDesc { }) => Some(NodeDesc {
handle: self.handle.clone(), handle: self.handle,
node, node,
stack_window: None, stack_window: None,
focus_stack, focus_stack,
@ -1571,7 +1569,7 @@ impl Workspace {
}; };
if matches!(focused, Some(FocusTarget::Fullscreen(_))) { if matches!(focused, Some(FocusTarget::Fullscreen(_))) {
elements.extend(fullscreen_elements.drain(..)); elements.append(&mut fullscreen_elements);
} }
if !matches!(focused, Some(FocusTarget::Fullscreen(_))) if !matches!(focused, Some(FocusTarget::Fullscreen(_)))

View file

@ -80,7 +80,7 @@ impl OutputZoomState {
let focal_point = if output_geometry.contains(cursor_position) { let focal_point = if output_geometry.contains(cursor_position) {
match movement { match movement {
ZoomMovement::Continuously | ZoomMovement::OnEdge => { ZoomMovement::Continuously | ZoomMovement::OnEdge => {
cursor_position.to_local(&output) cursor_position.to_local(output)
} }
ZoomMovement::Centered => { ZoomMovement::Centered => {
let mut zoomed_output_geometry = output.geometry().to_f64().downscale(level); let mut zoomed_output_geometry = output.geometry().to_f64().downscale(level);
@ -89,18 +89,18 @@ impl OutputZoomState {
let mut focal_point = zoomed_output_geometry let mut focal_point = zoomed_output_geometry
.loc .loc
.to_local(&output) .to_local(output)
.upscale(level) .upscale(level)
.to_global(&output); .to_global(output);
focal_point.x = focal_point.x.clamp( focal_point.x = focal_point.x.clamp(
output_geometry.loc.x as f64, output_geometry.loc.x,
((output_geometry.loc.x + output_geometry.size.w) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable (output_geometry.loc.x + output_geometry.size.w).next_lower(), // FIXME: Replace with f64::next_down when stable
); );
focal_point.y = focal_point.y.clamp( focal_point.y = focal_point.y.clamp(
output_geometry.loc.y as f64, output_geometry.loc.y,
((output_geometry.loc.y + output_geometry.size.h) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable (output_geometry.loc.y + output_geometry.size.h).next_lower(), // FIXME: Replace with f64::next_down when stable
); );
focal_point.to_local(&output) focal_point.to_local(output)
} }
} }
} else { } else {
@ -282,16 +282,16 @@ impl ZoomState {
if !zoomed_output_geometry if !zoomed_output_geometry
.overlaps_or_touches(Rectangle::new(original_position, Size::from((16, 16)))) .overlaps_or_touches(Rectangle::new(original_position, Size::from((16, 16))))
{ {
zoomed_output_geometry.loc = cursor_position.to_global(&output) zoomed_output_geometry.loc = cursor_position.to_global(output)
- zoomed_output_geometry.size.downscale(2).to_point(); - zoomed_output_geometry.size.downscale(2).to_point();
let mut focal_point = zoomed_output_geometry let mut focal_point = zoomed_output_geometry
.loc .loc
.to_local(&output) .to_local(output)
.upscale( .upscale(
output_geometry.size.w output_geometry.size.w
/ (output_geometry.size.w - zoomed_output_geometry.size.w), / (output_geometry.size.w - zoomed_output_geometry.size.w),
) )
.to_global(&output); .to_global(output);
focal_point.x = focal_point.x.clamp( focal_point.x = focal_point.x.clamp(
output_geometry.loc.x, output_geometry.loc.x,
output_geometry.loc.x + output_geometry.size.w - 1, output_geometry.loc.x + output_geometry.size.w - 1,
@ -302,10 +302,10 @@ impl ZoomState {
); );
output_state_ref.previous_point = output_state_ref.previous_point =
Some((output_state_ref.focal_point, Instant::now())); Some((output_state_ref.focal_point, Instant::now()));
output_state_ref.focal_point = focal_point.to_local(&output).to_f64(); output_state_ref.focal_point = focal_point.to_local(output).to_f64();
} else if !zoomed_output_geometry.contains(cursor_position.to_global(&output)) { } else if !zoomed_output_geometry.contains(cursor_position.to_global(output)) {
let mut diff = output_state_ref.focal_point.to_global(&output) let mut diff = output_state_ref.focal_point.to_global(output)
+ (cursor_position.to_global(&output) - original_position) + (cursor_position.to_global(output) - original_position)
.to_f64() .to_f64()
.upscale(output_state_ref.level); .upscale(output_state_ref.level);
diff.x = diff.x.clamp( diff.x = diff.x.clamp(
@ -316,18 +316,18 @@ impl ZoomState {
output_geometry.loc.y as f64, output_geometry.loc.y as f64,
((output_geometry.loc.y + output_geometry.size.h) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable ((output_geometry.loc.y + output_geometry.size.h) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable
); );
diff -= output_state_ref.focal_point.to_global(&output); diff -= output_state_ref.focal_point.to_global(output);
output_state_ref.focal_point += diff.as_logical().as_local(); output_state_ref.focal_point += diff.as_logical().as_local();
} }
} }
ZoomMovement::Centered => { ZoomMovement::Centered => {
zoomed_output_geometry.loc = cursor_position.to_global(&output) zoomed_output_geometry.loc = cursor_position.to_global(output)
- zoomed_output_geometry.size.downscale(2).to_point(); - zoomed_output_geometry.size.downscale(2).to_point();
let mut focal_point = zoomed_output_geometry let mut focal_point = zoomed_output_geometry
.loc .loc
.to_local(&output) .to_local(output)
.upscale( .upscale(
output_geometry output_geometry
.size .size
@ -335,7 +335,7 @@ impl ZoomState {
.checked_div(output_geometry.size.w - zoomed_output_geometry.size.w) .checked_div(output_geometry.size.w - zoomed_output_geometry.size.w)
.unwrap_or(1), .unwrap_or(1),
) )
.to_global(&output); .to_global(output);
focal_point.x = focal_point.x.clamp( focal_point.x = focal_point.x.clamp(
output_geometry.loc.x, output_geometry.loc.x,
output_geometry.loc.x + output_geometry.size.w - 1, output_geometry.loc.x + output_geometry.size.w - 1,
@ -344,7 +344,7 @@ impl ZoomState {
output_geometry.loc.y, output_geometry.loc.y,
output_geometry.loc.y + output_geometry.size.h - 1, output_geometry.loc.y + output_geometry.size.h - 1,
); );
output_state_ref.focal_point = focal_point.to_local(&output).to_f64(); output_state_ref.focal_point = focal_point.to_local(output).to_f64();
} }
} }
} }

View file

@ -161,7 +161,7 @@ impl ClientData for ClientState {
pub fn advertised_node_for_client(client: &Client) -> Option<DrmNode> { pub fn advertised_node_for_client(client: &Client) -> Option<DrmNode> {
// Lets check the global drm-node the client got either through default-feedback or wl_drm // Lets check the global drm-node the client got either through default-feedback or wl_drm
if let Some(normal_client) = client.get_data::<ClientState>() { if let Some(normal_client) = client.get_data::<ClientState>() {
return normal_client.advertised_drm_node.clone(); return normal_client.advertised_drm_node;
} }
// last but not least all xwayland-surfaces should also share a single node // last but not least all xwayland-surfaces should also share a single node
if let Some(xwayland_client) = client.get_data::<XWaylandClientData>() { if let Some(xwayland_client) = client.get_data::<XWaylandClientData>() {
@ -338,7 +338,7 @@ impl BackendData {
BackendData::Kms(state) => { BackendData::Kms(state) => {
return state return state
.dmabuf_imported(client, global, dmabuf) .dmabuf_imported(client, global, dmabuf)
.map(|node| Some(node)); .map(Some);
} }
BackendData::Winit(state) => { BackendData::Winit(state) => {
state.backend.renderer().import_dmabuf(&dmabuf, None)?; state.backend.renderer().import_dmabuf(&dmabuf, None)?;
@ -402,7 +402,7 @@ impl BackendData {
} }
} }
impl<'a> LockedBackend<'a> { impl LockedBackend<'_> {
pub fn all_outputs(&self) -> Vec<Output> { pub fn all_outputs(&self) -> Vec<Output> {
match self { match self {
LockedBackend::Kms(state) => state.all_outputs(), LockedBackend::Kms(state) => state.all_outputs(),
@ -515,11 +515,11 @@ impl<'a> LockedBackend<'a> {
}); });
match final_config.enabled { match final_config.enabled {
OutputState::Enabled => shell_ref.workspaces.add_output(&output, workspace_state), OutputState::Enabled => shell_ref.workspaces.add_output(output, workspace_state),
_ => { _ => {
let shell = &mut *shell_ref; let shell = &mut *shell_ref;
shell.workspaces.remove_output( shell.workspaces.remove_output(
&output, output,
shell.seats.iter(), shell.seats.iter(),
workspace_state, workspace_state,
xdg_activation_state, xdg_activation_state,
@ -527,7 +527,7 @@ impl<'a> LockedBackend<'a> {
} }
} }
layer_map_for_output(&output).arrange(); layer_map_for_output(output).arrange();
} }
// Update layout for changes in resolution, scale, orientation // Update layout for changes in resolution, scale, orientation
@ -574,14 +574,12 @@ impl From<DrmNode> for KmsNodes {
pub fn client_has_no_security_context(client: &Client) -> bool { pub fn client_has_no_security_context(client: &Client) -> bool {
client client
.get_data::<ClientState>() .get_data::<ClientState>().is_none_or(|client_state| client_state.security_context.is_none())
.map_or(true, |client_state| client_state.security_context.is_none())
} }
pub fn client_is_privileged(client: &Client) -> bool { pub fn client_is_privileged(client: &Client) -> bool {
client client
.get_data::<ClientState>() .get_data::<ClientState>().is_some_and(|client_state| client_state.privileged)
.map_or(false, |client_state| client_state.privileged)
} }
fn enable_wayland_security() -> bool { fn enable_wayland_security() -> bool {
@ -626,24 +624,24 @@ impl State {
let seat_state = SeatState::<Self>::new(); let seat_state = SeatState::<Self>::new();
let viewporter_state = ViewporterState::new::<Self>(dh); let viewporter_state = ViewporterState::new::<Self>(dh);
let wl_drm_state = WlDrmState::<Option<DrmNode>>::default(); let wl_drm_state = WlDrmState::<Option<DrmNode>>::default();
let kde_decoration_state = KdeDecorationState::new::<Self>(&dh, Mode::Client); let kde_decoration_state = KdeDecorationState::new::<Self>(dh, Mode::Client);
let xdg_decoration_state = XdgDecorationState::new::<Self>(&dh); let xdg_decoration_state = XdgDecorationState::new::<Self>(dh);
let session_lock_manager_state = let session_lock_manager_state =
SessionLockManagerState::new::<Self, _>(&dh, client_is_privileged); SessionLockManagerState::new::<Self, _>(dh, client_is_privileged);
XWaylandKeyboardGrabState::new::<Self>(&dh); XWaylandKeyboardGrabState::new::<Self>(dh);
let xwayland_shell_state = XWaylandShellState::new::<Self>(&dh); let xwayland_shell_state = XWaylandShellState::new::<Self>(dh);
PointerConstraintsState::new::<Self>(&dh); PointerConstraintsState::new::<Self>(dh);
PointerGesturesState::new::<Self>(&dh); PointerGesturesState::new::<Self>(dh);
TabletManagerState::new::<Self>(&dh); TabletManagerState::new::<Self>(dh);
SecurityContextState::new::<Self, _>(&dh, client_has_no_security_context); SecurityContextState::new::<Self, _>(dh, client_has_no_security_context);
InputMethodManagerState::new::<Self, _>(&dh, client_is_privileged); InputMethodManagerState::new::<Self, _>(dh, client_is_privileged);
TextInputManagerState::new::<Self>(&dh); TextInputManagerState::new::<Self>(dh);
VirtualKeyboardManagerState::new::<State, _>(&dh, client_is_privileged); VirtualKeyboardManagerState::new::<State, _>(dh, client_is_privileged);
AlphaModifierState::new::<Self>(&dh); AlphaModifierState::new::<Self>(dh);
SinglePixelBufferState::new::<Self>(&dh); SinglePixelBufferState::new::<Self>(dh);
let idle_notifier_state = IdleNotifierState::<Self>::new(&dh, handle.clone()); let idle_notifier_state = IdleNotifierState::<Self>::new(dh, handle.clone());
let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(&dh); let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(dh);
let idle_inhibiting_surfaces = HashSet::new(); let idle_inhibiting_surfaces = HashSet::new();
let data_control_state = crate::utils::env::bool_var("COSMIC_DATA_CONTROL_ENABLED") let data_control_state = crate::utils::env::bool_var("COSMIC_DATA_CONTROL_ENABLED")
@ -839,30 +837,28 @@ impl State {
} }
} }
} }
} else { } else if let Some(_fd) = self.common.inhibit_lid_fd.take() {
if let Some(_fd) = self.common.inhibit_lid_fd.take() { debug!("Removing inhibitor-lock on lid switch");
debug!("Removing inhibitor-lock on lid switch");
let backend = self.backend.lock(); let backend = self.backend.lock();
let output = backend let output = backend
.all_outputs() .all_outputs()
.iter() .iter()
.find(|o| o.is_internal()) .find(|o| o.is_internal())
.cloned(); .cloned();
backend.enable_internal_output(&mut self.common.output_configuration_state); backend.enable_internal_output(&mut self.common.output_configuration_state);
std::mem::drop(backend); std::mem::drop(backend);
if let Err(err) = self.refresh_output_config() { if let Err(err) = self.refresh_output_config() {
warn!(?err, "Failed to re-enable internal connector"); warn!(?err, "Failed to re-enable internal connector");
if let Some(output) = output { if let Some(output) = output {
output.config_mut().enabled = OutputState::Disabled; output.config_mut().enabled = OutputState::Disabled;
if let Err(err) = self.refresh_output_config() { if let Err(err) = self.refresh_output_config() {
error!("Unrecoverable output configuration error: {}", err); error!("Unrecoverable output configuration error: {}", err);
}
} }
} }
// drop _fd
} }
// drop _fd
} }
} }
} }
@ -992,10 +988,10 @@ impl Common {
if let Some(lock_surface) = session_lock.surfaces.get(output) { if let Some(lock_surface) = session_lock.surfaces.get(output) {
if let Some(feedback) = if let Some(feedback) =
advertised_node_for_surface(lock_surface.wl_surface(), &self.display_handle) advertised_node_for_surface(lock_surface.wl_surface(), &self.display_handle)
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
send_dmabuf_feedback_surface_tree( send_dmabuf_feedback_surface_tree(
&lock_surface.wl_surface(), lock_surface.wl_surface(),
output, output,
surface_primary_scanout_output, surface_primary_scanout_output,
|surface, _| { |surface, _| {
@ -1021,7 +1017,7 @@ impl Common {
if let CursorImageStatus::Surface(wl_surface) = cursor_status { if let CursorImageStatus::Surface(wl_surface) = cursor_status {
if let Some(feedback) = if let Some(feedback) =
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
send_dmabuf_feedback_surface_tree( send_dmabuf_feedback_surface_tree(
&wl_surface, &wl_surface,
@ -1042,7 +1038,7 @@ impl Common {
if let Some(icon) = get_dnd_icon(seat) { if let Some(icon) = get_dnd_icon(seat) {
if let Some(feedback) = if let Some(feedback) =
advertised_node_for_surface(&icon.surface, &self.display_handle) advertised_node_for_surface(&icon.surface, &self.display_handle)
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
send_dmabuf_feedback_surface_tree( send_dmabuf_feedback_surface_tree(
&icon.surface, &icon.surface,
@ -1068,7 +1064,7 @@ impl Common {
.and_then(|wl_surface| { .and_then(|wl_surface| {
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
}) })
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
window.send_dmabuf_feedback( window.send_dmabuf_feedback(
output, output,
@ -1096,7 +1092,7 @@ impl Common {
.and_then(|wl_surface| { .and_then(|wl_surface| {
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
}) })
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
window.send_dmabuf_feedback( window.send_dmabuf_feedback(
output, output,
@ -1115,7 +1111,7 @@ impl Common {
.and_then(|wl_surface| { .and_then(|wl_surface| {
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
}) })
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
window.send_dmabuf_feedback( window.send_dmabuf_feedback(
output, output,
@ -1132,7 +1128,7 @@ impl Common {
.and_then(|wl_surface| { .and_then(|wl_surface| {
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
}) })
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
window.send_dmabuf_feedback( window.send_dmabuf_feedback(
output, output,
@ -1149,7 +1145,7 @@ impl Common {
if let Some(wl_surface) = or.wl_surface() { if let Some(wl_surface) = or.wl_surface() {
if let Some(feedback) = if let Some(feedback) =
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
send_dmabuf_feedback_surface_tree( send_dmabuf_feedback_surface_tree(
&wl_surface, &wl_surface,
@ -1172,7 +1168,7 @@ impl Common {
for layer_surface in map.layers() { for layer_surface in map.layers() {
if let Some(feedback) = if let Some(feedback) =
advertised_node_for_surface(layer_surface.wl_surface(), &self.display_handle) advertised_node_for_surface(layer_surface.wl_surface(), &self.display_handle)
.and_then(|source| dmabuf_feedback(source)) .and_then(&mut dmabuf_feedback)
{ {
layer_surface.send_dmabuf_feedback( layer_surface.send_dmabuf_feedback(
output, output,

View file

@ -12,11 +12,11 @@ pub fn ready(common: &Common) {
.env("WAYLAND_DISPLAY", &common.socket) .env("WAYLAND_DISPLAY", &common.socket)
.env( .env(
"DISPLAY", "DISPLAY",
&common common
.xwayland_state .xwayland_state
.as_ref() .as_ref()
.map(|s| format!(":{}", s.display)) .map(|s| format!(":{}", s.display))
.unwrap_or(String::new()), .unwrap_or_default(),
) )
.status() .status()
{ {

View file

@ -106,8 +106,7 @@ fn try_parse_dev_from_str(val: &str) -> Option<DeviceIdentifier> {
let node = node let node = node
.node_with_type(NodeType::Render) .node_with_type(NodeType::Render)
.map(|res| res.ok()) .and_then(|res| res.ok())
.flatten()
.unwrap_or(node); .unwrap_or(node);
Some(DeviceIdentifier::Node(node)) Some(DeviceIdentifier::Node(node))
} else if val.contains(':') { } else if val.contains(':') {
@ -140,8 +139,7 @@ fn try_parse_dev_from_str(val: &str) -> Option<DeviceIdentifier> {
let node = node let node = node
.node_with_type(NodeType::Render) .node_with_type(NodeType::Render)
.map(|res| res.ok()) .and_then(|res| res.ok())
.flatten()
.unwrap_or(node); .unwrap_or(node);
Some(DeviceIdentifier::Node(node)) Some(DeviceIdentifier::Node(node))
} else { } else {
@ -159,8 +157,7 @@ fn try_parse_dev_from_str(val: &str) -> Option<DeviceIdentifier> {
let node = node let node = node
.node_with_type(NodeType::Render) .node_with_type(NodeType::Render)
.map(|res| res.ok()) .and_then(|res| res.ok())
.flatten()
.unwrap_or(node); .unwrap_or(node);
Some(DeviceIdentifier::Node(node)) Some(DeviceIdentifier::Node(node))
} }

View file

@ -206,10 +206,10 @@ impl<P: Program + Send + Clone + 'static> Clone for IcedElementInternal<P> {
additional_scale: self.additional_scale, additional_scale: self.additional_scale,
outputs: self.outputs.clone(), outputs: self.outputs.clone(),
buffers: self.buffers.clone(), buffers: self.buffers.clone(),
pending_realloc: self.pending_realloc.clone(), pending_realloc: self.pending_realloc,
size: self.size.clone(), size: self.size,
last_seat: self.last_seat.clone(), last_seat: self.last_seat.clone(),
cursor_pos: self.cursor_pos.clone(), cursor_pos: self.cursor_pos,
touch_map: self.touch_map.clone(), touch_map: self.touch_map.clone(),
theme: self.theme.clone(), theme: self.theme.clone(),
renderer, renderer,
@ -632,7 +632,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
internal.touch_map.insert(id, position); internal.touch_map.insert(id, position);
internal.cursor_pos = Some(event_location); internal.cursor_pos = Some(event_location);
*internal.last_seat.lock().unwrap() = Some((seat.clone(), seq)); *internal.last_seat.lock().unwrap() = Some((seat.clone(), seq));
let _ = internal.update(false); internal.update(false);
} }
fn up( fn up(
@ -649,7 +649,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
internal internal
.state .state
.queue_event(Event::Touch(TouchEvent::FingerLifted { id, position })); .queue_event(Event::Touch(TouchEvent::FingerLifted { id, position }));
let _ = internal.update(false); internal.update(false);
} }
} }
@ -670,7 +670,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
.queue_event(Event::Touch(TouchEvent::FingerMoved { id, position })); .queue_event(Event::Touch(TouchEvent::FingerMoved { id, position }));
internal.touch_map.insert(id, position); internal.touch_map.insert(id, position);
internal.cursor_pos = Some(event_location); internal.cursor_pos = Some(event_location);
let _ = internal.update(false); internal.update(false);
} }
fn frame( fn frame(
@ -693,7 +693,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
.state .state
.queue_event(Event::Touch(TouchEvent::FingerLost { id, position })); .queue_event(Event::Touch(TouchEvent::FingerLost { id, position }));
} }
let _ = internal.update(false); internal.update(false);
} }
fn shape( fn shape(
@ -771,7 +771,7 @@ impl<P: Program + Send + 'static> KeyboardTarget<crate::state::State> for IcedEl
internal internal
.state .state
.queue_event(Event::Keyboard(KeyboardEvent::ModifiersChanged(mods))); .queue_event(Event::Keyboard(KeyboardEvent::ModifiersChanged(mods)));
let _ = internal.update(false); internal.update(false);
} }
} }
@ -804,7 +804,7 @@ impl<P: Program + Send + 'static> SpaceElement for IcedElement<P> {
} else { } else {
WindowEvent::Unfocused WindowEvent::Unfocused
})); }));
let _ = internal.update(false); internal.update(false);
} }
fn output_enter(&self, output: &Output, _overlap: Rectangle<i32, Logical>) { fn output_enter(&self, output: &Output, _overlap: Rectangle<i32, Logical>) {
@ -940,7 +940,7 @@ where
.and_then(|(last_primitives, last_color)| { .and_then(|(last_primitives, last_color)| {
(last_color == &background_color).then(|| { (last_color == &background_color).then(|| {
damage::diff( damage::diff(
&last_primitives, last_primitives,
current_layers, current_layers,
|_| { |_| {
vec![cosmic::iced::Rectangle::new( vec![cosmic::iced::Rectangle::new(
@ -1012,7 +1012,7 @@ where
match MemoryRenderBufferRenderElement::from_buffer( match MemoryRenderBufferRenderElement::from_buffer(
renderer, renderer,
location.to_f64(), location.to_f64(),
&buffer, buffer,
Some(alpha), Some(alpha),
Some(Rectangle::from_size( Some(Rectangle::from_size(
size.to_f64() size.to_f64()

View file

@ -2,7 +2,7 @@ use cosmic_comp_config::output::comp::{AdaptiveSync, OutputConfig, OutputState};
use smithay::{ use smithay::{
backend::drm::VrrSupport as Support, backend::drm::VrrSupport as Support,
output::{Output, WeakOutput}, output::{Output, WeakOutput},
utils::{Rectangle, Transform}, utils::Rectangle,
}; };
pub use super::geometry::*; pub use super::geometry::*;
@ -50,7 +50,7 @@ impl OutputExt for Output {
fn geometry(&self) -> Rectangle<i32, Global> { fn geometry(&self) -> Rectangle<i32, Global> {
Rectangle::new(self.current_location(), { Rectangle::new(self.current_location(), {
Transform::from(self.current_transform()) self.current_transform()
.transform_size( .transform_size(
self.current_mode() self.current_mode()
.map(|m| m.size) .map(|m| m.size)
@ -104,13 +104,12 @@ impl OutputExt for Output {
fn adaptive_sync_support(&self) -> Option<Support> { fn adaptive_sync_support(&self) -> Option<Support> {
self.user_data() self.user_data()
.get::<VrrSupport>() .get::<VrrSupport>()
.map(|vrr| match vrr.0.load(Ordering::SeqCst) { .and_then(|vrr| match vrr.0.load(Ordering::SeqCst) {
0 => None, 0 => None,
2 => Some(Support::RequiresModeset), 2 => Some(Support::RequiresModeset),
3 => Some(Support::Supported), 3 => Some(Support::Supported),
_ => Some(Support::NotSupported), _ => Some(Support::NotSupported),
}) })
.flatten()
} }
fn set_adaptive_sync_support(&self, vrr: Option<Support>) { fn set_adaptive_sync_support(&self, vrr: Option<Support>) {

View file

@ -79,7 +79,7 @@ pub fn screenshot_window(state: &mut State, surface: &CosmicSurface) {
)); ));
let file = std::fs::File::create(path.join(name))?; let file = std::fs::File::create(path.join(name))?;
let ref mut writer = std::io::BufWriter::new(file); let writer = &mut std::io::BufWriter::new(file);
let mut encoder = png::Encoder::new(writer, bbox.size.w as u32, bbox.size.h as u32); let mut encoder = png::Encoder::new(writer, bbox.size.w as u32, bbox.size.h as u32);
encoder.set_color(png::ColorType::Rgba); encoder.set_color(png::ColorType::Rgba);
encoder.set_depth(png::BitDepth::Eight); encoder.set_depth(png::BitDepth::Eight);
@ -93,7 +93,7 @@ pub fn screenshot_window(state: &mut State, surface: &CosmicSurface) {
); );
encoder.set_source_chromaticities(source_chromaticities); encoder.set_source_chromaticities(source_chromaticities);
let mut writer = encoder.write_header()?; let mut writer = encoder.write_header()?;
writer.write_image_data(&gl_data)?; writer.write_image_data(gl_data)?;
} }
Ok(()) Ok(())

View file

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

View file

@ -11,16 +11,13 @@ impl BufferHandler for State {
fn buffer_destroyed(&mut self, buffer: &WlBuffer) { fn buffer_destroyed(&mut self, buffer: &WlBuffer) {
if let BackendData::Kms(kms_state) = &mut self.backend { if let BackendData::Kms(kms_state) = &mut self.backend {
for device in kms_state.drm_devices.values_mut() { for device in kms_state.drm_devices.values_mut() {
if device.inner.active_buffers.remove(&buffer.downgrade()) { if device.inner.active_buffers.remove(&buffer.downgrade()) && !device
if !device
.inner .inner
.in_use(kms_state.primary_node.read().unwrap().as_ref()) .in_use(kms_state.primary_node.read().unwrap().as_ref()) {
{ if let Err(err) = kms_state.refresh_used_devices() {
if let Err(err) = kms_state.refresh_used_devices() { warn!(?err, "Failed to init devices.");
warn!(?err, "Failed to init devices."); };
}; break;
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 let Some(ref last) = data.last_commit {
// if the time since the last commit is already higher than our estimation, // 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" // 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)) Some(diff.max(data.estimation))
} else { } else {
Some(data.estimation) Some(data.estimation)
@ -275,7 +275,7 @@ impl CompositorHandler for State {
// schedule a new render // schedule a new render
if let Some(output) = shell.visible_output_for_surface(surface) { if let Some(output) = shell.visible_output_for_surface(surface) {
self.backend.schedule_render(&output); self.backend.schedule_render(output);
} }
if mapped { if mapped {
@ -349,7 +349,7 @@ impl CompositorHandler for State {
if let Some(element) = shell.element_for_surface(surface).cloned() { if let Some(element) = shell.element_for_surface(surface).cloned() {
crate::shell::layout::floating::ResizeSurfaceGrab::apply_resize_to_location( crate::shell::layout::floating::ResizeSurfaceGrab::apply_resize_to_location(
element.clone(), element.clone(),
&mut *shell, &mut shell,
); );
} }
} }
@ -392,8 +392,8 @@ impl State {
} else { } else {
None None
}; };
if toplevel_ensure_initial_configure(&toplevel, initial_size) if toplevel_ensure_initial_configure(toplevel, initial_size)
&& with_renderer_surface_state(&surface, |state| state.buffer().is_some()) && with_renderer_surface_state(surface, |state| state.buffer().is_some())
.unwrap_or(false) .unwrap_or(false)
{ {
let window = pending.surface.clone(); let window = pending.surface.clone();

View file

@ -68,7 +68,7 @@ impl ClientDndGrabHandler for State {
seat: Seat<Self>, seat: Seat<Self>,
) { ) {
let user_data = seat.user_data(); 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() { let offset = if let CursorImageStatus::Surface(ref surface) = seat.cursor_image_status() {
compositor::with_states(surface, |states| { compositor::with_states(surface, |states| {

View file

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

View file

@ -46,7 +46,7 @@ fn kms_surfaces_for_output<'a>(
output: &'a Output, output: &'a Output,
) -> impl Iterator<Item = &'a mut Surface> + 'a { ) -> impl Iterator<Item = &'a mut Surface> + 'a {
kms_surfaces(state).filter(move |surface| { 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>) { fn new_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle<Self>) {
// XXX region // XXX region
if pointer if pointer
.current_focus() .current_focus().is_some_and(|x| x.wl_surface().as_deref() == Some(surface))
.map_or(false, |x| x.wl_surface().as_deref() == Some(surface))
{ {
with_pointer_constraint(surface, pointer, |constraint| { with_pointer_constraint(surface, pointer, |constraint| {
constraint.unwrap().activate(); constraint.unwrap().activate();

View file

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

View file

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

View file

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

View file

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

View file

@ -126,7 +126,7 @@ impl XdgActivationHandler for State {
let Some((element_output, element_workspace)) = shell let Some((element_output, element_workspace)) = shell
.space_for(&element) .space_for(&element)
.map(|w| (w.output.clone(), w.handle.clone())) .map(|w| (w.output.clone(), w.handle))
else { else {
return; return;
}; };
@ -227,7 +227,7 @@ impl XdgActivationHandler for State {
} else { } else {
shell shell
.pending_activations .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 { if let Some(root) = maybe_root {
let target = root.into(); let target = root;
let ret = self.common.popups.grab_popup(target, kind, &seat, serial); let ret = self.common.popups.grab_popup(target, kind, &seat, serial);
match ret { match ret {
Ok(mut grab) => { Ok(mut grab) => {
@ -304,12 +304,10 @@ impl XdgShellHandler for State {
if should_focus { if should_focus {
Shell::set_focus(self, Some(&target), &seat, None, true); Shell::set_focus(self, Some(&target), &seat, None, true);
} }
} else { } else if let Some(pending) = shell.pending_windows.iter_mut().find(|pending| {
if let Some(pending) = shell.pending_windows.iter_mut().find(|pending| { pending.surface.wl_surface().as_deref() == Some(surface.wl_surface())
pending.surface.wl_surface().as_deref() == Some(surface.wl_surface()) }) {
}) { pending.fullscreen.take();
pending.fullscreen.take();
}
} }
} }
@ -337,12 +335,12 @@ impl XdgShellHandler for State {
{ {
let dh = self.common.display_handle.clone(); let dh = self.common.display_handle.clone();
for client in clients.values() { 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() { 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 { impl Shell {
pub fn unconstrain_popup(&self, surface: &PopupSurface) { 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) { if let Some(elem) = self.element_for_surface(&parent) {
let (mut element_geo, output, is_tiled) = let (mut element_geo, output, is_tiled) =
if let Some(workspace) = self.space_for(elem) { 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()) { for (popup, _) in PopupManager::popups_for_surface(toplevel.wl_surface()) {
match popup { match popup {
PopupKind::Xdg(surface) => { PopupKind::Xdg(surface) => {
let positioner = with_states(&surface.wl_surface(), |states| { let positioner = with_states(surface.wl_surface(), |states| {
let attributes = states let attributes = states
.data_map .data_map
.get::<XdgPopupSurfaceData>() .get::<XdgPopupSurfaceData>()
.unwrap() .unwrap()
.lock() .lock()
.unwrap(); .unwrap();
attributes.current.positioner.clone() attributes.current.positioner
}); });
if positioner.reactive { if positioner.reactive {
let anchor_point = loc + positioner.get_anchor_point().as_global(); let anchor_point = loc + positioner.get_anchor_point().as_global();

View file

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

View file

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

View file

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

View file

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

View file

@ -136,13 +136,10 @@ where
_dh: &DisplayHandle, _dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>, _data_init: &mut DataInit<'_, D>,
) { ) {
match request { if let zwlr_output_head_v1::Request::Release = request {
zwlr_output_head_v1::Request::Release => { for instance in &mut state.output_configuration_state().instances {
for instance in &mut state.output_configuration_state().instances { instance.heads.retain(|h| &h.obj != obj);
instance.heads.retain(|h| &h.obj != obj);
}
} }
_ => {}
} }
} }
@ -173,16 +170,13 @@ where
_dh: &DisplayHandle, _dh: &DisplayHandle,
_data_init: &mut DataInit<'_, D>, _data_init: &mut DataInit<'_, D>,
) { ) {
match request { if let zwlr_output_mode_v1::Request::Release = request {
zwlr_output_mode_v1::Request::Release => { let state = state.output_configuration_state();
let state = state.output_configuration_state(); for instance in &mut state.instances {
for instance in &mut state.instances { for head in &mut instance.heads {
for head in &mut instance.heads { head.modes.retain(|mode| mode != obj)
head.modes.retain(|mode| mode != obj)
}
} }
} }
_ => {}
} }
} }
} }
@ -281,13 +275,11 @@ where
.heads .heads
.iter_mut() .iter_mut()
.map(|(head, conf)| { .map(|(head, conf)| {
let output = match { let output = match inner
inner .instances
.instances .iter()
.iter() .find_map(|instance| instance.heads.iter().find(|h| h.obj == *head))
.find_map(|instance| instance.heads.iter().find(|h| h.obj == *head)) .map(|i| i.output.clone()) {
.map(|i| i.output.clone())
} {
Some(o) => o, Some(o) => o,
None => { None => {
return Err(zwlr_output_configuration_head_v1::Error::InvalidMode); 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 { pub fn head_is_enabled(output: &Output) -> bool {
output output
.user_data() .user_data()
.get::<OutputState>() .get::<OutputState>().is_some_and(|inner| inner.lock().unwrap().enabled)
.map_or(false, |inner| inner.lock().unwrap().enabled)
} }
#[derive(Debug)] #[derive(Debug)]
@ -135,7 +134,7 @@ impl<'a> TryFrom<&'a mut PendingOutputConfigurationInner> for OutputConfiguratio
wlr_mode wlr_mode
.data::<Mode>() .data::<Mode>()
.cloned() .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 }) => {
Some(ModeConfiguration::Custom { size, refresh }) Some(ModeConfiguration::Custom { size, refresh })
@ -283,7 +282,7 @@ where
for instance in &mut self.instances { for instance in &mut self.instances {
let mut removed_heads = Vec::new(); let mut removed_heads = Vec::new();
for head in &mut instance.heads { 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 { if head.obj.version() < zwlr_output_head_v1::REQ_RELEASE_SINCE {
removed_heads.push(head.obj.clone()); removed_heads.push(head.obj.clone());
} }
@ -435,7 +434,7 @@ where
.map(|c| c == output_mode) .map(|c| c == output_mode)
.unwrap_or(false) .unwrap_or(false)
{ {
instance.obj.current_mode(&*mode); instance.obj.current_mode(mode);
} }
} }
} }

View file

@ -120,7 +120,7 @@ impl OverlapNotifyState {
w.is_sticky() w.is_sticky()
|| active_workspaces.iter().any(|active_workspace| { || 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 for (identifier, namespace, exclusive, layer, overlap) in
&self.last_snapshot.layer_overlaps self.last_snapshot.layer_overlaps.values()
{ {
new_notification.layer_enter( new_notification.layer_enter(
identifier.clone(), identifier.clone(),
@ -414,22 +414,19 @@ where
_dhandle: &DisplayHandle, _dhandle: &DisplayHandle,
data_init: &mut smithay::reexports::wayland_server::DataInit<'_, D>, data_init: &mut smithay::reexports::wayland_server::DataInit<'_, D>,
) { ) {
match request { if let zcosmic_overlap_notify_v1::Request::NotifyOnOverlap {
zcosmic_overlap_notify_v1::Request::NotifyOnOverlap {
overlap_notification, overlap_notification,
layer_surface, layer_surface,
} => { } = request {
let notification = data_init.init(overlap_notification, ()); let notification = data_init.init(overlap_notification, ());
if let Some(surface) = state.layer_surface_from_resource(layer_surface) { if let Some(surface) = state.layer_surface_from_resource(layer_surface) {
let mut data = surface let mut data = surface
.user_data() .user_data()
.get_or_insert_threadsafe(LayerOverlapNotificationData::default) .get_or_insert_threadsafe(LayerOverlapNotificationData::default)
.lock() .lock()
.unwrap(); .unwrap();
data.add_notification(notification); data.add_notification(notification);
}
} }
_ => {}
} }
} }
@ -461,9 +458,7 @@ where
_dhandle: &DisplayHandle, _dhandle: &DisplayHandle,
_data_init: &mut smithay::reexports::wayland_server::DataInit<'_, D>, _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 { pub fn user_data(&self) -> &UserDataMap {
&*self.user_data &self.user_data
} }
} }
@ -346,7 +346,7 @@ impl CursorSessionRef {
} }
pub fn user_data(&self) -> &UserDataMap { pub fn user_data(&self) -> &UserDataMap {
&*self.user_data &self.user_data
} }
} }
@ -746,25 +746,22 @@ where
_dhandle: &DisplayHandle, _dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>, data_init: &mut DataInit<'_, D>,
) { ) {
match request { if let ext_image_copy_capture_session_v1::Request::CreateFrame { frame } = request {
ext_image_copy_capture_session_v1::Request::CreateFrame { frame } => { let inner = Arc::new(Mutex::new(FrameInner::new(
let inner = Arc::new(Mutex::new(FrameInner::new( resource.clone(),
resource.clone(), data.inner.lock().unwrap().constraints.clone(),
data.inner.lock().unwrap().constraints.clone(), )));
))); let obj = data_init.init(
let obj = data_init.init( frame,
frame, FrameData {
FrameData { inner: inner.clone(),
inner: inner.clone(), },
}, );
); data.inner
data.inner .lock()
.lock() .unwrap()
.unwrap() .active_frames
.active_frames .push(FrameRef { obj, inner });
.push(FrameRef { obj, inner });
}
_ => {}
} }
} }
@ -803,45 +800,42 @@ where
_dhandle: &DisplayHandle, _dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>, data_init: &mut DataInit<'_, D>,
) { ) {
match request { if let ext_image_copy_capture_cursor_session_v1::Request::GetCaptureSession { session } = request {
ext_image_copy_capture_cursor_session_v1::Request::GetCaptureSession { session } => { let new_data = CursorSessionData {
let new_data = CursorSessionData { inner: data.inner.clone(),
inner: data.inner.clone(), };
}; let session = data_init.init(session, new_data);
let session = data_init.init(session, new_data);
let mut inner = data.inner.lock().unwrap(); let mut inner = data.inner.lock().unwrap();
if inner.session.is_some() { if inner.session.is_some() {
resource.post_error( resource.post_error(
ext_image_copy_capture_cursor_session_v1::Error::DuplicateSession, ext_image_copy_capture_cursor_session_v1::Error::DuplicateSession,
"Duplicate session", "Duplicate session",
); );
return; 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);
} }
_ => {}
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, _dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>, data_init: &mut DataInit<'_, D>,
) { ) {
match request { if let ext_image_copy_capture_session_v1::Request::CreateFrame { frame } = request {
ext_image_copy_capture_session_v1::Request::CreateFrame { frame } => { let inner = Arc::new(Mutex::new(FrameInner::new(
let inner = Arc::new(Mutex::new(FrameInner::new( resource.clone(),
resource.clone(), data.inner.lock().unwrap().constraints.clone(),
data.inner.lock().unwrap().constraints.clone(), )));
))); let obj = data_init.init(
let obj = data_init.init( frame,
frame, FrameData {
FrameData { inner: inner.clone(),
inner: inner.clone(), },
}, );
); data.inner
data.inner .lock()
.lock() .unwrap()
.unwrap() .active_frames
.active_frames .push(FrameRef { obj, inner });
.push(FrameRef { obj, inner });
}
_ => {}
} }
} }

View file

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

View file

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

View file

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

View file

@ -143,7 +143,6 @@ impl State {
Err(err) => { Err(err) => {
error!(?err, "Failed to listen for Xwayland"); error!(?err, "Failed to listen for Xwayland");
self.notify_ready(); self.notify_ready();
return;
} }
} }
} }
@ -188,7 +187,7 @@ fn scale_cursor(
&[Rectangle::new((0, 0).into(), output_size)], &[Rectangle::new((0, 0).into(), output_size)],
)?; )?;
let sync = frame.finish()?; let sync = frame.finish()?;
while let Err(_) = sync.wait() {} while sync.wait().is_err() {}
let len = (buffer_size.w * buffer_size.h * 4) as usize; let len = (buffer_size.w * buffer_size.h * 4) as usize;
let mut data = Vec::with_capacity(len); let mut data = Vec::with_capacity(len);
@ -750,7 +749,7 @@ impl XwmHandler for State {
{ {
shell.pending_activations.insert( shell.pending_activations.insert(
crate::shell::ActivationKey::X11(window.window_id()), crate::shell::ActivationKey::X11(window.window_id()),
context.clone(), *context,
); );
} }
@ -771,10 +770,8 @@ impl XwmHandler for State {
.find(|pending| pending.surface.x11_surface() == Some(&surface)) .find(|pending| pending.surface.x11_surface() == Some(&surface))
.map(|pending| pending.surface.clone()) .map(|pending| pending.surface.clone())
{ {
if !shell if let std::collections::hash_map::Entry::Vacant(e) = shell
.pending_activations .pending_activations.entry(crate::shell::ActivationKey::X11(surface.window_id())) {
.contains_key(&crate::shell::ActivationKey::X11(surface.window_id()))
{
if let Some(startup_id) = window.x11_surface().and_then(|x| x.startup_id()) { if let Some(startup_id) = window.x11_surface().and_then(|x| x.startup_id()) {
if let Some(context) = self if let Some(context) = self
.common .common
@ -782,10 +779,7 @@ impl XwmHandler for State {
.data_for_token(&XdgActivationToken::from(startup_id)) .data_for_token(&XdgActivationToken::from(startup_id))
.and_then(|data| data.user_data.get::<ActivationContext>()) .and_then(|data| data.user_data.get::<ActivationContext>())
{ {
shell.pending_activations.insert( e.insert(*context);
crate::shell::ActivationKey::X11(surface.window_id()),
context.clone(),
);
} }
} }
} }
@ -875,7 +869,7 @@ impl XwmHandler for State {
set.sticky_layer set.sticky_layer
.element_geometry(mapped) .element_geometry(mapped)
.unwrap() .unwrap()
.to_global(&output), .to_global(output),
) )
} else { } else {
None None
@ -1100,14 +1094,12 @@ impl XwmHandler for State {
if should_focus { if should_focus {
Shell::set_focus(self, Some(&target), &seat, None, true); Shell::set_focus(self, Some(&target), &seat, None, true);
} }
} else { } else if let Some(pending) = shell
if let Some(pending) = shell .pending_windows
.pending_windows .iter_mut()
.iter_mut() .find(|pending| pending.surface.x11_surface() == Some(&window))
.find(|pending| pending.surface.x11_surface() == Some(&window)) {
{ pending.fullscreen.take();
pending.fullscreen.take();
}
} }
} }