ref: 8f2168e57310fe3dd03a48d28bc6c6d9333754c0
parent: 8682f23f6e095931007c21c139a5fbcf6645b970
 parent: c576f663c7ae8d964540ad071c9d79982f7e6672
	author: cinap_lenrek <cinap_lenrek@felloff.net>
	date: Mon Aug 20 22:04:33 EDT 2018
	
merge
--- a/sys/src/cmd/vnc/draw.c
+++ b/sys/src/cmd/vnc/draw.c
@@ -29,6 +29,9 @@
pixbuf = realloc(pixbuf, v->dim.max.x * pixb * v->dim.max.y);
if(linebuf == nil || pixbuf == nil)
 		sysfatal("can't allocate pix decompression storage");+ lockdisplay(display);
+ adjustwin(v, 0);
+ unlockdisplay(display);
}
static void
@@ -79,7 +82,7 @@
r = rectsubpt(screen->r, screen->r.min);
unlockdisplay(display);
vnclock(v);
-	if(incremental == 0 && v->canresize && !eqrect(r, v->dim)){+	if(incremental == 0 && (v->canresize&2)!=0 && !eqrect(r, v->dim)){vncwrchar(v, MSetDesktopSize);
vncwrchar(v, 0);
vncwrpoint(v, r.max);
--- a/sys/src/cmd/vnc/vncv.h
+++ b/sys/src/cmd/vnc/vncv.h
@@ -18,6 +18,7 @@
extern int mousefd;
/* wsys.c */
+extern void adjustwin(Vnc*, int);
extern void readkbd(Vnc*);
extern void initmouse(void);
extern void mousewarp(Point);
--- a/sys/src/cmd/vnc/wsys.c
+++ b/sys/src/cmd/vnc/wsys.c
@@ -10,35 +10,46 @@
Point xy;
};
-static void
-resize(Vnc *v, int first)
+void
+adjustwin(Vnc *v, int force)
 {int fd;
Point d;
- lockdisplay(display);
- if(getwindow(display, Refnone) < 0)
-		sysfatal("internal error: can't get the window image");-	if(!v->canresize){+ if(force)
+ d = v->dim.max;
+	else {/*
* limit the window to at most the vnc server's size
*/
- d = addpt(v->dim.max, Pt(2*Borderwidth, 2*Borderwidth));
-		if(first || d.x < Dx(screen->r) || d.y < Dy(screen->r)){-			fd = open("/dev/wctl", OWRITE);-			if(fd >= 0){- fprint(fd, "resize -dx %d -dy %d", d.x, d.y);
- close(fd);
- }
+ d = subpt(screen->r.max, screen->r.min);
+		if(d.x > v->dim.max.x){+ d.x = v->dim.max.x;
+ force = 1;
}
+		if(d.y > v->dim.max.y){+ d.y = v->dim.max.y;
+ force = 1;
+ }
}
- unlockdisplay(display);
+	if(force) {+		fd = open("/dev/wctl", OWRITE);+		if(fd >= 0){+ fprint(fd, "resize -dx %d -dy %d", d.x+2*Borderwidth, d.y+2*Borderwidth);
+ close(fd);
+ }
+ }
}
static void
-eresized(void)
+resized(int first)
 {- resize(vnc, 0);
+ lockdisplay(display);
+ if(getwindow(display, Refnone) < 0)
+		sysfatal("internal error: can't get the window image");+ if((vnc->canresize&2) == 0)
+ adjustwin(vnc, first);
+ unlockdisplay(display);
requestupdate(vnc, 0);
}
@@ -130,8 +141,7 @@
memmove(curs+2*4, cs->clr, 2*2*16);
write(cursorfd, curs, sizeof curs);
- resize(v, 1);
- requestupdate(vnc, 0);
+ resized(1);
start = end = buf;
len = 0;
 	for(;;){@@ -155,8 +165,7 @@
}
}
} else
- eresized();
-
+ resized(0);
start += EventSize;
len -= EventSize;
}
--
⑨