Skip to content

Commit 1affc91

Browse files
author
Doro Wu
committed
feat: add resize endpoint to resize screen size (fix fcwu#115)
1 parent d4d3f86 commit 1affc91

File tree

5 files changed

+24
-130
lines changed

5 files changed

+24
-130
lines changed

Dockerfile

Lines changed: 0 additions & 119 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile.amd64

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Troubleshooting and FAQ
146146
3. Autostart, https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/85
147147
4. x11vnc arguments(multiptr), https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/101
148148
5. firefox/chrome crash (/dev/shm), https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/112
149+
6. resize display size without destroying container, https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/115#issuecomment-522426037
149150

150151
License
151152
==================

rootfs/etc/nginx/sites-enabled/default

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@ server {
1313
root /usr/local/lib/web/frontend/;
1414
index index.html index.htm;
1515

16-
location /api/ {
16+
location ~ /api/ {
1717
try_files $uri @api;
1818
}
1919

20+
location ~ /resize$ {
21+
try_files $uri @api;
22+
}
23+
24+
#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
25+
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 break;
26+
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
27+
#_RELATIVE_URL_ROOT_}
28+
2029
location ~ /websockify$ {
21-
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 last;
30+
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
2231
proxy_http_version 1.1;
2332
proxy_set_header Upgrade $http_upgrade;
2433
proxy_set_header Connection "upgrade";
@@ -30,17 +39,12 @@ server {
3039
}
3140

3241
location @api {
33-
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 last;
42+
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
3443
proxy_set_header X-Real-IP $remote_addr;
3544
proxy_set_header X-Forwarded-For $remote_addr;
3645
proxy_set_header Host $host;
3746
proxy_pass http://127.0.0.1:6079;
3847
max_ranges 0;
3948
}
40-
41-
#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
42-
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 last;
43-
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
44-
#_RELATIVE_URL_ROOT_}
4549
}
4650

rootfs/usr/local/lib/web/backend/vnc/app.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
Response,
1010
jsonify,
1111
abort,
12-
url_for,
1312
)
1413
from gevent import subprocess as gsp, spawn, sleep
1514
from geventwebsocket.exceptions import WebSocketError
@@ -28,7 +27,6 @@
2827
@app.route('/api/state')
2928
@httperror
3029
def apistate():
31-
print(url_for("apistate"))
3230
state.wait(int(request.args.get('id', -1)), 30)
3331
state.switch_video(request.args.get('video', 'false') == 'true')
3432
mystate = state.to_dict()
@@ -40,7 +38,6 @@ def apistate():
4038

4139
@app.route('/api/health')
4240
def apihealth():
43-
print(url_for("apihealth"))
4441
if state.health:
4542
return 'success'
4643
abort(503, 'unhealthy')
@@ -71,6 +68,13 @@ def reset():
7168
return jsonify({'code': 200})
7269

7370

71+
@app.route('/resize')
72+
@httperror
73+
def apiresize():
74+
state.reset_size()
75+
return '<html><head><script type = "text/javascript">var h=window.location.href;window.location.href=h.substring(0,h.length-6);</script></head></html>'
76+
77+
7478
@app.route('/api/live.flv')
7579
@httperror
7680
def liveflv():

rootfs/usr/local/lib/web/backend/vnc/state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def _update_size(self):
113113
except gsp.CalledProcessError as e:
114114
log.warn('failed to get dispaly size: ' + str(e))
115115

116+
def reset_size(self):
117+
self.size_changed_count = 0
118+
116119
@property
117120
def w(self):
118121
return self._w

0 commit comments

Comments
 (0)