From b9f5ce3953c0bfd886959b147a87951e55bbb56e Mon Sep 17 00:00:00 2001 From: mattmcclaskey Date: Thu, 26 Oct 2023 08:20:13 -0400 Subject: [PATCH] revert previous changes, cleanup --- app/ui.js | 16 +++++++--------- core/display.js | 37 +++++++++++++++++++++++++++++++++---- core/rfb.js | 34 +++++++--------------------------- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/app/ui.js b/app/ui.js index 61108eef..f7eec4b4 100644 --- a/app/ui.js +++ b/app/ui.js @@ -2831,16 +2831,14 @@ const UI = { console.log('screen registered') // Get the current screen plan // When a new display is added, it is defaulted to be placed to the far right relative to existing displays and to the top - let screenPlan = UI.rfb.getScreenPlan(); - console.log(screenPlan) - // Now make adjustments to the screen plan, this is just an example - // screenPlan.screens[1].y = 0; - - // Finally apply the screen plan + if (UI.rfb) { + let screenPlan = UI.rfb.getScreenPlan(); + console.log(screenPlan) - // UI.rfb.applyScreenPlan(screenPlan); // applyScreenPlan is triggered in UI.updateMonitors - UI.updateMonitors(screenPlan) - UI._identify(UI.monitors) + UI.updateMonitors(screenPlan) + UI._identify(UI.monitors) + } + }, //Helper to add options to dropdown. diff --git a/core/display.js b/core/display.js index 802fbf6d..822b4b5d 100644 --- a/core/display.js +++ b/core/display.js @@ -174,10 +174,22 @@ export default class Display { // ===== PUBLIC METHODS ===== /* - Returns the screen index given serverside relative coordinates + Returns the screen index and relative coordinates given globally scoped coordinates */ - getScreenIndexByServerCoords(x, y) { - + getClientRelativeCoordinates(x, y) { + for (let i = 0; i < this._screens.length; i++) { + if ( + (x >= this._screens[i].x && x <= this._screens[i].x + this._screens[i].serverWidth) && + (y >= this._screens[i].y && y <= this._screens[i].y + this._screens[i].serverHeight) + ) + { + return { + "screenIndex": i, + "x": x - this._screens[i].x, + "y": y - this._screens[i].y + } + } + } } /* @@ -329,6 +341,8 @@ export default class Display { if (this._isPrimaryDisplay) { for (let i=1; i> 24; // id - buff[offset + 9] = id >> 16; - buff[offset + 10] = id >> 8; - buff[offset + 11] = id; - buff[offset + 12] = 0; // x-position - buff[offset + 13] = 0; - buff[offset + 14] = 0; // y-position - buff[offset + 15] = 0; - buff[offset + 16] = width >> 8; // width - buff[offset + 17] = width; - buff[offset + 18] = height >> 8; // height - buff[offset + 19] = height; - buff[offset + 20] = flags >> 24; // flags - buff[offset + 21] = flags >> 16; - buff[offset + 22] = flags >> 8; - buff[offset + 23] = flags; - - sock._sQlen += 24; - sock.flush(); - */ }, setMaxVideoResolution(sock, width, height) {