diff --git a/src/backend/allocator/format.rs b/src/backend/allocator/format.rs index ff0fb754df9e..78d745829419 100644 --- a/src/backend/allocator/format.rs +++ b/src/backend/allocator/format.rs @@ -127,7 +127,7 @@ macro_rules! format_tables { } } - fn _impl_formats() -> &'static [$crate::backend::allocator::Fourcc] { + const fn _impl_formats() -> &'static [$crate::backend::allocator::Fourcc] { &[ $( $crate::backend::allocator::Fourcc::$fourcc, diff --git a/src/backend/drm/compositor/mod.rs b/src/backend/drm/compositor/mod.rs index 5bd61712e271..4e1e7acb3701 100644 --- a/src/backend/drm/compositor/mod.rs +++ b/src/backend/drm/compositor/mod.rs @@ -180,14 +180,14 @@ pub mod gbm; use elements::*; impl RenderElementState { - pub(crate) fn zero_copy(visible_area: usize) -> Self { + pub(crate) const fn zero_copy(visible_area: usize) -> Self { RenderElementState { visible_area, presentation_state: RenderElementPresentationState::ZeroCopy, } } - pub(crate) fn rendering_with_reason(reason: RenderingReason) -> Self { + pub(crate) const fn rendering_with_reason(reason: RenderingReason) -> Self { RenderElementState { visible_area: 0, presentation_state: RenderElementPresentationState::Rendering { reason: Some(reason) }, @@ -4205,7 +4205,7 @@ fn apply_underlying_storage_transform( } #[inline] -fn apply_output_transform(transform: Transform, output_transform: Transform) -> Transform { +const fn apply_output_transform(transform: Transform, output_transform: Transform) -> Transform { match (transform, output_transform) { (Transform::Normal, output_transform) => output_transform, diff --git a/src/backend/drm/device/mod.rs b/src/backend/drm/device/mod.rs index c8ef57ef80f1..905c823f9101 100644 --- a/src/backend/drm/device/mod.rs +++ b/src/backend/drm/device/mod.rs @@ -281,7 +281,7 @@ impl DrmDevice { } /// Claim a plane so that it won't be used by a different crtc - /// + /// /// Returns `None` if the plane could not be claimed pub fn claim_plane(&self, plane: plane::Handle, crtc: crtc::Handle) -> Option { self.plane_claim_storage.claim(plane, crtc) diff --git a/src/backend/drm/node/mod.rs b/src/backend/drm/node/mod.rs index e10524156ff4..12f82e2e8d5a 100644 --- a/src/backend/drm/node/mod.rs +++ b/src/backend/drm/node/mod.rs @@ -65,12 +65,12 @@ impl DrmNode { } /// Returns the type of the DRM node. - pub fn ty(&self) -> NodeType { + pub const fn ty(&self) -> NodeType { self.ty } /// Returns the device_id of the underlying DRM node. - pub fn dev_id(&self) -> dev_t { + pub const fn dev_id(&self) -> dev_t { self.dev } @@ -148,7 +148,7 @@ impl NodeType { /// Returns a string representing the prefix of a minor device's name. /// /// For example, on Linux with a primary node, the returned string would be `card`. - pub fn minor_name_prefix(&self) -> &str { + pub const fn minor_name_prefix(&self) -> &str { match self { NodeType::Primary => PRIMARY_NAME, NodeType::Control => CONTROL_NAME, diff --git a/src/backend/drm/surface/gbm.rs b/src/backend/drm/surface/gbm.rs index 8233e1fc554c..a72b1e9f2178 100644 --- a/src/backend/drm/surface/gbm.rs +++ b/src/backend/drm/surface/gbm.rs @@ -460,7 +460,7 @@ where } /// Tries to mark a [`connector`](drm::control::connector) - /// for removal on the next commit. + /// for removal on the next commit. pub fn remove_connector(&self, connector: connector::Handle) -> Result<(), Error> { self.drm.remove_connector(connector).map_err(Error::DrmError) } @@ -470,19 +470,19 @@ where /// Fails if one new `connector` is not compatible with the underlying [`crtc`](drm::control::crtc) /// (e.g. no suitable [`encoder`](drm::control::encoder) may be found) /// or is not compatible with the currently pending - /// [`Mode`](drm::control::Mode). + /// [`Mode`](drm::control::Mode). pub fn set_connectors(&self, connectors: &[connector::Handle]) -> Result<(), Error> { self.drm.set_connectors(connectors).map_err(Error::DrmError) } /// Returns the currently active [`Mode`](drm::control::Mode) - /// of the underlying [`crtc`](drm::control::crtc) + /// of the underlying [`crtc`](drm::control::crtc) pub fn current_mode(&self) -> Mode { self.drm.current_mode() } /// Returns the currently pending [`Mode`](drm::control::Mode) - /// to be used after the next commit. + /// to be used after the next commit. pub fn pending_mode(&self) -> Mode { self.drm.pending_mode() } diff --git a/src/backend/drm/surface/mod.rs b/src/backend/drm/surface/mod.rs index 04438058a377..d4f4edf941a1 100644 --- a/src/backend/drm/surface/mod.rs +++ b/src/backend/drm/surface/mod.rs @@ -397,7 +397,7 @@ impl DrmSurface { } /// Claim a plane so that it won't be used by a different crtc - /// + /// /// Returns `None` if the plane could not be claimed pub fn claim_plane(&self, plane: plane::Handle) -> Option { // Validate that we are called with an plane that belongs to us diff --git a/src/backend/egl/context.rs b/src/backend/egl/context.rs index 70906421b3dc..5991a2ed2162 100644 --- a/src/backend/egl/context.rs +++ b/src/backend/egl/context.rs @@ -545,7 +545,7 @@ pub struct PixelFormatRequirements { impl PixelFormatRequirements { /// Format selection to get a 8-bit color format with alpha, depth and stencil bits - pub fn _8_bit() -> Self { + pub const fn _8_bit() -> Self { PixelFormatRequirements { hardware_accelerated: Some(true), color_bits: Some(24), @@ -558,7 +558,7 @@ impl PixelFormatRequirements { } /// Format selection to get a 10-bit color format with alpha, depth and stencil bits - pub fn _10_bit() -> Self { + pub const fn _10_bit() -> Self { PixelFormatRequirements { hardware_accelerated: Some(true), color_bits: Some(30), @@ -571,7 +571,7 @@ impl PixelFormatRequirements { } /// Format selection to get a 10-bit color format based on floating point values with alpha, depth and stencil bits - pub fn _10f_bit() -> Self { + pub const fn _10f_bit() -> Self { PixelFormatRequirements { hardware_accelerated: Some(true), color_bits: Some(48), diff --git a/src/backend/egl/ffi.rs b/src/backend/egl/ffi.rs index f98535f49312..9e351fbca714 100644 --- a/src/backend/egl/ffi.rs +++ b/src/backend/egl/ffi.rs @@ -18,7 +18,7 @@ pub type NativeDisplayType = *const c_void; pub type NativePixmapType = *const c_void; pub type NativeWindowType = *const c_void; -fn error_str(error: egl::types::EGLenum) -> &'static str { +const fn error_str(error: egl::types::EGLenum) -> &'static str { match error { egl::SUCCESS => "SUCCESS", egl::NOT_INITIALIZED => "NOT_INITIALIZED", diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index b25766638dd0..44da601b1bda 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -219,7 +219,7 @@ pub enum Format { impl Format { /// Amount of planes this format uses #[inline] - pub fn num_planes(&self) -> usize { + pub const fn num_planes(&self) -> usize { match *self { Format::RGB | Format::RGBA | Format::External => 1, Format::Y_UV | Format::Y_XUXV => 2, diff --git a/src/backend/input/mod.rs b/src/backend/input/mod.rs index e629fda99859..82b87affdeef 100644 --- a/src/backend/input/mod.rs +++ b/src/backend/input/mod.rs @@ -812,7 +812,7 @@ pub enum InputEvent { /// /// Taken from https://sources.debian.org/src/xserver-xorg-input-libinput/1.1.0-1/src/xf86libinput.c/?hl=1508#L236-L252 #[cfg(any(feature = "backend_winit", feature = "backend_x11"))] -pub(crate) fn xorg_mouse_to_libinput(xorg: u32) -> u32 { +pub(crate) const fn xorg_mouse_to_libinput(xorg: u32) -> u32 { match xorg { 0 => 0, 1 => 0x110, // BTN_LEFT diff --git a/src/backend/renderer/color.rs b/src/backend/renderer/color.rs index 5db441a09155..bf7e0b74644d 100644 --- a/src/backend/renderer/color.rs +++ b/src/backend/renderer/color.rs @@ -23,31 +23,31 @@ impl Color32F { impl Color32F { /// Red color component #[inline] - pub fn r(&self) -> f32 { + pub const fn r(&self) -> f32 { self.0[0] } /// Green color component #[inline] - pub fn g(&self) -> f32 { + pub const fn g(&self) -> f32 { self.0[1] } /// Blue color component #[inline] - pub fn b(&self) -> f32 { + pub const fn b(&self) -> f32 { self.0[2] } /// Alpha color component #[inline] - pub fn a(&self) -> f32 { + pub const fn a(&self) -> f32 { self.0[3] } /// Color components #[inline] - pub fn components(self) -> [f32; 4] { + pub const fn components(self) -> [f32; 4] { self.0 } } diff --git a/src/backend/renderer/damage/shaper.rs b/src/backend/renderer/damage/shaper.rs index c88573b7fadd..96215ed185d5 100644 --- a/src/backend/renderer/damage/shaper.rs +++ b/src/backend/renderer/damage/shaper.rs @@ -273,7 +273,7 @@ enum DamageSplitAxis { impl DamageSplitAxis { /// Invert the split direction. - fn invert(self) -> Self { + const fn invert(self) -> Self { match self { DamageSplitAxis::X => DamageSplitAxis::Y, DamageSplitAxis::Y => DamageSplitAxis::X, diff --git a/src/backend/renderer/element/mod.rs b/src/backend/renderer/element/mod.rs index d12605e1c6f5..50dc31be9014 100644 --- a/src/backend/renderer/element/mod.rs +++ b/src/backend/renderer/element/mod.rs @@ -139,7 +139,7 @@ pub enum RenderElementPresentationState { #[derive(Debug, Clone, Copy)] pub struct RenderElementState { /// Holds the physical visible area of the element on the output in pixels. - /// + /// /// Note: If the presentation_state is [`RenderElementPresentationState::Skipped`] this will be zero. pub visible_area: usize, /// Holds the presentation state of the element on the output @@ -154,7 +154,7 @@ impl RenderElementState { } } - pub(crate) fn rendered(visible_area: usize) -> Self { + pub(crate) const fn rendered(visible_area: usize) -> Self { RenderElementState { visible_area, presentation_state: RenderElementPresentationState::Rendering { reason: None }, diff --git a/src/backend/renderer/mod.rs b/src/backend/renderer/mod.rs index 4c5739f77c72..95bce882664d 100644 --- a/src/backend/renderer/mod.rs +++ b/src/backend/renderer/mod.rs @@ -69,7 +69,7 @@ pub enum TextureFilter { impl Transform { /// A projection matrix to apply this transformation #[inline] - pub fn matrix(&self) -> Matrix3 { + pub const fn matrix(&self) -> Matrix3 { match self { Transform::Normal => Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0), Transform::_90 => Matrix3::new(0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0), diff --git a/src/backend/winit/input.rs b/src/backend/winit/input.rs index b433131f1039..02402c0f4f86 100644 --- a/src/backend/winit/input.rs +++ b/src/backend/winit/input.rs @@ -376,7 +376,7 @@ pub(crate) struct RelativePosition { } impl RelativePosition { - pub(crate) fn new(x: f64, y: f64) -> Self { + pub(crate) const fn new(x: f64, y: f64) -> Self { Self { x, y } } } diff --git a/src/backend/x11/mod.rs b/src/backend/x11/mod.rs index 0839c0bf56e2..791e4266b1d1 100644 --- a/src/backend/x11/mod.rs +++ b/src/backend/x11/mod.rs @@ -435,7 +435,7 @@ pub struct WindowBuilder<'a> { impl<'a> WindowBuilder<'a> { #[allow(clippy::new_without_default)] /// Returns a new builder. - pub fn new() -> WindowBuilder<'a> { + pub const fn new() -> WindowBuilder<'a> { WindowBuilder { name: None, size: None, @@ -443,7 +443,7 @@ impl<'a> WindowBuilder<'a> { } /// Sets the title of the window that will be created by the builder. - pub fn title(self, name: &'a str) -> Self { + pub const fn title(self, name: &'a str) -> Self { Self { name: Some(name), ..self @@ -454,7 +454,7 @@ impl<'a> WindowBuilder<'a> { /// /// There is no guarantee the size specified here will be the actual size of the window when it is /// presented. - pub fn size(self, size: Size) -> Self { + pub const fn size(self, size: Size) -> Self { Self { size: Some(size), ..self diff --git a/src/input/pointer/cursor_image.rs b/src/input/pointer/cursor_image.rs index 93ee72e1a95b..3277af72e787 100644 --- a/src/input/pointer/cursor_image.rs +++ b/src/input/pointer/cursor_image.rs @@ -13,7 +13,7 @@ pub struct CursorImageAttributes { pub hotspot: Point, } -/// Data associated with XDG toplevel surface +/// Data associated with XDG toplevel surface /// /// ```no_run /// # #[cfg(feature = "wayland_frontend")] diff --git a/src/input/pointer/mod.rs b/src/input/pointer/mod.rs index 3d29c2460c8b..5a83f592a2a7 100644 --- a/src/input/pointer/mod.rs +++ b/src/input/pointer/mod.rs @@ -1063,7 +1063,7 @@ pub struct GestureHoldEndEvent { impl AxisFrame { /// Create a new frame of axis events - pub fn new(time: u32) -> Self { + pub const fn new(time: u32) -> Self { AxisFrame { source: None, relative_direction: (AxisRelativeDirection::Identical, AxisRelativeDirection::Identical), @@ -1081,13 +1081,13 @@ impl AxisFrame { /// /// Using the [`AxisSource::Finger`] requires a stop event to be send, /// when the user lifts off the finger (not necessarily in the same frame). - pub fn source(mut self, source: AxisSource) -> Self { + pub const fn source(mut self, source: AxisSource) -> Self { self.source = Some(source); self } /// Specify the direction of the physical motion, relative to axis direction - pub fn relative_direction(mut self, axis: Axis, relative_direction: AxisRelativeDirection) -> Self { + pub const fn relative_direction(mut self, axis: Axis, relative_direction: AxisRelativeDirection) -> Self { match axis { Axis::Horizontal => { self.relative_direction.0 = relative_direction; @@ -1135,7 +1135,7 @@ impl AxisFrame { /// /// This event is required for sources of the [`AxisSource::Finger`] type /// and otherwise optional. - pub fn stop(mut self, axis: Axis) -> Self { + pub const fn stop(mut self, axis: Axis) -> Self { match axis { Axis::Horizontal => { self.stop.0 = true; diff --git a/src/output.rs b/src/output.rs index c155eae10166..d166a181218c 100644 --- a/src/output.rs +++ b/src/output.rs @@ -202,7 +202,7 @@ impl Scale { } /// Returns the fractional scale (calculated if necessary) - pub fn fractional_scale(&self) -> f64 { + pub const fn fractional_scale(&self) -> f64 { match self { Scale::Integer(scale) => *scale as f64, Scale::Fractional(scale) => *scale, diff --git a/src/utils/clock.rs b/src/utils/clock.rs index 55cc2c9256ed..29e51dddee32 100644 --- a/src/utils/clock.rs +++ b/src/utils/clock.rs @@ -37,7 +37,7 @@ pub struct Clock { impl Clock { /// Initialize a new clock #[allow(clippy::new_without_default)] - pub fn new() -> Self { + pub const fn new() -> Self { Clock { _kind: PhantomData } } @@ -47,7 +47,7 @@ impl Clock { } /// Gets the id of the clock - pub fn id(&self) -> ClockId { + pub const fn id(&self) -> ClockId { Kind::ID } } diff --git a/src/utils/geometry.rs b/src/utils/geometry.rs index 2f77f6ef5cf8..c02dbe41815c 100644 --- a/src/utils/geometry.rs +++ b/src/utils/geometry.rs @@ -687,7 +687,7 @@ pub struct Size { impl Size { /// Convert this [`Size`] to a [`Point`] with the same coordinates #[inline] - pub fn to_point(self) -> Point { + pub const fn to_point(self) -> Point { Point { x: self.w, y: self.h, @@ -1526,7 +1526,7 @@ impl Transform { /// /// Flipping is preserved and 180/Normal transformation are uneffected. #[inline] - pub fn invert(&self) -> Transform { + pub const fn invert(&self) -> Transform { match self { Transform::Normal => Transform::Normal, Transform::Flipped => Transform::Flipped, @@ -1601,7 +1601,7 @@ impl Transform { } /// Returns true if the transformation would flip contents - pub fn flipped(&self) -> bool { + pub const fn flipped(&self) -> bool { !matches!( self, Transform::Normal | Transform::_90 | Transform::_180 | Transform::_270 @@ -1610,7 +1610,7 @@ impl Transform { /// Returns the angle (in degrees) of the transformation #[inline] - pub fn degrees(&self) -> u32 { + pub const fn degrees(&self) -> u32 { match self { Transform::Normal | Transform::Flipped => 0, Transform::_90 | Transform::Flipped90 => 90, diff --git a/src/utils/sealed_file.rs b/src/utils/sealed_file.rs index 178e91ca8eb0..8217a8fbe286 100644 --- a/src/utils/sealed_file.rs +++ b/src/utils/sealed_file.rs @@ -90,7 +90,7 @@ impl SealedFile { } // Only used in KeymapFile which is under the wayland_frontend feature - pub fn size(&self) -> usize { + pub const fn size(&self) -> usize { self.size } } diff --git a/src/wayland/alpha_modifier/mod.rs b/src/wayland/alpha_modifier/mod.rs index d0327b1027ea..3712be4c92d5 100644 --- a/src/wayland/alpha_modifier/mod.rs +++ b/src/wayland/alpha_modifier/mod.rs @@ -30,7 +30,7 @@ //! } //! //! fn client_compositor_state<'a>(&self, client: &'a wayland_server::Client) -> &'a CompositorClientState { -//! &client.get_data::().unwrap().compositor_state +//! &client.get_data::().unwrap().compositor_state //! } //! //! fn commit(&mut self, surface: &WlSurface) { @@ -88,7 +88,7 @@ pub struct AlphaModifierSurfaceCachedState { impl AlphaModifierSurfaceCachedState { /// Alpha multiplier for the surface - pub fn multiplier(&self) -> Option { + pub const fn multiplier(&self) -> Option { self.multiplier } @@ -121,7 +121,7 @@ struct AlphaModifierSurfaceData { } impl AlphaModifierSurfaceData { - fn new() -> Self { + const fn new() -> Self { Self { is_resource_attached: AtomicBool::new(false), } diff --git a/src/wayland/compositor/handlers.rs b/src/wayland/compositor/handlers.rs index 36a5b1e9975e..282c3defde56 100644 --- a/src/wayland/compositor/handlers.rs +++ b/src/wayland/compositor/handlers.rs @@ -518,7 +518,7 @@ pub(crate) struct SubsurfaceState { } impl SubsurfaceState { - fn new() -> SubsurfaceState { + const fn new() -> SubsurfaceState { SubsurfaceState { sync: AtomicBool::new(true), } diff --git a/src/wayland/content_type/mod.rs b/src/wayland/content_type/mod.rs index 635dafd2b9a0..b7d669f82ebe 100644 --- a/src/wayland/content_type/mod.rs +++ b/src/wayland/content_type/mod.rs @@ -27,7 +27,7 @@ //! } //! //! fn client_compositor_state<'a>(&self, client: &'a wayland_server::Client) -> &'a CompositorClientState { -//! &client.get_data::().unwrap().compositor_state +//! &client.get_data::().unwrap().compositor_state //! } //! //! fn commit(&mut self, surface: &WlSurface) { @@ -88,7 +88,7 @@ pub struct ContentTypeSurfaceCachedState { impl ContentTypeSurfaceCachedState { /// This informs the compositor that the client believes it is displaying buffers matching this content type. - pub fn content_type(&self) -> &wp_content_type_v1::Type { + pub const fn content_type(&self) -> &wp_content_type_v1::Type { &self.content_type } } @@ -117,7 +117,7 @@ struct ContentTypeSurfaceData { } impl ContentTypeSurfaceData { - fn new() -> Self { + const fn new() -> Self { Self { is_resource_attached: AtomicBool::new(false), } diff --git a/src/wayland/cursor_shape.rs b/src/wayland/cursor_shape.rs index 52da9b9a005b..8581e0512840 100644 --- a/src/wayland/cursor_shape.rs +++ b/src/wayland/cursor_shape.rs @@ -295,7 +295,7 @@ where } } -fn shape_to_cursor_icon(shape: Shape) -> CursorIcon { +const fn shape_to_cursor_icon(shape: Shape) -> CursorIcon { match shape { Shape::Default => CursorIcon::Default, Shape::ContextMenu => CursorIcon::ContextMenu, diff --git a/src/wayland/dmabuf/mod.rs b/src/wayland/dmabuf/mod.rs index 3586c8010b6d..6ef04d596202 100644 --- a/src/wayland/dmabuf/mod.rs +++ b/src/wayland/dmabuf/mod.rs @@ -271,7 +271,7 @@ struct DmabufFeedbackFormat { } impl DmabufFeedbackFormat { - fn to_ne_bytes(self) -> [u8; 16] { + const fn to_ne_bytes(self) -> [u8; 16] { let format: [u8; 4] = self.format.to_ne_bytes(); let reserved: [u8; 4] = self._reserved.to_ne_bytes(); let modifier: [u8; 8] = self.modifier.to_ne_bytes(); diff --git a/src/wayland/shell/wlr_layer/mod.rs b/src/wayland/shell/wlr_layer/mod.rs index 5855331a42a3..cf70a01a6f0b 100644 --- a/src/wayland/shell/wlr_layer/mod.rs +++ b/src/wayland/shell/wlr_layer/mod.rs @@ -74,7 +74,7 @@ pub use types::{Anchor, ExclusiveZone, KeyboardInteractivity, Layer, Margins}; /// The role of a wlr_layer_shell_surface pub const LAYER_SURFACE_ROLE: &str = "zwlr_layer_surface_v1"; -/// Data associated with XDG popup surface +/// Data associated with XDG popup surface /// /// ```no_run /// use smithay::wayland::compositor; diff --git a/src/wayland/shell/wlr_layer/types.rs b/src/wayland/shell/wlr_layer/types.rs index dc9ef270e9b5..1c9c4d91c489 100644 --- a/src/wayland/shell/wlr_layer/types.rs +++ b/src/wayland/shell/wlr_layer/types.rs @@ -139,14 +139,14 @@ impl Anchor { /// /// If it is anchored to `left` and `right` anchor at the same time /// it returns `true` - pub fn anchored_horizontally(&self) -> bool { + pub const fn anchored_horizontally(&self) -> bool { self.contains(Self::LEFT) && self.contains(Self::RIGHT) } /// Check if anchored vertically /// /// If it is anchored to `top` and `bottom` anchor at the same time /// it returns `true` - pub fn anchored_vertically(&self) -> bool { + pub const fn anchored_vertically(&self) -> bool { self.contains(Self::TOP) && self.contains(Self::BOTTOM) } } diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index f4d88cfed093..44772435a524 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -365,7 +365,7 @@ xdg_role!( } ); -/// Data associated with XDG toplevel surface +/// Data associated with XDG toplevel surface /// /// ```no_run /// use smithay::wayland::compositor; @@ -439,7 +439,7 @@ xdg_role!( } ); -/// Data associated with XDG popup surface +/// Data associated with XDG popup surface /// /// ```no_run /// use smithay::wayland::compositor; @@ -769,7 +769,10 @@ impl PositionerState { } } -fn compute_offsets(target: Rectangle, popup: Rectangle) -> (i32, i32, i32, i32) { +const fn compute_offsets( + target: Rectangle, + popup: Rectangle, +) -> (i32, i32, i32, i32) { let off_left = target.loc.x - popup.loc.x; let off_right = (popup.loc.x + popup.size.w) - (target.loc.x + target.size.w); let off_top = target.loc.y - popup.loc.y; @@ -777,7 +780,7 @@ fn compute_offsets(target: Rectangle, popup: Rectangle Anchor { +const fn invert_anchor_x(anchor: Anchor) -> Anchor { match anchor { Anchor::Left => Anchor::Right, Anchor::Right => Anchor::Left, @@ -789,7 +792,7 @@ fn invert_anchor_x(anchor: Anchor) -> Anchor { } } -fn invert_anchor_y(anchor: Anchor) -> Anchor { +const fn invert_anchor_y(anchor: Anchor) -> Anchor { match anchor { Anchor::Top => Anchor::Bottom, Anchor::Bottom => Anchor::Top, @@ -801,7 +804,7 @@ fn invert_anchor_y(anchor: Anchor) -> Anchor { } } -fn invert_gravity_x(gravity: Gravity) -> Gravity { +const fn invert_gravity_x(gravity: Gravity) -> Gravity { match gravity { Gravity::Left => Gravity::Right, Gravity::Right => Gravity::Left, @@ -813,7 +816,7 @@ fn invert_gravity_x(gravity: Gravity) -> Gravity { } } -fn invert_gravity_y(gravity: Gravity) -> Gravity { +const fn invert_gravity_y(gravity: Gravity) -> Gravity { match gravity { Gravity::Top => Gravity::Bottom, Gravity::Bottom => Gravity::Top, diff --git a/src/wayland/single_pixel_buffer/mod.rs b/src/wayland/single_pixel_buffer/mod.rs index 1edc47219634..701fc27fda6a 100644 --- a/src/wayland/single_pixel_buffer/mod.rs +++ b/src/wayland/single_pixel_buffer/mod.rs @@ -97,12 +97,12 @@ pub struct SinglePixelBufferUserData { impl SinglePixelBufferUserData { /// Check if pixel has alpha - pub fn has_alpha(&self) -> bool { + pub const fn has_alpha(&self) -> bool { self.a != u32::MAX } /// RGAB8888 color buffer - pub fn rgba8888(&self) -> [u8; 4] { + pub const fn rgba8888(&self) -> [u8; 4] { let divisor = u32::MAX / 255; [ diff --git a/src/xwayland/x11_sockets.rs b/src/xwayland/x11_sockets.rs index 458bb463e703..5e30d4788309 100644 --- a/src/xwayland/x11_sockets.rs +++ b/src/xwayland/x11_sockets.rs @@ -115,7 +115,7 @@ impl X11Lock { } } - pub(crate) fn display_number(&self) -> u32 { + pub(crate) const fn display_number(&self) -> u32 { self.display } } diff --git a/src/xwayland/xwm/mod.rs b/src/xwayland/xwm/mod.rs index 0092c0a0054e..642101471fc2 100644 --- a/src/xwayland/xwm/mod.rs +++ b/src/xwayland/xwm/mod.rs @@ -83,7 +83,7 @@ //! client.clone(), //! ) //! .expect("Failed to attach X11 Window Manager"); -//! +//! //! // store the WM somewhere //! } //! XWaylandEvent::Error => eprintln!("XWayland failed to start!"), @@ -248,14 +248,14 @@ enum StackingDirection { } impl StackingDirection { - fn pos_comparator(&self, pos: usize, last_pos: usize) -> bool { + const fn pos_comparator(&self, pos: usize, last_pos: usize) -> bool { match self { Self::Downwards => last_pos < pos, Self::Upwards => last_pos > pos, } } - fn stack_mode(&self) -> StackMode { + const fn stack_mode(&self) -> StackMode { match self { Self::Downwards => StackMode::BELOW, Self::Upwards => StackMode::ABOVE, @@ -1033,7 +1033,7 @@ impl X11Wm { /// /// So if windows `A -> C` are given in order and the internal stack is `C -> B -> A`, /// no reordering will occur. - /// + /// /// See [`X11Wm::update_stacking_order_downwards`] for a variant of this algorithm, /// which works from the top down or [`X11Wm::raise_window`] for an easier but /// much more limited way to reorder. diff --git a/src/xwayland/xwm/settings.rs b/src/xwayland/xwm/settings.rs index 2924f7382caa..63754fb7d3ab 100644 --- a/src/xwayland/xwm/settings.rs +++ b/src/xwayland/xwm/settings.rs @@ -211,7 +211,7 @@ impl XSettings { } impl Value { - fn _type(&self) -> i8 { + const fn _type(&self) -> i8 { match self { Value::Integer(_) => 0, Value::String(_) => 1, diff --git a/src/xwayland/xwm/surface.rs b/src/xwayland/xwm/surface.rs index f6fdccf75f7f..a5b70bc24934 100644 --- a/src/xwayland/xwm/surface.rs +++ b/src/xwayland/xwm/surface.rs @@ -250,7 +250,7 @@ impl X11Surface { } /// Returns if this window has the override redirect flag set or not - pub fn is_override_redirect(&self) -> bool { + pub const fn is_override_redirect(&self) -> bool { self.override_redirect }