shithub: rio

Download patch

ref: e8e42318371ad89d7b048a3a05d3c57aed8fc0fd
parent: 1cc8d9ba9399a31c6e8559ef80f59a1c95d8814d
author: glenda <glenda@cirno>
date: Tue Mar 18 20:32:43 EDT 2025

window maintains contents when dragged

--- a/rio.c
+++ b/rio.c
@@ -979,7 +979,7 @@
 Image*
 drag(Window *w)
 {
-	Point p, op, d, dm, om;
+	Point p, op, origp, d, dm, om;
 	Rectangle r;
 
 	menuing = TRUE;
@@ -988,11 +988,14 @@
 	dm = subpt(om, w->screenr.min);
 	d = subpt(w->screenr.max, w->screenr.min);
 	op = subpt(om, dm);
+	origp = w->i->r.min;
 	drawborder(Rect(op.x, op.y, op.x+d.x, op.y+d.y), sizecol);
 	while(mouse->buttons==4){
 		p = subpt(mouse->xy, dm);
+		r = Rect(p.x, p.y, p.x+d.x, p.y+d.y);
 		if(!eqpt(p, op)){
-			drawborder(Rect(p.x, p.y, p.x+d.x, p.y+d.y), sizecol);
+			originwindow(w->i, w->i->r.min, r.min);
+			drawborder(r, sizecol);
 			op = p;
 		}
 		readmouse(mousectl);
@@ -1003,6 +1006,7 @@
 	riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil);
 	menuing = FALSE;
 	if(mouse->buttons!=0 || !goodrect(r) || eqrect(r, w->screenr)){
+		originwindow(w->i, w->i->r.min, origp);
 		flushimage(display, 1);
 		while(mouse->buttons)
 			readmouse(mousectl);