mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 21:51:23 +00:00
Automatically scale client to fit screen.
This commit is contained in:
@@ -592,9 +592,19 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
|
|
||||||
// Scroll (if necessary) to keep mouse on screen.
|
// Scroll (if necessary) to keep mouse on screen.
|
||||||
window.scrollBy(scroll_amount_x, scroll_amount_y);
|
window.scrollBy(scroll_amount_x, scroll_amount_y);
|
||||||
|
|
||||||
|
// 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
|
// Send mouse event
|
||||||
guac.sendMouseState(mouseState);
|
guac.sendMouseState(scaledState);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -684,6 +694,20 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
// Enable keyboard by default
|
// Enable keyboard by default
|
||||||
enableKeyboard();
|
enableKeyboard();
|
||||||
|
|
||||||
|
// Handle resize
|
||||||
|
guac.onresize = function(width, height) {
|
||||||
|
|
||||||
|
// Calculate scale to fit screen
|
||||||
|
var fit_scale = Math.min(
|
||||||
|
window.innerWidth / width,
|
||||||
|
window.innerHeight / height
|
||||||
|
);
|
||||||
|
|
||||||
|
// Scale client
|
||||||
|
guac.scale(fit_scale);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Handle client state change
|
// Handle client state change
|
||||||
guac.onstatechange = function(clientState) {
|
guac.onstatechange = function(clientState) {
|
||||||
|
|
||||||
@@ -759,7 +783,18 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
|
|
||||||
// Send size events on resize
|
// Send size events on resize
|
||||||
window.onresize = function() {
|
window.onresize = function() {
|
||||||
|
|
||||||
guac.sendSize(window.innerWidth, window.innerHeight);
|
guac.sendSize(window.innerWidth, window.innerHeight);
|
||||||
|
|
||||||
|
// Calculate scale to fit screen
|
||||||
|
var fit_scale = Math.min(
|
||||||
|
window.innerWidth / guac.getWidth(),
|
||||||
|
window.innerHeight / guac.getHeight()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Scale client
|
||||||
|
guac.scale(fit_scale);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle clipboard events
|
// Handle clipboard events
|
||||||
|
Reference in New Issue
Block a user