mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-30 00:23:21 +00:00 
			
		
		
		
	GUAC-324: Maintain scroll state of menu. Separate touch from mouse. Allow default actions from touch events on menu only.
This commit is contained in:
		| @@ -817,11 +817,8 @@ GuacUI.Client.showMenu = function(shown) { | |||||||
|         GuacUI.Client.menu.className = "closed"; |         GuacUI.Client.menu.className = "closed"; | ||||||
|         GuacUI.Client.commitClipboard(); |         GuacUI.Client.commitClipboard(); | ||||||
|     } |     } | ||||||
|     else { |     else | ||||||
|         GuacUI.Client.menu.scrollLeft = 0; |  | ||||||
|         GuacUI.Client.menu.scrollTop = 0; |  | ||||||
|         GuacUI.Client.menu.className = "open"; |         GuacUI.Client.menu.className = "open"; | ||||||
|     } |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -1162,29 +1159,30 @@ GuacUI.Client.attach = function(guac) { | |||||||
|      */ |      */ | ||||||
|  |  | ||||||
|     // Mouse |     // Mouse | ||||||
|     var mouse = new Guacamole.Mouse(guac_display); |     function __handle_mouse_state(mouseState) { | ||||||
|  |  | ||||||
|  |         // Scale event by current scale | ||||||
|  |         var scaledState = new Guacamole.Mouse.State( | ||||||
|  |                 mouseState.x / guac.getScale(), | ||||||
|  |                 mouseState.y / guac.getScale(), | ||||||
|  |                 mouseState.left, | ||||||
|  |                 mouseState.middle, | ||||||
|  |                 mouseState.right, | ||||||
|  |                 mouseState.up, | ||||||
|  |                 mouseState.down); | ||||||
|  |  | ||||||
|  |         // Send mouse event | ||||||
|  |         guac.sendMouseState(scaledState); | ||||||
|  |          | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     var touch = new Guacamole.Mouse.Touchscreen(guac_display); |     var touch = new Guacamole.Mouse.Touchscreen(guac_display); | ||||||
|     touch.onmousedown = touch.onmouseup = touch.onmousemove = |     touch.onmousedown = touch.onmouseup = touch.onmousemove = __handle_mouse_state; | ||||||
|     mouse.onmousedown = mouse.onmouseup = mouse.onmousemove = |  | ||||||
|         function(mouseState) { |  | ||||||
|  |  | ||||||
|             // Scale event by current scale |  | ||||||
|             var scaledState = new Guacamole.Mouse.State( |  | ||||||
|                     mouseState.x / guac.getScale(), |  | ||||||
|                     mouseState.y / guac.getScale(), |  | ||||||
|                     mouseState.left, |  | ||||||
|                     mouseState.middle, |  | ||||||
|                     mouseState.right, |  | ||||||
|                     mouseState.up, |  | ||||||
|                     mouseState.down); |  | ||||||
|  |  | ||||||
|             // Send mouse event |  | ||||||
|             guac.sendMouseState(scaledState); |  | ||||||
|              |  | ||||||
|         }; |  | ||||||
|  |  | ||||||
|     GuacUI.Client.touch = touch; |     GuacUI.Client.touch = touch; | ||||||
|  |  | ||||||
|  |     var mouse = new Guacamole.Mouse(guac_display); | ||||||
|  |     mouse.onmousedown = mouse.onmouseup = mouse.onmousemove = __handle_mouse_state; | ||||||
|  |  | ||||||
|     // Hide any existing status notifications |     // Hide any existing status notifications | ||||||
|     GuacUI.Client.hideStatus(); |     GuacUI.Client.hideStatus(); | ||||||
|  |  | ||||||
| @@ -1620,7 +1618,25 @@ GuacUI.Client.attach = function(guac) { | |||||||
|  |  | ||||||
|     // Prevent default on all touch events |     // Prevent default on all touch events | ||||||
|     document.addEventListener("touchstart", function(e) { |     document.addEventListener("touchstart", function(e) { | ||||||
|  |  | ||||||
|  |         // Inspect touch event target to determine whether the touch should | ||||||
|  |         // be allowed. | ||||||
|  |         if (e.touches.length === 1) { | ||||||
|  |  | ||||||
|  |             var element = e.target; | ||||||
|  |             while (element) { | ||||||
|  |  | ||||||
|  |                 // Allow single-touch events on the menu | ||||||
|  |                 if (element === GuacUI.Client.menu) | ||||||
|  |                     return; | ||||||
|  |  | ||||||
|  |                 element = element.parentNode; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |  | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|  |  | ||||||
|     }, false); |     }, false); | ||||||
|  |  | ||||||
| })(); | })(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user