Merge remote branch 'kanaka/master' into mobile
This commit is contained in:
commit
42e04907ff
|
@ -0,0 +1,29 @@
|
||||||
|
.fullscreen {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-layout {
|
||||||
|
display: box;
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -moz-box;
|
||||||
|
display: -ms-box;
|
||||||
|
box-orient: vertical;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-moz-box-orient: vertical;
|
||||||
|
-ms-box-orient: vertical;
|
||||||
|
}
|
||||||
|
.flex-box {
|
||||||
|
box-flex: 1;
|
||||||
|
-webkit-box-flex: 1;
|
||||||
|
-moz-box-flex: 1;
|
||||||
|
-ms-box-flex: 1;
|
||||||
|
}
|
||||||
|
|
|
@ -1,21 +1,37 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head><title>Viewport Test</title></head>
|
<head><title>Viewport Test</title>
|
||||||
|
<link rel="stylesheet" href="../include/mobile.css">
|
||||||
|
<!--
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
|
-->
|
||||||
|
<meta name=viewport content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<br><br>
|
<div class="fullscreen flex-layout">
|
||||||
|
|
||||||
|
<div>
|
||||||
Canvas:
|
Canvas:
|
||||||
<input id="move-selector" type="button" value="Move"
|
<input id="move-selector" type="button" value="Move"
|
||||||
onclick="toggleMove();">
|
onclick="toggleMove();">
|
||||||
<br>
|
<br>
|
||||||
<canvas id="canvas" width="640" height="20"
|
</div>
|
||||||
|
<div id="container" class="flex-box">
|
||||||
|
<canvas id="canvas"
|
||||||
style="border-style: dotted; border-width: 1px;">
|
style="border-style: dotted; border-width: 1px;">
|
||||||
Canvas not supported.
|
Canvas not supported.
|
||||||
</canvas>
|
</canvas>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
<br>
|
<br>
|
||||||
Results:<br>
|
Results:<br>
|
||||||
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
|
<textarea id="messages" style="font-size: 9;" cols=80 rows=8></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -30,10 +46,8 @@
|
||||||
<script>
|
<script>
|
||||||
var msg_cnt = 0, iterations,
|
var msg_cnt = 0, iterations,
|
||||||
fb_width = 800,
|
fb_width = 800,
|
||||||
fb_height = 600,
|
fb_height = 768,
|
||||||
viewport = {
|
viewport = {'x': 0, 'y': 0, 'w' : 0, 'h' : 0 },
|
||||||
'x': 0, 'y': 0,
|
|
||||||
'w' : 400, 'h' : 200 },
|
|
||||||
cleanRect = {},
|
cleanRect = {},
|
||||||
penDown = false, doMove = false,
|
penDown = false, doMove = false,
|
||||||
inMove = false, lastPos = {},
|
inMove = false, lastPos = {},
|
||||||
|
@ -112,17 +126,24 @@
|
||||||
deltaX = - v.x;
|
deltaX = - v.x;
|
||||||
}
|
}
|
||||||
if ((vx2 + deltaX) >= fb_width) {
|
if ((vx2 + deltaX) >= fb_width) {
|
||||||
deltaX -= ((vx2 + deltaX) - fb_width);
|
deltaX -= ((vx2 + deltaX) - fb_width + 1);
|
||||||
}
|
}
|
||||||
v.x += deltaX;
|
|
||||||
vx2 += deltaX;
|
|
||||||
|
|
||||||
if ((v.y + deltaY) < 0) {
|
if ((v.y + deltaY) < 0) {
|
||||||
deltaY = - v.y;
|
deltaY = - v.y;
|
||||||
}
|
}
|
||||||
if ((vy2 + deltaY) >= fb_height) {
|
if ((vy2 + deltaY) >= fb_height) {
|
||||||
deltaY -= ((vy2 + deltaY) - fb_height);
|
deltaY -= ((vy2 + deltaY) - fb_height + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((deltaX === 0) && (deltaY === 0)) {
|
||||||
|
//message("skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
message("deltaX: " + deltaX + ", deltaY: " + deltaY);
|
||||||
|
|
||||||
|
v.x += deltaX;
|
||||||
|
vx2 += deltaX;
|
||||||
v.y += deltaY;
|
v.y += deltaY;
|
||||||
vy2 += deltaY;
|
vy2 += deltaY;
|
||||||
|
|
||||||
|
@ -197,6 +218,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawArea(x, y, w, h) {
|
function drawArea(x, y, w, h) {
|
||||||
|
message("draw "+x+","+y+" ("+w+","+h+")");
|
||||||
var imgData = ctx.createImageData(w, h),
|
var imgData = ctx.createImageData(w, h),
|
||||||
data = imgData.data, pixel, realX, realY;
|
data = imgData.data, pixel, realX, realY;
|
||||||
|
|
||||||
|
@ -227,6 +249,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.onresize = function() {
|
||||||
|
var v = viewport,
|
||||||
|
cw = $D('container').offsetWidth,
|
||||||
|
ch = $D('container').offsetHeight;
|
||||||
|
|
||||||
|
message("container: " + cw + "," + ch);
|
||||||
|
|
||||||
|
if (cw > fb_width) {
|
||||||
|
cw = fb_width;
|
||||||
|
}
|
||||||
|
if (ch > fb_height) {
|
||||||
|
ch = fb_height;
|
||||||
|
}
|
||||||
|
if ((cw !== v.w) || (ch !== v.h)) {
|
||||||
|
v.w = cw;
|
||||||
|
v.h = ch;
|
||||||
|
message("new viewport: " + v.w + "," + v.h);
|
||||||
|
canvas.resize(v.w, v.h);
|
||||||
|
drawArea(0, 0, v.w, v.h);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
canvas = new Display({'target' : $D('canvas')});
|
canvas = new Display({'target' : $D('canvas')});
|
||||||
ctx = canvas.get_context();
|
ctx = canvas.get_context();
|
||||||
|
@ -234,11 +278,10 @@
|
||||||
'onMouseButton': mouseButton,
|
'onMouseButton': mouseButton,
|
||||||
'onMouseMove': mouseMove});
|
'onMouseMove': mouseMove});
|
||||||
|
|
||||||
canvas.resize(viewport.w, viewport.h, true);
|
window.onresize();
|
||||||
mouse.grab();
|
mouse.grab();
|
||||||
message("Display initialized");
|
|
||||||
|
|
||||||
drawArea(0, 0, viewport.w, viewport.h);
|
message("Display initialized");
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -8,7 +8,7 @@ Licensed under LGPL version 3 (see docs/LICENSE.LGPL-3)
|
||||||
Supports following protocol versions:
|
Supports following protocol versions:
|
||||||
- http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75
|
- http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75
|
||||||
- http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76
|
- http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76
|
||||||
- http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07
|
- http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
|
||||||
|
|
||||||
You can make a cert/key with openssl using:
|
You can make a cert/key with openssl using:
|
||||||
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
|
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
|
||||||
|
@ -49,8 +49,7 @@ else:
|
||||||
|
|
||||||
# Degraded functionality if these imports are missing
|
# Degraded functionality if these imports are missing
|
||||||
for mod, sup in [('numpy', 'HyBi protocol'),
|
for mod, sup in [('numpy', 'HyBi protocol'),
|
||||||
('ctypes', 'HyBi protocol'), ('ssl', 'TLS/SSL/wss'),
|
('ssl', 'TLS/SSL/wss'), ('resource', 'daemonizing')]:
|
||||||
('resource', 'daemonizing')]:
|
|
||||||
try:
|
try:
|
||||||
globals()[mod] = __import__(mod)
|
globals()[mod] = __import__(mod)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -226,7 +225,7 @@ Sec-WebSocket-Accept: %s\r
|
||||||
payload_len = len(buf)
|
payload_len = len(buf)
|
||||||
if payload_len <= 125:
|
if payload_len <= 125:
|
||||||
header = struct.pack('>BB', b1, payload_len)
|
header = struct.pack('>BB', b1, payload_len)
|
||||||
elif payload_len > 125 and payload_len <= 65536:
|
elif payload_len > 125 and payload_len < 65536:
|
||||||
header = struct.pack('>BBH', b1, 126, payload_len)
|
header = struct.pack('>BBH', b1, 126, payload_len)
|
||||||
elif payload_len >= 65536:
|
elif payload_len >= 65536:
|
||||||
header = struct.pack('>BBQ', b1, 127, payload_len)
|
header = struct.pack('>BBQ', b1, 127, payload_len)
|
||||||
|
@ -298,15 +297,15 @@ Sec-WebSocket-Accept: %s\r
|
||||||
f['mask'] = buf[f['hlen']:f['hlen']+4]
|
f['mask'] = buf[f['hlen']:f['hlen']+4]
|
||||||
b = c = ''
|
b = c = ''
|
||||||
if f['length'] >= 4:
|
if f['length'] >= 4:
|
||||||
mask = numpy.frombuffer(buf, dtype=numpy.dtype('<L4'),
|
mask = numpy.frombuffer(buf, dtype=numpy.dtype('<u4'),
|
||||||
offset=f['hlen'], count=1)
|
offset=f['hlen'], count=1)
|
||||||
data = numpy.frombuffer(buf, dtype=numpy.dtype('<L4'),
|
data = numpy.frombuffer(buf, dtype=numpy.dtype('<u4'),
|
||||||
offset=f['hlen'] + 4, count=int(f['length'] / 4))
|
offset=f['hlen'] + 4, count=int(f['length'] / 4))
|
||||||
#b = numpy.bitwise_xor(data, mask).data
|
#b = numpy.bitwise_xor(data, mask).data
|
||||||
b = numpy.bitwise_xor(data, mask).tostring()
|
b = numpy.bitwise_xor(data, mask).tostring()
|
||||||
|
|
||||||
if f['length'] % 4:
|
if f['length'] % 4:
|
||||||
print("Partial unmask")
|
#print("Partial unmask")
|
||||||
mask = numpy.frombuffer(buf, dtype=numpy.dtype('B'),
|
mask = numpy.frombuffer(buf, dtype=numpy.dtype('B'),
|
||||||
offset=f['hlen'], count=(f['length'] % 4))
|
offset=f['hlen'], count=(f['length'] % 4))
|
||||||
data = numpy.frombuffer(buf, dtype=numpy.dtype('B'),
|
data = numpy.frombuffer(buf, dtype=numpy.dtype('B'),
|
||||||
|
@ -615,8 +614,11 @@ Sec-WebSocket-Accept: %s\r
|
||||||
if sys.hexversion < 0x2060000 or not numpy:
|
if sys.hexversion < 0x2060000 or not numpy:
|
||||||
raise self.EClose("Python >= 2.6 and numpy module is required for HyBi-07 or greater")
|
raise self.EClose("Python >= 2.6 and numpy module is required for HyBi-07 or greater")
|
||||||
|
|
||||||
if ver in ['7', '8', '9']:
|
# HyBi-07 report version 7
|
||||||
self.version = "hybi-0" + ver
|
# HyBi-08 - HyBi-12 report version 8
|
||||||
|
# HyBi-13 reports version 13
|
||||||
|
if ver in ['7', '8', '13']:
|
||||||
|
self.version = "hybi-%02d" % int(ver)
|
||||||
else:
|
else:
|
||||||
raise self.EClose('Unsupported protocol version %s' % ver)
|
raise self.EClose('Unsupported protocol version %s' % ver)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue