Bugfix/kasm 5601 display mgr changes (#97)
* KASM-5598 modify click logic to tell other windows they can receive a click event * KASM-5598 dont run the rest of the switch on click focus set * KASM-5598 forgot to false * fix detection of changes of x and y of secondary screens * always apply resize after recieving display reregister --------- Co-authored-by: ryan.kuba <ryan.kuba@kasmweb.com> Co-authored-by: mattmcclaskey <matt@kasmweb.com>
This commit is contained in:
parent
3d7047e546
commit
5a3b4f0d69
|
@ -329,18 +329,24 @@ export default class Display {
|
|||
}
|
||||
|
||||
applyScreenPlan(screenPlan) {
|
||||
//check all screens for any changes, but only apply changes to primary screen, secondary screens will individually be updated and report back with their new settings
|
||||
let changes = false;
|
||||
for (let i = 0; i < screenPlan.screens.length; i++) {
|
||||
for (let z = 0; z < this._screens.length; z++) {
|
||||
if (screenPlan.screens[i].screenID === this._screens[z].screenID) {
|
||||
if (this._screens[z].x !== screenPlan.screens[i].x || this._screens[z].y !== screenPlan.screens[i].y) {
|
||||
if (z == 0) {
|
||||
this._screens[z].x = screenPlan.screens[i].x;
|
||||
this._screens[z].y = screenPlan.screens[i].y;
|
||||
}
|
||||
changes = true;
|
||||
}
|
||||
if (this._screens[z].x2 !== this._screens[z].x + this._screens[z].serverWidth || this._screens[z].y2 !== this._screens[z].y + this._screens[z].serverHeight) {
|
||||
if (z == 0) {
|
||||
this._screens[z].x2 = this._screens[z].x + this._screens[z].serverWidth
|
||||
this._screens[z].y2 = this._screens[z].y + this._screens[z].serverHeight
|
||||
|
||||
}
|
||||
changes = true;
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +355,7 @@ export default class Display {
|
|||
return changes;
|
||||
}
|
||||
|
||||
addScreen(screenID, width, height, pixelRatio, containerHeight, containerWidth, scale, serverWidth, serverHeight) {
|
||||
addScreen(screenID, width, height, pixelRatio, containerHeight, containerWidth, scale, serverWidth, serverHeight, x, y) {
|
||||
if (!this._isPrimaryDisplay) {
|
||||
throw new Error("Cannot add a screen to a secondary display.");
|
||||
}
|
||||
|
@ -367,23 +373,26 @@ export default class Display {
|
|||
|
||||
if (screenIdx > 0) {
|
||||
//existing screen, update
|
||||
const screen = this._screens[screenIdx];
|
||||
if (screen.serverHeight !== serverHeight || screen.serverWidth !== serverWidth || screen.width !== width || screen.height !== height || screen.containerHeight !== containerHeight || screen.containerWidth !== containerWidth || screen.scale !== screen.scale || screen.pixelRatio !== screen.pixelRatio) {
|
||||
screen.width = width;
|
||||
screen.height = height;
|
||||
screen.containerHeight = containerHeight;
|
||||
screen.containerWidth = containerWidth;
|
||||
screen.pixelRatio = pixelRatio;
|
||||
screen.scale = scale;
|
||||
screen.serverWidth = serverWidth;
|
||||
screen.serverHeight = serverHeight;
|
||||
screen.x2 = screen.x + screen.serverWidth;
|
||||
screen.y2 = screen.y + screen.serverHeight;
|
||||
const existing_screen = this._screens[screenIdx];
|
||||
if (existing_screen.serverHeight !== serverHeight || existing_screen.serverWidth !== serverWidth || existing_screen.width !== width || existing_screen.height !== height
|
||||
|| existing_screen.containerHeight !== containerHeight || existing_screen.containerWidth !== containerWidth || existing_screen.scale !== scale || existing_screen.pixelRatio !== pixelRatio ||
|
||||
existing_screen.x !== x || existing_screen.y !== y) {
|
||||
existing_screen.width = width;
|
||||
existing_screen.height = height;
|
||||
existing_screen.containerHeight = containerHeight;
|
||||
existing_screen.containerWidth = containerWidth;
|
||||
existing_screen.pixelRatio = pixelRatio;
|
||||
existing_screen.scale = scale;
|
||||
existing_screen.serverWidth = serverWidth;
|
||||
existing_screen.serverHeight = serverHeight;
|
||||
existing_screen.x = x;
|
||||
existing_screen.y = y;
|
||||
existing_screen.x2 = existing_screen.x + existing_screen.serverWidth;
|
||||
existing_screen.y2 = existing_screen.y + existing_screen.serverHeight;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
//New Screen, add to far right until user repositions it
|
||||
let x = 0;
|
||||
for (let i = 0; i < this._screens.length; i++) {
|
||||
x = Math.max(x, this._screens[i].x + this._screens[i].serverWidth);
|
||||
}
|
||||
|
|
10
core/rfb.js
10
core/rfb.js
|
@ -805,6 +805,8 @@ export default class RFB extends EventTargetMixin {
|
|||
}
|
||||
|
||||
this._pendingApplyResolutionChange = true;
|
||||
} else {
|
||||
Log.Debug("Screen plan did not apply, no changes detected.");
|
||||
}
|
||||
|
||||
return changes;
|
||||
|
@ -1814,7 +1816,7 @@ export default class RFB extends EventTargetMixin {
|
|||
...event.data.details,
|
||||
screenID: event.data.screenID
|
||||
}
|
||||
let screenIndex = this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth, event.data.scale, event.data.serverWidth, event.data.serverHeight);
|
||||
let screenIndex = this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth, event.data.scale, event.data.serverWidth, event.data.serverHeight, event.data.x, event.data.y);
|
||||
this._proxyRFBMessage('screenRegistrationConfirmed', [ this._display.screens[screenIndex].screenID, screenIndex ]);
|
||||
this._sendEncodings();
|
||||
clearTimeout(this._resizeTimeout);
|
||||
|
@ -1823,14 +1825,12 @@ export default class RFB extends EventTargetMixin {
|
|||
Log.Info(`Secondary monitor (${event.data.screenID}) has been registered.`);
|
||||
break;
|
||||
case 'reattach':
|
||||
let changes = this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth, event.data.scale, event.data.serverWidth, event.data.serverHeight);
|
||||
let changes = this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth, event.data.scale, event.data.serverWidth, event.data.serverHeight, event.data.x, event.data.y);
|
||||
|
||||
if (changes) {
|
||||
clearTimeout(this._resizeTimeout);
|
||||
this._resizeTimeout = setTimeout(this._requestRemoteResize.bind(this), 500);
|
||||
this.dispatchEvent(new CustomEvent("screenregistered", {}));
|
||||
Log.Info(`Secondary monitor (${event.data.screenID}) has been reattached.`);
|
||||
}
|
||||
break;
|
||||
case 'unregister':
|
||||
if (this._display.removeScreen(event.data.screenID)) {
|
||||
|
@ -2257,7 +2257,7 @@ export default class RFB extends EventTargetMixin {
|
|||
|
||||
//Simulate a left click on focus change
|
||||
//this was added to aid multi-display, not requiring two clicks when switching between displays
|
||||
if (this._sendLeftClickonNextMove) {
|
||||
if (this._sendLeftClickonNextMove && this._display.screens.length > 1) {
|
||||
this._sendLeftClickonNextMove = false;
|
||||
this._handleMouseButton(this._mousePos.x, this._mousePos.y, true, 0x1);
|
||||
this._handleMouseButton(this._mousePos.x, this._mousePos.y, false, 0x1);
|
||||
|
|
Loading…
Reference in New Issue