Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ logind-zbus = { version = "5.3.2", optional = true }
futures-executor = { version = "0.3.32", features = ["thread-pool"] }
futures-util = "0.3.32"
cgmath = "0.18.0"
smallvec = "1.15.1"

[dependencies.id_tree]
branch = "feature/copy_clone"
Expand Down Expand Up @@ -148,4 +149,4 @@ cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch
cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" }

[patch.crates-io]
smithay = { git = "https://github.com/smithay/smithay.git", rev = "da42569" }
smithay = { git = "https://github.com/smithay/smithay.git", rev = "f6d1070" }
2 changes: 2 additions & 0 deletions cosmic-comp-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct AppearanceConfig {
pub clip_floating_windows: bool,
pub clip_tiled_windows: bool,
pub shadow_tiled_windows: bool,
pub blur_strength: u8,
}

impl Default for AppearanceConfig {
Expand All @@ -62,6 +63,7 @@ impl Default for AppearanceConfig {
clip_floating_windows: true,
clip_tiled_windows: true,
shadow_tiled_windows: false,
blur_strength: 9,
}
}
}
Expand Down
16 changes: 1 addition & 15 deletions src/backend/kms/render/gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use smithay::backend::{
},
drm::{CreateDrmNodeError, DrmNode},
renderer::{
RendererSuper,
gles::{GlesError, GlesRenderer},
glow::GlowRenderer,
multigpu::{ApiDevice, Error as MultiError, GraphicsApi},
multigpu::{ApiDevice, GraphicsApi},
},
};
use std::{borrow::Borrow, cell::Cell};
Expand All @@ -23,8 +22,6 @@ use std::{
sync::atomic::{AtomicBool, Ordering},
};

use crate::backend::render::element::FromGlesError;

/// Errors raised by the [`GbmGlesBackend`]
#[derive(Debug, thiserror::Error)]
pub enum Error {
Expand Down Expand Up @@ -181,14 +178,3 @@ impl ApiDevice for GbmGlowDevice {
!Borrow::<GlesRenderer>::borrow(&self.renderer).is_software()
}
}

impl<T: GraphicsApi, A: AsFd + Clone + 'static> FromGlesError for MultiError<GbmGlowBackend<A>, T>
where
T::Error: 'static,
<<T::Device as ApiDevice>::Renderer as RendererSuper>::Error: 'static,
{
#[inline]
fn from_gles_error(err: GlesError) -> MultiError<GbmGlowBackend<A>, T> {
MultiError::Render(err)
}
}
69 changes: 43 additions & 26 deletions src/backend/render/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only

use crate::{utils::prelude::*, wayland::handlers::compositor::FRAME_TIME_FILTER};
use crate::{
backend::render::{
element::AsGlowRenderer,
wayland::{SurfaceRenderElement, push_render_elements_from_surface_tree},
},
utils::prelude::*,
wayland::handlers::compositor::FRAME_TIME_FILTER,
};
use smithay::{
backend::{
allocator::Fourcc,
Expand All @@ -9,10 +16,10 @@ use smithay::{
element::{
Kind,
memory::{MemoryRenderBuffer, MemoryRenderBufferRenderElement},
surface::{WaylandSurfaceRenderElement, render_elements_from_surface_tree},
},
},
},
desktop::utils::bbox_from_surface_tree,
input::{
Seat,
pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus},
Expand Down Expand Up @@ -118,19 +125,20 @@ fn load_icon(theme: &CursorTheme, shape: CursorIcon) -> Result<Vec<Image>, Error
}

render_elements! {
pub CursorRenderElement<R> where R: ImportAll + ImportMem;
pub CursorRenderElement<R> where R: ImportAll + ImportMem + AsGlowRenderer;
Static=MemoryRenderBufferRenderElement<R>,
Surface=WaylandSurfaceRenderElement<R>,
Surface=SurfaceRenderElement<R>,
}

