Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gets the true monitor resolution of the input source for multi-monitor setups #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emptycrown
Copy link
Collaborator

Something like this is needed to actually use the true monitor resolution to scale a scene. When there is only one monitor, this doesn't matter much since Electron's getPrimaryDisplay() will handle that.

However, in multi-monitor setups, Electron's displays are not helpful. To get the resolution dimensions, we must wait until after the source is added and then scale the scene accordingly.

Solves #15

…r setups where just using Electron's primaryDisplay is not accurate.
@emptycrown emptycrown requested a review from Envek June 8, 2020 15:20
Copy link
Owner

@Envek Envek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we're still using width and height reported by Electron here:

const { physicalWidth, physicalHeight, aspectRatio } = displayInfo();
// Update source settings:
let settings = videoSource.settings;
settings['width'] = physicalWidth;
settings['height'] = physicalHeight;
videoSource.update(settings);
videoSource.save();

So we also should redefine displayInfo function:

// Get information about prinary display
function displayInfo() {
const { screen } = require('electron');
const primaryDisplay = screen.getPrimaryDisplay();
const { width, height } = primaryDisplay.size;
const { scaleFactor } = primaryDisplay;
return {
width,
height,
scaleFactor: scaleFactor,
aspectRatio: width / height,
physicalWidth: width * scaleFactor,
physicalHeight: height * scaleFactor,
}
}


// Properly scale the video scene using the resolution off whatever monitor is used
// The source width is only available after it is set as an output source
const realDisplayWidth = osn.Global.getOutputSource(1).source.width;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting undefined from osn.Global.getOutputSource(1) here and everything breaks.

We can access videoSource variable here (which should contain plain desktop capture), but videoSource.width returns 0 for me here. Weird.

@Envek Envek linked an issue Aug 28, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using the correct scene resolution in multi-monitor setups
2 participants