chore: clippy

This commit is contained in:
Vukašin Vojinović 2026-02-23 16:25:06 +01:00 • committed by Victoria Brekenfeld
parent c13e52da04
commit 2ca99c670a
59 changed files with 1974 additions and 2137 deletions

View file

@ -49,8 +49,9 @@ pub struct ScrollConfig {
pub scroll_factor: Option<f64>, pub scroll_factor: Option<f64>,
} }
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub enum DeviceState { pub enum DeviceState {
#[default]
Enabled, Enabled,
Disabled, Disabled,
DisabledOnExternalMouse, DisabledOnExternalMouse,
@ -63,12 +64,6 @@ pub enum TouchpadOverride {
ForceDisable, ForceDisable,
} }
impl Default for DeviceState {
fn default() -> Self {
Self::Enabled
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TapConfig { pub struct TapConfig {
pub enabled: bool, pub enabled: bool,

View file

@ -204,8 +204,9 @@ impl State {
} }
} }
} }
if let Some(blocklist) = dev_list_var("COSMIC_DRM_BLOCK_DEVICES") { if let Some(blocklist) = dev_list_var("COSMIC_DRM_BLOCK_DEVICES")
if let Ok(node) = DrmNode::from_dev_id(dev) { && let Ok(node) = DrmNode::from_dev_id(dev)
{
let node = node let node = node
.node_with_type(NodeType::Render) .node_with_type(NodeType::Render)
.and_then(|res| res.ok()) .and_then(|res| res.ok())
@ -220,7 +221,6 @@ impl State {
} }
} }
} }
}
let fd = DrmDeviceFd::new(DeviceFd::from( let fd = DrmDeviceFd::new(DeviceFd::from(
self.backend self.backend
@ -271,12 +271,12 @@ impl State {
notifier, notifier,
move |event, metadata, state: &mut State| match event { move |event, metadata, state: &mut State| match event {
DrmEvent::VBlank(crtc) => { DrmEvent::VBlank(crtc) => {
if let Some(device) = state.backend.kms().drm_devices.get_mut(&drm_node) { if let Some(device) = state.backend.kms().drm_devices.get_mut(&drm_node)
if let Some(surface) = device.inner.surfaces.get_mut(&crtc) { && let Some(surface) = device.inner.surfaces.get_mut(&crtc)
{
surface.on_vblank(metadata.take()); surface.on_vblank(metadata.take());
} }
} }
}
DrmEvent::Error(err) => { DrmEvent::Error(err) => {
warn!(?err, "Failed to read events of device {:?}.", dev); warn!(?err, "Failed to read events of device {:?}.", dev);
} }
@ -676,13 +676,13 @@ impl LockedDevice<'_> {
let mut compositor = compositor.lock().unwrap(); let mut compositor = compositor.lock().unwrap();
compositor.render_frame(renderer, &elements, CLEAR_COLOR, FrameFlags::empty())?; compositor.render_frame(renderer, &elements, CLEAR_COLOR, FrameFlags::empty())?;
if let Err(err) = compositor.commit_frame() { if let Err(err) = compositor.commit_frame()
if !matches!(err, FrameError::EmptyFrame) { && !matches!(err, FrameError::EmptyFrame)
{
return Err(err.into()); return Err(err.into());
} }
} }
} }
}
Ok(()) Ok(())
} }

View file

@ -32,8 +32,9 @@ pub fn display_configuration(
.iter() .iter()
.flat_map(|conn| device.get_connector(*conn, true).ok()) .flat_map(|conn| device.get_connector(*conn, true).ok())
{ {
if let Some(enc) = conn.current_encoder() { if let Some(enc) = conn.current_encoder()
if let Some(crtc) = device.get_encoder(enc)?.crtc() { && let Some(crtc) = device.get_encoder(enc)?.crtc()
{
// If is is connected we found a mapping // If is is connected we found a mapping
if conn.state() == ConnectorState::Connected { if conn.state() == ConnectorState::Connected {
map.insert(conn.handle(), Some(crtc)); map.insert(conn.handle(), Some(crtc));
@ -45,7 +46,6 @@ pub fn display_configuration(
} }
} }
} }
}
// But just in case we try to match all remaining connectors. // But just in case we try to match all remaining connectors.
for conn in connectors for conn in connectors
@ -81,13 +81,12 @@ pub fn display_configuration(
.iter() .iter()
.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 Ok(enc) = device.get_encoder(enc) { && let Ok(enc) = device.get_encoder(enc)
if let Some(crtc) = enc.crtc() { && let Some(crtc) = enc.crtc()
{
return cleanup.contains(&crtc); return cleanup.contains(&crtc);
} }
}
}
false false
}) })
.map(|info| info.handle()) .map(|info| info.handle())

View file

