[GH-ISSUE #304] Client reports wrong screen size for multiple monitors #244

Closed
opened 2026-05-05 05:49:56 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @mrwensveen on GitHub (May 9, 2019).
Original GitHub issue: https://github.com/debauchee/barrier/issues/304

Operating Systems

Server: Windows 10 Version 1809 (OS Build 17763.475)

Client: Windows 10 Version 1809 (OS Build 17763.437)

Barrier Version

2.2.0-Release-18ac0fe4

Steps to reproduce bug

Multiple monitors with different DPI settings. 1st monitor 1920x1080 125% DPI, 2nd monitor 1920x1200 100% (set as main display).

After connecting, the client reports a virtual screen size of 3456x1200.

Other info

It seems the issue is in MSWindowsScreen::updateScreenShape(). Apparently, GetSystemMetrics reports wrong values for applications that are not DPI-aware.

    m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
    m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);

My screens are 1920x1200 and 1920x1080. And my debug log shows a virtual screen size of [2019-05-09T11:20:18] DEBUG: screen shape: 0,0 3456x1200 (multi-monitor)
1920 for the screen on 100% and 1536 for the screen on 125% (1536 * 1,25 = 1920).

See also: https://stackoverflow.com/questions/2630392/getsystemmetrics-returns-wrong-value-for-sm-cxscreen#2630531

Since I've not done anything with C++ for about 15 years, I'm a little afraid to make a patch / pull request. But testing with a simple C++ console application in VS2017, it appears the problem will be fixed when setting the DPI awareness to Per-monitor in the application manifest (this project has multiple, but I think it would be barrierc.exe.manifest).

3 different settings: Not DPI-aware, Per-monitor High DPI-aware, High DPI-aware.

PS P:\> .\DPITest.exe
screen shape : 3456x1200
PS P:\> .\DPITest.exe
screen shape : 3840x1200
PS P:\> .\DPITest.exe
screen shape : 3456x1200
Originally created by @mrwensveen on GitHub (May 9, 2019). Original GitHub issue: https://github.com/debauchee/barrier/issues/304 ### Operating Systems ### Server: Windows 10 Version 1809 (OS Build 17763.475) Client: Windows 10 Version 1809 (OS Build 17763.437) ### Barrier Version ### 2.2.0-Release-18ac0fe4 ### Steps to reproduce bug ### Multiple monitors with different DPI settings. 1st monitor 1920x1080 125% DPI, 2nd monitor 1920x1200 100% (set as main display). After connecting, the client reports a virtual screen size of 3456x1200. ### Other info ### It seems the issue is in `MSWindowsScreen::updateScreenShape()`. Apparently, GetSystemMetrics reports wrong values for applications that are not DPI-aware. ``` m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); ``` My screens are 1920x1200 and 1920x1080. And my debug log shows a virtual screen size of `[2019-05-09T11:20:18] DEBUG: screen shape: 0,0 3456x1200 (multi-monitor)` 1920 for the screen on 100% and 1536 for the screen on 125% (1536 * 1,25 = 1920). See also: https://stackoverflow.com/questions/2630392/getsystemmetrics-returns-wrong-value-for-sm-cxscreen#2630531 Since I've not done anything with C++ for about 15 years, I'm a little afraid to make a patch / pull request. But testing with a simple C++ console application in VS2017, it appears the problem will be fixed when setting the DPI awareness to Per-monitor in the application manifest (this project has multiple, but I think it would be barrierc.exe.manifest). 3 different settings: Not DPI-aware, Per-monitor High DPI-aware, High DPI-aware. ``` PS P:\> .\DPITest.exe screen shape : 3456x1200 PS P:\> .\DPITest.exe screen shape : 3840x1200 PS P:\> .\DPITest.exe screen shape : 3456x1200 ```
Author
Owner

@mrwensveen commented on GitHub (May 9, 2019):

I forgot to mention that the result of this, is that I can't move the mouse to the right edge of the right screen. It stops at about 3/4 of the screen (1536/1920 = 4/5, to be precise :) ). So I can't reach the systray icons and such.

<!-- gh-comment-id:490883033 --> @mrwensveen commented on GitHub (May 9, 2019): I forgot to mention that the result of this, is that I can't move the mouse to the right edge of the right screen. It stops at about 3/4 of the screen (1536/1920 = 4/5, to be precise :) ). So I can't reach the systray icons and such.
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: github-starred/barrier#244
No description provided.