chore: clippy
This commit is contained in:
parent
c13e52da04
commit
2ca99c670a
59 changed files with 1974 additions and 2137 deletions
|
|
@ -602,10 +602,10 @@ impl CosmicStack {
|
|||
let previous = p.previous_keyboard.swap(active, Ordering::SeqCst);
|
||||
if previous != active || p.reenter.swap(false, Ordering::SeqCst) {
|
||||
let windows = p.windows.lock().unwrap();
|
||||
if let Some(previous_surface) = windows.get(previous) {
|
||||
if previous != active {
|
||||
KeyboardTarget::leave(previous_surface, seat, data, serial);
|
||||
}
|
||||
if let Some(previous_surface) = windows.get(previous)
|
||||
&& previous != active
|
||||
{
|
||||
KeyboardTarget::leave(previous_surface, seat, data, serial);
|
||||
}
|
||||
KeyboardTarget::enter(
|
||||
&windows[active],
|
||||
|
|
@ -685,15 +685,15 @@ impl CosmicStack {
|
|||
if tiled && !appearance.shadow_tiled_windows {
|
||||
return None;
|
||||
}
|
||||
let radii = round
|
||||
.then(|| {
|
||||
theme
|
||||
.cosmic()
|
||||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x } else { x + 4.0 })
|
||||
.map(|x| (x * scale as f32).round() as u8)
|
||||
})
|
||||
.unwrap_or([0, 0, 0, 0]);
|
||||
let radii = if round {
|
||||
theme
|
||||
.cosmic()
|
||||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x } else { x + 4.0 })
|
||||
.map(|x| (x * scale as f32).round() as u8)
|
||||
} else {
|
||||
[0, 0, 0, 0]
|
||||
};
|
||||
|
||||
let mut geo = SpaceElement::geometry(&windows[active]).to_f64();
|
||||
geo.size.h += TAB_HEIGHT as f64;
|
||||
|
|
@ -857,37 +857,35 @@ impl CosmicStack {
|
|||
if let Some(dragged_out) = self
|
||||
.0
|
||||
.with_program(|p| p.potential_drag.lock().unwrap().take())
|
||||
{
|
||||
if let Some(surface) = self
|
||||
&& let Some(surface) = self
|
||||
.0
|
||||
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1152,47 +1150,46 @@ impl Program for CosmicStackInternal {
|
|||
}
|
||||
}
|
||||
Message::TabMenu(idx) => {
|
||||
if let Some((seat, serial)) = last_seat.cloned() {
|
||||
if let Some(surface) = self.windows.lock().unwrap()[idx]
|
||||
if let Some((seat, serial)) = last_seat.cloned()
|
||||
&& let Some(surface) = self.windows.lock().unwrap()[idx]
|
||||
.wl_surface()
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
let position = elem_geo.loc.to_global(&workspace.output);
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned()
|
||||
&& let Some(workspace) = shell.space_for(&mapped)
|
||||
{
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
let position = elem_geo.loc.to_global(&workspace.output);
|
||||
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
@ -1701,37 +1698,35 @@ impl PointerTarget<State> for CosmicStack {
|
|||
if let Some(dragged_out) = self
|
||||
.0
|
||||
.with_program(|p| p.potential_drag.lock().unwrap().take())
|
||||
{
|
||||
if let Some(surface) = self
|
||||
&& let Some(surface) = self
|
||||
.0
|
||||
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,22 +356,20 @@ where
|
|||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||
) {
|
||||
if let Some(message) = self.press_message.clone() {
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
) && let Some(message) = self.press_message.clone()
|
||||
{
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Right))
|
||||
) {
|
||||
if let Some(message) = self.right_click_message.clone() {
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
) && let Some(message) = self.right_click_message.clone()
|
||||
{
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
if matches!(
|
||||
event,
|
||||
|
|
@ -379,7 +377,6 @@ where
|
|||
) {
|
||||
shell.publish(Message::activate(self.idx));
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,10 +270,10 @@ impl State {
|
|||
pub fn cleanup_old_animations(&mut self) {
|
||||
let start_time = Instant::now();
|
||||
|
||||
if let Some(animation) = self.scroll_animation.as_ref() {
|
||||
if start_time.duration_since(animation.start_time) > SCROLL_ANIMATION_DURATION {
|
||||
self.scroll_animation.take();
|
||||
}
|
||||
if let Some(animation) = self.scroll_animation.as_ref()
|
||||
&& start_time.duration_since(animation.start_time) > SCROLL_ANIMATION_DURATION
|
||||
{
|
||||
self.scroll_animation.take();
|
||||
}
|
||||
|
||||
Self::discard_expired_tab_animations(&mut self.tab_animations, start_time);
|
||||
|
|
|
|||
|
|
@ -693,15 +693,13 @@ impl CosmicSurface {
|
|||
.primary_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else {
|
||||
if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else {
|
||||
&feedback.render_feedback
|
||||
}
|
||||
&feedback.render_feedback
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -983,6 +981,6 @@ fn with_toplevel_state<T, F: FnOnce(Option<&smithay::wayland::shell::xdg::Toplev
|
|||
if pending {
|
||||
toplevel.with_pending_state(|pending| cb(Some(pending)))
|
||||
} else {
|
||||
toplevel.with_committed_state(|committed| cb(committed))
|
||||
toplevel.with_committed_state(cb)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -576,10 +576,8 @@ impl CosmicWindow {
|
|||
*conf = *appearance;
|
||||
if appearance.clip_floating_windows {
|
||||
p.window.set_tiled(true);
|
||||
} else {
|
||||
if !p.tiled.load(Ordering::Acquire) {
|
||||
p.window.set_tiled(false);
|
||||
}
|
||||
} else if !p.tiled.load(Ordering::Acquire) {
|
||||
p.window.set_tiled(false);
|
||||
}
|
||||
p.window.send_configure();
|
||||
}
|
||||
|
|
@ -633,8 +631,8 @@ impl CosmicWindow {
|
|||
&& !p.window.is_maximized(false);
|
||||
let round =
|
||||
(!is_tiled || appearance.clip_tiled_windows) && !p.window.is_maximized(false);
|
||||
let radii = round
|
||||
.then(|| {
|
||||
let radii = if round {
|
||||
{
|
||||
p.theme
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
|
@ -642,8 +640,10 @@ impl CosmicWindow {
|
|||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x } else { x + 4.0 })
|
||||
.map(|x| x.round() as u8)
|
||||
})
|
||||
.unwrap_or([0; 4]);
|
||||
}
|
||||
} else {
|
||||
[0; 4]
|
||||
};
|
||||
|
||||
match (has_ssd, clip) {
|
||||
(has_ssd, true) => {
|
||||
|
|
@ -698,30 +698,30 @@ impl Program for CosmicWindowInternal {
|
|||
) -> Task<Self::Message> {
|
||||
match message {
|
||||
Message::DragStart => {
|
||||
if let Some((seat, serial)) = last_seat.cloned() {
|
||||
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
if let Some((seat, serial)) = last_seat.cloned()
|
||||
&& let Some(surface) = self.window.wl_surface().map(Cow::into_owned)
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Message::Minimize => {
|
||||
|
|
@ -745,51 +745,51 @@ impl Program for CosmicWindowInternal {
|
|||
}
|
||||
Message::Close => self.window.close(),
|
||||
Message::Menu => {
|
||||
if let Some((seat, serial)) = last_seat.cloned() {
|
||||
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let position = if let Some((output, set)) =
|
||||
shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
set.sticky_layer.mapped().any(|m| m == &mapped)
|
||||
}) {
|
||||
set.sticky_layer
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(output)
|
||||
} else if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
elem_geo.loc.to_global(&workspace.output)
|
||||
} else {
|
||||
if let Some((seat, serial)) = last_seat.cloned()
|
||||
&& let Some(surface) = self.window.wl_surface().map(Cow::into_owned)
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let position = if let Some((output, set)) =
|
||||
shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
set.sticky_layer.mapped().any(|m| m == &mapped)
|
||||
}) {
|
||||
set.sticky_layer
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(output)
|
||||
} else if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
elem_geo.loc.to_global(&workspace.output)
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let mut cursor = pointer.current_location().to_i32_round();
|
||||
cursor.y -= SSD_HEIGHT;
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let mut cursor = pointer.current_location().to_i32_round();
|
||||
cursor.y -= SSD_HEIGHT;
|
||||
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue