mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-17 01:00:41 +01:00
Fix niri monitor switching, rotated input and mobile text (#71)
niri 实验性支持:三屏切换、90°/180°/270° 旋转输出的采集与指针映射、手机中文文本输入,全部 gated 在 NIRI_SOCKET,不影响 Hyprland/X11 路径。新增 wayland_transform.h 及其 ASAN 单测。 感谢 @WALKERKILLER 的贡献与 CachyOS + niri 实机验收。 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
1 parent
482c01a85d
commit
835bfa2319
10 files changed
+205
-27
No files matched your search
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
# Requires an unlocked niri session; opens a fullscreen test window and moves the pointer.
|
||||
# UU_TEST_OUTPUT selects the output. UU_TEST_ENGINE is the built libuu-wayland.so.
|
||||
import os,json,subprocess,ctypes,gi
|
||||
os.environ['UU_WAYLAND_OUTPUT']=os.environ['UU_TEST_OUTPUT']
|
||||
gi.require_version('Gtk','3.0');from gi.repository import Gtk,Gdk,GLib
|
||||
inv=json.loads(subprocess.check_output(['niri','msg','-j','outputs']))
|
||||
out=next(o for o in inv.values() if o['name']==os.environ['UU_TEST_OUTPUT']);geo=out['logical'];d=Gdk.Display.get_default()
|
||||
monitor=next(i for i in range(d.get_n_monitors()) if (d.get_monitor(i).get_geometry().x,d.get_monitor(i).get_geometry().y)==(geo['x'],geo['y']))
|
||||
w=Gtk.Window(title='UU pointer acceptance');box=Gtk.EventBox();box.set_above_child(True);grid=Gtk.Grid();grid.set_row_homogeneous(True);grid.set_column_homogeneous(True)
|
||||
for i,color in enumerate(['red','lime','blue','yellow']):
|
||||
cell=Gtk.EventBox();rgba=Gdk.RGBA();rgba.parse(color);cell.override_background_color(Gtk.StateFlags.NORMAL,rgba);grid.attach(cell,i%2,i//2,1,1)
|
||||
box.add(grid);w.add(box);box.add_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.ENTER_NOTIFY_MASK)
|
||||
positions=[];box.connect('motion-notify-event',lambda widget,e:positions.append((e.x,e.y)) or False)
|
||||
box.connect('enter-notify-event',lambda widget,e:positions.append((e.x,e.y)) or False)
|
||||
w.fullscreen_on_monitor(w.get_screen(),monitor);w.show_all()
|
||||
lib=ctypes.CDLL(os.environ['UU_TEST_ENGINE']);width=ctypes.c_int();height=ctypes.c_int();points=iter([(0.2,0.2),(0.8,0.2),(0.8,0.8),(0.2,0.8),(0.5,0.5)]);passed=[];image_matches=0
|
||||
def step():
|
||||
try:x,y=next(points)
|
||||
except StopIteration:print('pointer_points_passed=',sum(passed),'total=',len(passed),'points=',passed,flush=True);Gtk.main_quit();return False
|
||||
positions.clear();assert lib.uu_wl_move(int(x*width.value),int(y*height.value),0)==0
|
||||
def check():
|
||||
size=box.get_allocation();matched=any(abs(px-x*size.width)<4 and abs(py-y*size.height)<4 for px,py in positions);passed.append(matched);GLib.timeout_add(100,step);return False
|
||||
GLib.timeout_add(150,check);return False
|
||||
def start():
|
||||
global image_matches
|
||||
assert lib.uu_wl_init(ctypes.byref(width),ctypes.byref(height))==0
|
||||
frame=(ctypes.c_ubyte*(width.value*height.value*4))();assert lib.uu_wl_capture(frame,len(frame))==0
|
||||
for (x,y),(r,g,b) in zip([(0.25,0.25),(0.75,0.25),(0.25,0.75),(0.75,0.75)],[(255,0,0),(0,255,0),(0,0,255),(255,255,0)]):
|
||||
at=(int(y*height.value)*width.value+int(x*width.value))*4
|
||||
image_matches+=abs(frame[at]-b)<10 and abs(frame[at+1]-g)<10 and abs(frame[at+2]-r)<10
|
||||
print('rotation_color_checks=',image_matches,'of=4',flush=True)
|
||||
step();return False
|
||||
GLib.timeout_add(1500,start);GLib.timeout_add(10000,lambda:(Gtk.main_quit(),False)[1]);Gtk.main()
|
||||
raise SystemExit(0 if len(passed)==5 and all(passed) and image_matches==4 else 1)
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
# Run with /usr/bin/python, UU_TEST_BIN set to the test binary, and GDK_BACKEND=x11 or wayland.
|
||||
# Opens and focuses a dedicated entry; only the built-in sample is injected.
|
||||
import os
|
||||
os.environ["GTK_IM_MODULE"]="gtk-im-context-simple"
|
||||
import gi,subprocess,threading
|
||||
gi.require_version('Gtk','3.0')
|
||||
from gi.repository import Gtk,GLib
|
||||
events=[]
|
||||
passed=False
|
||||
expected=os.environ.get("UU_PROBE_SEQUENCE","abc你好XYZ").replace("|","")
|
||||
w=Gtk.Window(title='UU input acceptance'); e=Gtk.Entry();w.add(e);w.show_all();e.grab_focus();w.present();e.connect("key-press-event",lambda widget,event:events.append(event.keyval) and False)
|
||||
def start():
|
||||
if "UU input acceptance" not in subprocess.check_output(["niri","msg","-j","focused-window"],text=True):
|
||||
Gtk.main_quit();return False
|
||||
def run():
|
||||
r=subprocess.run([os.environ.get('UU_TEST_BIN',os.path.expanduser('~/.local/bin/uuremote-server')),'wayland-text-probe'],env={**os.environ,'UU_PROBE_TEXT':'abc你好XYZ'},stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||
GLib.timeout_add(1000,finish,r.returncode)
|
||||
threading.Thread(target=run).start();return False
|
||||
def finish(code):
|
||||
global passed
|
||||
passed=code==0 and e.get_text()==expected
|
||||
print('probe_exit=',code,'matches=',e.get_text()==expected,'received_chars=',len(e.get_text()),'key_events=',len(events),flush=True);Gtk.main_quit();return False
|
||||
GLib.timeout_add(1500,start);GLib.timeout_add(15000,lambda:(Gtk.main_quit(),False)[1]);Gtk.main()
|
||||
|
||||
raise SystemExit(0 if passed else 1)
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <assert.h>
|
||||
#include "../c_engine/wayland_transform.h"
|
||||
int main(void) {
|
||||
assert(uu_output_transform_supported(0,0));
|
||||
for(int t=1;t<=3;t++) {
|
||||
assert(!uu_output_transform_supported(t,0));
|
||||
assert(uu_output_transform_supported(t,1));
|
||||
}
|
||||
assert(!uu_output_transform_supported(4,1));
|
||||
assert(!uu_output_transform_supported(-1,1));
|
||||
const unsigned expected[4][6]={{0,1,2,3,4,5},{3,0,4,1,5,2},{5,4,3,2,1,0},{2,5,1,4,0,3}};
|
||||
for(int t=0;t<4;t++) {
|
||||
unsigned dw=t&1?2:3,dh=t&1?3:2;
|
||||
for(unsigned y=0;y<dh;y++) for(unsigned x=0;x<dw;x++) {
|
||||
uint32_t sx,sy;uu_source_pixel(t,3,2,x,y,&sx,&sy);
|
||||
assert(sx<3 && sy<2 && sy*3+sx==expected[t][y*dw+x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user