Windows 10 / wxFrame-scaling on multipe Displays

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Windows 10 / wxFrame-scaling on multipe Displays

Post by art-ganseforth » Fri May 08, 2020 4:32 pm

Hello,

i have a very strange effect working with multiple monitors and multiple wxFrames.

First:
It seems, that it has nothing to do, with high-dpi-resolution. I have optionally implemented an DPI-Awarenes-dll. The library works for fonts, but not for bitmaps and positions, but this is no big problem because my application has an uniersal scaling-factor for positions and sizes. Therfore i can easly compile my application with or whithout this dll.
In both cases my application looks nearly simelar and the effect i talk about also appers in both cases in the same way. So dpi-awareness seems not to be the reason.

The Effect is the following:
On starting the progrem, there are a number of wxFrame-instances created, that corrospond to the number of connected displays (one more wxFrame as available displays). One wxFrame contains a control panel full of controls and the second contains a file-editor (incl. directory-tree in a wxTreeCtrl). All the others one wxGLCanvas-control each.
As long as all wxFrames are positioned on the main-display, everything is okay. If i move one of the canvas-frames to another display, the remaining wxFrames are scaled incuding their whole content like bitmaps, text and OpenGL-content. Also the tool-tips are scaled.

The Scaling-factor corrosponds to the sacling-factors doe the displays that are defined in the system-settings, like i.e. this:
Scaling-factor of the main display: 250%
Scaling-factor of the second display: 200%
Resulting wxFrame scaling-factor: 200/250 (0,8).

But this only appears at wxFrames that are not maximized. So, clicking maximize or restore, scales / unscales all the content of the wxFrame, while in this case (maximized wxFrame) tooltips are not rescaled - so that the positioning of tooltips differ for the mouse-position.

Finally:
Not every wxFrame moved to the second display causes this effect, like i.e. the wxFrame that contains the text-editor does not. Also i was not able to reproduce it with a test-wxFrame (incuding wxGLCanvas), that i implemented at different points of my code.
I had the idea of a dummy-wxFrame, like i.e. with wxSize(1,1), so that the effect does not depend on the postition of the other wxFrames, that are in use...

I also tried to log various return-values of wxWidgets-functions concerning this context, like wxDisplay().GetGeometry() or wxWindow.FromDPI() etc. I did not find any value that chaged parallel to this scaling-effect. For exmple if a wxFrame is scaled or not, does not effect the values i retrieve from GetScreenPosition() even if the screen-positions oviously changes. If there is a value like this, it would be possible, to program a fix but i did not find one.

Is there anyone who has an idea, what i can do against this?


Thank you for reading,
Frank

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4240
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by ONEEYEMAN » Fri May 08, 2020 5:25 pm

Hi,
What version of wxWidgets do you use?
Can you try with the Git master?

Thank you.

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by art-ganseforth » Fri May 08, 2020 5:28 pm

wx 3.1.2 - sorry, i should have mentioned that..

Git master???

What is it?

User avatar
doublemax
Moderator
Moderator
Posts: 14969
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by doublemax » Fri May 08, 2020 5:38 pm

Among other issues, using SetProcessDPIAware() has the disadvantage that you can't set the "dpiAware" mode to "Per Monitor DPI".

Use the manifest and re-test your application from there. You will also need the very latest version of wxWidgets (from GIT) to support per-monitor DPI. Then you will also receive the wxDPIChangedEvent when a window is moved to a display with different DPI. https://docs.wxwidgets.org/trunk/classw ... event.html
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4240
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by ONEEYEMAN » Fri May 08, 2020 5:47 pm

Hi,
art-ganseforth wrote:
Fri May 08, 2020 5:28 pm
wx 3.1.2 - sorry, i should have mentioned that..

Git master???

What is it?
I'm talking about very latest code from the repository.

Thank you.

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by art-ganseforth » Fri May 08, 2020 6:38 pm

... Then you will also receive the wxDPIChangedEvent when a window is moved to a display with different DPI.
I think this is not really the problem because, all of this would be okay if the position of 'main-window' would have influence on the scaling of the others. But unfortunately it's the other way around: if the main wxFrame and one of the wxFrames with the wxGLCanvases are placed on different displays (independend of which wxFrame is positioned on which display), its always my main-window that is distorted, like this:
All wxFrames on diplay 1: All okay
Moving OpenGL-frame to display 2: Main-window-scaling distorts, moved frame not
Moving main-window to display 2: Main-window-scaling distorts, the others don't
Beginnig this with all wxFrames on display 2, it's the same.

