Skip to content

Commit

Permalink
Update Smithay
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottatop committed Jul 1, 2024
1 parent 88c1a88 commit c7907df
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 99 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ indexmap = "2.2.6"

[workspace.dependencies.smithay]
git = "https://github.com/Smithay/smithay"
rev = "69b379d"
rev = "3731734"
# path = "../../git/smithay"
default-features = false
features = [
Expand Down Expand Up @@ -85,7 +85,7 @@ keywords = ["wayland", "compositor", "smithay", "lua"]
[dependencies]
# Smithay
smithay = { workspace = true }
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "69b379d" }
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "3731734" }
# Tracing
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Problems:
- Xwayland popups are screwed when the output is not at (0, 0)
- Dragging an xwayland window to another output and closing a nested right click menu closes the whole
right click menu because the keyboard focus is getting updated on the original output.
- Turning a monitor off then on causes scale increases to not propagate the new scale to clients resulting in blurry windows
124 changes: 33 additions & 91 deletions src/backend/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl Udev {
/// Schedule a new render that will cause the compositor to redraw everything.
pub fn schedule_render(&mut self, loop_handle: &LoopHandle<State>, output: &Output) {
let Some(surface) = render_surface_for_output(output, &mut self.backends) else {
tracing::info!("no render surface on output {}", output.name());
debug!("no render surface on output {}", output.name());
return;
};

Expand Down Expand Up @@ -522,58 +522,12 @@ impl Udev {
impl State {
/// Switch the tty.
///
/// This will first clear the overlay plane to prevent any lingering artifacts,
/// then switch the vt.
///
/// Does nothing when called on the winit backend.
pub fn switch_vt(&mut self, vt: i32) {
if let Backend::Udev(udev) = &mut self.backend {
if let Err(err) = udev.session.change_vt(vt) {
error!("Failed to switch to vt {vt}: {err}");
}

// TODO: uncomment this when `RenderFrameResult::blit_frame_result` is fixed for
// | overlay/cursor planes

// for backend in udev.backends.values_mut() {
// for surface in backend.surfaces.values_mut() {
// // Clear the overlay planes on tty switch.
// //
// // On my machine, switching a tty would leave the topmost window on the
// // screen. Smithay will render the topmost window on the overlay plane,
// // so we clear it here.
// let planes = surface.compositor.surface().planes().clone();
// tracing::debug!("Clearing overlay planes");
// for overlay_plane in planes.overlay {
// if let Err(err) = surface
// .compositor
// .surface()
// .clear_plane(overlay_plane.handle)
// {
// warn!("Failed to clear overlay planes: {err}");
// }
// }
// }
// }

// Wait for the clear to commit before switching
// self.schedule(
// |state| {
// let udev = state.backend.udev();
// !udev
// .backends
// .values()
// .flat_map(|backend| backend.surfaces.values())
// .map(|surface| surface.compositor.surface())
// .any(|drm_surf| drm_surf.commit_pending())
// },
// move |state| {
// let udev = state.backend.udev_mut();
// if let Err(err) = udev.session.change_vt(vt) {
// error!("Failed to switch to vt {vt}: {err}");
// }
// },
// );
}
}
}
Expand Down Expand Up @@ -708,8 +662,8 @@ fn get_surface_dmabuf_feedback(
// the supplied buffer can not be scanned out directly
let planes_formats = planes
.primary
.formats
.into_iter()
.flat_map(|p| p.formats)
.chain(planes.overlay.into_iter().flat_map(|p| p.formats))
.collect::<IndexSet<_>>()
.intersection(&all_render_formats)
Expand Down Expand Up @@ -800,7 +754,7 @@ enum PendingGammaChange {
struct ScreencopyCommitState {
primary_plane_swapchain: CommitCounter,
primary_plane_element: CommitCounter,
_cursor: CommitCounter,
cursor: CommitCounter,
}

type GbmDrmCompositor = DrmCompositor<
Expand Down Expand Up @@ -1036,8 +990,9 @@ impl Udev {
let mut planes = surface.planes().clone();

// INFO: We are disabling overlay planes because it seems that any elements on
// | overlay planes don't get up/downscaled according to the set filter;
// | it always defaults to linear.
// overlay planes don't get up/downscaled according to the set filter;
// it always defaults to linear. Also alacritty seems to have the wrong alpha
// when it's on the overlay plane.
planes.overlay.clear();

match DrmCompositor::new(
Expand Down Expand Up @@ -1117,7 +1072,7 @@ impl Udev {
node: DrmNode,
crtc: crtc::Handle,
) {
tracing::debug!(?crtc, "connector_disconnected");
debug!(?crtc, "connector_disconnected");

let device = if let Some(device) = self.backends.get_mut(&node) {
device
Expand Down Expand Up @@ -1185,7 +1140,7 @@ impl Udev {
self.connector_disconnected(pinnacle, node, crtc);
}

tracing::debug!("Surfaces dropped");
debug!("Surfaces dropped");

// drop the backends on this side
if let Some(backend_data) = self.backends.remove(&node) {
Expand All @@ -1195,7 +1150,7 @@ impl Udev {

pinnacle.loop_handle.remove(backend_data.registration_token);

tracing::debug!("Dropping device");
debug!("Dropping device");
}
}

Expand Down Expand Up @@ -1393,19 +1348,6 @@ impl Udev {
|| (pinnacle.lock_state.is_locked()
&& output.with_state(|state| state.lock_surface.is_none()));

// HACK: Doing `blit_frame_result` with something on the cursor/overlay plane overwrites
// transparency. This workaround makes the cursor not be on the cursor plane for blitting.
let kind = if output.with_state(|state| {
state
.screencopy
.as_ref()
.is_some_and(|sc| sc.overlay_cursor())
}) {
element::Kind::Unspecified
} else {
element::Kind::Cursor
};

let (pointer_render_elements, cursor_ids) = pointer_render_elements(
output,
&mut renderer,
Expand All @@ -1414,7 +1356,6 @@ impl Udev {
pointer_location,
pinnacle.dnd_icon.as_ref(),
&pinnacle.clock,
kind,
);
output_render_elements.extend(
pointer_render_elements
Expand Down Expand Up @@ -1587,7 +1528,7 @@ fn handle_pending_screencopy<'a>(
// region. Sway does the former, Hyprland the latter. Also, no one actually seems to be using the
// received damage. wf-recorder and wl-mirror have no-op handlers for the damage event.

let damage = match &render_frame_result.primary_element {
let mut damage = match &render_frame_result.primary_element {
PrimaryPlaneElement::Swapchain(element) => {
let swapchain_commit = &mut surface.screencopy_commit_state.primary_plane_swapchain;
let damage = element.damage.damage_since(Some(*swapchain_commit));
Expand Down Expand Up @@ -1622,29 +1563,30 @@ fn handle_pending_screencopy<'a>(
)])
});

// INFO: This code is here for if the bug where `blit_frame_result` makes the area around
// | the cursor transparent is fixed/a workaround found.
// let cursor_damage = render_frame_result
// .cursor_element
// .map(|cursor| {
// let damage =
// cursor.damage_since(scale, Some(surface.screencopy_commit_state.cursor));
// new_commit_counters.cursor = cursor.current_commit();
// damage
// })
// .unwrap_or_default();
//
// damage.extend(cursor_damage);
let cursor_damage = render_frame_result
.cursor_element
.map(|cursor| {
let damage =
cursor.damage_since(scale, Some(surface.screencopy_commit_state.cursor));
surface.screencopy_commit_state.cursor = cursor.current_commit();
damage
})
.unwrap_or_default();

damage = damage.into_iter().chain(cursor_damage).collect();

// The primary plane and cursor had no damage but something got rendered,
// so it must be the cursor moving.
//
// // The primary plane and cursor had no damage but something got rendered,
// // so it must be the cursor moving.
// //
// // We currently have overlay planes disabled, so we don't have to worry about that.
// if damage.is_empty() && !render_frame_result.is_empty {
// if let Some(cursor_elem) = render_frame_result.cursor_element {
// damage.push(cursor_elem.geometry(scale));
// }
// }
// We currently have overlay planes disabled, so we don't have to worry about that.
if damage.is_empty() && !render_frame_result.is_empty {
if let Some(cursor_elem) = render_frame_result.cursor_element {
damage = damage
.into_iter()
.chain([cursor_elem.geometry(scale)])
.collect();
}
}

// INFO: Protocol states that `copy_with_damage` should wait until there is
// | damage to be copied.
Expand Down
1 change: 0 additions & 1 deletion src/backend/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ impl Winit {
pointer_location,
pinnacle.dnd_icon.as_ref(),
&pinnacle.clock,
element::Kind::Cursor,
);
output_render_elements.extend(
pointer_render_elements
Expand Down
2 changes: 1 addition & 1 deletion src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl WindowElement {
pub fn render_elements<R: PRenderer>(
&self,
renderer: &mut R,
location: Point<i32, Logical>,
location: Point<i32, Logical>, // TODO: make f64
scale: Scale<f64>,
alpha: f32,
) -> Vec<WaylandSurfaceRenderElement<R>> {
Expand Down
3 changes: 1 addition & 2 deletions src/render/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub fn pointer_render_elements<R: PRenderer>(
pointer_location: Point<f64, Logical>,
dnd_icon: Option<&WlSurface>,
clock: &Clock<Monotonic>,
kind: element::Kind,
) -> (Vec<PointerRenderElement<R>>, Vec<Id>) {
let mut pointer_render_elements = Vec::new();
let mut cursor_ids = Vec::new();
Expand Down Expand Up @@ -83,7 +82,7 @@ pub fn pointer_render_elements<R: PRenderer>(
None,
None,
None,
kind,
element::Kind::Cursor,
);

elem.map(|elem| vec![PointerRenderElement::Memory(elem)])
Expand Down

0 comments on commit c7907df

Please sign in to comment.