@ -230,15 +230,15 @@ fn determine_primary_gpu(
drm_devices: &IndexMap<DrmNode, Device>, drm_devices: &IndexMap<DrmNode, Device>,
seat: String, seat: String,
) -> Result<Option<DrmNode>> { ) -> Result<Option<DrmNode>> {
if let Some(device) = dev_var("COSMIC_RENDER_DEVICE") { if let Some(device) = dev_var("COSMIC_RENDER_DEVICE")
if let Some(node) = drm_devices.values().find_map(|dev| { && let Some(node) = drm_devices.values().find_map(|dev| {
device device
.matches(&dev.inner.render_node) .matches(&dev.inner.render_node)
.then_some(dev.inner.render_node) .then_some(dev.inner.render_node)
}) { })
{
return Ok(Some(node)); return Ok(Some(node));
} }
}
// try to find builtin display // try to find builtin display
for dev in drm_devices.values() { for dev in drm_devices.values() {
@ -256,14 +256,13 @@ fn determine_primary_gpu(
// else try to find the boot gpu // else try to find the boot gpu
let boot = determine_boot_gpu(seat); let boot = determine_boot_gpu(seat);
if let Some(boot) = boot { if let Some(boot) = boot
if drm_devices && drm_devices
.values() .values()
.any(|dev| dev.inner.render_node == boot) .any(|dev| dev.inner.render_node == boot)
{ {
return Ok(Some(boot)); return Ok(Some(boot));
} }
}
// else just take the first // else just take the first
Ok(drm_devices Ok(drm_devices
@ -319,12 +318,11 @@ fn init_udev(
let backend = state.backend.kms(); let backend = state.backend.kms();
if matches!(event, UdevEvent::Added { .. } | UdevEvent::Removed { .. }) if matches!(event, UdevEvent::Added { .. } | UdevEvent::Removed { .. })
&& backend.primary_node.read().unwrap().is_none() && backend.primary_node.read().unwrap().is_none()
&& let Err(err) = state.backend.kms().select_primary_gpu(&dh)
{ {
if let Err(err) = state.backend.kms().select_primary_gpu(&dh) {
warn!("Failed to determine a new primary gpu: {}", err); warn!("Failed to determine a new primary gpu: {}", err);
} }
} }
}
if let Err(err) = state.refresh_output_config() { if let Err(err) = state.refresh_output_config() {
warn!("Unable to load output config: {}", err); warn!("Unable to load output config: {}", err);
@ -462,8 +460,8 @@ impl KmsState {
if let Some(primary_node) = primary_node if let Some(primary_node) = primary_node
.as_ref() .as_ref()
.and_then(|node| node.node_with_type(NodeType::Primary).and_then(|x| x.ok())) .and_then(|node| node.node_with_type(NodeType::Primary).and_then(|x| x.ok()))
&& let Some(device) = self.drm_devices.get(&primary_node)
{ {
if let Some(device) = self.drm_devices.get(&primary_node) {
let import_device = device.drm.device().device_fd().clone(); let import_device = device.drm.device().device_fd().clone();
if supports_syncobj_eventfd(&import_device) { if supports_syncobj_eventfd(&import_device) {
if let Some(state) = self.syncobj_state.as_mut() { if let Some(state) = self.syncobj_state.as_mut() {
@ -475,7 +473,6 @@ impl KmsState {
return Ok(()); return Ok(());
} }
} }
}
if let Some(old_state) = self.syncobj_state.take() { if let Some(old_state) = self.syncobj_state.take() {
dh.remove_global::<State>(old_state.into_global()); dh.remove_global::<State>(old_state.into_global());
@ -939,8 +936,9 @@ impl KmsGuard<'_> {
compositor compositor
}; };
if let Some(bpc) = output_config.0.max_bpc { if let Some(bpc) = output_config.0.max_bpc
if let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc) { && let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc)
{
warn!( warn!(
?bpc, ?bpc,
?err, ?err,
@ -948,7 +946,6 @@ impl KmsGuard<'_> {
surface.output.name() surface.output.name()
); );
} }
}
let vrr = output_config.0.vrr; let vrr = output_config.0.vrr;
std::mem::drop(output_config); std::mem::drop(output_config);

View file

@ -782,8 +782,8 @@ impl SurfaceThreadState {
// mark last frame completed // mark last frame completed
if let Ok(Some(Some((mut feedback, frames, estimated_presentation_time)))) = if let Ok(Some(Some((mut feedback, frames, estimated_presentation_time)))) =
compositor.frame_submitted() compositor.frame_submitted()
&& self.mirroring.is_none()
{ {
if self.mirroring.is_none() {
let name = self.output.name(); let name = self.output.name();
let message = if let Some(presentation_time) = presentation_time { let message = if let Some(presentation_time) = presentation_time {
let misprediction_s = let misprediction_s =
@ -868,7 +868,6 @@ impl SurfaceThreadState {
); );
} }
} }
}
let redraw_needed = match mem::replace(&mut self.state, QueueState::Idle) { let redraw_needed = match mem::replace(&mut self.state, QueueState::Idle) {
QueueState::Idle => unreachable!(), QueueState::Idle => unreachable!(),
@ -1077,11 +1076,11 @@ impl SurfaceThreadState {
// we can't use the elements after `compositor.render_frame`, // we can't use the elements after `compositor.render_frame`,
// so let's collect everything we need for screencopy now // so let's collect everything we need for screencopy now
let mut has_cursor_mode_none = false; let mut has_cursor_mode_none = false;
let frames = self let frames = if self.mirroring.is_none() {
.mirroring take_screencopy_frames(&self.output, &elements, &mut has_cursor_mode_none)
.is_none() } else {
.then(|| take_screencopy_frames(&self.output, &elements, &mut has_cursor_mode_none)) Default::default()
.unwrap_or_default(); };
// actual rendering // actual rendering
let source_output = self let source_output = self
@ -1312,11 +1311,11 @@ impl SurfaceThreadState {
None None
}; };
if frame_result.needs_sync() { if frame_result.needs_sync()
if let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element { && let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element
{
elem.sync.wait()?; elem.sync.wait()?;
} }
}
match compositor.queue_frame(feedback) { match compositor.queue_frame(feedback) {
x @ Ok(()) | x @ Err(FrameError::EmptyFrame) => { x @ Ok(()) | x @ Err(FrameError::EmptyFrame) => {

View file

@ -103,11 +103,11 @@ pub fn init_backend_auto(
} }
} }
if let Some(inverted) = greeter_state.invert_colors { if let Some(inverted) = greeter_state.invert_colors
if inverted != state.a11y_state().screen_inverted() { && inverted != state.a11y_state().screen_inverted()
{
state.request_screen_invert(inverted); state.request_screen_invert(inverted);
} }
}
if state if state
.common .common

View file

@ -85,8 +85,8 @@ where
}; };
let buf_translation = Matrix3::from_translation(Vector2::new( let buf_translation = Matrix3::from_translation(Vector2::new(
(view.src.loc.x as f64 / buf_size.w as f64) as f32, (view.src.loc.x / buf_size.w as f64) as f32,
(view.src.loc.y as f64 / buf_size.h as f64) as f32, (view.src.loc.y / buf_size.h as f64) as f32,
)); ));
let input_to_geo = let input_to_geo =

View file

@ -528,8 +528,7 @@ where
); );
} }
if !exclude_dnd_icon { if !exclude_dnd_icon && 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,
@ -541,7 +540,6 @@ where
.map(CosmicElement::Dnd), .map(CosmicElement::Dnd),
); );
} }
}
let theme = theme.cosmic(); let theme = theme.cosmic();
if let Some(grab_elements) = seat if let Some(grab_elements) = seat
@ -1102,8 +1100,7 @@ impl PostprocessState {
if let (Some(tex), Some(tracker)) = ( if let (Some(tex), Some(tracker)) = (
self.cursor_texture.as_ref(), self.cursor_texture.as_ref(),
self.cursor_damage_tracker.as_ref(), self.cursor_damage_tracker.as_ref(),
) { ) && tex.format().is_some_and(|f| f == format)
if tex.format().is_some_and(|f| f == format)
&& tracker.mode() && tracker.mode()
== &(OutputModeSource::Static { == &(OutputModeSource::Static {
size, size,
@ -1113,7 +1110,6 @@ impl PostprocessState {
{ {
return Ok(()); return Ok(());
} }
}
let texture = Offscreen::<GlesTexture>::create_buffer(renderer, format, buffer_size)?; let texture = Offscreen::<GlesTexture>::create_buffer(renderer, format, buffer_size)?;

View file

@ -61,10 +61,10 @@ impl ShadowShader {
let mut geo = geo.to_f64(); let mut geo = geo.to_f64();
let fractional_pixel = scale.ceil() / scale; let fractional_pixel = scale.ceil() / scale;
geo.loc.x = geo.loc.x + fractional_pixel; geo.loc.x += fractional_pixel;
geo.loc.y = geo.loc.y + fractional_pixel; geo.loc.y += fractional_pixel;
geo.size.w = geo.size.w - fractional_pixel * 2.; geo.size.w -= fractional_pixel * 2.;
geo.size.h = geo.size.h - fractional_pixel * 2.; geo.size.h -= fractional_pixel * 2.;
let user_data = Borrow::<GlesRenderer>::borrow(renderer.glow_renderer()) let user_data = Borrow::<GlesRenderer>::borrow(renderer.glow_renderer())
.egl_context() .egl_context()
@ -125,7 +125,7 @@ impl ShadowShader {
.cast::<f32>() .cast::<f32>()
.unwrap(); .unwrap();
let window_geo_loc = Vector2::new(window_geo.loc.x as f64, window_geo.loc.y as f64); let window_geo_loc = Vector2::new(window_geo.loc.x, window_geo.loc.y);
let window_input_to_geo = (Matrix3::from_nonuniform_scale(area_size.x, area_size.y) let window_input_to_geo = (Matrix3::from_nonuniform_scale(area_size.x, area_size.y)
* Matrix3::from_translation(Vector2::new( * Matrix3::from_translation(Vector2::new(
-window_geo_loc.x / area_size.x, -window_geo_loc.x / area_size.x,

View file

@ -517,8 +517,9 @@ 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
if let InputEvent::PointerMotionAbsolute { event } = &event { if let InputEvent::PointerMotionAbsolute { event } = &event
if let Some(window) = event.window() { && let Some(window) = event.window()
{
let output = self let output = self
.backend .backend
.x11() .x11()
@ -536,7 +537,6 @@ impl State {
break; break;
} }
} }
}
}; };
self.process_input_event(event); self.process_input_event(event);

View file

@ -142,71 +142,71 @@ pub fn update_device(
); );
} }
if let Some((accel, is_default)) = config!(|x| x.acceleration.as_ref()) { if let Some((accel, is_default)) = config!(|x| x.acceleration.as_ref()) {
if let Some(profile) = accel.profile { if let Some(profile) = accel.profile
if let Err(err) = device.config_accel_set_profile(profile) { && let Err(err) = device.config_accel_set_profile(profile)
{
config_set_error(device, "acceleration profile", profile, err, is_default); config_set_error(device, "acceleration profile", profile, err, is_default);
} }
}
if let Err(err) = device.config_accel_set_speed(accel.speed) { if let Err(err) = device.config_accel_set_speed(accel.speed) {
config_set_error(device, "acceleration speed", accel.speed, err, is_default); config_set_error(device, "acceleration speed", accel.speed, err, is_default);
} }
} }
if let Some((matrix, is_default)) = config!(|x| x.calibration) { if let Some((matrix, is_default)) = config!(|x| x.calibration)
if let Err(err) = device.config_calibration_set_matrix(matrix) { && let Err(err) = device.config_calibration_set_matrix(matrix)
{
config_set_error(device, "calibration matrix", matrix, err, is_default); config_set_error(device, "calibration matrix", matrix, err, is_default);
} }
} if let Some((method, is_default)) = config!(|x| x.click_method)
if let Some((method, is_default)) = config!(|x| x.click_method) { && let Err(err) = device.config_click_set_method(method)
if let Err(err) = device.config_click_set_method(method) { {
config_set_error(device, "click method", method, err, is_default); config_set_error(device, "click method", method, err, is_default);
} }
} if let Some((dwt, is_default)) = config!(|x| x.disable_while_typing)
if let Some((dwt, is_default)) = config!(|x| x.disable_while_typing) { && let Err(err) = device.config_dwt_set_enabled(dwt)
if let Err(err) = device.config_dwt_set_enabled(dwt) { {
config_set_error(device, "disable-while-typing", dwt, err, is_default); config_set_error(device, "disable-while-typing", dwt, err, is_default);
} }
} if let Some((left, is_default)) = config!(|x| x.left_handed)
if let Some((left, is_default)) = config!(|x| x.left_handed) { && let Err(err) = device.config_left_handed_set(left)
if let Err(err) = device.config_left_handed_set(left) { {
config_set_error(device, "left-handed", left, err, is_default); config_set_error(device, "left-handed", left, err, is_default);
} }
} if let Some((middle, is_default)) = config!(|x| x.middle_button_emulation)
if let Some((middle, is_default)) = config!(|x| x.middle_button_emulation) { && let Err(err) = device.config_middle_emulation_set_enabled(middle)
if let Err(err) = device.config_middle_emulation_set_enabled(middle) { {
config_set_error(device, "middle-button-emulation", middle, err, is_default); config_set_error(device, "middle-button-emulation", middle, err, is_default);
} }
} if let Some((angle, is_default)) = config!(|x| x.rotation_angle)
if let Some((angle, is_default)) = config!(|x| x.rotation_angle) { && let Err(err) = device.config_rotation_set_angle(angle)
if let Err(err) = device.config_rotation_set_angle(angle) { {
config_set_error(device, "rotation-angle", angle, err, is_default); config_set_error(device, "rotation-angle", angle, err, is_default);
} }
}
if let Some((scroll, is_default)) = config!(|x| x.scroll_config.as_ref()) { if let Some((scroll, is_default)) = config!(|x| x.scroll_config.as_ref()) {
if let Some(method) = scroll.method { if let Some(method) = scroll.method
if let Err(err) = device.config_scroll_set_method(method) { && let Err(err) = device.config_scroll_set_method(method)
{
config_set_error(device, "scroll method", scroll, err, is_default); config_set_error(device, "scroll method", scroll, err, is_default);
} }
} if let Some(natural) = scroll.natural_scroll
if let Some(natural) = scroll.natural_scroll { && let Err(err) = device.config_scroll_set_natural_scroll_enabled(natural)
if let Err(err) = device.config_scroll_set_natural_scroll_enabled(natural) { {
config_set_error(device, "natural scrolling", natural, err, is_default); config_set_error(device, "natural scrolling", natural, err, is_default);
} }
} if let Some(button) = scroll.scroll_button
if let Some(button) = scroll.scroll_button { && let Err(err) = device.config_scroll_set_button(button)
if let Err(err) = device.config_scroll_set_button(button) { {
config_set_error(device, "scroll button", button, err, is_default); config_set_error(device, "scroll button", button, err, is_default);
} }
} }
}
if let Some((tap, is_default)) = config!(|x| x.tap_config.as_ref()) { if let Some((tap, is_default)) = config!(|x| x.tap_config.as_ref()) {
if let Err(err) = device.config_tap_set_enabled(tap.enabled) { if let Err(err) = device.config_tap_set_enabled(tap.enabled) {
config_set_error(device, "tap-to-click", tap.enabled, err, is_default); config_set_error(device, "tap-to-click", tap.enabled, err, is_default);
} }
if let Some(button_map) = tap.button_map { if let Some(button_map) = tap.button_map
if let Err(err) = device.config_tap_set_button_map(button_map) { && let Err(err) = device.config_tap_set_button_map(button_map)
{
config_set_error(device, "button map", button_map, err, is_default); config_set_error(device, "button map", button_map, err, is_default);
} }
}
if let Err(err) = device.config_tap_set_drag_enabled(tap.drag) { if let Err(err) = device.config_tap_set_drag_enabled(tap.drag) {
config_set_error(device, "tap-drag", tap.drag, err, is_default); config_set_error(device, "tap-drag", tap.drag, err, is_default);
} }

View file

@ -371,8 +371,9 @@ impl Config {
} }
fn load_filter_state(path: &Option<PathBuf>) -> ScreenFilter { fn load_filter_state(path: &Option<PathBuf>) -> ScreenFilter {
if let Some(path) = path.as_ref() { if let Some(path) = path.as_ref()
if path.exists() { && path.exists()
{
match ron::de::from_reader::<_, ScreenFilter>( match ron::de::from_reader::<_, ScreenFilter>(
OpenOptions::new().read(true).open(path).unwrap(), OpenOptions::new().read(true).open(path).unwrap(),
) { ) {
@ -385,7 +386,6 @@ impl Config {
} }
}; };
} }
}
ScreenFilter { ScreenFilter {
inverted: false, inverted: false,

View file

@ -19,7 +19,7 @@ use zbus::{
use super::name_owners::NameOwners; use super::name_owners::NameOwners;
static ALLOWED_NAMES: &'static [WellKnownName] = &[WellKnownName::from_static_str_unchecked( static ALLOWED_NAMES: &[WellKnownName] = &[WellKnownName::from_static_str_unchecked(
"org.gnome.Orca.KeyboardMonitor", "org.gnome.Orca.KeyboardMonitor",
)]; )];

View file

@ -156,7 +156,7 @@ impl NameOwners {
} else { } else {
allowed_names allowed_names
.iter() .iter()
.any(|n| inner.name_owners.get(n).map(|x| x.as_ref()).flatten() == Some(name)) .any(|n| inner.name_owners.get(n).and_then(|x| x.as_ref()) == Some(name))
} }
} }

View file

@ -188,17 +188,16 @@ impl State {
} }
Action::NextWorkspace => { Action::NextWorkspace => {
if let Some(direction) = pattern.inferred_direction() { if let Some(direction) = pattern.inferred_direction()
if ((direction == Direction::Left || direction == Direction::Right) && (((direction == Direction::Left || direction == Direction::Right)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Vertical) == WorkspaceLayout::Vertical)
|| ((direction == Direction::Up || direction == Direction::Down) || ((direction == Direction::Up || direction == Direction::Down)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Horizontal) == WorkspaceLayout::Horizontal))
{ {
return; return;
} }
}
let next = to_next_workspace( let next = to_next_workspace(
&mut self.common.shell.write(), &mut self.common.shell.write(),
@ -234,17 +233,16 @@ impl State {
} }
Action::PreviousWorkspace => { Action::PreviousWorkspace => {
if let Some(direction) = pattern.inferred_direction() { if let Some(direction) = pattern.inferred_direction()
if ((direction == Direction::Left || direction == Direction::Right) && (((direction == Direction::Left || direction == Direction::Right)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Vertical) == WorkspaceLayout::Vertical)
|| ((direction == Direction::Up || direction == Direction::Down) || ((direction == Direction::Up || direction == Direction::Down)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Horizontal) == WorkspaceLayout::Horizontal))
{ {
return; return;
} }
}
let previous = to_previous_workspace( let previous = to_previous_workspace(
&mut self.common.shell.write(), &mut self.common.shell.write(),
@ -336,17 +334,16 @@ impl State {
} }
x @ Action::MoveToNextWorkspace | x @ Action::SendToNextWorkspace => { x @ Action::MoveToNextWorkspace | x @ Action::SendToNextWorkspace => {
if let Some(direction) = pattern.inferred_direction() { if let Some(direction) = pattern.inferred_direction()
if ((direction == Direction::Left || direction == Direction::Right) && (((direction == Direction::Left || direction == Direction::Right)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Vertical) == WorkspaceLayout::Vertical)
|| ((direction == Direction::Up || direction == Direction::Down) || ((direction == Direction::Up || direction == Direction::Down)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Horizontal) == WorkspaceLayout::Horizontal))
{ {
return; return;
} }
}
let Some(focused_output) = seat.focused_output() else { let Some(focused_output) = seat.focused_output() else {
return; return;
}; };
@ -420,17 +417,16 @@ impl State {
} }
x @ Action::MoveToPreviousWorkspace | x @ Action::SendToPreviousWorkspace => { x @ Action::MoveToPreviousWorkspace | x @ Action::SendToPreviousWorkspace => {
if let Some(direction) = pattern.inferred_direction() { if let Some(direction) = pattern.inferred_direction()
if ((direction == Direction::Left || direction == Direction::Right) && (((direction == Direction::Left || direction == Direction::Right)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Vertical) == WorkspaceLayout::Vertical)
|| ((direction == Direction::Up || direction == Direction::Down) || ((direction == Direction::Up || direction == Direction::Down)
&& self.common.config.cosmic_conf.workspaces.workspace_layout && self.common.config.cosmic_conf.workspaces.workspace_layout
== WorkspaceLayout::Horizontal) == WorkspaceLayout::Horizontal))
{ {
return; return;
} }
}
let Some(focused_output) = seat.focused_output() else { let Some(focused_output) = seat.focused_output() else {
return; return;
}; };
@ -511,11 +507,10 @@ impl State {
if let Some(next_output) = next_output { if let Some(next_output) = next_output {
let res = { let res = {
let mut workspace_guard = self.common.workspace_state.update(); let mut workspace_guard = self.common.workspace_state.update();
if propagate { if propagate
if let Some((serial, prev_output, prev_idx)) = && let Some((serial, prev_output, prev_idx)) =
shell.previous_workspace_idx.take() shell.previous_workspace_idx.take()
{ && seat.last_modifier_change().is_some_and(|s| s == serial)
if seat.last_modifier_change().is_some_and(|s| s == serial)
&& prev_output == current_output && prev_output == current_output
{ {
let _ = shell.activate( let _ = shell.activate(
@ -525,8 +520,6 @@ impl State {
&mut workspace_guard, &mut workspace_guard,
); );
} }
}
}
let idx = shell.workspaces.active_num(&next_output).1; let idx = shell.workspaces.active_num(&next_output).1;
let res = shell.activate( let res = shell.activate(
@ -607,11 +600,12 @@ impl State {
&self.common.event_loop_handle, &self.common.event_loop_handle,
); );
if is_move_action && propagate { if is_move_action
if let Some((_, prev_output, prev_idx)) = && propagate
&& let Some((_, prev_output, prev_idx)) =
shell.previous_workspace_idx.take() shell.previous_workspace_idx.take()
&& prev_output == focused_output
{ {
if prev_output == focused_output {
let _ = shell.activate( let _ = shell.activate(
&focused_output, &focused_output,
prev_idx, prev_idx,
@ -619,8 +613,6 @@ impl State {
&mut workspace_guard, &mut workspace_guard,
); );
} }
}
}
res res
}; };
@ -837,8 +829,8 @@ impl State {
let workspace = shell.active_space(&current_output).unwrap(); let workspace = shell.active_space(&current_output).unwrap();
if let Some(FocusTarget::Window(focused_window)) = if let Some(FocusTarget::Window(focused_window)) =
workspace.focus_stack.get(seat).last() workspace.focus_stack.get(seat).last()
&& workspace.is_tiled(&focused_window.active_window())
{ {
if workspace.is_tiled(&focused_window.active_window()) {
shell.set_overview_mode( shell.set_overview_mode(
Some(Trigger::KeyboardMove(pattern.modifiers)), Some(Trigger::KeyboardMove(pattern.modifiers)),
self.common.event_loop_handle.clone(), self.common.event_loop_handle.clone(),
@ -847,7 +839,6 @@ impl State {
} }
} }
} }
}
Action::SwapWindow => { Action::SwapWindow => {
let Some(focused_output) = seat.focused_output() else { let Some(focused_output) = seat.focused_output() else {
@ -858,8 +849,9 @@ impl State {
let workspace = shell.active_space_mut(&focused_output).unwrap(); let workspace = shell.active_space_mut(&focused_output).unwrap();
let keyboard_handle = seat.get_keyboard().unwrap(); let keyboard_handle = seat.get_keyboard().unwrap();
if let Some(focus) = keyboard_handle.current_focus() { if let Some(focus) = keyboard_handle.current_focus()
if let Some(descriptor) = workspace.node_desc(focus) { && let Some(descriptor) = workspace.node_desc(focus)
{
let grab = SwapWindowGrab::new(seat.clone(), descriptor.clone()); let grab = SwapWindowGrab::new(seat.clone(), descriptor.clone());
drop(shell); drop(shell);
keyboard_handle.set_grab(self, grab, serial); keyboard_handle.set_grab(self, grab, serial);
@ -870,7 +862,6 @@ impl State {
); );
} }
} }
}
Action::Minimize => { Action::Minimize => {
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();

View file

@ -73,15 +73,15 @@ impl GestureState {
fn push(&mut self, delta: f64, timestamp: Duration) { fn push(&mut self, delta: f64, timestamp: Duration) {
// For the events that we care about, timestamps should always increase // For the events that we care about, timestamps should always increase
// monotonically. // monotonically.
if let Some(last) = self.history.back() { if let Some(last) = self.history.back()
if timestamp < last.timestamp { && timestamp < last.timestamp
{
trace!( trace!(
"ignoring event with timestamp {timestamp:?} earlier than last {:?}", "ignoring event with timestamp {timestamp:?} earlier than last {:?}",
last.timestamp last.timestamp
); );
return; return;
} }
}
self.history.push_back(SwipeEvent { delta, timestamp }); self.history.push_back(SwipeEvent { delta, timestamp });
self.delta += delta; self.delta += delta;

View file

@ -493,8 +493,7 @@ impl State {
} }
// If confined, don't move pointer if it would go outside surface or region // If confined, don't move pointer if it would go outside surface or region
if pointer_confined { if pointer_confined && let Some((surface, surface_loc)) = &under {
if let Some((surface, surface_loc)) = &under {
if new_under.as_ref().and_then(|(under, _)| under.wl_surface()) if new_under.as_ref().and_then(|(under, _)| under.wl_surface())
!= surface.wl_surface() != surface.wl_surface()
{ {
@ -530,16 +529,14 @@ impl State {
} }
_ => {} _ => {}
} }
if let Some(region) = confine_region { if let Some(region) = confine_region
if !region && !region
.contains((position.as_logical() - *surface_loc).to_i32_round()) .contains((position.as_logical() - *surface_loc).to_i32_round())
{ {
ptr.frame(self); ptr.frame(self);
return; return;
} }
} }
}
}
let serial = SERIAL_COUNTER.next_serial(); let serial = SERIAL_COUNTER.next_serial();
ptr.motion( ptr.motion(
@ -722,8 +719,8 @@ impl State {
State::element_under(global_position, &output, &shell, &seat) State::element_under(global_position, &output, &shell, &seat)
}; };
if let Some(target) = under { if let Some(target) = under {
if let Some(surface) = target.toplevel().map(Cow::into_owned) { if let Some(surface) = target.toplevel().map(Cow::into_owned)
if seat.get_keyboard().unwrap().modifier_state().logo && seat.get_keyboard().unwrap().modifier_state().logo
&& !shortcuts_inhibited && !shortcuts_inhibited
{ {
let seat_clone = seat.clone(); let seat_clone = seat.clone();
@ -770,9 +767,7 @@ impl State {
false, false,
); );
drop(shell); drop(shell);
dispatch_grab( dispatch_grab(res, seat_clone, serial, state);
res, seat_clone, serial, state,
);
}, },
); );
} }
@ -809,12 +804,10 @@ impl State {
let geom = geom.to_f64(); let geom = geom.to_f64();
let center = let center =
geom.loc + geom.size.downscale(2.0); geom.loc + geom.size.downscale(2.0);
let offset = center.to_global(&output) let offset =
- global_position; center.to_global(&output) - global_position;
let edge = match ( let edge =
offset.x > 0.0, match (offset.x > 0.0, offset.y > 0.0) {
offset.y > 0.0,
) {
(true, true) => ResizeEdge::TOP_LEFT, (true, true) => ResizeEdge::TOP_LEFT,
(false, true) => ResizeEdge::TOP_RIGHT, (false, true) => ResizeEdge::TOP_RIGHT,
(true, false) => { (true, false) => {
@ -837,9 +830,7 @@ impl State {
false, false,
); );
drop(shell); drop(shell);
dispatch_grab( dispatch_grab(res, seat_clone, serial, state);
res, seat_clone, serial, state,
);
}, },
); );
} }
@ -847,7 +838,6 @@ impl State {
} }
} }
} }
}
Shell::set_focus(self, Some(&target), &seat, Some(serial), false); Shell::set_focus(self, Some(&target), &seat, Some(serial), false);
} }
@ -856,11 +846,10 @@ impl State {
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();
if let Some(Trigger::Pointer(action_button)) = if let Some(Trigger::Pointer(action_button)) =
shell.overview_mode().0.active_trigger() shell.overview_mode().0.active_trigger()
&& *action_button == button
{ {
if *action_button == button {
shell.set_overview_mode(None, self.common.event_loop_handle.clone()); shell.set_overview_mode(None, self.common.event_loop_handle.clone());
} }
}
std::mem::drop(shell); std::mem::drop(shell);
}; };
@ -1016,11 +1005,10 @@ impl State {
let mut natural_scroll = false; let mut natural_scroll = false;
if let Some(scroll_config) = if let Some(scroll_config) =
&self.common.config.cosmic_conf.input_touchpad.scroll_config &self.common.config.cosmic_conf.input_touchpad.scroll_config
&& let Some(natural) = scroll_config.natural_scroll
{ {
if let Some(natural) = scroll_config.natural_scroll {
natural_scroll = natural; natural_scroll = natural;
} }
}
activate_action = match gesture_state.fingers { activate_action = match gesture_state.fingers {
3 => None, // TODO: 3 finger gestures 3 => None, // TODO: 3 finger gestures
4 => { 4 => {
@ -1317,11 +1305,11 @@ impl State {
} }
InputEvent::TouchUp { event, .. } => { InputEvent::TouchUp { event, .. } => {
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();
if let Some(Trigger::Touch(slot)) = shell.overview_mode().0.active_trigger() { if let Some(Trigger::Touch(slot)) = shell.overview_mode().0.active_trigger()
if *slot == event.slot() { && *slot == event.slot()
{
shell.set_overview_mode(None, self.common.event_loop_handle.clone()); shell.set_overview_mode(None, self.common.event_loop_handle.clone());
} }
}
let maybe_seat = shell.seats.for_device(&event.device()).cloned(); let maybe_seat = shell.seats.for_device(&event.device()).cloned();
if let Some(seat) = maybe_seat { if let Some(seat) = maybe_seat {
@ -1621,26 +1609,23 @@ impl State {
// Leave move overview mode, if any modifier was released // Leave move overview mode, if any modifier was released
if let Some(Trigger::KeyboardMove(action_modifiers)) = if let Some(Trigger::KeyboardMove(action_modifiers)) =
shell.overview_mode().0.active_trigger() shell.overview_mode().0.active_trigger()
{ && ((action_modifiers.ctrl && !modifiers.ctrl)
if (action_modifiers.ctrl && !modifiers.ctrl)
|| (action_modifiers.alt && !modifiers.alt) || (action_modifiers.alt && !modifiers.alt)
|| (action_modifiers.logo && !modifiers.logo) || (action_modifiers.logo && !modifiers.logo)
|| (action_modifiers.shift && !modifiers.shift) || (action_modifiers.shift && !modifiers.shift))
{ {
shell.set_overview_mode(None, self.common.event_loop_handle.clone()); shell.set_overview_mode(None, self.common.event_loop_handle.clone());
} }
}
// Leave swap overview mode, if any key was released // Leave swap overview mode, if any key was released
if let Some(Trigger::KeyboardSwap(action_pattern, old_descriptor)) = if let Some(Trigger::KeyboardSwap(action_pattern, old_descriptor)) =
shell.overview_mode().0.active_trigger() shell.overview_mode().0.active_trigger()
{ && ((action_pattern.modifiers.ctrl && !modifiers.ctrl)
if (action_pattern.modifiers.ctrl && !modifiers.ctrl)
|| (action_pattern.modifiers.alt && !modifiers.alt) || (action_pattern.modifiers.alt && !modifiers.alt)
|| (action_pattern.modifiers.logo && !modifiers.logo) || (action_pattern.modifiers.logo && !modifiers.logo)
|| (action_pattern.modifiers.shift && !modifiers.shift) || (action_pattern.modifiers.shift && !modifiers.shift)
|| (action_pattern.key.is_some() || (action_pattern.key.is_some()
&& key_matches(action_pattern.key.unwrap()) && key_matches(action_pattern.key.unwrap())
&& event.state() == KeyState::Released) && event.state() == KeyState::Released))
{ {
shell.set_overview_mode(None, self.common.event_loop_handle.clone()); shell.set_overview_mode(None, self.common.event_loop_handle.clone());
@ -1652,7 +1637,6 @@ impl State {
&focused_output, &focused_output,
); );
} }
}
// Leave or update resize mode, if modifiers changed or initial key was released // Leave or update resize mode, if modifiers changed or initial key was released
if let Some(action_pattern) = shell.resize_mode().0.active_binding() { if let Some(action_pattern) = shell.resize_mode().0.active_binding() {
@ -1832,14 +1816,14 @@ impl State {
} }
// Skip released events for initially surpressed keys // Skip released events for initially surpressed keys
if event.state() == KeyState::Released { if event.state() == KeyState::Released
if let Some(tokens) = seat.supressed_keys().filter(&handle) { && let Some(tokens) = seat.supressed_keys().filter(&handle)
{
for token in tokens { for token in tokens {
self.common.event_loop_handle.remove(token); self.common.event_loop_handle.remove(token);
} }
return FilterResult::Intercept(None); return FilterResult::Intercept(None);
} }
}
// Handle VT switches // Handle VT switches
if event.state() == KeyState::Pressed if event.state() == KeyState::Pressed
@ -1944,8 +1928,8 @@ impl State {
if old_descriptor.handle != new_descriptor.handle { if old_descriptor.handle != new_descriptor.handle {
let (mut old_w, mut other_w) = let (mut old_w, mut other_w) =
spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle); spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle);
if let Some(old_workspace) = old_w.get_mut(0) { if let Some(old_workspace) = old_w.get_mut(0)
if let Some(new_workspace) = other_w && let Some(new_workspace) = other_w
.iter_mut() .iter_mut()
.find(|w| w.handle == new_descriptor.handle) .find(|w| w.handle == new_descriptor.handle)
{ {
@ -1979,7 +1963,6 @@ impl State {
old_workspace.refresh_focus_stack(); old_workspace.refresh_focus_stack();
new_workspace.refresh_focus_stack(); new_workspace.refresh_focus_stack();
} }
}
} else if let Some(workspace) = spaces.find(|w| w.handle == new_descriptor.handle) { } else 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,
@ -2002,11 +1985,11 @@ impl State {
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) =
spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle); spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle);
if let Some(old_workspace) = old_w.get_mut(0) { if let Some(old_workspace) = old_w.get_mut(0)
if let Some(new_workspace) = && let Some(new_workspace) =
other_w.iter_mut().find(|w| w.handle == new_workspace) other_w.iter_mut().find(|w| w.handle == new_workspace)
&& 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| {
@ -2034,8 +2017,6 @@ impl State {
} }
} }
} }
}
}
#[profiling::function] #[profiling::function]
pub fn element_under( pub fn element_under(
@ -2136,12 +2117,11 @@ impl State {
.is_some_and(|geometry| { .is_some_and(|geometry| {
geometry.contains(global_pos.to_local(output).to_i32_round()) geometry.contains(global_pos.to_local(output).to_i32_round())
}) })
&& let Some(element) = workspace.popup_element_under(location, seat)
{ {
if let Some(element) = workspace.popup_element_under(location, seat) {
return ControlFlow::Break(Ok(Some(element))); return ControlFlow::Break(Ok(Some(element)));
} }
} }
}
Stage::Workspace { workspace, offset } => { Stage::Workspace { workspace, offset } => {
let location = global_pos + offset.as_global().to_f64(); let location = global_pos + offset.as_global().to_f64();
let output = workspace.output(); let output = workspace.output();
@ -2151,14 +2131,12 @@ impl State {
.is_some_and(|geometry| { .is_some_and(|geometry| {
geometry.contains(global_pos.to_local(output).to_i32_round()) geometry.contains(global_pos.to_local(output).to_i32_round())
}) })
{ && let Some(element) = workspace.toplevel_element_under(location, seat)
if let Some(element) = workspace.toplevel_element_under(location, seat)
{ {
return ControlFlow::Break(Ok(Some(element))); return ControlFlow::Break(Ok(Some(element)));
} }
} }
} }
}
ControlFlow::Continue(()) ControlFlow::Continue(())
}, },
) )
@ -2199,14 +2177,13 @@ impl State {
|stage| { |stage| {
match stage { match stage {
Stage::ZoomUI => { Stage::ZoomUI => {
if let Some(zoom_state) = shell.zoom_state() { if let Some(zoom_state) = shell.zoom_state()
if let Some((target, loc)) = && let Some((target, loc)) =
zoom_state.surface_under(output, global_pos) zoom_state.surface_under(output, global_pos)
{ {
return ControlFlow::Break(Ok(Some((target, loc)))); return ControlFlow::Break(Ok(Some((target, loc))));
} }
} }
}
Stage::SessionLock(lock_surface) => { Stage::SessionLock(lock_surface) => {
return ControlFlow::Break(Ok(lock_surface.and_then(|surface| { return ControlFlow::Break(Ok(lock_surface.and_then(|surface| {
let location = output_geo.loc; let location = output_geo.loc;

View file

@ -130,7 +130,7 @@ 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::SetEnv { .. }) => warn!("Got SetEnv from session? What is this?"), Ok(Message::SetEnv { .. }) => warn!("Got SetEnv from session? What is this?"),
_ => warn!("Unknown session socket message, are you using incompatible cosmic-session and cosmic-comp versions?"), _ => warn!("Unknown session socket message, are you using incompatible cosmic-session and cosmic-comp versions?"),
}; };

View file

@ -602,11 +602,11 @@ impl CosmicStack {
let previous = p.previous_keyboard.swap(active, Ordering::SeqCst); let previous = p.previous_keyboard.swap(active, Ordering::SeqCst);
if previous != active || p.reenter.swap(false, Ordering::SeqCst) { if previous != active || p.reenter.swap(false, Ordering::SeqCst) {
let windows = p.windows.lock().unwrap(); let windows = p.windows.lock().unwrap();
if let Some(previous_surface) = windows.get(previous) { if let Some(previous_surface) = windows.get(previous)
if previous != active { && previous != active
{
KeyboardTarget::leave(previous_surface, seat, data, serial); KeyboardTarget::leave(previous_surface, seat, data, serial);
} }
}
KeyboardTarget::enter( KeyboardTarget::enter(
&windows[active], &windows[active],
seat, seat,
@ -685,15 +685,15 @@ impl CosmicStack {
if tiled && !appearance.shadow_tiled_windows { if tiled && !appearance.shadow_tiled_windows {
return None; return None;
} }
let radii = round let radii = if round {
.then(|| {
theme theme
.cosmic() .cosmic()
.radius_s() .radius_s()
.map(|x| if x < 4.0 { x } else { x + 4.0 }) .map(|x| if x < 4.0 { x } else { x + 4.0 })
.map(|x| (x * scale as f32).round() as u8) .map(|x| (x * scale as f32).round() as u8)
}) } else {
.unwrap_or([0, 0, 0, 0]); [0, 0, 0, 0]
};
let mut geo = SpaceElement::geometry(&windows[active]).to_f64(); let mut geo = SpaceElement::geometry(&windows[active]).to_f64();
geo.size.h += TAB_HEIGHT as f64; geo.size.h += TAB_HEIGHT as f64;
@ -857,8 +857,7 @@ impl CosmicStack {
if let Some(dragged_out) = self if let Some(dragged_out) = self
.0 .0
.with_program(|p| p.potential_drag.lock().unwrap().take()) .with_program(|p| p.potential_drag.lock().unwrap().take())
{ && let Some(surface) = self
if let Some(surface) = self
.0 .0
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned()) .with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
{ {
@ -890,7 +889,6 @@ impl CosmicStack {
} }
} }
} }
}
pub fn min_size(&self) -> Option<Size<i32, Logical>> { pub fn min_size(&self) -> Option<Size<i32, Logical>> {
self.surfaces() self.surfaces()
@ -1152,15 +1150,16 @@ impl Program for CosmicStackInternal {
} }
} }
Message::TabMenu(idx) => { Message::TabMenu(idx) => {
if let Some((seat, serial)) = last_seat.cloned() { if let Some((seat, serial)) = last_seat.cloned()
if let Some(surface) = self.windows.lock().unwrap()[idx] && let Some(surface) = self.windows.lock().unwrap()[idx]
.wl_surface() .wl_surface()
.map(Cow::into_owned) .map(Cow::into_owned)
{ {
loop_handle.insert_idle(move |state| { loop_handle.insert_idle(move |state| {
let shell = state.common.shell.read(); let shell = state.common.shell.read();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() { if let Some(mapped) = shell.element_for_surface(&surface).cloned()
if let Some(workspace) = shell.space_for(&mapped) { && let Some(workspace) = shell.space_for(&mapped)
{
let Some(elem_geo) = workspace.element_geometry(&mapped) else { let Some(elem_geo) = workspace.element_geometry(&mapped) else {
return; return;
}; };
@ -1190,11 +1189,9 @@ impl Program for CosmicStackInternal {
.set_grab(state, grab, serial, focus); .set_grab(state, grab, serial, focus);
} }
} }
}
}); });
} }
} }
}
_ => unreachable!(), _ => unreachable!(),
} }
Task::none() Task::none()
@ -1701,8 +1698,7 @@ impl PointerTarget<State> for CosmicStack {
if let Some(dragged_out) = self if let Some(dragged_out) = self
.0 .0
.with_program(|p| p.potential_drag.lock().unwrap().take()) .with_program(|p| p.potential_drag.lock().unwrap().take())
{ && let Some(surface) = self
if let Some(surface) = self
.0 .0
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned()) .with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
{ {
@ -1734,7 +1730,6 @@ impl PointerTarget<State> for CosmicStack {
} }
} }
} }
}
fn gesture_swipe_begin( fn gesture_swipe_begin(
&self, &self,

View file

@ -356,30 +356,27 @@ where
if matches!( if matches!(
event, event,
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
) { ) && let Some(message) = self.press_message.clone()
if let Some(message) = self.press_message.clone() { {
shell.publish(message); shell.publish(message);
shell.capture_event(); shell.capture_event();
return; return;
} }
}
if matches!( if matches!(
event, event,
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Right)) event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Right))
) { ) && let Some(message) = self.right_click_message.clone()
if let Some(message) = self.right_click_message.clone() { {
shell.publish(message); shell.publish(message);
shell.capture_event(); shell.capture_event();
return; return;
} }
}
if matches!( if matches!(
event, event,
event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
) { ) {
shell.publish(Message::activate(self.idx)); shell.publish(Message::activate(self.idx));
shell.capture_event(); shell.capture_event();
return;
} }
} }
} }

View file

@ -270,11 +270,11 @@ impl State {
pub fn cleanup_old_animations(&mut self) { pub fn cleanup_old_animations(&mut self) {
let start_time = Instant::now(); let start_time = Instant::now();
if let Some(animation) = self.scroll_animation.as_ref() { if let Some(animation) = self.scroll_animation.as_ref()
if start_time.duration_since(animation.start_time) > SCROLL_ANIMATION_DURATION { && start_time.duration_since(animation.start_time) > SCROLL_ANIMATION_DURATION
{
self.scroll_animation.take(); self.scroll_animation.take();
} }
}
Self::discard_expired_tab_animations(&mut self.tab_animations, start_time); Self::discard_expired_tab_animations(&mut self.tab_animations, start_time);
} }

View file

@ -693,8 +693,7 @@ impl CosmicSurface {
.primary_scanout_feedback .primary_scanout_feedback
.as_ref() .as_ref()
.unwrap_or(&feedback.render_feedback) .unwrap_or(&feedback.render_feedback)
} else { } else if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
feedback feedback
.overlay_scanout_feedback .overlay_scanout_feedback
.as_ref() .as_ref()
@ -702,7 +701,6 @@ impl CosmicSurface {
} else { } 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 { if pending {
toplevel.with_pending_state(|pending| cb(Some(pending))) toplevel.with_pending_state(|pending| cb(Some(pending)))
} else { } else {
toplevel.with_committed_state(|committed| cb(committed)) toplevel.with_committed_state(cb)
} }
} }

View file

@ -576,11 +576,9 @@ impl CosmicWindow {
*conf = *appearance; *conf = *appearance;
if appearance.clip_floating_windows { if appearance.clip_floating_windows {
p.window.set_tiled(true); p.window.set_tiled(true);
} else { } else if !p.tiled.load(Ordering::Acquire) {
if !p.tiled.load(Ordering::Acquire) {
p.window.set_tiled(false); p.window.set_tiled(false);
} }
}
p.window.send_configure(); p.window.send_configure();
} }
}) })
@ -633,8 +631,8 @@ impl CosmicWindow {
&& !p.window.is_maximized(false); && !p.window.is_maximized(false);
let round = let round =
(!is_tiled || appearance.clip_tiled_windows) && !p.window.is_maximized(false); (!is_tiled || appearance.clip_tiled_windows) && !p.window.is_maximized(false);
let radii = round let radii = if round {
.then(|| { {
p.theme p.theme
.lock() .lock()
.unwrap() .unwrap()
@ -642,8 +640,10 @@ impl CosmicWindow {
.radius_s() .radius_s()
.map(|x| if x < 4.0 { x } else { x + 4.0 }) .map(|x| if x < 4.0 { x } else { x + 4.0 })
.map(|x| x.round() as u8) .map(|x| x.round() as u8)
}) }
.unwrap_or([0; 4]); } else {
[0; 4]
};
match (has_ssd, clip) { match (has_ssd, clip) {
(has_ssd, true) => { (has_ssd, true) => {
@ -698,8 +698,9 @@ impl Program for CosmicWindowInternal {
) -> Task<Self::Message> { ) -> Task<Self::Message> {
match message { match message {
Message::DragStart => { Message::DragStart => {
if let Some((seat, serial)) = last_seat.cloned() { if let Some((seat, serial)) = last_seat.cloned()
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) { && let Some(surface) = self.window.wl_surface().map(Cow::into_owned)
{
loop_handle.insert_idle(move |state| { loop_handle.insert_idle(move |state| {
let res = state.common.shell.write().move_request( let res = state.common.shell.write().move_request(
&surface, &surface,
@ -723,7 +724,6 @@ impl Program for CosmicWindowInternal {
}); });
} }
} }
}
Message::Minimize => { Message::Minimize => {
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) { if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
loop_handle.insert_idle(move |state| { loop_handle.insert_idle(move |state| {
@ -745,8 +745,9 @@ impl Program for CosmicWindowInternal {
} }
Message::Close => self.window.close(), Message::Close => self.window.close(),
Message::Menu => { Message::Menu => {
if let Some((seat, serial)) = last_seat.cloned() { if let Some((seat, serial)) = last_seat.cloned()
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) { && let Some(surface) = self.window.wl_surface().map(Cow::into_owned)
{
loop_handle.insert_idle(move |state| { loop_handle.insert_idle(move |state| {
let shell = state.common.shell.read(); let shell = state.common.shell.read();
if let Some(mapped) = shell.element_for_surface(&surface).cloned() { if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
@ -792,7 +793,6 @@ impl Program for CosmicWindowInternal {
} }
} }
} }
}
Task::none() Task::none()
} }

View file

@ -238,13 +238,12 @@ impl Shell {
.user_data() .user_data()
.get::<PopupGrabData>() .get::<PopupGrabData>()
.and_then(|x| x.take()) .and_then(|x| x.take())
&& !popup_grab.has_ended()
{ {
if !popup_grab.has_ended() {
popup_grab.ungrab(PopupUngrabStrategy::All); popup_grab.ungrab(PopupUngrabStrategy::All);
} }
} }
} }
}
fn update_active(&mut self) { fn update_active(&mut self) {
// update activate status // update activate status
@ -501,14 +500,14 @@ impl Common {
trace!("Wrong Window, focus fixup"); trace!("Wrong Window, focus fixup");
} }
} else { } else {
if let KeyboardFocusTarget::Popup(_) = target { if let KeyboardFocusTarget::Popup(_) = target
if let Some(popup_grab) = seat && let Some(popup_grab) = seat
.user_data() .user_data()
.get::<PopupGrabData>() .get::<PopupGrabData>()
.and_then(|x| x.take()) .and_then(|x| x.take())
&& !popup_grab.has_ended()
&& let Some(new) = popup_grab.current_grab()
{ {
if !popup_grab.has_ended() {
if let Some(new) = popup_grab.current_grab() {
trace!("restore focus to previous popup grab"); trace!("restore focus to previous popup grab");
std::mem::drop(shell); std::mem::drop(shell);
// TODO: verify whether cursor should be updated at end of popup grab // TODO: verify whether cursor should be updated at end of popup grab
@ -524,9 +523,6 @@ impl Common {
.set(Some(popup_grab)); .set(Some(popup_grab));
continue; continue;
} }
}
}
}
trace!("Surface dead, focus fixup"); trace!("Surface dead, focus fixup");
} }
} else { } else {
@ -547,11 +543,10 @@ impl Common {
.user_data() .user_data()
.get::<PopupGrabData>() .get::<PopupGrabData>()
.and_then(|x| x.take()) .and_then(|x| x.take())
&& !popup_grab.has_ended()
{ {
if !popup_grab.has_ended() {
popup_grab.ungrab(PopupUngrabStrategy::All); popup_grab.ungrab(PopupUngrabStrategy::All);
} }
}
// update keyboard focus // update keyboard focus
let target = update_focus_target(&shell, seat, &output); let target = update_focus_target(&shell, seat, &output);
@ -682,13 +677,13 @@ fn update_focus_target(
} else { } else {
let workspace = shell.active_space(output).unwrap(); let workspace = shell.active_space(output).unwrap();
if let Some(Trigger::KeyboardSwap(_, desc)) = shell.overview_mode().0.active_trigger() { if let Some(Trigger::KeyboardSwap(_, desc)) = shell.overview_mode().0.active_trigger()
if workspace.handle == desc.handle && workspace.tiling_layer.has_node(&desc.node) { && workspace.handle == desc.handle
if let Some(focus) = workspace.tiling_layer.node_desc_to_focus(desc) { && workspace.tiling_layer.has_node(&desc.node)
&& let Some(focus) = workspace.tiling_layer.node_desc_to_focus(desc)
{
return Some(focus); return Some(focus);
} }
}
}
workspace workspace
.focus_stack .focus_stack

View file

@ -271,8 +271,9 @@ fn render_input_order_internal<R: 'static>(
} }
} }
if let Some((_, has_fullscreen, offset)) = previous.as_ref() { if let Some((_, has_fullscreen, offset)) = previous.as_ref()
if !has_fullscreen { && !has_fullscreen
{
// previous bottom layer popups // previous bottom layer popups
for (layer, popup, location) in layer_popups(output, Layer::Bottom, element_filter) { for (layer, popup, location) in layer_popups(output, Layer::Bottom, element_filter) {
callback(Stage::LayerPopup { callback(Stage::LayerPopup {
@ -282,7 +283,6 @@ fn render_input_order_internal<R: 'static>(
})?; })?;
} }
} }
}
if !has_fullscreen { if !has_fullscreen {
// background layer popups // background layer popups
@ -295,11 +295,11 @@ fn render_input_order_internal<R: 'static>(
} }
} }
if let Some((_, has_fullscreen, offset)) = previous.as_ref() { if let Some((_, has_fullscreen, offset)) = previous.as_ref()
if !has_fullscreen { && !has_fullscreen
// previous background layer popups
for (layer, popup, location) in layer_popups(output, Layer::Background, element_filter)
{ {
// previous background layer popups
for (layer, popup, location) in layer_popups(output, Layer::Background, element_filter) {
callback(Stage::LayerPopup { callback(Stage::LayerPopup {
layer, layer,
popup: &popup, popup: &popup,
@ -307,7 +307,6 @@ fn render_input_order_internal<R: 'static>(
})?; })?;
} }
} }
}
if !has_focused_fullscreen { if !has_focused_fullscreen {
// top-layer shell // top-layer shell
@ -348,15 +347,15 @@ fn render_input_order_internal<R: 'static>(
} }
} }
if let Some((_, has_fullscreen, offset)) = previous.as_ref() { if let Some((_, has_fullscreen, offset)) = previous.as_ref()
if !has_fullscreen { && !has_fullscreen
{
// previous bottom layer // previous bottom layer
for (layer, mut location) in layer_surfaces(output, Layer::Bottom, element_filter) { for (layer, mut location) in layer_surfaces(output, Layer::Bottom, element_filter) {
location += offset.as_global(); location += offset.as_global();
callback(Stage::LayerSurface { layer, location })?; callback(Stage::LayerSurface { layer, location })?;
} }
} }
}
if !has_fullscreen { if !has_fullscreen {
// background layer // background layer
@ -366,15 +365,15 @@ fn render_input_order_internal<R: 'static>(
} }
} }
if let Some((_, has_fullscreen, offset)) = previous.as_ref() { if let Some((_, has_fullscreen, offset)) = previous.as_ref()
if !has_fullscreen { && !has_fullscreen
{
// previous background layer // previous background layer
for (layer, mut location) in layer_surfaces(output, Layer::Background, element_filter) { for (layer, mut location) in layer_surfaces(output, Layer::Background, element_filter) {
location += offset.as_global(); location += offset.as_global();
callback(Stage::LayerSurface { layer, location })?; callback(Stage::LayerSurface { layer, location })?;
} }
} }
}
ControlFlow::Continue(()) ControlFlow::Continue(())
} }

View file

@ -63,8 +63,9 @@ impl<G: PointerGrab<State>> PointerGrab<State> for DelayGrab<G> {
handle.motion(data, focus, event); handle.motion(data, focus, event);
let distance = self.start_data.distance(event.location); let distance = self.start_data.distance(event.location);
if distance >= 1. { if distance >= 1.
if let Some(factory) = self.grab_factory.take() { && let Some(factory) = self.grab_factory.take()
{
let serial = self.serial.unwrap_or(event.serial); let serial = self.serial.unwrap_or(event.serial);
let seat = self.seat.clone(); let seat = self.seat.clone();
data.common.event_loop_handle.insert_idle(move |data| { data.common.event_loop_handle.insert_idle(move |data| {
@ -76,7 +77,6 @@ impl<G: PointerGrab<State>> PointerGrab<State> for DelayGrab<G> {
}); });
} }
} }
}
fn relative_motion( fn relative_motion(
&mut self, &mut self,
@ -232,8 +232,9 @@ impl<G: TouchGrab<State>> TouchGrab<State> for DelayGrab<G> {
handle.motion(data, focus, event, seq); handle.motion(data, focus, event, seq);
let distance = self.start_data.distance(event.location); let distance = self.start_data.distance(event.location);
if distance >= 1. { if distance >= 1.
if let Some(factory) = self.grab_factory.take() { && let Some(factory) = self.grab_factory.take()
{
let seat = self.seat.clone(); let seat = self.seat.clone();
let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()); let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial());
data.common.event_loop_handle.insert_idle(move |data| { data.common.event_loop_handle.insert_idle(move |data| {
@ -243,7 +244,6 @@ impl<G: TouchGrab<State>> TouchGrab<State> for DelayGrab<G> {
}); });
} }
} }
}
fn frame(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, seq: Serial) { fn frame(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, seq: Serial) {
handle.frame(data, seq) handle.frame(data, seq)

View file

@ -260,8 +260,9 @@ impl Program for ContextMenu {
// But right now we don't have any touch responsive menus with submenus // But right now we don't have any touch responsive menus with submenus
} }
Message::ItemEntered(idx, bounds) => { Message::ItemEntered(idx, bounds) => {
if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx) { if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx)
if let Some((seat, _)) = last_seat.cloned() { && let Some((seat, _)) = last_seat.cloned()
{
let items = items.clone(); let items = items.clone();
let _ = loop_handle.insert_idle(move |state| { let _ = loop_handle.insert_idle(move |state| {
let grab_state = seat let grab_state = seat
@ -304,16 +305,14 @@ impl Program for ContextMenu {
position position
+ Point::from(( + Point::from((
bounds.width.ceil() as i32, bounds.width.ceil() as i32,
bounds.y.ceil() as i32 bounds.y.ceil() as i32 + bounds.height.ceil() as i32
+ bounds.height.ceil() as i32
- min_size.h, - min_size.h,
)), )),
min_size.as_global(), min_size.as_global(),
), ),
// to the left -> down // to the left -> down
Rectangle::new( Rectangle::new(
position position + Point::from((-min_size.w, bounds.y.ceil() as i32)),
+ Point::from((-min_size.w, bounds.y.ceil() as i32)),
min_size.as_global(), min_size.as_global(),
), ),
// to the left -> up // to the left -> up
@ -321,8 +320,7 @@ impl Program for ContextMenu {
position position
+ Point::from(( + Point::from((
-min_size.w, -min_size.w,
bounds.y.ceil() as i32 bounds.y.ceil() as i32 + bounds.height.ceil() as i32
+ bounds.height.ceil() as i32
- min_size.h, - min_size.h,
)), )),
min_size.as_global(), min_size.as_global(),
@ -351,10 +349,10 @@ impl Program for ContextMenu {
}); });
} }
} }
}
Message::ItemLeft(idx, _) => { Message::ItemLeft(idx, _) => {
if let Some(Item::Submenu { .. }) = self.items.get_mut(idx) { if let Some(Item::Submenu { .. }) = self.items.get_mut(idx)
if let Some((seat, _)) = last_seat.cloned() { && let Some((seat, _)) = last_seat.cloned()
{
let _ = loop_handle.insert_idle(move |_| { let _ = loop_handle.insert_idle(move |_| {
let grab_state = seat let grab_state = seat
.user_data() .user_data()
@ -370,7 +368,6 @@ impl Program for ContextMenu {
}); });
} }
} }
}
}; };
Task::none() Task::none()

View file

@ -862,8 +862,9 @@ impl Drop for MoveGrab {
window_location.to_local(&workspace.output), window_location.to_local(&workspace.output),
); );
if matches!(previous, ManagedLayer::Floating) { if matches!(previous, ManagedLayer::Floating)
if let Some(sz) = grab_state.snapping_zone { && let Some(sz) = grab_state.snapping_zone
{
if sz == SnappingZone::Maximize { if sz == SnappingZone::Maximize {
shell.maximize_toggle( shell.maximize_toggle(
&window, &window,
@ -901,7 +902,6 @@ impl Drop for MoveGrab {
} }
} }
} }
}
Some((window, location.to_global(&output))) Some((window, location.to_global(&output)))
} }
} }

View file

@ -525,11 +525,11 @@ impl ResizeSurfaceGrab {
}; };
// Finish resizing. // Finish resizing.
if let Some(ResizeState::WaitingForCommit(_)) = *resize_state { if let Some(ResizeState::WaitingForCommit(_)) = *resize_state
if !window.is_resizing(false).unwrap_or(false) { && !window.is_resizing(false).unwrap_or(false)
{
*resize_state = None; *resize_state = None;
} }
}
std::mem::drop(resize_state); std::mem::drop(resize_state);
if let Some(new_location) = new_location { if let Some(new_location) = new_location {

View file

@ -385,13 +385,12 @@ impl FloatingLayout {
} else { } else {
self.animations.remove(&mapped); self.animations.remove(&mapped);
} }
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() { && let Some(state) = mapped.maximized_state.lock().unwrap().as_mut()
if let Some(real_old_geo) = *mapped.last_geometry.lock().unwrap() { && let Some(real_old_geo) = *mapped.last_geometry.lock().unwrap()
{
state.original_geometry = real_old_geo; state.original_geometry = real_old_geo;
}
}; };
}
self.space self.space
.map_element(mapped, geometry.loc.as_logical(), true); .map_element(mapped, geometry.loc.as_logical(), true);
self.space.refresh(); self.space.refresh();
@ -683,11 +682,11 @@ impl FloatingLayout {
mapped_geometry.size = last_size; mapped_geometry.size = last_size;
} }
} else if !window.is_maximized(true) { } else if !window.is_maximized(true) {
if window.active_window().has_pending_changes() { if window.active_window().has_pending_changes()
if let Some(pending_size) = window.pending_size() { && let Some(pending_size) = window.pending_size()
{
mapped_geometry.size = pending_size.as_local(); mapped_geometry.size = pending_size.as_local();
} }
}
*window.last_geometry.lock().unwrap() = Some(mapped_geometry); *window.last_geometry.lock().unwrap() = Some(mapped_geometry);
} }

View file

@ -452,8 +452,8 @@ impl TilingLayout {
mut sizes, mut sizes,
}) = tiling_state }) = tiling_state
{ {
if let Some(node) = parent.as_ref().and_then(|parent| tree.get_mut(parent).ok()) { if let Some(node) = parent.as_ref().and_then(|parent| tree.get_mut(parent).ok())
if let Data::Group { && let Data::Group {
orientation: current_orientation, orientation: current_orientation,
sizes: current_sizes, sizes: current_sizes,
.. ..
@ -461,8 +461,7 @@ impl TilingLayout {
{ {
let parent_id = parent.unwrap(); let parent_id = parent.unwrap();
if *current_orientation == orientation && sizes.len() == current_sizes.len() + 1 if *current_orientation == orientation && sizes.len() == current_sizes.len() + 1 {
{
let previous_length: i32 = sizes.iter().copied().sum(); let previous_length: i32 = sizes.iter().copied().sum();
let new_length: i32 = current_sizes.iter().copied().sum(); let new_length: i32 = current_sizes.iter().copied().sum();
if previous_length != new_length { if previous_length != new_length {
@ -499,7 +498,6 @@ impl TilingLayout {
.push_tree(tree, MINIMIZE_ANIMATION_DURATION, blocker); .push_tree(tree, MINIMIZE_ANIMATION_DURATION, blocker);
return; return;
} }
}
if sibling if sibling
.as_ref() .as_ref()
@ -1414,8 +1412,8 @@ impl TilingLayout {
let tiling_node_id = mapped.tiling_node_id.lock().unwrap().as_ref().cloned(); let tiling_node_id = mapped.tiling_node_id.lock().unwrap().as_ref().cloned();
let gaps = self.gaps(); let gaps = self.gaps();
if let Some(node_id) = tiling_node_id { if let Some(node_id) = tiling_node_id
if self && self
.queue .queue
.trees .trees
.back() .back()
@ -1439,7 +1437,6 @@ impl TilingLayout {
return true; return true;
} }
}
false false
} }
@ -1742,7 +1739,7 @@ impl TilingLayout {
_ => { _ => {
// we want the middle // we want the middle
let group_len = tree.get(&next_child_id).unwrap().data().len(); let group_len = tree.get(&next_child_id).unwrap().data().len();
if group_len % 2 == 0 { if group_len.is_multiple_of(2) {
tree.make_nth_sibling(&node_id, group_len / 2).unwrap(); tree.make_nth_sibling(&node_id, group_len / 2).unwrap();
tree.get_mut(&next_child_id) tree.get_mut(&next_child_id)
.unwrap() .unwrap()
@ -1965,8 +1962,8 @@ impl TilingLayout {
if focus_subtree.is_some() { if focus_subtree.is_some() {
let mut node_id = focus_subtree; let mut node_id = focus_subtree;
while node_id.is_some() { while node_id.is_some() {
if let Some(desc) = swap_desc.as_ref() { if let Some(desc) = swap_desc.as_ref()
if let Some(replacement_id) = tree && let Some(replacement_id) = tree
.ancestor_ids(node_id.unwrap()) .ancestor_ids(node_id.unwrap())
.unwrap() .unwrap()
.find(|anchestor| *anchestor == &desc.node) .find(|anchestor| *anchestor == &desc.node)
@ -2000,7 +1997,6 @@ impl TilingLayout {
_ => unreachable!(), _ => unreachable!(),
}; };
} }
}
match tree.get(node_id.unwrap()).unwrap().data() { match tree.get(node_id.unwrap()).unwrap().data() {
Data::Group { orientation, .. } if orientation == &main_orientation => { Data::Group { orientation, .. } if orientation == &main_orientation => {
@ -2098,9 +2094,9 @@ impl TilingLayout {
}; };
let mut tree = self.queue.trees.back().unwrap().0.copy_clone(); let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
if let Some((last_active, _)) = TilingLayout::currently_focused_node(&tree, target) { if let Some((last_active, _)) = TilingLayout::currently_focused_node(&tree, target)
if let Some(group) = tree.get(&last_active).unwrap().parent().cloned() { && let Some(group) = tree.get(&last_active).unwrap().parent().cloned()
if let &mut Data::Group { && let &mut Data::Group {
ref mut orientation, ref mut orientation,
ref mut sizes, ref mut sizes,
ref last_geometry, ref last_geometry,
@ -2118,8 +2114,8 @@ impl TilingLayout {
}; };
sizes.iter_mut().for_each(|len| { sizes.iter_mut().for_each(|len| {
*len = (((*len as f64) / (previous_length as f64)) * (new_length as f64)) *len = (((*len as f64) / (previous_length as f64)) * (new_length as f64)).round()
.round() as i32; as i32;
}); });
let sum: i32 = sizes.iter().sum(); let sum: i32 = sizes.iter().sum();
if sum < new_length { if sum < new_length {
@ -2132,8 +2128,6 @@ impl TilingLayout {
self.queue.push_tree(tree, ANIMATION_DURATION, blocker); self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
} }
} }
}
}
pub fn toggle_stacking( pub fn toggle_stacking(
&mut self, &mut self,
@ -3371,8 +3365,8 @@ impl TilingLayout {
if matches!( if matches!(
overview.active_trigger(), overview.active_trigger(),
Some(Trigger::Pointer(_) | Trigger::Touch(_)) Some(Trigger::Pointer(_) | Trigger::Touch(_))
) { ) && location_f64.is_some()
if location_f64.is_some() { {
let mut tree = tree.copy_clone(); let mut tree = tree.copy_clone();
tree.insert( tree.insert(
Node::new(Data::Placeholder { Node::new(Data::Placeholder {
@ -3386,7 +3380,6 @@ impl TilingLayout {
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps); let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
self.queue.push_tree(tree, ANIMATION_DURATION, blocker); self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
} }
}
return; return;
}; };
@ -4626,8 +4619,9 @@ where
geo.loc += (gap, gap).into(); geo.loc += (gap, gap).into();
geo.size -= (gap * 2, gap * 2).into(); geo.size -= (gap * 2, gap * 2).into();
if mouse_tiling.is_some() { if mouse_tiling.is_some()
if let Some(PillIndicator::Outer(direction)) = pill_indicator { && let Some(PillIndicator::Outer(direction)) = pill_indicator
{
let (pill_geo, remaining_geo) = match direction { let (pill_geo, remaining_geo) = match direction {
Direction::Left => ( Direction::Left => (
Rectangle::new( Rectangle::new(
@ -4681,7 +4675,6 @@ where
geo = remaining_geo; geo = remaining_geo;
}; };
}
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() {
@ -4758,8 +4751,9 @@ where
(geo.loc.x, geo.loc.y + previous).into(), (geo.loc.x, geo.loc.y + previous).into(),
(geo.size.w, *size).into(), (geo.size.w, *size).into(),
); );
if mouse_tiling.is_some() { if mouse_tiling.is_some()
if let Some(PillIndicator::Inner(pill_idx)) = pill_indicator { && let Some(PillIndicator::Inner(pill_idx)) = pill_indicator
{
if *pill_idx == idx { if *pill_idx == idx {
geo.size.h -= 32; geo.size.h -= 32;
} }
@ -4788,7 +4782,6 @@ where
geo.size.h -= 32; geo.size.h -= 32;
} }
} }
}
stack.push((geo, depth + 1)); stack.push((geo, depth + 1));
} }
} }
@ -4800,8 +4793,9 @@ where
(geo.loc.x + previous, geo.loc.y).into(), (geo.loc.x + previous, geo.loc.y).into(),
(*size, geo.size.h).into(), (*size, geo.size.h).into(),
); );
if mouse_tiling.is_some() { if mouse_tiling.is_some()
if let Some(PillIndicator::Inner(pill_idx)) = pill_indicator { && let Some(PillIndicator::Inner(pill_idx)) = pill_indicator
{
if *pill_idx == idx { if *pill_idx == idx {
geo.size.w -= 32; geo.size.w -= 32;
} }
@ -4830,7 +4824,6 @@ where
geo.size.w -= 32; geo.size.w -= 32;
} }
} }
}
stack.push((geo, depth + 1)); stack.push((geo, depth + 1));
} }
} }
@ -5102,10 +5095,7 @@ where
}, },
); );
shadow_elements shadow_elements.into_iter().chain(elements).collect()
.into_iter()
.chain(elements.into_iter())
.collect()
} }
fn render_old_tree( fn render_old_tree(
@ -5518,8 +5508,8 @@ where
.unwrap_or(false) .unwrap_or(false)
}) })
.unwrap_or(false)) .unwrap_or(false))
&& let Some(swap) = swap_indicator.as_ref()
{ {
if let Some(swap) = swap_indicator.as_ref() {
swap.resize(geo.size.as_logical()); swap.resize(geo.size.as_logical());
swap.output_enter(output, output_geo.as_logical()); swap.output_enter(output, output_geo.as_logical());
swap_elements.extend( swap_elements.extend(
@ -5534,7 +5524,6 @@ where
); );
} }
} }
}
if let Some((mode, resize)) = resize_indicator.as_mut() { if let Some((mode, resize)) = resize_indicator.as_mut() {
let mut geo = geo; let mut geo = geo;
@ -5716,7 +5705,7 @@ where
.into_iter() .into_iter()
.flatten() .flatten()
.chain(swap_elements) .chain(swap_elements)
.chain(indicators.into_iter().map(Into::into)) .chain(indicators)
.chain(window_elements) .chain(window_elements)
.chain(animating_window_elements) .chain(animating_window_elements)
.chain(shadow_elements) .chain(shadow_elements)
@ -5858,11 +5847,11 @@ fn render_new_tree(
(new_geo, percentage, false) (new_geo, percentage, false)
}; };
if let Data::Mapped { mapped, .. } = data { if let Data::Mapped { mapped, .. } = data
if mapped.is_maximized(false) { && mapped.is_maximized(false)
{
return; return;
} }
}
processor(node_id, data, geo, original_geo, alpha, animating) processor(node_id, data, geo, original_geo, alpha, animating)
}); });
} }

View file

@ -479,7 +479,7 @@ impl WorkspaceSet {
appearance: AppearanceConfig, appearance: AppearanceConfig,
) -> WorkspaceSet { ) -> WorkspaceSet {
let group_handle = state.create_workspace_group(); let group_handle = state.create_workspace_group();
let sticky_layer = FloatingLayout::new(theme.clone(), appearance.clone(), output); let sticky_layer = FloatingLayout::new(theme.clone(), appearance, output);
WorkspaceSet { WorkspaceSet {
previously_active: None, previously_active: None,
@ -753,7 +753,7 @@ impl Workspaces {
autotile: config.cosmic_conf.autotile, autotile: config.cosmic_conf.autotile,
autotile_behavior: config.cosmic_conf.autotile_behavior, autotile_behavior: config.cosmic_conf.autotile_behavior,
theme, theme,
appearance: config.cosmic_conf.appearance_settings.clone(), appearance: config.cosmic_conf.appearance_settings,
persisted_workspaces: config.cosmic_conf.pinned_workspaces.clone(), persisted_workspaces: config.cosmic_conf.pinned_workspaces.clone(),
} }
} }
@ -1462,7 +1462,7 @@ impl Common {
let mut shell = self.shell.write(); let mut shell = self.shell.write();
let shell_ref = &mut *shell; let shell_ref = &mut *shell;
shell_ref.active_hint = self.config.cosmic_conf.active_hint; shell_ref.active_hint = self.config.cosmic_conf.active_hint;
shell_ref.appearance_conf = self.config.cosmic_conf.appearance_settings.clone(); shell_ref.appearance_conf = self.config.cosmic_conf.appearance_settings;
if let Some(zoom_state) = shell_ref.zoom_state.as_mut() { if let Some(zoom_state) = shell_ref.zoom_state.as_mut() {
zoom_state.increment = self.config.cosmic_conf.accessibility_zoom.increment; zoom_state.increment = self.config.cosmic_conf.accessibility_zoom.increment;
zoom_state.movement = self.config.cosmic_conf.accessibility_zoom.view_moves; zoom_state.movement = self.config.cosmic_conf.accessibility_zoom.view_moves;
@ -1519,14 +1519,14 @@ impl Common {
let shell = self.shell.read(); let shell = self.shell.read();
for seat in shell.seats.iter() { for seat in shell.seats.iter() {
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() { if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() { && let Some(grab_state) = move_grab.lock().unwrap().as_ref()
{
let mapped = grab_state.element(); let mapped = grab_state.element();
if mapped.active_window().wl_surface().as_deref() == Some(surface) { if mapped.active_window().wl_surface().as_deref() == Some(surface) {
mapped.on_commit(surface); mapped.on_commit(surface);
} }
} }
}
data_device::on_commit(surface, seat); data_device::on_commit(surface, seat);
} }
@ -1595,7 +1595,7 @@ impl Shell {
resize_mode: ResizeMode::None, resize_mode: ResizeMode::None,
resize_state: None, resize_state: None,
resize_indicator: None, resize_indicator: None,
appearance_conf: config.cosmic_conf.appearance_settings.clone(), appearance_conf: config.cosmic_conf.appearance_settings,
zoom_state: None, zoom_state: None,
tiling_exceptions, tiling_exceptions,
@ -1972,14 +1972,15 @@ impl Shell {
.filter(|seat| seat.active_output() == **o) .filter(|seat| seat.active_output() == **o)
.any(|seat| { .any(|seat| {
let cursor_status = seat.cursor_image_status(); let cursor_status = seat.cursor_image_status();
if let CursorImageStatus::Surface(s) = cursor_status { if let CursorImageStatus::Surface(s) = cursor_status
if s == *surface { && s == *surface
{
return true; return true;
} }
}
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() { if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() { && let Some(grab_state) = move_grab.lock().unwrap().as_ref()
{
for (window, _) in grab_state.element().windows() { for (window, _) in grab_state.element().windows() {
let mut matches = false; let mut matches = false;
window.0.with_surfaces(|s, _| { window.0.with_surfaces(|s, _| {
@ -1990,7 +1991,6 @@ impl Shell {
} }
} }
} }
}
get_dnd_icon(seat).is_some_and(|icon| icon.surface == *surface) get_dnd_icon(seat).is_some_and(|icon| icon.surface == *surface)
}) })
@ -2216,19 +2216,19 @@ impl Shell {
} }
pub fn overview_mode(&self) -> (OverviewMode, Option<SwapIndicator>) { pub fn overview_mode(&self) -> (OverviewMode, Option<SwapIndicator>) {
if let OverviewMode::Started(trigger, timestamp) = &self.overview_mode { if let OverviewMode::Started(trigger, timestamp) = &self.overview_mode
if Instant::now().duration_since(*timestamp) > ANIMATION_DURATION { && Instant::now().duration_since(*timestamp) > ANIMATION_DURATION
{
return ( return (
OverviewMode::Active(trigger.clone()), OverviewMode::Active(trigger.clone()),
self.swap_indicator.clone(), self.swap_indicator.clone(),
); );
} }
} if let OverviewMode::Ended(_, timestamp) = &self.overview_mode
if let OverviewMode::Ended(_, timestamp) = &self.overview_mode { && Instant::now().duration_since(*timestamp) > ANIMATION_DURATION
if Instant::now().duration_since(*timestamp) > ANIMATION_DURATION { {
return (OverviewMode::None, None); return (OverviewMode::None, None);
} }
}
(self.overview_mode.clone(), self.swap_indicator.clone()) (self.overview_mode.clone(), self.swap_indicator.clone())
} }
@ -2261,19 +2261,19 @@ impl Shell {
} }
pub fn resize_mode(&self) -> (ResizeMode, Option<ResizeIndicator>) { pub fn resize_mode(&self) -> (ResizeMode, Option<ResizeIndicator>) {
if let ResizeMode::Started(binding, timestamp, direction) = &self.resize_mode { if let ResizeMode::Started(binding, timestamp, direction) = &self.resize_mode
if Instant::now().duration_since(*timestamp) > ANIMATION_DURATION { && Instant::now().duration_since(*timestamp) > ANIMATION_DURATION
{
return ( return (
ResizeMode::Active(binding.clone(), *direction), ResizeMode::Active(binding.clone(), *direction),
self.resize_indicator.clone(), self.resize_indicator.clone(),
); );
} }
} if let ResizeMode::Ended(timestamp, _) = self.resize_mode
if let ResizeMode::Ended(timestamp, _) = self.resize_mode { && Instant::now().duration_since(timestamp) > ANIMATION_DURATION
if Instant::now().duration_since(timestamp) > ANIMATION_DURATION { {
return (ResizeMode::None, None); return (ResizeMode::None, None);
} }
}
(self.resize_mode.clone(), self.resize_indicator.clone()) (self.resize_mode.clone(), self.resize_indicator.clone())
} }
@ -2299,7 +2299,7 @@ impl Shell {
} }
pub fn appearance_config(&self) -> AppearanceConfig { pub fn appearance_config(&self) -> AppearanceConfig {
self.appearance_conf.clone() self.appearance_conf
} }
pub fn trigger_zoom( pub fn trigger_zoom(
@ -2333,11 +2333,11 @@ impl Shell {
} }
let mut toggled = self.zoom_state.is_none(); let mut toggled = self.zoom_state.is_none();
if let Some(old_state) = self.zoom_state.as_ref() { if let Some(old_state) = self.zoom_state.as_ref()
if &old_state.seat != seat { && &old_state.seat != seat
{
return; return;
} }
}
for output in &outputs { for output in &outputs {
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap(); let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
@ -2766,19 +2766,17 @@ impl Shell {
} }
let maybe_focused = workspace.focus_stack.get(&seat).iter().next().cloned(); let maybe_focused = workspace.focus_stack.get(&seat).iter().next().cloned();
if let Some(FocusTarget::Window(focused)) = maybe_focused { if let Some(FocusTarget::Window(focused)) = maybe_focused
if (focused.is_stack() && !is_dialog && !should_be_maximized) && (focused.is_stack() && !is_dialog && !should_be_maximized)
&& !(workspace.is_tiled(&focused.active_window()) && floating_exception) && !(workspace.is_tiled(&focused.active_window()) && floating_exception)
{ {
focused.stack_ref().unwrap().add_window(window, None, None); focused.stack_ref().unwrap().add_window(window, None, None);
if was_activated { if was_activated {
workspace_state.add_workspace_state(&workspace_handle, WState::Urgent); workspace_state.add_workspace_state(&workspace_handle, WState::Urgent);
} }
return (workspace_output == seat.active_output() return (workspace_output == seat.active_output() && active_handle == workspace_handle)
&& active_handle == workspace_handle)
.then_some(KeyboardFocusTarget::Element(focused)); .then_some(KeyboardFocusTarget::Element(focused));
} }
}
let mapped = CosmicMapped::from(CosmicWindow::new( let mapped = CosmicMapped::from(CosmicWindow::new(
window.clone(), window.clone(),
@ -3026,8 +3024,9 @@ impl Shell {
let spaces = self.workspaces.spaces_mut(); let spaces = self.workspaces.spaces_mut();
let (mut from_w, mut other_w) = spaces.partition::<Vec<_>, _>(|w| w.handle == from); let (mut from_w, mut other_w) = spaces.partition::<Vec<_>, _>(|w| w.handle == from);
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) { && 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| {
@ -3082,7 +3081,6 @@ impl Shell {
return Ok(res.zip(new_pos)); return Ok(res.zip(new_pos));
} }
}
Ok(None) Ok(None)
} }
@ -3155,14 +3153,12 @@ impl Shell {
was_maximized: previous.was_maximized(), was_maximized: previous.was_maximized(),
}, },
}; };
} else { } else if let FullscreenRestoreState::Tiling { workspace, .. }
if let FullscreenRestoreState::Tiling { workspace, .. }
| FullscreenRestoreState::Floating { workspace, .. } = previous | FullscreenRestoreState::Floating { workspace, .. } = previous
{ {
*workspace = *to; *workspace = *to;
} }
} }
}
if is_minimized { if is_minimized {
let to_workspace = self.workspaces.space_for_handle_mut(to).unwrap(); // checked above let to_workspace = self.workspaces.space_for_handle_mut(to).unwrap(); // checked above
@ -3408,8 +3404,8 @@ impl Shell {
} }
pub fn update_reactive_popups(&self, mapped: &CosmicMapped) { pub fn update_reactive_popups(&self, mapped: &CosmicMapped) {
if let Some(workspace) = self.space_for(mapped) { if let Some(workspace) = self.space_for(mapped)
if let Some(element_loc) = workspace && let Some(element_loc) = workspace
.element_geometry(mapped) .element_geometry(mapped)
.map(|geo| geo.loc.to_global(&workspace.output)) .map(|geo| geo.loc.to_global(&workspace.output))
{ {
@ -3425,7 +3421,6 @@ impl Shell {
} }
} }
} }
}
pub fn menu_request( pub fn menu_request(
&self, &self,
@ -3744,13 +3739,12 @@ impl Shell {
None None
}; };
if mapped == old_mapped { if mapped == old_mapped
if let Some(geo) = sticky_layer.unmap(&mapped, None) { && let Some(geo) = sticky_layer.unmap(&mapped, None)
if geo.size != elem_geo.size { && geo.size != elem_geo.size
{
new_size = Some(geo.size.as_logical()); new_size = Some(geo.size.as_logical());
} }
}
}
if let Some(new_size) = new_size { if let Some(new_size) = new_size {
let ratio = let ratio =
@ -4404,18 +4398,19 @@ impl Shell {
.resize(&focused, direction, edge, amount) .resize(&focused, direction, edge, amount)
{ {
self.resize_state = Some((focused, direction, edge, amount, idx, output)); self.resize_state = Some((focused, direction, edge, amount, idx, output));
} else if let Some(workspace) = self.workspaces.get_mut(idx, &output) { } else if let Some(workspace) = self.workspaces.get_mut(idx, &output)
if workspace.resize(&focused, direction, edge, amount) { && workspace.resize(&focused, direction, edge, amount)
{
self.resize_state = Some((focused, direction, edge, amount, idx, output)); self.resize_state = Some((focused, direction, edge, amount, idx, output));
} }
} }
}
pub fn finish_resize(&mut self, direction: ResizeDirection, edge: ResizeEdge) { pub fn finish_resize(&mut self, direction: ResizeDirection, edge: ResizeEdge) {
if let Some((old_focused, old_direction, old_edge, _, idx, output)) = if let Some((old_focused, old_direction, old_edge, _, idx, output)) =
self.resize_state.take() self.resize_state.take()
&& old_direction == direction
&& old_edge == edge
{ {
if old_direction == direction && old_edge == edge {
let Some(toplevel) = old_focused.toplevel() else { let Some(toplevel) = old_focused.toplevel() else {
return; return;
}; };
@ -4447,7 +4442,6 @@ impl Shell {
} }
} }
} }
}
#[must_use] #[must_use]
pub fn toggle_stacking( pub fn toggle_stacking(
@ -4520,11 +4514,9 @@ impl Shell {
None None
}; };
if was_maximized { if was_maximized && let Some(KeyboardFocusTarget::Element(mapped)) = res.as_ref() {
if let Some(KeyboardFocusTarget::Element(mapped)) = res.as_ref() {
self.maximize_request(mapped, seat, false, loop_handle); self.maximize_request(mapped, seat, false, loop_handle);
} }
}
res res
} else { } else {

View file

@ -112,13 +112,13 @@ impl Devices {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
map.insert(id, caps); map.insert(id, caps);
if device.has_capability(DeviceCapability::Keyboard) { if device.has_capability(DeviceCapability::Keyboard)
if let Some(device) = <dyn Any>::downcast_ref::<InputDevice>(device) { && let Some(device) = <dyn Any>::downcast_ref::<InputDevice>(device)
{
let mut device = device.clone(); let mut device = device.clone();
device.led_update(led_state.into()); device.led_update(led_state.into());
self.keyboards.borrow_mut().push(device); self.keyboards.borrow_mut().push(device);
} }
}
new_caps new_caps
} }
@ -385,11 +385,11 @@ impl SeatExt for Seat<State> {
let lock = self.user_data().get::<Mutex<CursorImageStatus>>().unwrap(); let lock = self.user_data().get::<Mutex<CursorImageStatus>>().unwrap();
// Reset the cursor if the surface is no longer alive // Reset the cursor if the surface is no longer alive
let mut cursor_status = lock.lock().unwrap(); let mut cursor_status = lock.lock().unwrap();
if let CursorImageStatus::Surface(ref surface) = *cursor_status { if let CursorImageStatus::Surface(ref surface) = *cursor_status
if !surface.alive() { && !surface.alive()
{
*cursor_status = CursorImageStatus::default_named(); *cursor_status = CursorImageStatus::default_named();
} }
}
cursor_status.clone() cursor_status.clone()
} }

View file

@ -487,11 +487,9 @@ impl Workspace {
.unwrap() .unwrap()
.lock() .lock()
.unwrap(); .unwrap();
let move_mapped = if let Some(move_grab_state) = &*move_grab_state { let move_mapped = (*move_grab_state)
Some(move_grab_state.element()) .as_ref()
} else { .map(|move_grab_state| move_grab_state.element());
None
};
let mapped = || { let mapped = || {
self.floating_layer self.floating_layer
@ -640,7 +638,7 @@ impl Workspace {
}))); })));
} }
let was_snapped = mapped.floating_tiled.lock().unwrap().clone(); let was_snapped = *mapped.floating_tiled.lock().unwrap();
// 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) {
@ -695,8 +693,9 @@ impl Workspace {
let mapped = self.element_for_surface(surface)?; let mapped = self.element_for_surface(surface)?;
let maybe_stack = mapped.stack_ref().filter(|s| s.len() > 1); let maybe_stack = mapped.stack_ref().filter(|s| s.len() > 1);
if let Some(stack) = maybe_stack { if let Some(stack) = maybe_stack
if stack.len() > 1 { && stack.len() > 1
{
let idx = stack.surfaces().position(|s| &s == surface); let idx = stack.surfaces().position(|s| &s == surface);
let layer = if self.is_tiled(surface) { let layer = if self.is_tiled(surface) {
ManagedLayer::Tiling ManagedLayer::Tiling
@ -707,7 +706,6 @@ impl Workspace {
.and_then(|idx| stack.remove_idx(idx)) .and_then(|idx| stack.remove_idx(idx))
.map(|s| (s, layer.into())); .map(|s| (s, layer.into()));
} }
}
// we know mapped is no stack with more than one element now, // we know mapped is no stack with more than one element now,
// so we can treat mapped as containing only our surface. // so we can treat mapped as containing only our surface.
@ -774,26 +772,26 @@ impl Workspace {
let stack = self.focus_stack.get(seat); let stack = self.focus_stack.get(seat);
let last_focused = stack.last(); let last_focused = stack.last();
if let Some(fullscreen) = self.fullscreen.as_ref() { if let Some(fullscreen) = self.fullscreen.as_ref()
if last_focused.is_some_and( && last_focused.is_some_and(
|t| matches!(t, FocusTarget::Fullscreen(f) if f == &fullscreen.surface), |t| matches!(t, FocusTarget::Fullscreen(f) if f == &fullscreen.surface),
) && !fullscreen.is_animating() )
&& !fullscreen.is_animating()
{ {
let geometry = self.fullscreen_geometry().unwrap(); let geometry = self.fullscreen_geometry().unwrap();
return fullscreen_element_under(fullscreen, geometry); return fullscreen_element_under(fullscreen, geometry);
} }
}
self.floating_layer self.floating_layer
.popup_element_under(location) .popup_element_under(location)
.or_else(|| self.tiling_layer.popup_element_under(location)) .or_else(|| self.tiling_layer.popup_element_under(location))
.or_else(|| { .or_else(|| {
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_))) { if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_)))
if let Some(fullscreen) = self.fullscreen.as_ref() { && let Some(fullscreen) = self.fullscreen.as_ref()
{
let geometry = self.fullscreen_geometry().unwrap(); let geometry = self.fullscreen_geometry().unwrap();
return fullscreen_element_under(fullscreen, geometry); return fullscreen_element_under(fullscreen, geometry);
} }
}
None None
}) })
} }
@ -824,26 +822,26 @@ impl Workspace {
let stack = self.focus_stack.get(seat); let stack = self.focus_stack.get(seat);
let last_focused = stack.last(); let last_focused = stack.last();
if let Some(fullscreen) = self.fullscreen.as_ref() { if let Some(fullscreen) = self.fullscreen.as_ref()
if last_focused.is_some_and( && last_focused.is_some_and(
|t| matches!(t, FocusTarget::Fullscreen(f) if f == &fullscreen.surface), |t| matches!(t, FocusTarget::Fullscreen(f) if f == &fullscreen.surface),
) && !fullscreen.is_animating() )
&& !fullscreen.is_animating()
{ {
let geometry = self.fullscreen_geometry().unwrap(); let geometry = self.fullscreen_geometry().unwrap();
return fullscreen_element_under(fullscreen, geometry); return fullscreen_element_under(fullscreen, geometry);
} }
}
self.floating_layer self.floating_layer
.toplevel_element_under(location) .toplevel_element_under(location)
.or_else(|| self.tiling_layer.toplevel_element_under(location)) .or_else(|| self.tiling_layer.toplevel_element_under(location))
.or_else(|| { .or_else(|| {
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_))) { if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_)))
if let Some(fullscreen) = self.fullscreen.as_ref() { && let Some(fullscreen) = self.fullscreen.as_ref()
{
let geometry = self.fullscreen_geometry().unwrap(); let geometry = self.fullscreen_geometry().unwrap();
return fullscreen_element_under(fullscreen, geometry); return fullscreen_element_under(fullscreen, geometry);
} }
}
None None
}) })
} }
@ -1071,7 +1069,7 @@ impl Workspace {
mapped.set_minimized(true); mapped.set_minimized(true);
mapped.configure(); mapped.configure();
let was_snapped = mapped.floating_tiled.lock().unwrap().clone(); let was_snapped = *mapped.floating_tiled.lock().unwrap();
if let Some(geometry) = self.floating_layer.unmap(&mapped, Some(to)) { if let Some(geometry) = self.floating_layer.unmap(&mapped, Some(to)) {
return Some(MinimizedWindow::Floating { return Some(MinimizedWindow::Floating {
window: mapped, window: mapped,

View file

@ -232,24 +232,24 @@ impl ZoomState {
let active_output = self.seat.active_output(); let active_output = self.seat.active_output();
let output = output.unwrap_or(&active_output); let output = output.unwrap_or(&active_output);
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap(); let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
let res = output_state
output_state
.lock() .lock()
.unwrap() .unwrap()
.animating_focal_point() .animating_focal_point()
.to_global(output); .to_global(output)
res
} }
pub fn current_focal_point(&self, output: Option<&Output>) -> Point<f64, Global> { pub fn current_focal_point(&self, output: Option<&Output>) -> Point<f64, Global> {
let active_output = self.seat.active_output(); let active_output = self.seat.active_output();
let output = output.unwrap_or(&active_output); let output = output.unwrap_or(&active_output);
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap(); let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
let res = output_state
output_state
.lock() .lock()
.unwrap() .unwrap()
.current_focal_point() .current_focal_point()
.to_global(output); .to_global(output)
res
} }
pub fn update_focal_point( pub fn update_focal_point(

View file

@ -655,9 +655,9 @@ impl State {
let cosmic_image_capture_source_state = let cosmic_image_capture_source_state =
CosmicImageCaptureSourceState::new::<Self, _>(dh, client_not_sandboxed); CosmicImageCaptureSourceState::new::<Self, _>(dh, client_not_sandboxed);
let output_capture_source_state = let output_capture_source_state =
OutputCaptureSourceState::new_with_filter::<State, _>(&dh, client_not_sandboxed); OutputCaptureSourceState::new_with_filter::<State, _>(dh, client_not_sandboxed);
let toplevel_capture_source_state = let toplevel_capture_source_state =
ToplevelCaptureSourceState::new_with_filter::<State, _>(&dh, client_not_sandboxed); ToplevelCaptureSourceState::new_with_filter::<State, _>(dh, client_not_sandboxed);
let image_copy_capture_state = let image_copy_capture_state =
ImageCopyCaptureState::new_with_filter::<Self, _>(dh, client_not_sandboxed); ImageCopyCaptureState::new_with_filter::<Self, _>(dh, client_not_sandboxed);
let shm_state = let shm_state =
@ -681,7 +681,7 @@ impl State {
VirtualKeyboardManagerState::new::<State, _>(dh, client_not_sandboxed); VirtualKeyboardManagerState::new::<State, _>(dh, client_not_sandboxed);
AlphaModifierState::new::<Self>(dh); AlphaModifierState::new::<Self>(dh);
SinglePixelBufferState::new::<Self>(dh); SinglePixelBufferState::new::<Self>(dh);
FixesState::new::<Self>(&dh); FixesState::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);
@ -954,11 +954,11 @@ impl Common {
}; };
// lock surface // lock surface
if let Some(session_lock) = shell.session_lock.as_ref() { if let Some(session_lock) = shell.session_lock.as_ref()
if let Some(lock_surface) = session_lock.surfaces.get(output) { && let Some(lock_surface) = session_lock.surfaces.get(output)
{
with_surfaces_surface_tree(lock_surface.wl_surface(), processor) with_surfaces_surface_tree(lock_surface.wl_surface(), processor)
} }
}
for seat in shell for seat in shell
.seats .seats
@ -973,13 +973,13 @@ impl Common {
} }
// grabs // grabs
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() { if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() { && let Some(grab_state) = move_grab.lock().unwrap().as_ref()
{
for (window, _) in grab_state.element().windows() { for (window, _) in grab_state.element().windows() {
window.with_surfaces(processor); window.with_surfaces(processor);
} }
} }
}
if let Some(icon) = get_dnd_icon(seat) { if let Some(icon) = get_dnd_icon(seat) {
with_surfaces_surface_tree(&icon.surface, processor); with_surfaces_surface_tree(&icon.surface, processor);
@ -1037,9 +1037,9 @@ impl Common {
) { ) {
let shell = self.shell.read(); let shell = self.shell.read();
if let Some(session_lock) = shell.session_lock.as_ref() { if let Some(session_lock) = shell.session_lock.as_ref()
if let Some(lock_surface) = session_lock.surfaces.get(output) { && let Some(lock_surface) = session_lock.surfaces.get(output)
if let Some(feedback) = && 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(&mut dmabuf_feedback) .and_then(&mut dmabuf_feedback)
{ {
@ -1060,8 +1060,6 @@ impl Common {
}, },
) )
} }
}
}
for seat in shell for seat in shell
.seats .seats
@ -1070,8 +1068,8 @@ impl Common {
{ {
let cursor_status = seat.cursor_image_status(); let cursor_status = seat.cursor_image_status();
if let CursorImageStatus::Surface(wl_surface) = cursor_status { if let CursorImageStatus::Surface(wl_surface) = cursor_status
if let Some(feedback) = && let Some(feedback) =
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
.and_then(&mut dmabuf_feedback) .and_then(&mut dmabuf_feedback)
{ {
@ -1092,10 +1090,9 @@ impl Common {
}, },
); );
} }
}
if let Some(icon) = get_dnd_icon(seat) { if let Some(icon) = get_dnd_icon(seat)
if let Some(feedback) = && let Some(feedback) =
advertised_node_for_surface(&icon.surface, &self.display_handle) advertised_node_for_surface(&icon.surface, &self.display_handle)
.and_then(&mut dmabuf_feedback) .and_then(&mut dmabuf_feedback)
{ {
@ -1116,10 +1113,10 @@ impl Common {
}, },
); );
} }
}
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() { if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() { && let Some(grab_state) = move_grab.lock().unwrap().as_ref()
{
for (window, _) in grab_state.element().windows() { for (window, _) in grab_state.element().windows() {
if let Some(feedback) = window if let Some(feedback) = window
.wl_surface() .wl_surface()
@ -1138,7 +1135,6 @@ impl Common {
} }
} }
} }
}
shell shell
.workspaces .workspaces
@ -1167,8 +1163,8 @@ impl Common {
}); });
if let Some(active) = shell.active_space(output) { if let Some(active) = shell.active_space(output) {
if let Some(window) = active.get_fullscreen() { if let Some(window) = active.get_fullscreen()
if let Some(feedback) = window && let Some(feedback) = window
.wl_surface() .wl_surface()
.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)
@ -1182,7 +1178,6 @@ impl Common {
surface_primary_scanout_output, surface_primary_scanout_output,
); );
} }
}
active.mapped().for_each(|mapped| { active.mapped().for_each(|mapped| {
for (window, _) in mapped.windows() { for (window, _) in mapped.windows() {
if let Some(feedback) = window if let Some(feedback) = window
@ -1204,8 +1199,8 @@ impl Common {
} }
shell.override_redirect_windows.iter().for_each(|or| { shell.override_redirect_windows.iter().for_each(|or| {
if let Some(wl_surface) = or.wl_surface() { if let Some(wl_surface) = or.wl_surface()
if let Some(feedback) = && let Some(feedback) =
advertised_node_for_surface(&wl_surface, &self.display_handle) advertised_node_for_surface(&wl_surface, &self.display_handle)
.and_then(&mut dmabuf_feedback) .and_then(&mut dmabuf_feedback)
{ {
@ -1226,7 +1221,6 @@ impl Common {
}, },
) )
} }
}
}); });
let map = smithay::desktop::layer_map_for_output(output); let map = smithay::desktop::layer_map_for_output(output);
@ -1280,11 +1274,12 @@ impl Common {
// If we already sent a frame callback to this surface this output refresh // If we already sent a frame callback to this surface this output refresh
// cycle, don't send one again to prevent empty-damage commit busy loops. // cycle, don't send one again to prevent empty-damage commit busy loops.
if let Some((last_output, last_sequence)) = &*last_sent_at { if let Some((last_output, last_sequence)) = &*last_sent_at
if last_output == output && *last_sequence == sequence { && last_output == output
&& *last_sequence == sequence
{
send = false; send = false;
} }
}
if send { if send {
*last_sent_at = Some((output.downgrade(), sequence)); *last_sent_at = Some((output.downgrade(), sequence));
@ -1306,16 +1301,10 @@ impl Common {
let shell = self.shell.read(); let shell = self.shell.read();
if let Some(session_lock) = shell.session_lock.as_ref() { if let Some(session_lock) = shell.session_lock.as_ref()
if let Some(lock_surface) = session_lock.surfaces.get(output) { && let Some(lock_surface) = session_lock.surfaces.get(output)
send_frames_surface_tree( {
lock_surface.wl_surface(), send_frames_surface_tree(lock_surface.wl_surface(), output, time, None, should_send);
output,
time,
None,
should_send,
);
}
} }
for seat in shell for seat in shell
@ -1335,13 +1324,13 @@ impl Common {
) )
} }
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() { if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() { && let Some(grab_state) = move_grab.lock().unwrap().as_ref()
{
for (window, _) in grab_state.element().windows() { for (window, _) in grab_state.element().windows() {
window.send_frame(output, time, throttle(&window), should_send); window.send_frame(output, time, throttle(&window), should_send);
} }
} }
}
if let Some(icon) = get_dnd_icon(seat) { if let Some(icon) = get_dnd_icon(seat) {
send_frames_surface_tree( send_frames_surface_tree(

View file

@ -449,15 +449,15 @@ impl<P: Program + Send + 'static> IcedElementInternal<P> {
) )
.1; .1;
if let Some(action) = actions { if let Some(action) = actions
if let Some(t) = into_stream(action) { && let Some(t) = into_stream(action)
{
let _ = self.scheduler.schedule(t.into_future().map(|f| match f.0 { let _ = self.scheduler.schedule(t.into_future().map(|f| match f.0 {
Some(Action::Output(msg)) => Some(msg), Some(Action::Output(msg)) => Some(msg),
_ => None, _ => None,
})); }));
} }
} }
}
} }
impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedElement<P> { impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedElement<P> {

View file

@ -145,11 +145,11 @@ where
// for now :^) // for now :^)
let temp_cache = user_interface.into_cache(); let temp_cache = user_interface.into_cache();
let tasks = Task::batch(messages.into_iter().map(|message| { let tasks = Task::batch(
let task = self.program.update(message); messages
.into_iter()
task .map(|message| self.program.update(message)),
})); );
let mut user_interface = let mut user_interface =
build_user_interface(id, &mut self.program, temp_cache, renderer, bounds); build_user_interface(id, &mut self.program, temp_cache, renderer, bounds);
@ -216,7 +216,5 @@ fn build_user_interface<'a, P: Program>(
) -> UserInterface<'a, P::Message, cosmic::Theme, cosmic::Renderer> { ) -> UserInterface<'a, P::Message, cosmic::Theme, cosmic::Renderer> {
let view = program.view(); let view = program.view();
let user_interface = UserInterface::build(view, size, cache, renderer); UserInterface::build(view, size, cache, renderer)
user_interface
} }

View file

@ -73,7 +73,7 @@ fn xdg_popup_ensure_initial_configure(popup: &PopupKind) {
fn layer_surface_check_inital_configure(surface: &LayerSurface) -> bool { fn layer_surface_check_inital_configure(surface: &LayerSurface) -> bool {
// send the initial configure if relevant // send the initial configure if relevant
let initial_configure_sent = with_states(surface.wl_surface(), |states| { with_states(surface.wl_surface(), |states| {
states states
.data_map .data_map
.get::<Mutex<LayerSurfaceAttributes>>() .get::<Mutex<LayerSurfaceAttributes>>()
@ -81,9 +81,7 @@ fn layer_surface_check_inital_configure(surface: &LayerSurface) -> bool {
.lock() .lock()
.unwrap() .unwrap()
.initial_configure_sent .initial_configure_sent
}); })
initial_configure_sent
} }
pub fn client_compositor_state(client: &Client) -> &CompositorClientState { pub fn client_compositor_state(client: &Client) -> &CompositorClientState {
@ -195,25 +193,26 @@ impl CompositorHandler for State {
}) })
}); });
if let Some(dmabuf) = maybe_dmabuf { if let Some(dmabuf) = maybe_dmabuf {
if let Some(acquire_point) = acquire_point { if let Some(acquire_point) = acquire_point
if let Ok((blocker, source)) = acquire_point.generate_blocker() { && let Ok((blocker, source)) = acquire_point.generate_blocker()
{
let client = surface.client().unwrap(); let client = surface.client().unwrap();
let res = state.common.event_loop_handle.insert_source( let res =
source, state
move |_, _, state| { .common
.event_loop_handle
.insert_source(source, move |_, _, state| {
let dh = state.common.display_handle.clone(); let dh = state.common.display_handle.clone();
state state
.client_compositor_state(&client) .client_compositor_state(&client)
.blocker_cleared(state, &dh); .blocker_cleared(state, &dh);
Ok(()) Ok(())
}, });
);
if res.is_ok() { if res.is_ok() {
add_blocker(surface, blocker); add_blocker(surface, blocker);
return; return;
} }
} }
}
if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) { if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) {
let client = surface.client().unwrap(); let client = surface.client().unwrap();
let res = let res =
@ -379,8 +378,8 @@ impl State {
.pending_windows .pending_windows
.iter() .iter()
.find(|pending| pending.surface.wl_surface().as_deref() == Some(surface)) .find(|pending| pending.surface.wl_surface().as_deref() == Some(surface))
&& let Some(toplevel) = pending.surface.0.toplevel()
{ {
if let Some(toplevel) = pending.surface.0.toplevel() {
let initial_size = if let Some(output) = pending.fullscreen.as_ref() { let initial_size = if let Some(output) = pending.fullscreen.as_ref() {
Some(output.geometry().size.as_logical()) Some(output.geometry().size.as_logical())
} else if pending.maximized { } else if pending.maximized {
@ -410,15 +409,14 @@ impl State {
} }
} }
} }
}
if let Some(layer_surface) = shell if let Some(layer_surface) = shell
.pending_layers .pending_layers
.iter() .iter()
.find(|pending| pending.surface.wl_surface() == surface) .find(|pending| pending.surface.wl_surface() == surface)
.map(|pending| pending.surface.clone()) .map(|pending| pending.surface.clone())
&& !layer_surface_check_inital_configure(&layer_surface)
{ {
if !layer_surface_check_inital_configure(&layer_surface) {
// compute initial dimensions by mapping // compute initial dimensions by mapping
if let Some(target) = shell.map_layer(&layer_surface) { if let Some(target) = shell.map_layer(&layer_surface) {
let seat = shell.seats.last_active().clone(); let seat = shell.seats.last_active().clone();
@ -427,7 +425,6 @@ impl State {
} }
layer_surface.layer_surface().send_configure(); layer_surface.layer_surface().send_configure();
return true; return true;
}
}; };
false false

View file

@ -74,8 +74,8 @@ impl XdgDecorationHandler for State {
if let Some((window, _)) = mapped if let Some((window, _)) = mapped
.windows() .windows()
.find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface())) .find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface()))
&& let Some(toplevel) = window.0.toplevel()
{ {
if let Some(toplevel) = window.0.toplevel() {
toplevel.with_pending_state(|state| { toplevel.with_pending_state(|state| {
state.decoration_mode = Some(mode); state.decoration_mode = Some(mode);
}); });
@ -83,7 +83,6 @@ impl XdgDecorationHandler for State {
} }
} }
} }
}
fn request_mode(&mut self, toplevel: ToplevelSurface, mode: XdgMode) { fn request_mode(&mut self, toplevel: ToplevelSurface, mode: XdgMode) {
let shell = self.common.shell.read(); let shell = self.common.shell.read();
@ -91,15 +90,14 @@ impl XdgDecorationHandler for State {
if let Some((window, _)) = mapped if let Some((window, _)) = mapped
.windows() .windows()
.find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface())) .find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface()))
&& let Some(toplevel) = window.0.toplevel()
{ {
if let Some(toplevel) = window.0.toplevel() {
PreferredDecorationMode::update(&window.0, Some(mode)); PreferredDecorationMode::update(&window.0, Some(mode));
toplevel.with_pending_state(|state| { toplevel.with_pending_state(|state| {
state.decoration_mode = Some(mode); state.decoration_mode = Some(mode);
}); });
toplevel.send_configure(); toplevel.send_configure();
} }
}
} else { } else {
toplevel.with_pending_state(|state| state.decoration_mode = Some(mode)); toplevel.with_pending_state(|state| state.decoration_mode = Some(mode));
} }
@ -107,12 +105,12 @@ impl XdgDecorationHandler for State {
fn unset_mode(&mut self, toplevel: ToplevelSurface) { fn unset_mode(&mut self, toplevel: ToplevelSurface) {
let shell = self.common.shell.read(); let shell = self.common.shell.read();
if let Some(mapped) = shell.element_for_surface(toplevel.wl_surface()) { if let Some(mapped) = shell.element_for_surface(toplevel.wl_surface())
if let Some((window, _)) = mapped && let Some((window, _)) = mapped
.windows() .windows()
.find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface())) .find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface()))
&& let Some(toplevel) = window.0.toplevel()
{ {
if let Some(toplevel) = window.0.toplevel() {
PreferredDecorationMode::update(&window.0, None); PreferredDecorationMode::update(&window.0, None);
toplevel.with_pending_state(|state| { toplevel.with_pending_state(|state| {
state.decoration_mode = None; state.decoration_mode = None;
@ -120,8 +118,6 @@ impl XdgDecorationHandler for State {
toplevel.send_configure(); toplevel.send_configure();
} }
} }
}
}
} }
impl KdeDecorationHandler for State { impl KdeDecorationHandler for State {

View file

@ -79,15 +79,13 @@ impl DmabufHandler for State {
feedback feedback
.primary_scanout_feedback .primary_scanout_feedback
.unwrap_or(feedback.render_feedback) .unwrap_or(feedback.render_feedback)
} else { } else if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
feedback feedback
.overlay_scanout_feedback .overlay_scanout_feedback
.unwrap_or(feedback.render_feedback) .unwrap_or(feedback.render_feedback)
} else { } else {
feedback.render_feedback feedback.render_feedback
} }
}
})) }))
} }
} }