pub fn draw_surface_cursor<R>(
renderer: &mut R,
surface: &wl_surface::WlSurface,
location: Point<f64, Logical>,
scale: impl Into<Scale<f64>>,
) -> Vec<(CursorRenderElement<R>, Point<i32, Physical>)>
where
R: Renderer + ImportAll,
blur_strength: usize,
push: &mut dyn FnMut(CursorRenderElement<R>, Point<i32, Physical>),
) where
R: Renderer + ImportAll + AsGlowRenderer,
R::TextureId: Clone + 'static,
{
let scale = scale.into();
Expand All @@ -145,17 +153,20 @@ where
.to_physical_precise_round(scale)
});

render_elements_from_surface_tree(
push_render_elements_from_surface_tree(
renderer,
surface,
location.to_physical(scale).to_i32_round(),
bbox_from_surface_tree(surface, location.to_i32_round()).to_f64(),
scale,
1.0,
false,
[0; 4],
blur_strength,
Kind::Cursor,
)
.into_iter()
.map(|elem| (elem, h))
.collect()
&mut |elem| push(elem.into(), h),
None,
);
}

#[profiling::function]
Expand All @@ -164,9 +175,10 @@ pub fn draw_dnd_icon<R>(
surface: &wl_surface::WlSurface,
location: Point<f64, Logical>,
scale: impl Into<Scale<f64>>,
) -> Vec<WaylandSurfaceRenderElement<R>>
where
R: Renderer + ImportAll,
blur_strength: usize,
push: &mut dyn FnMut(SurfaceRenderElement<R>),
) where
R: Renderer + ImportAll + AsGlowRenderer,
R::TextureId: Clone + 'static,
{
if get_role(surface) != Some("dnd_icon") {
Expand All @@ -176,14 +188,20 @@ where
);
}
let scale = scale.into();
render_elements_from_surface_tree(
push_render_elements_from_surface_tree(
renderer,
surface,
location.to_physical(scale).to_i32_round(),
bbox_from_surface_tree(surface, location.to_i32_round()).to_f64(),
scale,
1.0,
false,
[0; 4],
blur_strength,
FRAME_TIME_FILTER,
)
push,
None,
);
}

pub type CursorState = Mutex<CursorStateInner>;
Expand Down Expand Up @@ -258,10 +276,11 @@ pub fn draw_cursor<R>(
scale: Scale<f64>,
buffer_scale: f64,
time: Time<Monotonic>,
blur_strength: usize,
draw_default: bool,
) -> Vec<(CursorRenderElement<R>, Point<i32, Physical>)>
where
R: Renderer + ImportMem + ImportAll,
push: &mut dyn FnMut(CursorRenderElement<R>, Point<i32, Physical>),
) where
R: Renderer + ImportMem + ImportAll + AsGlowRenderer,
R::TextureId: Send + Clone + 'static,
{
// draw the cursor as relevant
Expand All @@ -277,7 +296,7 @@ where
});
if let Some(current_cursor) = named_cursor {
if !draw_default && current_cursor == CursorIcon::Default {
return Vec::new();
return;
}

let integer_scale = (scale.x.max(scale.y) * buffer_scale).ceil() as u32;
Expand Down Expand Up @@ -314,7 +333,7 @@ where
);
state.current_image = Some(frame);

return vec![(
push(
CursorRenderElement::Static(
MemoryRenderBufferRenderElement::from_buffer(
renderer,
Expand All @@ -328,10 +347,8 @@ where
.expect("Failed to import cursor bitmap"),
),
hotspot.to_physical_precise_round(scale),
)];
);
} else if let CursorImageStatus::Surface(ref wl_surface) = cursor_status {
return draw_surface_cursor(renderer, wl_surface, location, scale);
} else {
Vec::new()
draw_surface_cursor(renderer, wl_surface, location, scale, blur_strength, push);
}
}
Loading
Loading