mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-02 22:19:00 +00:00
Exercise the Windows Hand gesture with native hosted-desktop input
This commit is contained in:
@@ -167,12 +167,37 @@ try:
|
||||
engine("file.open",path=str(path))
|
||||
wait(lambda: object_count()==count, f"{path.name} should contain {count} rectangles")
|
||||
print(path.name,path.stat().st_size,digest(path),"objects:",count,flush=True)
|
||||
view=state(); x,y,w,h=view["canvasRect"]
|
||||
engine("file.new",width=700,height=500)
|
||||
engine("tool.select",tool="selection")
|
||||
call("ui.key",key="h")
|
||||
wait(lambda: state()["tool"]=="hand","H failed to select Hand")
|
||||
time.sleep(.6)
|
||||
# Send a real Windows mouse drag in the dedicated runner desktop; the drawing host reads
|
||||
# native cursor location between egui frames while its Hand gesture is held.
|
||||
view=state()
|
||||
x,y,w,h=view["canvasRect"]
|
||||
print("Native Hand drag in canvas",view["canvasRect"],"of window",view["window"],flush=True)
|
||||
user=ctypes.WinDLL("user32",use_last_error=True)
|
||||
hwnd=user.GetForegroundWindow()
|
||||
owner=wintypes.DWORD()
|
||||
user.GetWindowThreadProcessId(hwnd,ctypes.byref(owner))
|
||||
assert owner.value==process.pid,("foreground owner",owner.value,process.pid)
|
||||
client=wintypes.RECT()
|
||||
assert user.GetClientRect(hwnd,ctypes.byref(client))
|
||||
scale=client.right/view["window"][0]
|
||||
pt=wintypes.POINT(round((x+w*.47)*scale),round((y+h*.64)*scale))
|
||||
assert user.ClientToScreen(hwnd,ctypes.byref(pt))
|
||||
before=state()["view"]
|
||||
call("ui.drag",x=x+w*.4,y=y+h*.4,toX=x+w*.4+60,toY=y+h*.4+40,steps=8)
|
||||
assert user.SetCursorPos(pt.x,pt.y)
|
||||
time.sleep(.4)
|
||||
user.mouse_event(2,0,0,0,0)
|
||||
try:
|
||||
for i in range(1,11):
|
||||
time.sleep(.06)
|
||||
assert user.SetCursorPos(pt.x+i*6,pt.y+i*4)
|
||||
finally:
|
||||
user.mouse_event(4,0,0,0,0)
|
||||
time.sleep(.5)
|
||||
after=state()["view"]
|
||||
assert before["zoom"]==after["zoom"] and before["center"]!=after["center"],(before,after)
|
||||
print("Hand selected by H moved the canvas centre",before["center"],after["center"],flush=True)
|
||||
|
||||
Reference in New Issue
Block a user