Compare commits

...

4 Commits

Author SHA1 Message Date
Christian Meissl
e78a916753
Merge dbd066f91c into 77dafb819f 2024-07-06 09:43:12 +00:00
Christian Meissl
dbd066f91c bump smithay 2024-07-06 11:41:59 +02:00
Christian Meissl
60143a8236 bump smithay 2024-07-06 11:30:30 +02:00
Ivan Molodetskikh
77dafb819f Fix screenshot UI selection pointer clamping 2024-07-06 09:46:37 +04:00
11 changed files with 43 additions and 57 deletions

4
Cargo.lock generated
View File

@ -3355,7 +3355,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smithay"
version = "0.3.0"
source = "git+https://github.com/Smithay/smithay.git#234586dbea6bc084cb72a32f164997e47ea36b2b"
source = "git+https://github.com/Smithay/smithay.git?branch=fix/multiple_cursor_planes#9d36da3e692f9090c2ddbcf5a94b93bb185f32e1"
dependencies = [
"appendlist",
"bitflags 2.5.0",
@ -3429,7 +3429,7 @@ dependencies = [
[[package]]
name = "smithay-drm-extras"
version = "0.1.0"
source = "git+https://github.com/Smithay/smithay.git#234586dbea6bc084cb72a32f164997e47ea36b2b"
source = "git+https://github.com/Smithay/smithay.git#f208cd758416e4495e9eb8b27a96c523e92817a6"
dependencies = [
"drm",
"edid-rs",

View File

@ -21,6 +21,7 @@ tracy-client = { version = "0.17.0", default-features = false }
[workspace.dependencies.smithay]
git = "https://github.com/Smithay/smithay.git"
branch = "fix/multiple_cursor_planes"
# path = "../smithay"
default-features = false

View File

@ -1242,8 +1242,6 @@ pub struct DebugConfig {
#[knuffel(child)]
pub wait_for_frame_completion_before_queueing: bool,
#[knuffel(child)]
pub enable_color_transformations_capability: bool,
#[knuffel(child)]
pub enable_overlay_planes: bool,
#[knuffel(child)]
pub disable_cursor_plane: bool,

View File

@ -15,7 +15,7 @@ mod imp {
use niri::utils::get_monotonic_time;
use smithay::backend::egl::ffi::egl;
use smithay::backend::egl::EGLContext;
use smithay::backend::renderer::gles::{Capability, GlesRenderer};
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::{Frame, Renderer, Unbind};
use smithay::utils::{Physical, Rectangle, Scale, Transform};
@ -186,13 +186,8 @@ mod imp {
let egl_context = EGLContext::from_raw(egl_display, egl_config_id as *const _, egl_context)
.context("error creating EGL context")?;
let capabilities = GlesRenderer::supported_capabilities(&egl_context)
.context("error getting supported renderer capabilities")?
.into_iter()
.filter(|c| *c != Capability::ColorTransformations);
let mut renderer = GlesRenderer::with_capabilities(egl_context, capabilities)
.context("error creating GlesRenderer")?;
let mut renderer = GlesRenderer::new(egl_context).context("error creating GlesRenderer")?;
resources::init(&mut renderer);
shaders::init(&mut renderer);

View File

@ -24,9 +24,9 @@ use smithay::backend::drm::{
DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType,
};
use smithay::backend::egl::context::ContextPriority;
use smithay::backend::egl::{EGLContext, EGLDevice, EGLDisplay};
use smithay::backend::egl::{EGLDevice, EGLDisplay};
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
use smithay::backend::renderer::gles::{Capability, GlesRenderer};
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::multigpu::gbm::GbmGlesBackend;
use smithay::backend::renderer::multigpu::{GpuManager, MultiFrame, MultiRenderer};
use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
@ -148,7 +148,16 @@ impl OutputDevice {
builder.add_connector(connector);
builder.add_crtc(*crtc);
let planes = self.drm.planes(crtc).map_err(LeaseRejected::with_cause)?;
builder.add_plane(planes.primary.handle);
let (primary_plane, primary_plane_claim) = planes
.primary
.iter()
.find_map(|plane| {
self.drm
.claim_plane(plane.handle, *crtc)
.map(|claim| (plane, claim))
})
.ok_or_else(LeaseRejected::default)?;
builder.add_plane(primary_plane.handle, primary_plane_claim);
}
Ok(builder)
}
@ -239,25 +248,7 @@ impl Tty {
})
.unwrap();
let config_ = config.clone();
let create_renderer = move |display: &EGLDisplay| {
let color_transforms = config_
.borrow()
.debug
.enable_color_transformations_capability;
let egl_context = EGLContext::new_with_priority(display, ContextPriority::High)?;
let gles = if color_transforms {
unsafe { GlesRenderer::new(egl_context)? }
} else {
let capabilities = unsafe { GlesRenderer::supported_capabilities(&egl_context) }?
.into_iter()
.filter(|c| *c != Capability::ColorTransformations);
unsafe { GlesRenderer::with_capabilities(egl_context, capabilities)? }
};
Ok(gles)
};
let api = GbmGlesBackend::with_factory(Box::new(create_renderer));
let api = GbmGlesBackend::with_context_priority(ContextPriority::High);
let gpu_manager = GpuManager::new(api).context("error creating the GPU manager")?;
let (primary_node, primary_render_node) = primary_node_from_config(&config.borrow())
@ -1987,8 +1978,8 @@ fn surface_dmabuf_feedback(
let surface = compositor.surface();
let planes = surface.planes();
let plane_formats = planes
.primary
let plane_formats = surface
.plane_info()
.formats
.iter()
.chain(planes.overlay.iter().flat_map(|p| p.formats.iter()))

View File

@ -50,7 +50,8 @@ impl CompositorHandler for State {
let maybe_dmabuf = with_states(surface, |surface_data| {
surface_data
.cached_state
.pending::<SurfaceAttributes>()
.get::<SurfaceAttributes>()
.pending()
.buffer
.as_ref()
.and_then(|assignment| match assignment {

View File

@ -1000,8 +1000,10 @@ pub fn add_mapped_toplevel_pre_commit_hook(toplevel: &ToplevelSurface) -> HookId
};
let (got_unmapped, commit_serial) = with_states(surface, |states| {
let attrs = states.cached_state.pending::<SurfaceAttributes>();
let got_unmapped = matches!(attrs.buffer, Some(BufferAssignment::Removed));
let got_unmapped = {
let mut guard = states.cached_state.get::<SurfaceAttributes>();
matches!(guard.pending().buffer, Some(BufferAssignment::Removed))
};
let role = states
.data_map

View File

@ -1143,13 +1143,13 @@ impl State {
let geom = self.niri.global_space.output_geometry(output).unwrap();
let mut point = (new_pos - geom.loc.to_f64())
.to_physical(output.current_scale().fractional_scale())
.to_i32_round();
.to_i32_round::<i32>();
let size = output.current_mode().unwrap().size;
let transform = output.current_transform();
let size = transform.transform_size(size);
point.x = min(size.w - 1, point.x);
point.y = min(size.h - 1, point.y);
point.x = point.x.clamp(0, size.w - 1);
point.y = point.y.clamp(0, size.h - 1);
self.niri.screenshot_ui.pointer_motion(point);
}
@ -1242,13 +1242,13 @@ impl State {
let geom = self.niri.global_space.output_geometry(output).unwrap();
let mut point = (pos - geom.loc.to_f64())
.to_physical(output.current_scale().fractional_scale())
.to_i32_round();
.to_i32_round::<i32>();
let size = output.current_mode().unwrap().size;
let transform = output.current_transform();
let size = transform.transform_size(size);
point.x = min(size.w - 1, point.x);
point.y = min(size.h - 1, point.y);
point.x = point.x.clamp(0, size.w - 1);
point.y = point.y.clamp(0, size.h - 1);
self.niri.screenshot_ui.pointer_motion(point);
}

View File

@ -17,7 +17,7 @@ pub trait NiriRenderer:
+ AsGlesRenderer
{
// Associated types to work around the instability of associated type bounds.
type NiriTextureId: Texture + Clone + 'static;
type NiriTextureId: Texture + Clone + Send + 'static;
type NiriError: std::error::Error
+ Send
+ Sync
@ -28,7 +28,7 @@ pub trait NiriRenderer:
impl<R> NiriRenderer for R
where
R: ImportAll + ImportMem + ExportMem + Bind<Dmabuf> + Offscreen<GlesTexture> + AsGlesRenderer,
R::TextureId: Texture + Clone + 'static,
R::TextureId: Texture + Clone + Send + 'static,
R::Error: std::error::Error + Send + Sync + From<<GlesRenderer as Renderer>::Error> + 'static,
{
type NiriTextureId = R::TextureId;

View File

@ -25,7 +25,7 @@ pub fn render_snapshot_from_surface_tree(
let data = states.data_map.get::<RendererSurfaceStateUserData>();
if let Some(data) = data {
let data = &*data.borrow();
let data = &*data.lock().unwrap();
if let Some(view) = data.view() {
location += view.offset.to_f64();
@ -42,19 +42,17 @@ pub fn render_snapshot_from_surface_tree(
let data = states.data_map.get::<RendererSurfaceStateUserData>();
if let Some(data) = data {
if let Some(view) = data.borrow().view() {
location += view.offset.to_f64();
} else {
let Some(view) = data.lock().unwrap().view() else {
return;
}
};
location += view.offset.to_f64();
if let Err(err) = import_surface(renderer, states) {
warn!("failed to import surface: {err:?}");
return;
}
let data = data.borrow();
let view = data.view().unwrap();
let data = data.lock().unwrap();
let Some(texture) = data.texture::<GlesRenderer>(renderer.id()) else {
return;
};

View File

@ -461,8 +461,8 @@ impl LayoutElement for Mapped {
fn min_size(&self) -> Size<i32, Logical> {
let mut size = with_states(self.toplevel().wl_surface(), |state| {
let curr = state.cached_state.current::<SurfaceCachedState>();
curr.min_size
let mut guard = state.cached_state.get::<SurfaceCachedState>();
guard.current().min_size
});
if let Some(x) = self.rules.min_width {
@ -477,8 +477,8 @@ impl LayoutElement for Mapped {
fn max_size(&self) -> Size<i32, Logical> {
let mut size = with_states(self.toplevel().wl_surface(), |state| {
let curr = state.cached_state.current::<SurfaceCachedState>();
curr.max_size
let mut guard = state.cached_state.get::<SurfaceCachedState>();
guard.current().max_size
});
if let Some(x) = self.rules.max_width {