Concerning the wxDPIChangedEvent this means, that it will be recived by wrong wxFrame if i move one of the wxFrames containing wxGLCanvas-controls. So, if one wxFrame recieves this event, there seem to be no 'logic' how to find out, if the frame itself or the others have to be rescaled, and also which of the others.
What i mean is, that i can add a fourth OpenGL-Frame when i use two displays. In this case its like this: If i move one of them (no matter which) to display 2, the remainig main-window and the file-editor are rescaled, but not the remaining OpenGL-Frame.


Best,
Frank



EDIT: Also the different behaviour at maximized wxFrames especially concerning tooltips are a hint, that wxDPIChangedEvent will not rellay help.

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by art-ganseforth » Fri May 08, 2020 7:02 pm

ONEEYEMAN wrote:
Fri May 08, 2020 5:47 pm
Hi,
art-ganseforth wrote:
Fri May 08, 2020 5:28 pm
wx 3.1.2 - sorry, i should have mentioned that..

Git master???

What is it?
I'm talking about very latest code from the repository.

Thank you.
I think this wiedely besides my skills. For me as a non-professional, it's always a "fight", just to implement an additional library. I just upgraded to c++11, which needed several days until it compiled my application. Concerning wxWidgets, i always used precompiled (not sure if this is the correct word here) versions for windows and i'm far away of making own builds.

Thank you anyway...
Frank

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4240
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by ONEEYEMAN » Fri May 08, 2020 7:25 pm

Hi,
Below is very straightforward instructions on how to get the wxWidgets bleeding edge sources.

1. Install the GitHub client
1a. Go to https://desktop.github.com/ and click on the link "Download for Windows".
1b. Install te binaries.
2. Open the GitHub Terminal.
3. Issue the following command:
git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git <wxWidgets-master>
The sources will be retrieved in the wxWidgets-master directory. Adjust folder name as appropriate/to your liking
4. Start MSVC
5 Open the file wxWidgets-master\buuld\msw\wx_vc15.sln
6. Select "Build->Batch Build..."
7. Click Build All.
8. Go drink some coffee. ;-)
9. Open the file wxWidgets-master\samples\minimal\minimal_vc15.sln
10 Build the sample
11. Run the sample.

If you have any questions/problems at any of this steps - let us know and we will be able to help.

And I hope those instructions are good to get your started with the latest and greatest sources.

Thank you.

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by art-ganseforth » Fri May 08, 2020 8:36 pm

ONEEYEMAN wrote:
Fri May 08, 2020 7:25 pm
Hi,
Below is very straightforward instructions on how to get the wxWidgets bleeding edge sources.
[...]
Thank you!

thats a nice introduction. I'll try it these days.

Currently i'm working on the UI-layout and on parallelisation. Concerning the last point i also have a question, but step by step....


Best,
Frank

User avatar
doublemax
Moderator
Moderator
Posts: 14969
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by doublemax » Fri May 08, 2020 10:48 pm

Slightly off-topic:
7. Click Build All.
I think you should only build the two configurations you want/need.
8. Go drink some coffee.
Thos times are over. If you have a somewhat current machine, there is no time to make coffee ;) With an i7 and on an SSD, building one configuration takes about 60 seconds with VS. This is not MinGW.
Use the source, Luke!

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Windows 10 / wxFrame-scaling on multipe Displays

Post by art-ganseforth » Thu May 14, 2020 2:01 am

Addendum:

I found out that my problem seems not a wxWidgets-probelm at all. I found i.e. simelar distortions even in the windows-fileexplorer in some subwindows, like i.e. the file-search-field.

Anyway i would be interested in retrieving more information concerning the current exact screen-coordinates of a wxWindow. If i query the position and size of wxFrames on the main-display while i move one of the output-wxFrames from one display to the other, the returned position and size don't change, while the windows obviously change position and size.

Best and sorry for the late reply,
Frank

Post Reply