mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 08:50:40 +01:00
Separate portal input audit budgets and count native GTK button delivery
This commit is contained in:
1 parent
ef697de387
commit
7e334bfe69
3 files changed
+60
-3
No files matched your search
+10
-3
@@ -33,11 +33,11 @@ struct PendingPointer {
|
||||
unsafe fn x11_pointer_state(_: *mut libc::c_int,_:*mut libc::c_int,_:*mut libc::c_uint)->libc::c_int {-1}
|
||||
#[derive(Default)]
|
||||
struct HeldInput { buttons: std::collections::BTreeSet<i32>, keys: std::collections::BTreeSet<u64> }
|
||||
pub struct InputInjector { portal_failures: std::sync::atomic::AtomicUsize, portal_outcomes: std::sync::atomic::AtomicUsize, portal:std::sync::Mutex<Option<std::sync::Arc<crate::portal::PortalSession>>>, backend: crate::desktop_backend::DesktopBackend, pending: std::sync::Mutex<PendingPointer>, held: std::sync::Mutex<HeldInput> }
|
||||
pub struct InputInjector { portal_failures: std::sync::atomic::AtomicUsize, portal_outcomes: [std::sync::atomic::AtomicUsize; 3], portal:std::sync::Mutex<Option<std::sync::Arc<crate::portal::PortalSession>>>, backend: crate::desktop_backend::DesktopBackend, pending: std::sync::Mutex<PendingPointer>, held: std::sync::Mutex<HeldInput> }
|
||||
|
||||
impl InputInjector {
|
||||
pub fn new() -> Self {
|
||||
Self { portal_failures: std::sync::atomic::AtomicUsize::new(0), portal_outcomes: std::sync::atomic::AtomicUsize::new(0), portal:std::sync::Mutex::new(None), backend:crate::desktop_backend::detect().unwrap_or(crate::desktop_backend::DesktopBackend::X11), pending: std::sync::Mutex::new(PendingPointer::default()), held:std::sync::Mutex::new(HeldInput::default()) }
|
||||
Self { portal_failures: std::sync::atomic::AtomicUsize::new(0), portal_outcomes: std::array::from_fn(|_| std::sync::atomic::AtomicUsize::new(0)), portal:std::sync::Mutex::new(None), backend:crate::desktop_backend::detect().unwrap_or(crate::desktop_backend::DesktopBackend::X11), pending: std::sync::Mutex::new(PendingPointer::default()), held:std::sync::Mutex::new(HeldInput::default()) }
|
||||
}
|
||||
|
||||
pub fn bind_portal(&self,session:Option<std::sync::Arc<crate::portal::PortalSession>>) {
|
||||
@@ -95,6 +95,12 @@ impl InputInjector {
|
||||
}
|
||||
pub fn wire_mouse_button(&self, button: i32, is_press: bool) {
|
||||
if let Some(mapped) = crate::input_mapping::mouse_button_to_x11(button) { self.mouse_button(mapped,is_press); }
|
||||
else {
|
||||
static UNKNOWN: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||
if UNKNOWN.fetch_add(1, std::sync::atomic::Ordering::Relaxed) < 16 {
|
||||
log::warn!("Unsupported desktop wire mouse button: {}", button);
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn mouse_button(&self, button: i32, is_press: bool) {
|
||||
self.flush_pointer();
|
||||
@@ -136,7 +142,8 @@ impl InputInjector {
|
||||
// and D-Bus errors. Never include keys, coordinates, text or portal tokens.
|
||||
fn portal_result(&self, operation: &str, result: Result<(), String>) -> i32 {
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
if self.portal_outcomes.fetch_add(1, Relaxed) < 16 {
|
||||
let slot = match operation { "motion" => 0, "button" => 1, _ => 2 };
|
||||
if self.portal_outcomes[slot].fetch_add(1, Relaxed) < 16 {
|
||||
log::info!("Portal input outcome: operation={} success={}", operation, result.is_ok());
|
||||
}
|
||||
match result {
|
||||
|
||||
@@ -714,6 +714,16 @@ impl WebRtcSession {
|
||||
match crate::control_protocol::decode_control(&msg.data) {
|
||||
Ok(crate::control_protocol::ControlMessage::Input(event)) => {
|
||||
use crate::control_protocol::ControlInput;
|
||||
// Separate receipt budgets keep motion floods from hiding clicks.
|
||||
static RECEIPTS: [std::sync::atomic::AtomicUsize; 3] = [const { std::sync::atomic::AtomicUsize::new(0) }; 3];
|
||||
let (slot, kind) = match &event {
|
||||
ControlInput::MouseButton {..} | ControlInput::MouseClick {..} => (0, "button"),
|
||||
ControlInput::Keyboard {..} | ControlInput::KeyboardClick {..} => (1, "keyboard"),
|
||||
_ => (2, "motion"),
|
||||
};
|
||||
if RECEIPTS[slot].fetch_add(1, std::sync::atomic::Ordering::Relaxed) < 16 {
|
||||
log::info!("CONTROL input received: kind={}", kind);
|
||||
}
|
||||
match &event {
|
||||
ControlInput::MouseAbsolute {x,y} => input_worker.mouse_absolute_normalized(*x,*y,input_size),
|
||||
ControlInput::MouseRelative {dx,dy} => input_worker.mouse_relative(*dx,*dy),
|
||||
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
"""Official viewer clipboard fixture; only synthetic-marker match booleans are recorded."""
|
||||
import gi,json
|
||||
from pathlib import Path
|
||||
gi.require_version('Gtk','4.0'); gi.require_version('Gdk','4.0')
|
||||
from gi.repository import Gtk,Gdk,GLib
|
||||
assert Path('/proc/sys/kernel/hostname').read_text().strip()=='uu-hyprland-test'
|
||||
state={'native_wayland':False,'mac_to_vm':False,'reverse_owned':False,'button_presses':0,'button_releases':0,'check_activations':0,'copy_activations':0,'window_active':False}
|
||||
report=Path('/tmp/uuremote-clipboard-official.json')
|
||||
app=Gtk.Application(application_id='dev.uuremote.ClipboardOfficial')
|
||||
def activate(app):
|
||||
window=Gtk.ApplicationWindow(application=app,title='UU clipboard official acceptance')
|
||||
box=Gtk.Box(orientation=Gtk.Orientation.VERTICAL,spacing=24)
|
||||
box.set_halign(Gtk.Align.CENTER);box.set_valign(Gtk.Align.CENTER)
|
||||
label=Gtk.Label(label='UU Portal clipboard acceptance')
|
||||
check=Gtk.Button(label='Check Mac → VM')
|
||||
copy=Gtk.Button(label='Copy VM → Mac')
|
||||
box.append(label);box.append(check);box.append(copy);window.set_child(box)
|
||||
clipboard=window.get_clipboard()
|
||||
def read(*_):
|
||||
state['check_activations']+=1
|
||||
def done(source,result):
|
||||
try: state['mac_to_vm']=source.read_text_finish(result)=='UU-Mac-to-VM 中文🙂'
|
||||
except GLib.Error: state['mac_to_vm']=False
|
||||
label.set_label('Mac → VM: '+('PASS' if state['mac_to_vm'] else 'not matched'))
|
||||
clipboard.read_text_async(None,done)
|
||||
def write(*_):
|
||||
state['copy_activations']+=1
|
||||
clipboard.set('UU-VM-to-Mac 中文🚀');state['reverse_owned']=True
|
||||
label.set_label('VM marker copied')
|
||||
check.connect('clicked',read);copy.connect('clicked',write)
|
||||
window.connect('notify::is-active',lambda *_:state.update(window_active=window.is_active()))
|
||||
gesture=Gtk.GestureClick();gesture.set_propagation_phase(Gtk.PropagationPhase.CAPTURE)
|
||||
gesture.connect('pressed',lambda *_:state.update(button_presses=state['button_presses']+1))
|
||||
gesture.connect('released',lambda *_:state.update(button_releases=state['button_releases']+1))
|
||||
window.add_controller(gesture)
|
||||
window.present();window.fullscreen()
|
||||
state['native_wayland']='wayland' in type(Gdk.Display.get_default()).__name__.lower()
|
||||
def record(): report.write_text(json.dumps(state));return True
|
||||
GLib.timeout_add(200,record)
|
||||
app.connect('activate',activate);app.run([])
|
||||
Reference in new issue
Block a user