View file

@ -237,24 +237,24 @@ impl ImageCopyCaptureHandler for State {
} }
ImageCaptureSourceKind::Toplevel(mut toplevel) => { ImageCaptureSourceKind::Toplevel(mut toplevel) => {
let shell = self.common.shell.read(); let shell = self.common.shell.read();
if let Some(element) = shell.element_for_surface(&toplevel) { if let Some(element) = shell.element_for_surface(&toplevel)
if element.has_active_window(&toplevel) { && element.has_active_window(&toplevel)
if let Some(workspace) = shell.space_for(element) { && let Some(workspace) = shell.space_for(element)
if let Some(geometry) = workspace.element_geometry(element) { && let Some(geometry) = workspace.element_geometry(element)
{
let mut surface_geo = element.active_window_geometry().as_local(); let mut surface_geo = element.active_window_geometry().as_local();
surface_geo.loc += geometry.loc; surface_geo.loc += geometry.loc;
let global_geo = surface_geo.to_global(workspace.output()); let global_geo = surface_geo.to_global(workspace.output());
if global_geo.contains(pointer_loc) { if global_geo.contains(pointer_loc) {
let buffer_pos = (pointer_loc - global_geo.loc) let buffer_pos = (pointer_loc - global_geo.loc).as_logical().to_buffer(
.as_logical() 1,
.to_buffer(1, Transform::Normal, &toplevel.geometry().size); Transform::Normal,
&toplevel.geometry().size,
);
session.set_cursor_hotspot(hotspot); session.set_cursor_hotspot(hotspot);
session.set_cursor_pos(Some(buffer_pos)); session.set_cursor_pos(Some(buffer_pos));
} }
} }
}
}
}
toplevel.add_cursor_session(session); toplevel.add_cursor_session(session);
} }

