diff --git a/Cargo.lock b/Cargo.lock index 4610ca761..6699ff04e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -839,7 +839,7 @@ dependencies = [ [[package]] name = "cosmic-comp" -version = "0.1.0" +version = "1.0.0" dependencies = [ "anyhow", "bitflags 2.9.4", @@ -900,7 +900,7 @@ dependencies = [ [[package]] name = "cosmic-comp-config" -version = "0.1.0" +version = "1.0.0" dependencies = [ "cosmic-config", "cosmic-randr-shell", diff --git a/Cargo.toml b/Cargo.toml index 8ba71d8e3..1d8306346 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ authors = ["Victoria Brekenfeld"] edition = "2024" license = "GPL-3.0-only" name = "cosmic-comp" -version = "0.1.0" -rust-version = "1.85" +version = "1.0.0" +rust-version = "1.90" [workspace] members = ["cosmic-comp-config"] diff --git a/cosmic-comp-config/Cargo.toml b/cosmic-comp-config/Cargo.toml index c5ccb53ef..109b5f3be 100644 --- a/cosmic-comp-config/Cargo.toml +++ b/cosmic-comp-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmic-comp-config" -version = "0.1.0" +version = "1.0.0" edition = "2024" [dependencies] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a0b990516..9c8eecdc6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.90" components = [ "rust-src" ] diff --git a/src/input/mod.rs b/src/input/mod.rs index 7672be84e..9b06d0d7b 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -23,7 +23,7 @@ use crate::{ }, zoom::ZoomState, }, - utils::{float::NextDown, prelude::*, quirks::workspace_overview_is_open}, + utils::{prelude::*, quirks::workspace_overview_is_open}, wayland::{ handlers::{screencopy::SessionHolder, xwayland_keyboard_grab::XWaylandGrabSeat}, protocols::screencopy::{BufferConstraints, CursorSessionRef}, @@ -356,6 +356,16 @@ impl State { .cloned() .unwrap_or(current_output.clone()); + let output_geometry = output.geometry(); + position.x = position.x.clamp( + output_geometry.loc.x as f64, + (output_geometry.loc.x + output_geometry.size.w - 1) as f64, + ); + position.y = position.y.clamp( + output_geometry.loc.y as f64, + (output_geometry.loc.y + output_geometry.size.h - 1) as f64, + ); + let new_under = State::surface_under(position, &output, &shell) .map(|(target, pos)| (target, pos.as_logical())); @@ -482,17 +492,6 @@ impl State { } } - let output_geometry = output.geometry(); - - position.x = position.x.clamp( - output_geometry.loc.x as f64, - ((output_geometry.loc.x + output_geometry.size.w) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable - ); - position.y = position.y.clamp( - output_geometry.loc.y as f64, - ((output_geometry.loc.y + output_geometry.size.h) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable - ); - // If confined, don't move pointer if it would go outside surface or region if pointer_confined { if let Some((surface, surface_loc)) = &under { diff --git a/src/shell/zoom.rs b/src/shell/zoom.rs index a3455e15b..67914702b 100644 --- a/src/shell/zoom.rs +++ b/src/shell/zoom.rs @@ -34,7 +34,6 @@ use tracing::error; use crate::{ state::State, utils::{ - float::NextDown, iced::{IcedElement, Program}, prelude::*, tween::EasePoint, @@ -93,11 +92,11 @@ impl OutputZoomState { .to_global(output); focal_point.x = focal_point.x.clamp( output_geometry.loc.x, - (output_geometry.loc.x + output_geometry.size.w).next_lower(), // FIXME: Replace with f64::next_down when stable + (output_geometry.loc.x + output_geometry.size.w).next_down(), ); focal_point.y = focal_point.y.clamp( output_geometry.loc.y, - (output_geometry.loc.y + output_geometry.size.h).next_lower(), // FIXME: Replace with f64::next_down when stable + (output_geometry.loc.y + output_geometry.size.h).next_down(), ); focal_point.to_local(output) } @@ -309,11 +308,11 @@ impl ZoomState { .upscale(output_state_ref.level); diff.x = diff.x.clamp( output_geometry.loc.x as f64, - ((output_geometry.loc.x + output_geometry.size.w) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable + ((output_geometry.loc.x + output_geometry.size.w) as f64).next_down(), ); diff.y = diff.y.clamp( output_geometry.loc.y as f64, - ((output_geometry.loc.y + output_geometry.size.h) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable + ((output_geometry.loc.y + output_geometry.size.h) as f64).next_down(), ); diff -= output_state_ref.focal_point.to_global(output); diff --git a/src/utils/float.rs b/src/utils/float.rs deleted file mode 100644 index 042332c67..000000000 --- a/src/utils/float.rs +++ /dev/null @@ -1,28 +0,0 @@ -// FIXME: When f64::next_down reaches stable rust, use that instead -pub trait NextDown { - fn next_lower(self) -> Self; -} - -impl NextDown for f64 { - fn next_lower(self) -> Self { - // We must use strictly integer arithmetic to prevent denormals from - // flushing to zero after an arithmetic operation on some platforms. - const NEG_TINY_BITS: u64 = 0x8000_0000_0000_0001; // Smallest (in magnitude) negative f64. - const CLEAR_SIGN_MASK: u64 = 0x7fff_ffff_ffff_ffff; - - let bits = self.to_bits(); - if self.is_nan() || bits == Self::NEG_INFINITY.to_bits() { - return self; - } - - let abs = bits & CLEAR_SIGN_MASK; - let next_bits = if abs == 0 { - NEG_TINY_BITS - } else if bits == abs { - bits - 1 - } else { - bits + 1 - }; - Self::from_bits(next_bits) - } -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index a90ae986b..ac1df0194 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -3,7 +3,6 @@ pub mod env; mod ids; pub(crate) use self::ids::id_gen; -pub mod float; pub mod geometry; pub mod iced; pub mod prelude;