From 9ef4ba83f62761b517db23a16e2f61e5861aae23 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 25 Nov 2015 04:30:44 +0100 Subject: 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. --- sys/man/4/rio | 5 ++--- sys/src/cmd/rio/wctl.c | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sys/man/4/rio b/sys/man/4/rio index b0997bbef..caacd9552 100644 --- a/sys/man/4/rio +++ b/sys/man/4/rio @@ -258,14 +258,13 @@ The .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 , diff --git a/sys/src/cmd/rio/wctl.c b/sys/src/cmd/rio/wctl.c index a19c5a4e8..cb5acb64a 100644 --- a/sys/src/cmd/rio/wctl.c +++ b/sys/src/cmd/rio/wctl.c @@ -360,22 +360,29 @@ wctlcmd(Window *w, Rectangle r, int cmd, char *err) 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 @@ wctlcmd(Window *w, Rectangle r, int cmd, char *err) wbottomme(w); return 1; case Current: + if(Dx(w->screenr)<=0){ + strcpy(err, "window is hidden"); + return -1; + } wtopme(w); wcurrent(w); return 1; -- cgit v1.2.3