Skip to content

Commit

Permalink
Add electron open width/height setting support
Browse files Browse the repository at this point in the history
  • Loading branch information
avaer committed Dec 1, 2024
1 parent 31ac5e3 commit 5dd3c81
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ const startAgentMainServer = async ({
const j = await req.json();
const {
room,
width,
height,
jwt,
debug,
} = j;

await openFrontend({
room,
width,
height,
jwt,
debug,
});
Expand Down Expand Up @@ -179,19 +183,31 @@ const createOTP = async (jwt) => {

const openFrontend = async ({
room,
jwt,
debug,
width,
height,
jwt,
}) => {
// wait for the electron app to be ready
await app.whenReady();

// create the window
{
const primaryDisplay = screen.getPrimaryDisplay();
const { width: displayWidth, height: displayHeight } = primaryDisplay.workAreaSize;
// console.log('primary display', primaryDisplay, primaryDisplay.workAreaSize);
const { width: displayWidth, height: displayHeight } = primaryDisplay.workAreaSize; // primaryDisplay.bounds;

const localWidth = 600;
const localHeight = 800;
if (!debug) {
if (width === undefined) {
width = 600;
}
if (height === undefined) {
height = 800;
}
} else {
width = displayWidth;
height = displayHeight;
}

// trade the jwt for an otp auth token
const authToken = await createOTP(jwt);
Expand All @@ -207,10 +223,10 @@ const openFrontend = async ({
const win = new BrowserWindow({
// width,
// height,
width: localWidth,
height: localHeight,
x: displayWidth - localWidth, // Position at right edge
y: displayHeight - localHeight, // Position at bottom edge
width: width,
height: height,
x: displayWidth - width, // Position at right edge
y: displayHeight - height, // Position at bottom edge
transparent: true,
backgroundColor: '#00000000',
frame: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export class ReactAgentsElectronRuntime {
// open the frontend
async open({
room,
width,
height,
jwt,
debug,
}) {
Expand All @@ -139,6 +141,8 @@ export class ReactAgentsElectronRuntime {
body: JSON.stringify({
room,
jwt,
width,
height,
debug,
}),
});
Expand Down

0 comments on commit 5dd3c81

Please sign in to comment.