Skip to content

Conversation

@jalfd
Copy link

@jalfd jalfd commented Feb 25, 2020

This allows the viewport to be scaled to compensate for DPI scaling on
high-DPI monitors. Previously, if DPI scaling was set to 200% in Windows, for example,
noVNC would request a viewport half the size of the actual screen area,
and scale it up. Leading to the VNC session looking grainy and low-res.

The caller can now set scaleFactor to 1 / window.devicePixelRatio to
compensate for this, and get a canvas scaled to the actual physical
screen DPI.

@samhed samhed added the feature label Feb 25, 2020
@samhed
Copy link
Member

samhed commented Feb 25, 2020

What are you using on the VNC serverside to achieve good up-scaling? In my experience, support for this is lacking in Linux.

If thinking about merging this I'd like to see it used in the UI settings of vnc.html as well.

@CendioOssman
Copy link
Member

If the use case is HiDPI, then a simple boolean of "native" resolution or not should be sufficient. Let's try to keep things simple.

@samhed
Copy link
Member

samhed commented May 1, 2020

ping @jalfd

@samhed
Copy link
Member

samhed commented May 16, 2020

No response

@samhed samhed closed this May 16, 2020
@jalfd
Copy link
Author

jalfd commented May 25, 2020

Oops, very sorry, I completely dropped the ball on this. A boolean option to toggle "native" DPI sounds reasonable. Should I create a new PR for that?

@samhed samhed reopened this May 28, 2020
@samhed samhed removed the noresponse label May 28, 2020
@samhed
Copy link
Member

samhed commented May 28, 2020

Go ahead and update this one 👍

@jalfd jalfd force-pushed the dpi-scaling branch 2 times, most recently from 011ae5a to 7d06dd7 Compare June 3, 2020 14:29
Thomas Sondergaard and others added 2 commits June 3, 2020 16:31
This allows the viewport to be scaled to compensate for DPI scaling on
high-DPI monitors. Previously, if DPI scaling was set to 200% in Windows, for example,
noVNC would set the client area to twice the dimensions of the server-side framebuffer
and scale it up to fit, leading to the VNC session looking grainy and low-res.

useNativeDpi can now be set to true to compensate for this, and
let framebuffer pixels exactly match monitor pixels.
@jalfd
Copy link
Author

jalfd commented Jun 3, 2020

Go ahead and update this one 👍

Done!

Copy link
Member

@CendioOssman CendioOssman left a comment

Choose a reason for hiding this comment

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

Looks mostly good. I'd also like you to update the documentation for both the app and the library with this new setting.

const dpr = window.devicePixelRatio || 1;
const scaledWidth = Math.floor(window.innerWidth * dpr);
// Compute the exact scale factor to match the floored width/height
this._display.scale = window.innerWidth / scaledWidth;
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the purpose of this calculation. Why not just 1 / window.devicePixelRatio?


const size = this._screenSize();
size.w = Math.floor(size.w / this._display.scale);
size.h = Math.floor(size.h / this._display.scale);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we want to tie this in to the display scaling right now. I would prefer if you just use window.devicePixelRatio and this._nativeDpi here.

}

get useNativeDpi() { return this._nativeDpi; }
set useNativeDpi(nativeDpi) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be useNativeDPI? What does JavaScript APIs usually do with abbreviations?

Copy link
Member

@samhed samhed left a comment

Choose a reason for hiding this comment

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

Works great, tested in Chrome with a scale factor of 200%! 👍

Just a few minor style comments in addition to what @CendioOssman wrote

/* ------^-------
* /VIEW CLIPPING
* ==============
* NATIVE DPI
Copy link
Member

Choose a reason for hiding this comment

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

Please center this like the other section names, same goes for "/NATIVE DPI" below

Comment on lines +1316 to +1320
// Update native DPI scaling for the viewport. If enabled, a pixel on the screen will
// correspond to one pixel on the server framebuffer.
// If disabled, the client area will be scaled according to the DPI scaling applied by the OS
// When this is disabled on a high-DPI monitor, a smaller framebuffer will be used and the
// result scaled up to fit the client area
Copy link
Member

Choose a reason for hiding this comment

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

Good explanation!

Could you keep the lines a bit shorter? Most of the code in UI attempts to stay within 80 columns I believe.

</li>
<li><hr></li>
<li>
<label><input id="noVNC_setting_native_dpi" type="checkbox">Use native DPI</label>
Copy link
Member

Choose a reason for hiding this comment

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

The other surrounding checkboxes have a space in front of text

@samhed samhed added this to the v1.2.0 milestone Jun 5, 2020
@samhed
Copy link
Member

samhed commented Jul 1, 2020

ping @jalfd

@CendioOssman CendioOssman removed this from the v1.2.0 milestone Jul 3, 2020
@jalfd
Copy link
Author

jalfd commented Jul 13, 2020

Thanks for the feedback!
Sorry, I'm completely swamped with work at the moment, so it'll be a little while before I get back to this. I'll update the PR once I'm able to make the requested changes!

@samhed samhed added this to the Future Features milestone Jul 27, 2020
@samhed samhed removed the noresponse label Jul 27, 2020
@samhed samhed marked this pull request as draft July 27, 2020 14:04
@CendioOssman
Copy link
Member

Any luck getting the final parts fixed up? :)

@alectrocute
Copy link

@samhed Maybe we should re-add the “noresponse” label?

@CendioOssman
Copy link
Member

We try to close them now instead. The label doesn't really help out in getting some action on an issue. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants