shithub: patch

ref: 20aa3af767e567d9785b6d64fef6bc48c4680a3c
dir: /doom-mousegrab/

View raw version
doom: re-center mouse more often to limit it escaping

when a mouse motion reaches grabout's limits without crossing them, a following
event in which the mouse passes the remaining distance between grabout and the
window's limits will have the mouse jump out of the window.
this happens too frequently on terminals with a good drawing speed.

to reduce this, make grabout smaller, so that the distance to cross in one
event is larger. Dx(screen->r)/4 is sufficient for the terminals i have tested
this on.

diff d5938c597328adb8abb8785b4ac820ca0f094b6b uncommitted
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -44,7 +44,7 @@
 	draw(screen, screen->r, display->black, nil, ZP);
 
 	center = addpt(screen->r.min, Pt(Dx(screen->r)/2, Dy(screen->r)/2));
-	grabout = insetrect(screen->r, Dx(screen->r)/8);
+	grabout = insetrect(screen->r, Dx(screen->r)/4);
 
 	kbdpid = proccreate(kbdproc, nil, 4096);
 	mousepid = proccreate(mouseproc, nil, 4096);
@@ -152,7 +152,7 @@
 		draw(screen, screen->r, display->black, nil, ZP);
 
 		center = addpt(screen->r.min, Pt(Dx(screen->r)/2, Dy(screen->r)/2));
-		grabout = insetrect(screen->r, Dx(screen->r)/8);
+		grabout = insetrect(screen->r, Dx(screen->r)/4);
 	}
 
 	if(conv == nil){