Added new desktop display location/size command support.
Ylian Saint-Hilaire committed
May 16, 2021 at 12:44 UTC
ae936654a40724ac80a0a9237fdf187fcc5bd5f0
2 files changed
+19
-1
meshdesktopmultiplex.js
+13
-1
@@ -54,7 +54,8 @@ MNG_FILEDELETEREC = 62, // Same as MNG_FILEDELETE but recursive
54
MNG_USERCONSENT = 63, // Used to notify management console of user consent state
55
MNG_DEBUG = 64, // Debug/Logging Message for ILibRemoteLogging
56
MNG_ERROR = 65,
57
-MNG_ENCAPSULATE_AGENT_COMMAND = 70
57
+MNG_ENCAPSULATE_AGENT_COMMAND = 70,
58
+MNG_KVM_DISPLAY_INFO = 82
59
*/
60
61
function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
@@ -79,6 +80,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
80
obj.firstData = null; // Index in the image table of the first image in the table, generally this points to the display resolution command.
81
obj.lastData = null; // Index in the images table of the last image in the table.
82
obj.lastDisplayInfoData = null; // Pointer to the last display information command from the agent (Number of displays).
83
+ obj.lastDisplayLocationData = null; // Pointer to the last display location and size command from the agent.
84
obj.desktopPaused = true; // Current desktop pause state, it's true if all viewers are paused.
85
obj.imageCompression = 50; // Current image compression, this is the highest value of all viewers.
86
obj.imageScaling = 1024; // Current image scaling, this is the highest value of all viewers.
@@ -130,6 +132,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
132
133
// If the agent sent display information or console message, send it to the viewer
134
if (obj.lastDisplayInfoData != null) { obj.sendToViewer(peer, obj.lastDisplayInfoData); }
135
+ if (obj.lastDisplayLocationData != null) { obj.sendToViewer(peer, obj.lastDisplayLocationData); }
136
if (obj.lastConsoleMessage != null) { obj.sendToViewer(peer, obj.lastConsoleMessage); }
137
138
// Log joining the multiplex session
@@ -524,6 +527,9 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
527
break;
528
case 14: // Touch setup
529
break;
530
+ case 82: // Request display information
531
+ if (obj.lastDisplayLocationData != null) { obj.sendToAgent(obj.lastDisplayLocationData); }
532
+ break;
533
case 85: // Unicode Key Events, forward to agent
534
if (viewer.viewOnly == false) { obj.sendToAgent(data); }
535
break;
@@ -678,6 +684,12 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
684
// Send this to all viewers right away
685
obj.sendToAllViewers(data);
686
break;
687
+ case 82:
688
+ // Display information
689
+ if ((data.length < 14) || (((data.length - 4) % 10) != 0)) break; // Command must be 14 bytes and have header + 10 byte for each display.
690
+ obj.lastDisplayLocationData = data;
691
+ obj.sendToAllViewers(data);
692
+ break;
693
case 87: // MNG_KVM_INPUT_LOCK
694
// Send this to all viewers right away
695
// This will update all views on the current state of the input lock
public/scripts/agent-desktop-0.0.2.js
+6
@@ -271,6 +271,12 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
271
console.log('KVM: ' + str.substring(1));
272
}
273
break;
274
+ case 82: // DISPLAY LOCATION & SIZE
275
+ if ((cmdsize < 4) || (((cmdsize - 4) % 10) != 0)) break;
276
+ var screenCount = ((cmdsize - 4) / 10), screenInfo = {}, ptr = 4;
277
+ for (var i = 0; i < screenCount; i++) { screenInfo[(view[ptr + 0] << 8) + view[ptr + 1]] = { x: ((view[ptr + 2] << 8) + view[ptr + 3]), y: ((view[ptr + 4] << 8) + view[ptr + 5]), w: ((view[ptr + 6] << 8) + view[ptr + 7]), h: ((view[ptr + 8] << 8) + view[ptr + 9]) }; ptr += 10; }
278
+ console.log('ScreenInfo', JSON.stringify(screenInfo, null, 2));
279
+ break;
280
case 87: // MNG_KVM_INPUT_LOCK
281
if (cmdsize != 5) break;
282
if ((obj.RemoteInputLock == null) || (obj.RemoteInputLock !== (view[4] != 0))) {