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
wxGrid resize issue when using DPI aware manifest #24445
Comments
Just in case it was lost here as it was in the penultimate comment in #23091. The For example, my display setup is When I run this code #include <wx/wx.h>
#include <wx/grid.h>
class MyApp : public wxApp
{
bool OnInit() override
{
wxFrame* frame = new wxFrame(nullptr, wxID_ANY, "Test");
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
wxGrid* grid = new wxGrid(frame, wxID_ANY);
grid->CreateGrid(100, 100);
sizer->Add(grid, wxSizerFlags(1).Expand());
frame->SetSizer(sizer);
frame->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp); after launching it on my primary (HiDPI) monitor, the frame display coordinates are |
Yes, that is basically what I see as well. I intentionally made my sample a small grid (1x4) so that the resize can be seen as in this case it does not cause the window to become too large to fit in the screen. However, as you describe, for large grids the window often disappears from view due to being so large. This issue is a show stopper if you want to save the window position and size on exit which is what I wanted to do. But I think I'll have to leave this for now. |
In my case, it always disappears since it gets moved way outside the visible display area.
It is not just about saving the window position: It actually leaves the user baffled and helpless when their window disappears forever after they tried to move it to another screen. I do understand that this issue may not be easy to fix but still... |
It would leave the user confused. There is no doubt of that. But in that scenario, it's possible a restart would bring the application back to a normal state. In the scenario I mentioned, this would not be the case. The application would remain unusable even after a restart. But to be honest, I think we are seeing the same thing and probably describing it slightly differently. Not sure if this helps move the issue forward. There is a minimal sample to illustrate the issue, so that's a start at least. |
I have had a quick look into this issue and it looks like this is the method causing the issue:
The problem appears to occur when I'm not entirely sure what that section of code is trying to do. Is it trying to change the size of the window to fit everything it contains within it? If so, I'm not sure I would expect that. As a user, if the window size could not fit everything on after a change in DPI, I would not be surprised to have to resize it manually. Does anyone have any further information on this? |
It also appears that there is a bug in that section of code as well. The line However, I'm still leaning towards the size being set to I'd be very interested if anybody has a small sample application that puts this section of code to use in another way and demonstrates its purpose. |
The commit history of |
Having a quick look through I can see 4 issues raised that have minimal test examples including this one (feel free to let me know if I missed any). When #18649 = OK That's what testing on my system shows. Happy to try any others I have missed. |
#18649 is not OK with |
But maybe that behaviour is less problematic than the infinite grow of text/list/grid controls. |
It works fine both ways on mine. Are you just changing the |
Yes. And the app has to start on the 100% monitor. |
Ok. I can make it do that by adjusting the 4K monitor from 100% to 150%. But no switching of one monitor to the other is necessary. But this is not something I was checking. I don't remember seeing that in #18649. The original text was talking about changing from one DPI to the other. |
Well, for me it does happen when starting on a 100% (secondary) monitor and moving to the (main, system DPI) 150% monitor. |
I don't see it across monitors so I guess there may be a slight difference between different graphics cards, monitors etc. I agree this is a lot less problematic than what we are seeing with the text/list/grid controls. Assuming that the window can be resized, this would involve the user performing a slight drag to increase the size. With the text/list/grid controls the application becomes unusable. |
One thing I notice from this is a difference between the dpi change from moving across monitors and the dpi change on a single monitor changing from 100% to 150%. On my system:
So exactly the same in each scenario. However, for these scenarios newRect differs as follows:
It seems odd to me that the 2nd scenario has a slightly lower value for the height (which is the issue in this example). It is also odd that this is the figure the current solution calculates. Any idea why the width on these would be near identical and the height be different? |
I think I have found out why but not sure why it is happening. Perhaps you will have a better idea? It appears that when when my 4k monitor is set to 150% and the application is started to appear on the 1080p screen it causes the DPI changed event (144dpi to 96dpi) to occur so the size of the window is immediately changed as it starts. However, if the 4k monitor is set to 100% this does not happen. This event is false as the window has not transitioned from 144dpi to 96dpi. This does not happen when it starts on the 4k monitor whatever scale it is set to. I think this event might be clouding the potential answer to this issue. I'm signing off for now as I've spent far too long on this already! Will try to investigate further over the next few days. |
I've looked into this issue a bit further. It appears there are already a couple of hacks related to the size of However, the issue being seen with So the only possible solution I can think of is to change the size used for DPI changes for Currently, the Would it be possible for there to be new methods that return the same as the current method by default, but for problematic classes like wxGrid, it can return the current size? This would mean these problematic items are simply resized according to their current size which appears to work very well. Anybody have any thoughts on this? Or ideas for other possible solutions? |
Description
This issue relates to a wxGrid used on a dual monitor setup. One monitor is 4K and the other is 1080p.
I am unable to confirm if this issue affects a setup where the monitors are of the same type (i.e. both 4K or both 1080p). Perhaps someone with a suitable setup could confirm this?
The issue occurs when the application window is dragged from one monitor to the other. The direction is not important as it occurs in both directions.
Bug Description
When the application is run using the setup described above, the window resizes when it is transferred from one monitor to the other in the event the wxGrid requires a scrollbar. For large grids, this results in the window being resized to a size larger than the monitor and disappears from view completely. It appears the resize attempts to resize the window to fit the entire grid.
There is a simple sample attached to demonstrate the issue. The sample consists of a simple wxGrid. There is also a resource file that declares a DPI aware level 2.
If the sample is run and the steps to reproduce the behaviour are followed the issue will be observed. If the DPI aware declaration within the resource file is commented out, the sample is run and the steps to reproduce the behaviour are followed the issue will not be observed.
To Reproduce
Expected vs Observed Behaviour
It is expected that the window would not resize during the drag operation from one monitor to the other and this is the observed behaviour when not using a DPI aware manifest.
Attachment
sample.zip
Platform and Version Information
The text was updated successfully, but these errors were encountered: