Browse Source

Merge pull request #304 from samhed/localcursor

Enables local cursor by default
Samuel 11 years ago
parent
commit
270ae2f9f5
1 changed files with 7 additions and 4 deletions
  1. 7 4
      include/ui.js

+ 7 - 4
include/ui.js

@@ -24,6 +24,7 @@ connSettingsOpen : false,
 popupStatusOpen : false,
 clipboardOpen: false,
 keyboardVisible: false,
+isTouchDevice: false,
 
 // Setup rfb object, load settings from browser storage, then call
 // UI.init to setup the UI/menus
@@ -35,6 +36,8 @@ load: function (callback) {
 start: function(callback) {
     var html = '', i, sheet, sheets, llevels, port, autoconnect;
 
+    UI.isTouchDevice = 'ontouchstart' in document.documentElement;
+
     // Stylesheet selection dropdown
     sheet = WebUtil.selectStylesheet();
     sheets = WebUtil.getStylesheets();
@@ -75,7 +78,7 @@ start: function(callback) {
     UI.initSetting('password', '');
     UI.initSetting('encrypt', (window.location.protocol === "https:"));
     UI.initSetting('true_color', true);
-    UI.initSetting('cursor', false);
+    UI.initSetting('cursor', !UI.isTouchDevice);
     UI.initSetting('shared', true);
     UI.initSetting('view_only', false);
     UI.initSetting('connectTimeout', 2);
@@ -106,7 +109,7 @@ start: function(callback) {
     //    };
 
     // Show mouse selector buttons on touch screen devices
-    if ('ontouchstart' in document.documentElement) {
+    if (UI.isTouchDevice) {
         // Show mobile buttons
         $D('noVNC_mobile_buttons').style.display = "inline";
         UI.setMouseButton();
@@ -368,7 +371,7 @@ toggleSettingsPanel: function() {
         if (UI.rfb.get_display().get_cursor_uri()) {
             UI.updateSetting('cursor');
         } else {
-            UI.updateSetting('cursor', false);
+            UI.updateSetting('cursor', !UI.isTouchDevice);
             $D('noVNC_cursor').disabled = true;
         }
         UI.updateSetting('clip');
@@ -530,7 +533,7 @@ updateVisualState: function() {
         UI.rfb.get_display().get_cursor_uri()) {
         $D('noVNC_cursor').disabled = connected;
     } else {
-        UI.updateSetting('cursor', false);
+        UI.updateSetting('cursor', !UI.isTouchDevice);
         $D('noVNC_cursor').disabled = true;
     }
     $D('noVNC_shared').disabled = connected;