-
Notifications
You must be signed in to change notification settings - Fork 1
/
Xpra.coffee
160 lines (143 loc) · 4.43 KB
/
Xpra.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
class Xpra extends EventEmitter
constructor: (host, port) ->
@ws = new Websock
@ws.on 'open', (data) =>
@handlers = new XpraHandlers @
@proto = new Protocole @ws, @handlers
@keyboard = new Keyboard @
@_SendHello()
@ws.on 'close', (data) ->
console.log 'close', data
@ws.on 'error', (data) ->
console.log 'err', data
@ws.open 'ws://' + host + ':' + port + '/', ['binary']
#FIXME: to move into a whole new class for better clarity
_SendHello: ->
screen_width = document.body.scrollWidth
screen_height = document.body.scrollHeight
get_desktop_size = ->
[
screen_width
screen_height
]
get_screen_sizes = ->
dpi = 96
###
equivallent GTK code:
monitor = plug_name, geom.x, geom.y, geom.width, geom.height, wmm, hmm
monitors.append(monitor)
screen = (screen.make_display_name(), screen.get_width(), screen.get_height(),
screen.get_width_mm(), screen.get_height_mm(),
monitors,
work_x, work_y, work_width, work_height)
###
wmm = Math.round(screen_width * 25.4 / dpi)
hmm = Math.round(screen_height * 25.4 / dpi)
monitor = [
'Canvas'
0
0
screen_width
screen_height
wmm
hmm
]
screen = [
'HTML'
screen_width
screen_height
wmm
hmm
[ monitor ]
0
0
screen_width
screen_height
]
#just a single screen:
[ screen ]
get_keycodes = ->
#keycodes.append((nn(keyval), nn(name), nn(keycode), nn(group), nn(level)))
keycodes = []
kc = undefined
for keycode of CHARCODE_TO_NAME
kc = parseInt(keycode)
keycodes.push [
kc
CHARCODE_TO_NAME[keycode]
kc
0
0
]
#show("keycodes="+keycodes.toSource());
keycodes
get_keyboard_layout = ->
v = window.navigator.userLanguage || window.navigator.language
v = v.split(",")[0]
l = v.split("-", 2)
if l.length is 1
l = v.split("_", 2)
if l.length is 1
return ""
return l[1].toLowerCase()
@proto.Send 'hello',
"version" : "0.15.0",
"platform" : "linux2"
"platform.name" : "Linux"
"platform.processor" : "unknown"
"platform.platform" : navigator.appVersion
"namespace" : true
"client_type" : "HTML5"
"share" : false
"auto_refresh_delay" : 500
"randr_notify" : true
"sound.server_driven" : true
"generic_window_types" : true
"server-window-resize" : true
"notify-startup-complete" : true
"generic-rgb-encodings" : true
"window.raise" : true
"encodings" : ["rgb"]
"raw_window_icons" : true
#rgb24 is not efficient in HTML so don't use it:
#png and jpeg will need extra code
#"encodings.core" : ["rgb24", "rgb32", "png", "jpeg"]
"encodings.core" : ["rgb32"]
"encodings.rgb_formats" : ["RGBX", "RGBA"]
"encoding.generic" : true
"encoding.transparency" : true
"encoding.client_options" : true
"encoding.csc_atoms" : true
"encoding.uses_swscale" : false
#video stuff we may handle later:
"encoding.video_reinit" : false
"encoding.video_scaling" : false
"encoding.csc_modes" : []
#sound (not yet):
"sound.receive" : false
"sound.send" : false
#compression bits:
"zlib" : true
"lz4" : false
"compression_level" : 0
"compressible_cursors" : true
"encoding.rgb24zlib" : true
"encoding.rgb_zlib" : true
"encoding.rgb_lz4" : false
"bencode": true
"windows" : true
#partial support:
"keyboard" : true
"xkbmap_layout" : get_keyboard_layout()
"xkbmap_keycodes" : get_keycodes()
"desktop_size" : get_desktop_size()
"screen_sizes" : get_screen_sizes()
"dpi" : 96
#not handled yet, but we will:
"clipboard_enabled" : false
"notifications" : true
"cursors" : true
"bell" : true
"system_tray" : true
#we cannot handle this (GTK only):
"named_cursors" : false