View file

@ -577,19 +577,17 @@ pub fn render_window_to_buffer(
let pointer = seat.get_pointer().unwrap(); let pointer = seat.get_pointer().unwrap();
let pointer_loc = pointer.current_location().to_i32_round().as_global(); let pointer_loc = pointer.current_location().to_i32_round().as_global();
let mut location = None; let mut location = None;
if let Some(element) = shell.element_for_surface(toplevel) { if let Some(element) = shell.element_for_surface(toplevel)
if element.has_active_window(toplevel) { && element.has_active_window(toplevel)
if let Some(workspace) = shell.space_for(element) { && let Some(workspace) = shell.space_for(element)
if let Some(geometry) = workspace.element_geometry(element) { && let Some(geometry) = workspace.element_geometry(element)
{
let mut surface_geo = element.active_window_geometry().as_local(); let mut surface_geo = element.active_window_geometry().as_local();
surface_geo.loc += geometry.loc; surface_geo.loc += geometry.loc;
let global_geo = surface_geo.to_global(workspace.output()); let global_geo = surface_geo.to_global(workspace.output());
if global_geo.contains(pointer_loc) { if global_geo.contains(pointer_loc) {
location = Some((pointer_loc - global_geo.loc).as_logical().to_f64()); location = Some((pointer_loc - global_geo.loc).as_logical().to_f64());
} }
}
}
}
}; };
std::mem::drop(shell); std::mem::drop(shell);
@ -620,8 +618,7 @@ pub fn render_window_to_buffer(
// TODO cosmic-workspaces wants to omit, but metadata cursor capture in portal should // TODO cosmic-workspaces wants to omit, but metadata cursor capture in portal should
// still include dnd surface in window capture buffer? // still include dnd surface in window capture buffer?
if draw_cursor { if draw_cursor && 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,
@ -634,7 +631,6 @@ pub fn render_window_to_buffer(
); );
} }
} }
}
elements.extend(AsRenderElements::<R>::render_elements::< elements.extend(AsRenderElements::<R>::render_elements::<
WindowCaptureElement<R>, WindowCaptureElement<R>,

View file

@ -174,8 +174,8 @@ impl State {
*current_config = backup; *current_config = backup;
} }
} }
if !test_only { if !test_only
if let Err(err) = backend.apply_config_for_outputs( && let Err(err) = backend.apply_config_for_outputs(
false, false,
&self.common.event_loop_handle, &self.common.event_loop_handle,
self.common.config.dynamic_conf.screen_filter(), self.common.config.dynamic_conf.screen_filter(),
@ -184,10 +184,10 @@ impl State {
&self.common.xdg_activation_state, &self.common.xdg_activation_state,
self.common.startup_done.clone(), self.common.startup_done.clone(),
&self.common.clock, &self.common.clock,
) { )
{
error!("Failed to reset output config: {:?}", err); error!("Failed to reset output config: {:?}", err);
} }
}
return false; return false;
} }
self.common.refresh(); self.common.refresh();

