git: 9front

Download patch

ref: 0ae050c485857a73ba52b0101a2449fd19b7840b
parent: a9cd342c2e331388c6521ce42a95b850f746a96a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Nov 24 23:30:44 EST 2015

rio: fix handling "resize" wctl for hidden windows

when the "resize" wctl was used on a hidden window, the window
was put back on the screen, however, it was not removed from
the hidden[] array so trying to hide the window again failed
because whide() assumed it was already hidden.

the fix is to not unhide the window, but preserve the hidden
state, so windows can programmatically be reshaped and moved,
but will remain hidden unless explicitely unhidden.

--- a/sys/man/4/rio
+++ b/sys/man/4/rio
@@ -258,14 +258,13 @@
 .B top
 and
 .B bottom
-commands do not change whether the window is current or not;
-the others always make the affected window current.
-.IP
+commands do not change whether the window is current or not.
 Neither
 .B top
 nor
 .B bottom
 has any options.
+.IP
 The
 .BR resize ,
 .BR move ,
--- a/sys/src/cmd/rio/wctl.c
+++ b/sys/src/cmd/rio/wctl.c
@@ -360,22 +360,29 @@
 		r = rectonscreen(r);
 		/* fall through */
 	case Resize:
-		if(eqrect(r, w->screenr))
-			return 1;
 		if(!goodrect(r)){
 			strcpy(err, Ebadwr);
 			return -1;
 		}
-		if(w != input){
-			strcpy(err, "window not current");
-			return -1;
+		if(Dx(w->screenr) > 0){
+			if(eqrect(r, w->screenr))
+				return 1;
+			if(w != input){
+				strcpy(err, "window not current");
+				return -1;
+			}
+			i = allocwindow(wscreen, r, Refbackup, DNofill);
+		} else { /* hidden */
+			if(eqrect(r, w->i->r))
+				return 1;
+			i = allocimage(display, r, w->i->chan, 0, DNofill);
+			r = ZR;
 		}
-		i = allocwindow(wscreen, r, Refbackup, DNofill);
 		if(i == nil){
 			strcpy(err, Ewalloc);
 			return -1;
 		}
-		wsendctlmesg(w, Reshaped, i->r, i);
+		wsendctlmesg(w, Reshaped, r, i);
 		return 1;
 	case Scroll:
 		w->scrolling = 1;
@@ -393,6 +400,10 @@
 		wbottomme(w);
 		return 1;
 	case Current:
+		if(Dx(w->screenr)<=0){
+			strcpy(err, "window is hidden");
+			return -1;
+		}
 		wtopme(w);
 		wcurrent(w);
 		return 1;
--