From 68b4cb1f1bf28fa2b6eb09acadfa10721b26a70e Mon Sep 17 00:00:00 2001 From: Utkarsh Dalal Date: Tue, 10 Nov 2026 10:07:01 +0530 Subject: [PATCH] injector: an absolute pointer position carries its extent nativePointerAbsolute takes (x, y, width, height): the position on a width x height extent that covers the output. The virtual pointer's motion_absolute now sends that extent instead of 0, 0, which wlroots drops. An event with a zero or negative extent is dropped; a negative coordinate is clamped to 0. --- docs/02-gamenative-drm.md | 3 ++- modules/gndrm-android/src/injector.rs | 24 +++++++++++++++++------- modules/gndrm-android/src/lib.rs | 7 +++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/02-gamenative-drm.md b/docs/02-gamenative-drm.md index cc2c55e..d081ae8 100644 --- a/docs/02-gamenative-drm.md +++ b/docs/02-gamenative-drm.md @@ -340,7 +340,8 @@ in the app's `jniLibs/arm64-v8a/` and is loaded via - session inputs, before `nativeStart`: `nativeSetPanelRefreshHz(hz)` (the mode's rate) and `nativeSetScanoutGeometry(w, h)` (the mode's size — the app's Upscaling Resolution; `0, 0` clears it). -- injector calls: `nativePointerAbsolute(x, y)`, `nativePointerMotion(dx, dy)`, +- injector calls: `nativePointerAbsolute(x, y, width, height)` ((x, y) on a + width x height extent that covers the output), `nativePointerMotion(dx, dy)`, `nativePointerButton(btn, pressed)`, `nativePointerAxis(axis, value)`, `nativeKey(evdevCode, pressed)`. diff --git a/modules/gndrm-android/src/injector.rs b/modules/gndrm-android/src/injector.rs index a3d6077..4be80ac 100644 --- a/modules/gndrm-android/src/injector.rs +++ b/modules/gndrm-android/src/injector.rs @@ -116,7 +116,8 @@ const XKB_KEYMAP_FORMAT_TEXT_V1: u32 = 1; /// Input events posted from JNI (any thread) into the injector thread. enum InputEvent { - PointerAbsolute(i32, i32), + /// (x, y) on a width x height extent that covers the output. + PointerAbsolute(i32, i32, i32, i32), PointerMotion(i32, i32), PointerButton(i32, bool), PointerAxis(i32, f32), @@ -262,8 +263,8 @@ fn post(ev: InputEvent) { } } -pub fn pointer_absolute(x: i32, y: i32) { - post(InputEvent::PointerAbsolute(x, y)); +pub fn pointer_absolute(x: i32, y: i32, width: i32, height: i32) { + post(InputEvent::PointerAbsolute(x, y, width, height)); } pub fn pointer_motion(dx: i32, dy: i32) { post(InputEvent::PointerMotion(dx, dy)); @@ -742,11 +743,20 @@ fn connect_and_run( fn apply(state: &State, ev: InputEvent) { let t = now_ms(); match ev { - InputEvent::PointerAbsolute(x, y) => { + InputEvent::PointerAbsolute(x, y, width, height) => { if let Some(p) = &state.pointer { - // Extent = the gamescope output size; coordinates arrive in - // the same space (the view the user touches IS the output). - p.motion_absolute(t, x as u32, y as u32, 0, 0); + // The compositor maps (x, y) / (width, height) onto the + // output; wlroots drops a motion_absolute with a 0 extent. + if width <= 0 || height <= 0 { + return; + } + p.motion_absolute( + t, + x.max(0) as u32, + y.max(0) as u32, + width as u32, + height as u32, + ); p.frame(); } } diff --git a/modules/gndrm-android/src/lib.rs b/modules/gndrm-android/src/lib.rs index baa1f4f..c7d25cf 100644 --- a/modules/gndrm-android/src/lib.rs +++ b/modules/gndrm-android/src/lib.rs @@ -1598,17 +1598,20 @@ pub extern "system" fn Java_app_gamenative_display_GameNativeDrm_nativeDisplayIn .unwrap_or(std::ptr::null_mut()) } -/// `GameNativeDrm.nativePointerAbsolute(x, y)`. +/// `GameNativeDrm.nativePointerAbsolute(x, y, width, height)` — (x, y) on a +/// width x height extent that covers the output. #[no_mangle] pub extern "system" fn Java_app_gamenative_display_GameNativeDrm_nativePointerAbsolute( _env: JNIEnv, _class: JClass, x: jint, y: jint, + width: jint, + height: jint, ) { // Input handlers are a subsystem too: a poisoned injector lock must not // abort the app (see injector.rs), and anything else is contained here. - if let Err(e) = std::panic::catch_unwind(|| injector::pointer_absolute(x, y)) { + if let Err(e) = std::panic::catch_unwind(|| injector::pointer_absolute(x, y, width, height)) { report_panic("gndrm-input", e.as_ref()); } }