View file

@ -70,10 +70,9 @@ impl SelectionHandler for State {
.xwayland_state .xwayland_state
.as_mut() .as_mut()
.and_then(|xstate| xstate.xwm.as_mut()) .and_then(|xstate| xstate.xwm.as_mut())
&& let Err(err) = xwm.send_selection(target, mime_type, fd)
{ {
if let Err(err) = xwm.send_selection(target, mime_type, fd) {
warn!(?err, "Failed to send selection (X11 -> Wayland)."); warn!(?err, "Failed to send selection (X11 -> Wayland).");
} }
} }
}
} }

View file

@ -21,8 +21,8 @@ impl SessionLockHandler for State {
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();
// Reject lock if sesion lock exists and is still valid // Reject lock if sesion lock exists and is still valid
if let Some(session_lock) = shell.session_lock.as_ref() { if let Some(session_lock) = shell.session_lock.as_ref()
if self && self
.common .common
.display_handle .display_handle
.get_client(session_lock.ext_session_lock.id()) .get_client(session_lock.ext_session_lock.id())
@ -30,7 +30,6 @@ impl SessionLockHandler for State {
{ {
return; return;
} }
}
let ext_session_lock = locker.ext_session_lock().clone(); let ext_session_lock = locker.ext_session_lock().clone();
locker.lock(); locker.lock();
@ -55,8 +54,9 @@ impl SessionLockHandler for State {
fn new_surface(&mut self, lock_surface: LockSurface, wl_output: WlOutput) { fn new_surface(&mut self, lock_surface: LockSurface, wl_output: WlOutput) {
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();
if let Some(session_lock) = &mut shell.session_lock { if let Some(session_lock) = &mut shell.session_lock
if let Some(output) = Output::from_resource(&wl_output) { && let Some(output) = Output::from_resource(&wl_output)
{
lock_surface.with_pending_state(|states| { lock_surface.with_pending_state(|states| {
let size = output.geometry().size; let size = output.geometry().size;
states.size = Some(Size::from((size.w as u32, size.h as u32))); states.size = Some(Size::from((size.w as u32, size.h as u32)));
@ -67,7 +67,6 @@ impl SessionLockHandler for State {
.insert(output.clone(), lock_surface.clone()); .insert(output.clone(), lock_surface.clone());
} }
} }
}
} }
delegate_session_lock!(State); delegate_session_lock!(State);

View file

@ -113,8 +113,8 @@ impl ToplevelManagementHandler for State {
// move pointer to window if it’s on a different monitor/output // move pointer to window if it’s on a different monitor/output
if seat.active_output() != *output if seat.active_output() != *output
&& self.common.config.cosmic_conf.cursor_follows_focus && self.common.config.cosmic_conf.cursor_follows_focus
&& 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();
@ -130,7 +130,6 @@ impl ToplevelManagementHandler for State {
ptr.frame(self); ptr.frame(self);
} }
} }
}
Shell::set_focus(self, Some(&target), &seat, None, false); Shell::set_focus(self, Some(&target), &seat, None, false);
return; return;

View file

@ -213,7 +213,7 @@ impl State {
None, None,
false, false,
); );
} else if let Some((workspace, _)) = shell.workspace_for_surface(&surface) { } else if let Some((workspace, _)) = shell.workspace_for_surface(surface) {
let current_workspace = shell.active_space(&current_output).unwrap(); let current_workspace = shell.active_space(&current_output).unwrap();
if workspace == current_workspace.handle { if workspace == current_workspace.handle {
let Some(target) = shell let Some(target) = shell

View file

@ -45,12 +45,7 @@ impl XdgShellHandler for State {
let mut shell = self.common.shell.write(); let mut shell = self.common.shell.write();
let seat = shell.seats.last_active().clone(); let seat = shell.seats.last_active().clone();
if shell if !shell.pending_windows.iter().any(|w| w.surface == surface) {
.pending_windows
.iter()
.find(|w| &w.surface == &surface)
.is_none()
{
let surface = CosmicSurface::from(surface); let surface = CosmicSurface::from(surface);
shell.pending_windows.push(PendingWindow { shell.pending_windows.push(PendingWindow {
surface, surface,

View file

@ -96,7 +96,7 @@ 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 mut guard = states.cached_state.get::<PopupCachedState>(); let mut guard = states.cached_state.get::<PopupCachedState>();
guard guard
.current() .current()

View file

@ -204,12 +204,12 @@ where
state.request_screen_invert(inverted); state.request_screen_invert(inverted);
} }
if let Ok(filter) = filter { if let Ok(filter) = filter
if filter != state.a11y_state().screen_filter { && filter != state.a11y_state().screen_filter
{
state.request_screen_filter(filter); state.request_screen_filter(filter);
} }
} }
}
_ => unreachable!(), _ => unreachable!(),
} }
} }

View file

@ -428,8 +428,7 @@ where
} }
} else { } else {
None None
} { } && inner.enabled
if inner.enabled
&& output && output
.current_mode() .current_mode()
.map(|c| c == output_mode) .map(|c| c == output_mode)
@ -438,7 +437,6 @@ where
instance.obj.current_mode(mode); instance.obj.current_mode(mode);
} }
} }
}
instance instance
.obj .obj
@ -513,13 +511,12 @@ where
} }
} }
if let Some(extension_obj) = instance.extension_obj.as_ref() { if let Some(extension_obj) = instance.extension_obj.as_ref()
if inner.enabled && inner.enabled
&& extension_obj.version() >= zcosmic_output_head_v1::EVT_XWAYLAND_PRIMARY_SINCE && extension_obj.version() >= zcosmic_output_head_v1::EVT_XWAYLAND_PRIMARY_SINCE
{ {
extension_obj.xwayland_primary(output.config().xwayland_primary as u32); extension_obj.xwayland_primary(output.config().xwayland_primary as u32);
} }
}
} }
fn remove_global_with_timer<D: 'static>( fn remove_global_with_timer<D: 'static>(

View file

@ -58,8 +58,9 @@ impl OutputPowerState {
let mut output_powers = mem::take(&mut state.output_power_state().output_powers); let mut output_powers = mem::take(&mut state.output_power_state().output_powers);
for (output_power, old_mode) in output_powers.iter_mut() { for (output_power, old_mode) in output_powers.iter_mut() {
let data = output_power.data::<OutputPowerData>().unwrap(); let data = output_power.data::<OutputPowerData>().unwrap();
if let Some(output) = data.output.upgrade() { if let Some(output) = data.output.upgrade()
if let Some(on) = state.get_dpms(&output) { && let Some(on) = state.get_dpms(&output)
{
let mode = output_power_mode(on); let mode = output_power_mode(on);
if mode != *old_mode { if mode != *old_mode {
output_power.mode(mode); output_power.mode(mode);
@ -67,7 +68,6 @@ impl OutputPowerState {
} }
} }
} }
}
state.output_power_state().output_powers = output_powers; state.output_power_state().output_powers = output_powers;
} }
} }

