Skip to content

Commit

Permalink
feat: add resize endpoint to resize screen size (fix #115)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doro Wu committed Aug 19, 2019
1 parent d4d3f86 commit 1affc91
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 130 deletions.
119 changes: 0 additions & 119 deletions Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions Dockerfile
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Troubleshooting and FAQ
3. Autostart, https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/85
4. x11vnc arguments(multiptr), https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/101
5. firefox/chrome crash (/dev/shm), https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/112
6. resize display size without destroying container, https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/115#issuecomment-522426037

License
==================
Expand Down
20 changes: 12 additions & 8 deletions rootfs/etc/nginx/sites-enabled/default
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ server {
root /usr/local/lib/web/frontend/;
index index.html index.htm;

location /api/ {
location ~ /api/ {
try_files $uri @api;
}

location ~ /resize$ {
try_files $uri @api;
}

#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 break;
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
#_RELATIVE_URL_ROOT_}

location ~ /websockify$ {
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 last;
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Expand All @@ -30,17 +39,12 @@ server {
}

location @api {
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 last;
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:6079;
max_ranges 0;
}

#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 last;
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
#_RELATIVE_URL_ROOT_}
}

10 changes: 7 additions & 3 deletions rootfs/usr/local/lib/web/backend/vnc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Response,
jsonify,
abort,
url_for,
)
from gevent import subprocess as gsp, spawn, sleep
from geventwebsocket.exceptions import WebSocketError
Expand All @@ -28,7 +27,6 @@
@app.route('/api/state')
@httperror
def apistate():
print(url_for("apistate"))
state.wait(int(request.args.get('id', -1)), 30)
state.switch_video(request.args.get('video', 'false') == 'true')
mystate = state.to_dict()
Expand All @@ -40,7 +38,6 @@ def apistate():

@app.route('/api/health')
def apihealth():
print(url_for("apihealth"))
if state.health:
return 'success'
abort(503, 'unhealthy')
Expand Down Expand Up @@ -71,6 +68,13 @@ def reset():
return jsonify({'code': 200})


@app.route('/resize')
@httperror
def apiresize():
state.reset_size()
return '<html><head><script type = "text/javascript">var h=window.location.href;window.location.href=h.substring(0,h.length-6);</script></head></html>'


@app.route('/api/live.flv')
@httperror
def liveflv():
Expand Down
3 changes: 3 additions & 0 deletions rootfs/usr/local/lib/web/backend/vnc/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def _update_size(self):
except gsp.CalledProcessError as e:
log.warn('failed to get dispaly size: ' + str(e))

def reset_size(self):
self.size_changed_count = 0

@property
def w(self):
return self._w
Expand Down

0 comments on commit 1affc91

Please sign in to comment.