You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/06/13 01:07:41 UTC
git commit: 1) Fix Console viewer CTRL key problem on Chrome browser
Updated Branches:
refs/heads/master c15948a3e -> 8d436e949
1) Fix Console viewer CTRL key problem on Chrome browser
2) Support mouse drag/drop
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8d436e94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8d436e94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8d436e94
Branch: refs/heads/master
Commit: 8d436e949c4b65a52f19031f796fc5b5c25d5764
Parents: c15948a
Author: Kelven Yang <ke...@cloud.com>
Authored: Tue Jun 12 15:53:20 2012 -0700
Committer: Kelven Yang <ke...@cloud.com>
Committed: Tue Jun 12 16:01:59 2012 -0700
----------------------------------------------------------------------
console-proxy/js/ajaxviewer.js | 10 ++-
.../cloud/consoleproxy/ConsoleProxyVncClient.java | 64 ++++++++++++---
2 files changed, 59 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8d436e94/console-proxy/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/console-proxy/js/ajaxviewer.js b/console-proxy/js/ajaxviewer.js
index 2001b3f..b15642a 100644
--- a/console-proxy/js/ajaxviewer.js
+++ b/console-proxy/js/ajaxviewer.js
@@ -284,7 +284,11 @@ JsCookedKeyboardMapper.prototype.inputFeed = function(eventType, code, modifiers
} else {
this.mappedInput.push({type : eventType, code: X11Keysym, modifiers: modifiers});
}
- }
+ } else {
+ if((modifiers & AjaxViewer.CTRL_KEY_MASK) != 0) {
+ this.mappedInput.push({type : eventType, code: X11Keysym, modifiers: modifiers});
+ }
+ }
// special handling for ALT/CTRL key
if(eventType == AjaxViewer.KEY_UP && (code == AjaxViewer.JS_KEY_ALT || code == code == AjaxViewer.JS_KEY_CTRL))
@@ -328,8 +332,8 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi
// trouble-shooting
g_logger = new Logger();
- //g_logger.enable(true);
- //g_logger.open();
+ // g_logger.enable(true);
+ // g_logger.open();
var ajaxViewer = this;
this.imageLoaded = false;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8d436e94/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
----------------------------------------------------------------------
diff --git a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
index 09a3bc9..b23b6c3 100644
--- a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
+++ b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java
@@ -18,7 +18,6 @@ package com.cloud.consoleproxy;
import java.io.IOException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.UnknownHostException;
import org.apache.log4j.Logger;
@@ -35,10 +34,23 @@ import com.cloud.consoleproxy.vnc.VncClient;
*/
public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
private static final Logger s_logger = Logger.getLogger(ConsoleProxyVncClient.class);
+
+ private static final int SHIFT_KEY_MASK = 64;
+ private static final int CTRL_KEY_MASK = 128;
+ private static final int META_KEY_MASK = 256;
+ private static final int ALT_KEY_MASK = 512;
+
+ private static final int X11_KEY_SHIFT = 0xffe1;
+ private static final int X11_KEY_CTRL = 0xffe3;
+ private static final int X11_KEY_ALT = 0xffe9;
+ private static final int X11_KEY_META = 0xffe7;
private VncClient client;
private Thread worker;
- private boolean workerDone = false;
+ private boolean workerDone = false;
+
+ private int lastModifierStates = 0;
+ private int lastPointerMask = 0;
public ConsoleProxyVncClient() {
}
@@ -152,12 +164,14 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
updateFrontEndActivityTime();
switch(event) {
- case KEY_DOWN :
+ case KEY_DOWN :
+ sendModifierEvents(modifiers);
client.sendClientKeyboardEvent(RfbConstants.KEY_DOWN, code, 0);
break;
- case KEY_UP :
- client.sendClientKeyboardEvent(RfbConstants.KEY_UP, code, 0);
+ case KEY_UP :
+ client.sendClientKeyboardEvent(RfbConstants.KEY_UP, code, 0);
+ sendModifierEvents(0);
break;
case KEY_PRESS :
@@ -168,7 +182,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
break;
}
}
-
+
public void sendClientMouseEvent(InputEventType event, int x, int y, int code, int modifiers) {
if(client == null)
return;
@@ -178,12 +192,22 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
int pointerMask = 0;
int mask = 1;
if(code == 2)
- mask = 4;
- if(event == InputEventType.MOUSE_DOWN) {
- pointerMask = mask;
- }
-
- client.sendClientMouseEvent(pointerMask, x, y, code, modifiers);
+ mask = 4;
+
+ if(event == InputEventType.MOUSE_DOWN) {
+ pointerMask = mask;
+ lastPointerMask = pointerMask;
+ } else if(event == InputEventType.MOUSE_UP) {
+ lastPointerMask = 0;
+ } else if(event == InputEventType.MOUSE_MOVE) {
+ if(lastPointerMask != 0)
+ pointerMask = lastPointerMask;
+ }
+
+ sendModifierEvents(modifiers);
+ client.sendClientMouseEvent(pointerMask, x, y, code, modifiers);
+ if(pointerMask == 0)
+ sendModifierEvents(0);
}
@Override
@@ -191,5 +215,21 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
if(client != null)
return client.getFrameBufferCanvas();
return null;
+ }
+
+ private void sendModifierEvents(int modifiers) {
+ if((modifiers & SHIFT_KEY_MASK) != (lastModifierStates & SHIFT_KEY_MASK))
+ client.sendClientKeyboardEvent((modifiers & SHIFT_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_SHIFT, 0);
+
+ if((modifiers & CTRL_KEY_MASK) != (lastModifierStates & CTRL_KEY_MASK))
+ client.sendClientKeyboardEvent((modifiers & CTRL_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_CTRL, 0);
+
+ if((modifiers & META_KEY_MASK) != (lastModifierStates & META_KEY_MASK))
+ client.sendClientKeyboardEvent((modifiers & META_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_META, 0);
+
+ if((modifiers & ALT_KEY_MASK) != (lastModifierStates & ALT_KEY_MASK))
+ client.sendClientKeyboardEvent((modifiers & ALT_KEY_MASK) != 0 ? RfbConstants.KEY_DOWN : RfbConstants.KEY_UP, X11_KEY_ALT, 0);
+
+ lastModifierStates = modifiers;
}
}