View file

@ -124,8 +124,9 @@ impl OverlapNotifyState {
}) })
}) })
{ {
if let Some(window_geo) = window.global_geometry() { if let Some(window_geo) = window.global_geometry()
if let Some(intersection) = layer_geo.intersection(window_geo) { && let Some(intersection) = layer_geo.intersection(window_geo)
{
// relative to layer location // relative to layer location
let region = Rectangle::new( let region = Rectangle::new(
intersection.loc - layer_geo.loc, intersection.loc - layer_geo.loc,
@ -135,7 +136,6 @@ impl OverlapNotifyState {
new_snapshot.add_toplevel(window, region); new_snapshot.add_toplevel(window, region);
} }
} }
}
for other_surface in map.layers().filter(|s| *s != layer_surface) { for other_surface in map.layers().filter(|s| *s != layer_surface) {
if other_surface.wl_surface().id() == layer_surface.wl_surface().id() { if other_surface.wl_surface().id() == layer_surface.wl_surface().id() {
@ -238,9 +238,10 @@ impl LayerOverlapNotificationDataInternal {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for toplevel in self.last_snapshot.toplevel_overlaps.keys() { for toplevel in self.last_snapshot.toplevel_overlaps.keys() {
if !new_snapshot.toplevel_overlaps.contains_key(toplevel) { if !new_snapshot.toplevel_overlaps.contains_key(toplevel)
if let Ok(toplevel) = toplevel.upgrade() { && let Ok(toplevel) = toplevel.upgrade()
if let Some(client) = toplevel.client() { && let Some(client) = toplevel.client()
{
for notification in notifications for notification in notifications
.iter() .iter()
.filter(|n| n.client().is_some_and(|c| c == client)) .filter(|n| n.client().is_some_and(|c| c == client))
@ -249,17 +250,15 @@ impl LayerOverlapNotificationDataInternal {
} }
} }
} }
}
}
for (toplevel, overlap) in &new_snapshot.toplevel_overlaps { for (toplevel, overlap) in &new_snapshot.toplevel_overlaps {
if !self if !self
.last_snapshot .last_snapshot
.toplevel_overlaps .toplevel_overlaps
.get(toplevel) .get(toplevel)
.is_some_and(|old_overlap| old_overlap == overlap) .is_some_and(|old_overlap| old_overlap == overlap)
&& let Ok(toplevel) = toplevel.upgrade()
&& let Some(client) = toplevel.client()
{ {
if let Ok(toplevel) = toplevel.upgrade() {
if let Some(client) = toplevel.client() {
for notification in notifications for notification in notifications
.iter() .iter()
.filter(|n| n.client().is_some_and(|c| c == client)) .filter(|n| n.client().is_some_and(|c| c == client))
@ -274,8 +273,6 @@ impl LayerOverlapNotificationDataInternal {
} }
} }
} }
}
}
for (layer_surface, (identifier, ..)) in &self.last_snapshot.layer_overlaps { for (layer_surface, (identifier, ..)) in &self.last_snapshot.layer_overlaps {
if !new_snapshot.layer_overlaps.contains_key(layer_surface) { if !new_snapshot.layer_overlaps.contains_key(layer_surface) {

View file

@ -574,13 +574,11 @@ where
instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h); instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h);
} }
changed = true; changed = true;
} else if geometry_changed { } else if geometry_changed && let Some(geo) = geometry {
if let Some(geo) = geometry {
instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h); instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h);
} }
} }
} }
}
handle_state.wl_outputs.retain(|wl_output| { handle_state.wl_outputs.retain(|wl_output| {
let retain = wl_output.is_alive() let retain = wl_output.is_alive()
&& handle_state && handle_state
@ -635,10 +633,10 @@ pub fn window_from_handle<W: Window + 'static>(handle: ZcosmicToplevelHandleV1)
.and_then(|state| state.lock().unwrap().window.clone()) .and_then(|state| state.lock().unwrap().window.clone())
} }
pub fn window_from_ext<'a, W: Window + 'static, D>( pub fn window_from_ext<W: Window + 'static, D>(
state: &'a D, state: &D,
handle: ForeignToplevelHandle, handle: ForeignToplevelHandle,
) -> Option<&'a W> ) -> Option<&W>
where where
D: ToplevelInfoHandler<Window = W>, D: ToplevelInfoHandler<Window = W>,
{ {

View file

@ -258,12 +258,11 @@ where
let window = window_from_handle(toplevel).unwrap(); let window = window_from_handle(toplevel).unwrap();
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
&& let Some(output) = Output::from_resource(&output)
{ {
if let Some(output) = Output::from_resource(&output) {
state.move_to_workspace(dh, &window, workspace_handle, output); state.move_to_workspace(dh, &window, workspace_handle, output);
} }
} }
}
_ => unreachable!(), _ => unreachable!(),
} }
} }

