[GH-ISSUE #423] RDP showing small fraction (upper left) of screen. #214

Closed
opened 2026-02-27 15:49:22 +03:00 by kerem · 5 comments
Owner

Originally created by @deebug on GitHub (Feb 25, 2016).
Original GitHub issue: https://github.com/quasar/Quasar/issues/423

Originally assigned to: @MaxXor on GitHub.

A desktop with an UHD resolution can't be viewed in its entirety which renders remote administration useless. It shows the top left part of the screen.

This could be either a scaling issue (not showing the entire desktop) or a screen-grabbing issue (not streaming the entire desktop)

OS: Windows 10 Pro 64 bit
Version: 1.2.0.0

Originally created by @deebug on GitHub (Feb 25, 2016). Original GitHub issue: https://github.com/quasar/Quasar/issues/423 Originally assigned to: @MaxXor on GitHub. A desktop with an UHD resolution can't be viewed in its entirety which renders remote administration useless. It shows the top left part of the screen. This could be either a scaling issue (not showing the entire desktop) or a screen-grabbing issue (not streaming the entire desktop) OS: Windows 10 Pro 64 bit Version: 1.2.0.0
kerem 2026-02-27 15:49:22 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@MaxXor commented on GitHub (Feb 25, 2016):

Sadly I don't have a monitor which supports UHD resolution to figure out the issue. :(

<!-- gh-comment-id:188684470 --> @MaxXor commented on GitHub (Feb 25, 2016): Sadly I don't have a monitor which supports UHD resolution to figure out the issue. :(
Author
Owner

@yankejustin commented on GitHub (Feb 25, 2016):

Neither do I. Hmmm...

<!-- gh-comment-id:188695231 --> @yankejustin commented on GitHub (Feb 25, 2016): Neither do I. Hmmm...
Author
Owner

@deebug commented on GitHub (Feb 27, 2016):

Mouse input is scaled correctly. So the true dimensions are known but somehow the bitmap doesn't reflect that. I'll use a debug build and try to figure this one out myself. I'll keep you posted, eta hopefully during next week.

<!-- gh-comment-id:189620530 --> @deebug commented on GitHub (Feb 27, 2016): Mouse input is scaled correctly. So the true dimensions are known but somehow the bitmap doesn't reflect that. I'll use a debug build and try to figure this one out myself. I'll keep you posted, eta hopefully during next week.
Author
Owner

@deebug commented on GitHub (Feb 29, 2016):

Windows 10 handles DPI scaling a bit differently.

I've learned that with e.g. a global 125% DPI setting the Screen.AllScreens[monitor].Bounds returns a bogus resolution. So this is not the the fault of the ultra-hight resolution (I did assume that at first).

In my test setting, using a Windows 10 machine with a global 125% DPI scaling, the bounds return 1280x720 while the actual resolution was 1600x900.

Creating a graphics instance from the current form and get dpiXand dpiY? No luck, always 96 DPI.

Option 1, not favorable: One could get the real DPI in a rather difficult way

[DllImport("gdi32.dll")]
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
public enum DeviceCap
{
    VERTRES = 10,
    DESKTOPVERTRES = 117,

    // http://pinvoke.net/default.aspx/gdi32/GetDeviceCaps.html
}  


private float getScalingFactor()
{
    Graphics g = Graphics.FromHwnd(IntPtr.Zero);
    IntPtr desktop = g.GetHdc();
    int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
    int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); 

    float ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;

    return ScreenScalingFactor; // 1.25 = 125%
}

Source

Using the scaling-factor, one can easily calculate the actual width and height.

Option 2, my favorite: Make the client application DPI aware
This fixes the screen bounds without changing code. How? By adding this to your app.manifest:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
    </windowsSettings>
  </application>

Since the Client isn't really and end-user GUI experience (except for a dialog window) this results in little or no strange GUI scaling issues when the client uses DPI scaling.

To keep this excellent piece of software future proof (high DPI Windows tablets, UHD screens) you probably should look into this issue.

You can find more information about DPI and all it's perils here. A big thanks to Christoph Nahr for his thorough and very comprehensive documentation concerning this issue.

Now then. I'm no expert and I know little about Mono build compatibility but option 2 sounds like a viable solution.

<!-- gh-comment-id:190161503 --> @deebug commented on GitHub (Feb 29, 2016): Windows 10 handles DPI scaling a bit differently. I've learned that with e.g. a global 125% DPI setting the `Screen.AllScreens[monitor].Bounds` returns a bogus resolution. So this is not the the fault of the ultra-hight resolution (I did assume that at first). In my test setting, using a Windows 10 machine with a global 125% DPI scaling, the bounds return 1280x720 while the actual resolution was 1600x900. Creating a graphics instance from the current form and get `dpiX`and `dpiY`? No luck, always 96 DPI. **Option 1, not favorable: One could get the real DPI in a rather difficult way** ``` [DllImport("gdi32.dll")] static extern int GetDeviceCaps(IntPtr hdc, int nIndex); public enum DeviceCap { VERTRES = 10, DESKTOPVERTRES = 117, // http://pinvoke.net/default.aspx/gdi32/GetDeviceCaps.html } private float getScalingFactor() { Graphics g = Graphics.FromHwnd(IntPtr.Zero); IntPtr desktop = g.GetHdc(); int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES); int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); float ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight; return ScreenScalingFactor; // 1.25 = 125% } ``` [Source](http://stackoverflow.com/a/21450169) Using the scaling-factor, one can easily calculate the actual width and height. **Option 2, my favorite: Make the client application DPI aware** This fixes the screen bounds without changing code. How? By adding this to your `app.manifest`: ``` <application xmlns="urn:schemas-microsoft-com:asm.v3"> <windowsSettings> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> </windowsSettings> </application> ``` Since the Client isn't really and end-user GUI experience (except for a dialog window) this results in little or no strange GUI scaling issues when the client uses DPI scaling. To keep this excellent piece of software future proof (high DPI Windows tablets, UHD screens) you probably should look into this issue. You can find more information about DPI and all it's perils [here](http://kynosarges.org/WindowsDpi.html). A big thanks to Christoph Nahr for his thorough and very comprehensive documentation concerning this issue. Now then. I'm no expert and I know little about Mono build compatibility but option 2 sounds like a viable solution.
Author
Owner

@MaxXor commented on GitHub (Feb 29, 2016):

Yes, Option 2 sounds very good. I'll add this.

<!-- gh-comment-id:190216901 --> @MaxXor commented on GitHub (Feb 29, 2016): Yes, Option 2 sounds very good. I'll add this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Quasar#214
No description provided.