From 0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:56:00 +0200 Subject: Checkpoint: preserve all uncommitted rust-rewrite worktree work Safety commit before reconciling this worktree with main, which has diverged with its own separate fixes today. Nothing here is reviewed or curated yet - this exists purely so none of this work can be lost to a git operation, disk issue, or worktree cleanup while that reconciliation happens. --- crates/wayland/src/udev/session.rs | 49 ++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'crates/wayland/src/udev/session.rs') diff --git a/crates/wayland/src/udev/session.rs b/crates/wayland/src/udev/session.rs index 4dd6db0..561ba7a 100644 --- a/crates/wayland/src/udev/session.rs +++ b/crates/wayland/src/udev/session.rs @@ -89,9 +89,17 @@ pub(crate) fn register_session_notifier(handle: &LoopHandle<'static, CompState>, // Some drivers reset mode-setting state across a VT // switch; reassert every head before rendering again. + // + // The real connector and mode, not an empty connector + // list and no mode - that shape is DRM/KMS's own way + // to *disable* a CRTC, not reassert it, and was + // confirmed live to leave the screen black after + // switching back with no further VT switch, either + // direction, able to recover it. See `UdevHead::mode`'s + // own doc comment. for head in &mut udev.heads { let fb = head.buffers[head.front].fb; - if let Err(e) = card.set_crtc(head.crtc, Some(fb), (0, 0), &[], None) { + if let Err(e) = card.set_crtc(head.crtc, Some(fb), (0, 0), &[head.connector], Some(head.mode)) { log::warn!("udev: failed to reassert crtc on resume: {e}"); } // Force a full repaint: contents are undefined after @@ -139,10 +147,41 @@ fn handle_libinput_event(state: &mut CompState, event: InputEvent { + let Some(udev) = state.udev.as_mut() else { return }; + // `position_transformed` maps the device's own normalized + // [0,1] position into a `(0, 0)`-anchored size - offset by + // `min_x`/`min_y` afterward, same reasoning as `PointerMotion` + // above, so this still addresses a negative-origin head. + let (min_x, min_y, max_x, max_y) = udev.bounds(); + let size = Size::from(((max_x - min_x) as i32, (max_y - min_y) as i32)); + let pos = event.position_transformed(size); + udev.pointer_pos.x = (pos.x + min_x).clamp(min_x, (max_x - 1.0).max(min_x)); + udev.pointer_pos.y = (pos.y + min_y).clamp(min_y, (max_y - 1.0).max(min_y)); let pos = udev.pointer_pos; handle_pointer_position(state, pos, event.time_msec()); } -- cgit v1.2.3