View file

@ -94,14 +94,13 @@ where
.iter() .iter()
.flat_map(|g| &g.workspaces) .flat_map(|g| &g.workspaces)
.find(|w| w.ext_instances.contains(&workspace)) .find(|w| w.ext_instances.contains(&workspace))
&& let Ok(ext_mngr) = data.manager.upgrade()
{ {
if let Ok(ext_mngr) = data.manager.upgrade() {
send_workspace_to_client(&cosmic_workspace, workspace); send_workspace_to_client(&cosmic_workspace, workspace);
ext_mngr.done(); ext_mngr.done();
} }
} }
} }
}
zcosmic_workspace_manager_v2::Request::Destroy => {} zcosmic_workspace_manager_v2::Request::Destroy => {}
_ => unreachable!(), _ => unreachable!(),
} }
@ -128,8 +127,7 @@ where
zcosmic_workspace_handle_v2::Request::Rename { name } => { zcosmic_workspace_handle_v2::Request::Rename { name } => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
{ && let Ok(manager) =
if let Ok(manager) =
workspace.data::<WorkspaceData>().unwrap().manager.upgrade() workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
{ {
let mut state = manager let mut state = manager
@ -143,14 +141,12 @@ where
}); });
} }
} }
}
zcosmic_workspace_handle_v2::Request::SetTilingState { zcosmic_workspace_handle_v2::Request::SetTilingState {
state: tiling_state, state: tiling_state,
} => { } => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
{ && let Ok(manager) =
if let Ok(manager) =
workspace.data::<WorkspaceData>().unwrap().manager.upgrade() workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
{ {
let mut state = manager let mut state = manager
@ -164,12 +160,10 @@ where
}); });
} }
} }
}
zcosmic_workspace_handle_v2::Request::Pin => { zcosmic_workspace_handle_v2::Request::Pin => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
{ && let Ok(manager) =
if let Ok(manager) =
workspace.data::<WorkspaceData>().unwrap().manager.upgrade() workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
{ {
let mut state = manager let mut state = manager
@ -183,12 +177,10 @@ where
}); });
} }
} }
}
zcosmic_workspace_handle_v2::Request::Unpin => { zcosmic_workspace_handle_v2::Request::Unpin => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
{ && let Ok(manager) =
if let Ok(manager) =
workspace.data::<WorkspaceData>().unwrap().manager.upgrade() workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
{ {
let mut state = manager let mut state = manager
@ -202,19 +194,16 @@ where
}); });
} }
} }
}
zcosmic_workspace_handle_v2::Request::MoveBefore { zcosmic_workspace_handle_v2::Request::MoveBefore {
other_workspace, other_workspace,
axis, axis,
} => { } => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
{ && let Some(other_workspace) = state
if let Some(other_workspace) = state
.workspace_state() .workspace_state()
.get_ext_workspace_handle(&other_workspace) .get_ext_workspace_handle(&other_workspace)
{ && let Ok(manager) =
if let Ok(manager) =
workspace.data::<WorkspaceData>().unwrap().manager.upgrade() workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
{ {
let mut state = manager let mut state = manager
@ -229,20 +218,16 @@ where
}); });
} }
} }
}
}
zcosmic_workspace_handle_v2::Request::MoveAfter { zcosmic_workspace_handle_v2::Request::MoveAfter {
other_workspace, other_workspace,
axis, axis,
} => { } => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(&workspace) state.workspace_state().get_ext_workspace_handle(&workspace)
{ && let Some(other_workspace) = state
if let Some(other_workspace) = state
.workspace_state() .workspace_state()
.get_ext_workspace_handle(&other_workspace) .get_ext_workspace_handle(&other_workspace)
{ && let Ok(manager) =
if let Ok(manager) =
workspace.data::<WorkspaceData>().unwrap().manager.upgrade() workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
{ {
let mut state = manager let mut state = manager
@ -257,8 +242,6 @@ where
}); });
} }
} }
}
}
zcosmic_workspace_handle_v2::Request::Destroy => {} zcosmic_workspace_handle_v2::Request::Destroy => {}
_ => unreachable!(), _ => unreachable!(),
} }

