summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vnc/wsys.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-08-21 02:02:50 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-08-21 02:02:50 +0200
commit37cbd6b632c56f09c0c561cddc1c4e5645dd4269 (patch)
tree91b6b7d6ad4c38216738e6d225626a371a049242 /sys/src/cmd/vnc/wsys.c
parentf8f677b48ebaf490c6d870e8728285bc409789c0 (diff)
vncv: adjust window size on desktop resize, fix canresize checks
Diffstat (limited to 'sys/src/cmd/vnc/wsys.c')
-rw-r--r--sys/src/cmd/vnc/wsys.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/sys/src/cmd/vnc/wsys.c b/sys/src/cmd/vnc/wsys.c
index 21c8ce424..81ffb39d9 100644
--- a/sys/src/cmd/vnc/wsys.c
+++ b/sys/src/cmd/vnc/wsys.c
@@ -10,35 +10,46 @@ struct Mouse {
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;
+ }
+ }
+ 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);
}
}
- unlockdisplay(display);
}
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 @@ readmouse(Vnc *v)
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 @@ readmouse(Vnc *v)
}
}
} else
- eresized();
-
+ resized(0);
start += EventSize;
len -= EventSize;
}