shithub: riscv

Download patch

ref: 9369f83bcdab140fbf485074654994f1ed625588
parent: 89ed97aaa2ee0eae0042220de288ed02073d4878
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Mon Jun 17 04:05:04 EDT 2013

page: use resizewin() to change window size for gif display

resizewin() has some extra logic making sure the rect doesnt get too big.
rio would otherwise refuse to create the window and the operation will fail
completely.

--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -1241,12 +1241,9 @@
 	if(p->ext == nil)
 		return;
 	snprint(label, sizeof(label), "%s %s", p->ext, p->label);
-	if(p->image){
-		ps = subpt(p->image->r.max, p->image->r.min);
-		ps.x += 24;
-		ps.y += 24;
-	} else
-		ps = subpt(screen->r.max, screen->r.min);
+	ps = Pt(0, 0);
+	if(p->image)
+		ps = addpt(subpt(p->image->r.max, p->image->r.min), Pt(24, 24));
 	drawlock(0);
 	if((fd = p->fd) < 0){
 		if(p->open != popenfile)
@@ -1257,7 +1254,7 @@
 		seek(fd, 0, 0);
 	}
 	if(rfork(RFPROC|RFMEM|RFFDG|RFNOTEG|RFNAMEG|RFNOWAIT) == 0){
-		snprint(buf, sizeof(buf), "-pid %d -dx %d -dy %d", getpid(), ps.x, ps.y);
+		snprint(buf, sizeof(buf), "-pid %d", getpid());
 		if(newwindow(buf) != -1){
 			dupfds(fd, 1, 2, -1);
 			if((fd = open("/dev/label", OWRITE)) >= 0){
@@ -1264,6 +1261,8 @@
 				write(fd, label, strlen(label));
 				close(fd);
 			}
+			if(ps.x && ps.y)
+				resizewin(ps);
 			argv[0] = "rc";
 			argv[1] = "-c";
 			argv[2] = p->ext;
--