View file

@ -152,8 +152,8 @@ where
.iter() .iter()
.find(|g| g.ext_instances.contains(obj)) .find(|g| g.ext_instances.contains(obj))
.map(|g| g.id) .map(|g| g.id)
&& let Ok(manager) = data.manager.upgrade()
{ {
if let Ok(manager) = data.manager.upgrade() {
let mut state = manager let mut state = manager
.data::<WorkspaceManagerData>() .data::<WorkspaceManagerData>()
.unwrap() .unwrap()
@ -165,7 +165,6 @@ where
}); });
} }
} }
}
ext_workspace_group_handle_v1::Request::Destroy => { ext_workspace_group_handle_v1::Request::Destroy => {
for group in &mut state.workspace_state_mut().groups { for group in &mut state.workspace_state_mut().groups {
group.ext_instances.retain(|i| i != obj) group.ext_instances.retain(|i| i != obj)
@ -204,8 +203,8 @@ where
ext_workspace_handle_v1::Request::Activate => { ext_workspace_handle_v1::Request::Activate => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(obj) state.workspace_state().get_ext_workspace_handle(obj)
&& let Ok(manager) = data.manager.upgrade()
{ {
if let Ok(manager) = data.manager.upgrade() {
let mut state = manager let mut state = manager
.data::<WorkspaceManagerData>() .data::<WorkspaceManagerData>()
.unwrap() .unwrap()
@ -214,12 +213,11 @@ where
state.requests.push(Request::Activate(workspace_handle)); state.requests.push(Request::Activate(workspace_handle));
} }
} }
}
ext_workspace_handle_v1::Request::Deactivate => { ext_workspace_handle_v1::Request::Deactivate => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(obj) state.workspace_state().get_ext_workspace_handle(obj)
&& let Ok(manager) = data.manager.upgrade()
{ {
if let Ok(manager) = data.manager.upgrade() {
let mut state = manager let mut state = manager
.data::<WorkspaceManagerData>() .data::<WorkspaceManagerData>()
.unwrap() .unwrap()
@ -228,12 +226,11 @@ where
state.requests.push(Request::Deactivate(workspace_handle)); state.requests.push(Request::Deactivate(workspace_handle));
} }
} }
}
ext_workspace_handle_v1::Request::Remove => { ext_workspace_handle_v1::Request::Remove => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(obj) state.workspace_state().get_ext_workspace_handle(obj)
&& let Ok(manager) = data.manager.upgrade()
{ {
if let Ok(manager) = data.manager.upgrade() {
let mut state = manager let mut state = manager
.data::<WorkspaceManagerData>() .data::<WorkspaceManagerData>()
.unwrap() .unwrap()
@ -242,19 +239,17 @@ where
state.requests.push(Request::Remove(workspace_handle)); state.requests.push(Request::Remove(workspace_handle));
} }
} }
}
ext_workspace_handle_v1::Request::Assign { workspace_group } => { ext_workspace_handle_v1::Request::Assign { workspace_group } => {
if let Some(workspace_handle) = if let Some(workspace_handle) =
state.workspace_state().get_ext_workspace_handle(obj) state.workspace_state().get_ext_workspace_handle(obj)
{ && let Some(group_id) = state
if let Some(group_id) = state
.workspace_state() .workspace_state()
.groups .groups
.iter() .iter()
.find(|g| g.ext_instances.contains(&workspace_group)) .find(|g| g.ext_instances.contains(&workspace_group))
.map(|g| g.id) .map(|g| g.id)
&& let Ok(manager) = data.manager.upgrade()
{ {
if let Ok(manager) = data.manager.upgrade() {
let mut state = manager let mut state = manager
.data::<WorkspaceManagerData>() .data::<WorkspaceManagerData>()
.unwrap() .unwrap()
@ -266,8 +261,6 @@ where
}); });
} }
} }
}
}
ext_workspace_handle_v1::Request::Destroy => { ext_workspace_handle_v1::Request::Destroy => {
for group in &mut state.workspace_state_mut().groups { for group in &mut state.workspace_state_mut().groups {
for workspace in &mut group.workspaces { for workspace in &mut group.workspaces {
@ -491,11 +484,11 @@ where
changed = true; changed = true;
} }
if handle_state.ext_id.is_none() { if handle_state.ext_id.is_none()
if let Some(id) = workspace.ext_id.clone() { && let Some(id) = workspace.ext_id.clone()
{
instance.id(id); instance.id(id);
} }
}
if let Some(cosmic_v2_handle) = handle_state if let Some(cosmic_v2_handle) = handle_state
.cosmic_v2_handle .cosmic_v2_handle

View file

@ -85,11 +85,11 @@ fn xrdb_thread(rx: Receiver<(String, u32)>, display: u32) {
"Xcursor.theme: {}\nXcursor.size: {}\n", "Xcursor.theme: {}\nXcursor.size: {}\n",
cursor_theme, cursor_size, cursor_theme, cursor_size,
); );
if let Some(mut stdin) = child.stdin.take() { if let Some(mut stdin) = child.stdin.take()
if let Err(err) = stdin.write_all(resources.as_bytes()) { && let Err(err) = stdin.write_all(resources.as_bytes())
{
warn!("Failed to update xresources: {}", err); warn!("Failed to update xresources: {}", err);
} }
}
match child.wait() { match child.wait() {
Ok(code) if code.success() => {} Ok(code) if code.success() => {}
Ok(code) => { Ok(code) => {
@ -346,8 +346,8 @@ impl Common {
self.xwayland_reset_eavesdropping(serial); self.xwayland_reset_eavesdropping(serial);
let xstate = self.xwayland_state.as_mut().unwrap(); let xstate = self.xwayland_state.as_mut().unwrap();
if let Some(mime_types) = xstate.clipboard_selection_dirty.take() { if let Some(mime_types) = xstate.clipboard_selection_dirty.take()
if let Err(err) = xstate && let Err(err) = xstate
.xwm .xwm
.as_mut() .as_mut()
.unwrap() .unwrap()
@ -355,9 +355,8 @@ impl Common {
{ {
warn!(?err, "Failed to set Xwayland clipboard selection."); warn!(?err, "Failed to set Xwayland clipboard selection.");
} }
} if let Some(mime_types) = xstate.primary_selection_dirty.take()
if let Some(mime_types) = xstate.primary_selection_dirty.take() { && let Err(err) = xstate
if let Err(err) = xstate
.xwm .xwm
.as_mut() .as_mut()
.unwrap() .unwrap()
@ -368,7 +367,6 @@ impl Common {
} }
} }
} }
}
pub fn xwayland_reset_eavesdropping(&mut self, serial: Serial) { pub fn xwayland_reset_eavesdropping(&mut self, serial: Serial) {
let seat = self.shell.read().seats.last_active().clone(); let seat = self.shell.read().seats.last_active().clone();
@ -650,7 +648,7 @@ impl Common {
} }
XwaylandDescaling::Fractional => { XwaylandDescaling::Fractional => {
let shell = self.shell.read(); let shell = self.shell.read();
let val =
if let Some(output) = shell.outputs().find(|o| o.config().xwayland_primary) { if let Some(output) = shell.outputs().find(|o| o.config().xwayland_primary) {
output.current_scale().fractional_scale().max(1f64) output.current_scale().fractional_scale().max(1f64)
} else { } else {
@ -658,8 +656,7 @@ impl Common {
.outputs() .outputs()
.map(|o| o.current_scale().fractional_scale()) .map(|o| o.current_scale().fractional_scale())
.fold(1f64, |acc, val| acc.max(val)) .fold(1f64, |acc, val| acc.max(val))
}; }
val
} }
}; };
let (_, cursor_size) = load_cursor_env(); let (_, cursor_size) = load_cursor_env();
@ -710,10 +707,14 @@ impl Common {
None None
}; };
if let Err(_) = xwayland.xrdb_thread.send(( if xwayland
.xrdb_thread
.send((
cosmic::icon_theme::default(), cosmic::icon_theme::default(),
(new_scale * cursor_size as f64).round() as u32, (new_scale * cursor_size as f64).round() as u32,
)) { ))
.is_err()
{
warn!("xrdb thread died"); warn!("xrdb thread died");
} }
@ -756,14 +757,13 @@ impl Common {
} }
} }
if let Some(xstate) = self.xwayland_state.as_mut() { if let Some(xstate) = self.xwayland_state.as_mut()
if let Some(xwm) = xstate.xwm.as_mut() { && let Some(xwm) = xstate.xwm.as_mut()
if let Err(err) = xwm.set_randr_primary_output(xwayland_primary_output.as_ref()) { && let Err(err) = xwm.set_randr_primary_output(xwayland_primary_output.as_ref())
{
warn!("Failed to set xwayland primary output: {}", err); warn!("Failed to set xwayland primary output: {}", err);
return; return;
}; };
}
}
self.output_configuration_state.update(); self.output_configuration_state.update();
} }
@ -808,12 +808,7 @@ impl XwmHandler for State {
*context, *context,
); );
} }
if shell if !shell.pending_windows.iter().any(|w| w.surface == window) {
.pending_windows
.iter()
.find(|w| w.surface == window)
.is_none()
{
let surface = CosmicSurface::from(window); let surface = CosmicSurface::from(window);
shell.pending_windows.push(PendingWindow { shell.pending_windows.push(PendingWindow {
surface, surface,
@ -835,9 +830,8 @@ impl XwmHandler for State {
if let std::collections::hash_map::Entry::Vacant(e) = shell if let std::collections::hash_map::Entry::Vacant(e) = shell
.pending_activations .pending_activations
.entry(crate::shell::ActivationKey::X11(surface.window_id())) .entry(crate::shell::ActivationKey::X11(surface.window_id()))
{ && 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()) { && let Some(context) = self
if let Some(context) = self
.common .common
.xdg_activation_state .xdg_activation_state
.data_for_token(&XdgActivationToken::from(startup_id)) .data_for_token(&XdgActivationToken::from(startup_id))
@ -845,8 +839,6 @@ impl XwmHandler for State {
{ {
e.insert(*context); e.insert(*context);
} }
}
}
let res = shell.map_window( let res = shell.map_window(
&window, &window,
&mut self.common.toplevel_info_state, &mut self.common.toplevel_info_state,
@ -881,11 +873,10 @@ impl XwmHandler for State {
let seat = shell.seats.last_active().clone(); let seat = shell.seats.last_active().clone();
if let Some(pending) = if let Some(pending) =
shell.unmap_surface(&window, &seat, &mut self.common.toplevel_info_state) shell.unmap_surface(&window, &seat, &mut self.common.toplevel_info_state)
&& shell && !shell
.pending_windows .pending_windows
.iter() .iter()
.find(|w| &w.surface == &pending.surface) .any(|w| w.surface == pending.surface)
.is_none()
{ {
shell.pending_windows.push(pending); shell.pending_windows.push(pending);
} }