mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
update spice-html5 packages to release 0.30
This commit is contained in:
parent
7bb5d6f313
commit
d0e3c11ccf
37 changed files with 236 additions and 138 deletions
119
static/js/spice-html5/inputs.js
Executable file → Normal file
119
static/js/spice-html5/inputs.js
Executable file → Normal file
|
@ -38,7 +38,8 @@ var Meta_state = -1;
|
|||
** SpiceInputsConn
|
||||
** Drive the Spice Inputs channel (e.g. mouse + keyboard)
|
||||
**--------------------------------------------------------------------------*/
|
||||
function SpiceInputsConn() {
|
||||
function SpiceInputsConn()
|
||||
{
|
||||
SpiceConn.apply(this, arguments);
|
||||
|
||||
this.mousex = undefined;
|
||||
|
@ -48,22 +49,26 @@ function SpiceInputsConn() {
|
|||
}
|
||||
|
||||
SpiceInputsConn.prototype = Object.create(SpiceConn.prototype);
|
||||
SpiceInputsConn.prototype.process_channel_message = function (msg) {
|
||||
if (msg.type == Constants.SPICE_MSG_INPUTS_INIT) {
|
||||
SpiceInputsConn.prototype.process_channel_message = function(msg)
|
||||
{
|
||||
if (msg.type == Constants.SPICE_MSG_INPUTS_INIT)
|
||||
{
|
||||
var inputs_init = new Messages.SpiceMsgInputsInit(msg.data);
|
||||
this.keyboard_modifiers = inputs_init.keyboard_modifiers;
|
||||
DEBUG > 1 && console.log("MsgInputsInit - modifier " + this.keyboard_modifiers);
|
||||
// FIXME - We don't do anything with the keyboard modifiers...
|
||||
return true;
|
||||
}
|
||||
if (msg.type == Constants.SPICE_MSG_INPUTS_KEY_MODIFIERS) {
|
||||
if (msg.type == Constants.SPICE_MSG_INPUTS_KEY_MODIFIERS)
|
||||
{
|
||||
var key = new Messages.SpiceMsgInputsKeyModifiers(msg.data);
|
||||
this.keyboard_modifiers = key.keyboard_modifiers;
|
||||
DEBUG > 1 && console.log("MsgInputsKeyModifiers - modifier " + this.keyboard_modifiers);
|
||||
// FIXME - We don't do anything with the keyboard modifiers...
|
||||
return true;
|
||||
}
|
||||
if (msg.type == Constants.SPICE_MSG_INPUTS_MOUSE_MOTION_ACK) {
|
||||
if (msg.type == Constants.SPICE_MSG_INPUTS_MOUSE_MOTION_ACK)
|
||||
{
|
||||
DEBUG > 1 && console.log("mouse motion ack");
|
||||
this.waiting_for_ack -= Constants.SPICE_INPUT_MOTION_ACK_BUNCH;
|
||||
return true;
|
||||
|
@ -73,28 +78,35 @@ SpiceInputsConn.prototype.process_channel_message = function (msg) {
|
|||
|
||||
|
||||
|
||||
function handle_mousemove(e) {
|
||||
function handle_mousemove(e)
|
||||
{
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
var move;
|
||||
if (this.sc.mouse_mode == Constants.SPICE_MOUSE_MODE_CLIENT) {
|
||||
if (this.sc.mouse_mode == Constants.SPICE_MOUSE_MODE_CLIENT)
|
||||
{
|
||||
move = new Messages.SpiceMsgcMousePosition(this.sc, e)
|
||||
msg.build_msg(Constants.SPICE_MSGC_INPUTS_MOUSE_POSITION, move);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
move = new Messages.SpiceMsgcMouseMotion(this.sc, e)
|
||||
msg.build_msg(Constants.SPICE_MSGC_INPUTS_MOUSE_MOTION, move);
|
||||
}
|
||||
if (this.sc && this.sc.inputs && this.sc.inputs.state === "ready") {
|
||||
if (this.sc.inputs.waiting_for_ack < (2 * Constants.SPICE_INPUT_MOTION_ACK_BUNCH)) {
|
||||
if (this.sc && this.sc.inputs && this.sc.inputs.state === "ready")
|
||||
{
|
||||
if (this.sc.inputs.waiting_for_ack < (2 * Constants.SPICE_INPUT_MOTION_ACK_BUNCH))
|
||||
{
|
||||
this.sc.inputs.send_msg(msg);
|
||||
this.sc.inputs.waiting_for_ack++;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
DEBUG > 0 && this.sc.log_info("Discarding mouse motion");
|
||||
}
|
||||
}
|
||||
|
||||
if (this.sc && this.sc.cursor && this.sc.cursor.spice_simulated_cursor) {
|
||||
if (this.sc && this.sc.cursor && this.sc.cursor.spice_simulated_cursor)
|
||||
{
|
||||
this.sc.cursor.spice_simulated_cursor.style.display = 'block';
|
||||
this.sc.cursor.spice_simulated_cursor.style.left = e.pageX - this.sc.cursor.spice_simulated_cursor.spice_hot_x + 'px';
|
||||
this.sc.cursor.spice_simulated_cursor.style.top = e.pageY - this.sc.cursor.spice_simulated_cursor.spice_hot_y + 'px';
|
||||
|
@ -103,7 +115,8 @@ function handle_mousemove(e) {
|
|||
|
||||
}
|
||||
|
||||
function handle_mousedown(e) {
|
||||
function handle_mousedown(e)
|
||||
{
|
||||
var press = new Messages.SpiceMsgcMousePress(this.sc, e)
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
msg.build_msg(Constants.SPICE_MSGC_INPUTS_MOUSE_PRESS, press);
|
||||
|
@ -113,12 +126,14 @@ function handle_mousedown(e) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
function handle_contextmenu(e) {
|
||||
function handle_contextmenu(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function handle_mouseup(e) {
|
||||
function handle_mouseup(e)
|
||||
{
|
||||
var release = new Messages.SpiceMsgcMouseRelease(this.sc, e)
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
msg.build_msg(Constants.SPICE_MSGC_INPUTS_MOUSE_RELEASE, release);
|
||||
|
@ -128,7 +143,8 @@ function handle_mouseup(e) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
function handle_mousewheel(e) {
|
||||
function handle_mousewheel(e)
|
||||
{
|
||||
var press = new Messages.SpiceMsgcMousePress;
|
||||
var release = new Messages.SpiceMsgcMouseRelease;
|
||||
if (e.deltaY < 0)
|
||||
|
@ -150,7 +166,8 @@ function handle_mousewheel(e) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
function handle_keydown(e) {
|
||||
function handle_keydown(e)
|
||||
{
|
||||
var key = new Messages.SpiceMsgcKeyDown(e)
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
check_and_update_modifiers(e, key.code, this.sc);
|
||||
|
@ -161,7 +178,8 @@ function handle_keydown(e) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
function handle_keyup(e) {
|
||||
function handle_keyup(e)
|
||||
{
|
||||
var key = new Messages.SpiceMsgcKeyUp(e)
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
check_and_update_modifiers(e, key.code, this.sc);
|
||||
|
@ -172,8 +190,9 @@ function handle_keyup(e) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
function sendCtrlAltDel(sc) {
|
||||
if (sc && sc.inputs && sc.inputs.state === "ready") {
|
||||
function sendCtrlAltDel(sc)
|
||||
{
|
||||
if (sc && sc.inputs && sc.inputs.state === "ready"){
|
||||
var key = new Messages.SpiceMsgcKeyDown();
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
|
||||
|
@ -227,14 +246,17 @@ function sendCtrlAltFN(sc, f) {
|
|||
}
|
||||
}
|
||||
|
||||
function update_modifier(state, code, sc) {
|
||||
function update_modifier(state, code, sc)
|
||||
{
|
||||
var msg = new Messages.SpiceMiniData();
|
||||
if (!state) {
|
||||
if (!state)
|
||||
{
|
||||
var key = new Messages.SpiceMsgcKeyUp()
|
||||
key.code = (0x80 | code);
|
||||
key.code =(0x80|code);
|
||||
msg.build_msg(Constants.SPICE_MSGC_INPUTS_KEY_UP, key);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
var key = new Messages.SpiceMsgcKeyDown()
|
||||
key.code = code;
|
||||
msg.build_msg(Constants.SPICE_MSGC_INPUTS_KEY_DOWN, key);
|
||||
|
@ -243,8 +265,10 @@ function update_modifier(state, code, sc) {
|
|||
sc.inputs.send_msg(msg);
|
||||
}
|
||||
|
||||
function check_and_update_modifiers(e, code, sc) {
|
||||
if (Shift_state === -1) {
|
||||
function check_and_update_modifiers(e, code, sc)
|
||||
{
|
||||
if (Shift_state === -1)
|
||||
{
|
||||
Shift_state = e.shiftKey;
|
||||
Ctrl_state = e.ctrlKey;
|
||||
Alt_state = e.altKey;
|
||||
|
@ -259,32 +283,37 @@ function check_and_update_modifiers(e, code, sc) {
|
|||
Ctrl_state = true;
|
||||
else if (code === 0xE0B5)
|
||||
Meta_state = true;
|
||||
else if (code === (0x80 | KeyNames.KEY_ShiftL))
|
||||
else if (code === (0x80|KeyNames.KEY_ShiftL))
|
||||
Shift_state = false;
|
||||
else if (code === (0x80 | KeyNames.KEY_Alt))
|
||||
else if (code === (0x80|KeyNames.KEY_Alt))
|
||||
Alt_state = false;
|
||||
else if (code === (0x80 | KeyNames.KEY_LCtrl))
|
||||
else if (code === (0x80|KeyNames.KEY_LCtrl))
|
||||
Ctrl_state = false;
|
||||
else if (code === (0x80 | 0xE0B5))
|
||||
else if (code === (0x80|0xE0B5))
|
||||
Meta_state = false;
|
||||
|
||||
if (sc && sc.inputs && sc.inputs.state === "ready") {
|
||||
if (Shift_state != e.shiftKey) {
|
||||
if (sc && sc.inputs && sc.inputs.state === "ready")
|
||||
{
|
||||
if (Shift_state != e.shiftKey)
|
||||
{
|
||||
console.log("Shift state out of sync");
|
||||
update_modifier(e.shiftKey, KeyNames.KEY_ShiftL, sc);
|
||||
Shift_state = e.shiftKey;
|
||||
}
|
||||
if (Alt_state != e.altKey) {
|
||||
if (Alt_state != e.altKey)
|
||||
{
|
||||
console.log("Alt state out of sync");
|
||||
update_modifier(e.altKey, KeyNames.KEY_Alt, sc);
|
||||
Alt_state = e.altKey;
|
||||
}
|
||||
if (Ctrl_state != e.ctrlKey) {
|
||||
if (Ctrl_state != e.ctrlKey)
|
||||
{
|
||||
console.log("Ctrl state out of sync");
|
||||
update_modifier(e.ctrlKey, KeyNames.KEY_LCtrl, sc);
|
||||
Ctrl_state = e.ctrlKey;
|
||||
}
|
||||
if (Meta_state != e.metaKey) {
|
||||
if (Meta_state != e.metaKey)
|
||||
{
|
||||
console.log("Meta state out of sync");
|
||||
update_modifier(e.metaKey, 0xE0B5, sc);
|
||||
Meta_state = e.metaKey;
|
||||
|
@ -293,14 +322,14 @@ function check_and_update_modifiers(e, code, sc) {
|
|||
}
|
||||
|
||||
export {
|
||||
SpiceInputsConn,
|
||||
handle_mousemove,
|
||||
handle_mousedown,
|
||||
handle_contextmenu,
|
||||
handle_mouseup,
|
||||
handle_mousewheel,
|
||||
handle_keydown,
|
||||
handle_keyup,
|
||||
sendCtrlAltDel,
|
||||
sendCtrlAltFN
|
||||
SpiceInputsConn,
|
||||
handle_mousemove,
|
||||
handle_mousedown,
|
||||
handle_contextmenu,
|
||||
handle_mouseup,
|
||||
handle_mousewheel,
|
||||
handle_keydown,
|
||||
handle_keyup,
|
||||
sendCtrlAltDel,
|
||||
sendCtrlAltFN
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue