improve UI handling

This commit is contained in:
lxsang
2022-08-18 21:35:37 +02:00
parent 55787b135b
commit 03f48f3211
11 changed files with 23 additions and 24 deletions

View File

@@ -175,12 +175,16 @@ class WVNC
@socket.onmessage = (e) ->
me.consume e
@socket.onerror = (e) =>
me.onerror("Websocket error")
@socket.onclose = () ->
me.socket = null
me.canvas.style.cursor = "auto"
me.canvas.getContext('2d').clearRect 0,0, me.resolution.w, me.resolution.h if me.canvas and me.resolution
clearTimeout(me.pingto) if me.pingto
me.pingto = undefined
me.ondisconnect()
console.log "socket closed"
disconnect: (close_worker) ->
@@ -279,6 +283,9 @@ class WVNC
onresize: () ->
console.log "resize"
ondisconnect: () ->
console.log "disconnect"
consume: (e) ->
data = new Uint8Array e.data

View File

@@ -98,8 +98,10 @@ class RemoteDesktop extends this.OS.application.BaseApplication
}
@bindKey "CTRL-SHIFT-V", (e) =>
@pasteText()
@client.onerror = (m) =>
@error m
#@client.onerror = (m) =>
# @error m.toString()
# @showConnectionDialog()
@client.ondisconnect = () =>
@showConnectionDialog()
@client.onresize = ()=>
@setScale()
@@ -160,16 +162,13 @@ class RemoteDesktop extends this.OS.application.BaseApplication
{ text: "__(New Connection)", dataid: "#{@name}-new", },
{ text: "__(Disconnect)", dataid: "#{@name}-close" }
],
onchildselect: (e) => @actionConnection()
onchildselect: (e) =>
@client.disconnect(false) if @client
}
]
actionConnection: (e) ->
@client.disconnect(false) if @client
@showConnectionDialog()
showConnectionDialog: () ->
return unless @client
@openDialog new ConnectionDialog, { title: __("Connection")}
.then (d) =>
@client.ws = d.wvnc
@@ -177,5 +176,6 @@ class RemoteDesktop extends this.OS.application.BaseApplication
cleanup: () ->
@client.disconnect(true) if @client
@client = undefined
this.OS.register "RemoteDesktop", RemoteDesktop