bpo-37039: Make IDLE's Zoom Height adjust to users' screens#13678
Conversation
|
On my computer (Windows 10, resolution: 3000 x 2000, scaling of UI elements set to 200%), clicking on Zoom Height makes Idle go full screen. Clicking on the same menu (now called Restore Height) does absolutely nothing: Idle stays in full screen mode. If I run the program on a secondary monitor (4k), the height only changes, but nowhere enough to be equal to the height of the screen. |
Sorry, something went wrong.
|
On Windows 10, I'm seeing the same thing as @aroberge, but there's some more. I'll enumerate the steps.
Another path:
This seems like a different bug/enhancement (to not allow zooming when the window is maximized), but I wanted to mention it since I was checking the behavior. Thanks! |
Sorry, something went wrong.
1. Tk's wm_geometry() doesn't report the actual position for maximized windows, but thankfully does report their actual dimensions. 2. The title bar height is different for normal vs. maximized windows.
Also clean up code and add comments where needed.
|
It works correctly on my system. It is a bit surprising to see the window taking the full screen for a second and then having its width reduced again, but it only does that when changing the zoom status for the first time. Moving the window to a second monitor with a different resolution after having clicked on zoom height at least once results in the zoom height feature not working properly as it remembers the settings from the first window. However, if one first moves the window to a second monitor and then clicks on the button, it works. |
Sorry, something went wrong.
This is true and very unfortunate. Many people use multiple monitors with different resolutions these days, so this should be considered a common scenario. To avoid this, we could check the screen dimensions and only cache values for screens with identical dimensions. We'll also need to properly handle screens with identical resolutions but different scaling settings. |
Sorry, something went wrong.
|
The test failures were all for test_enum. False positives with respect to this patch. Since test_idle passed on my machine, no need to retest with close/open -- wait until another commit. |
Sorry, something went wrong.
|
Testing and commenting without looking at the code yet. There seem to be three issues, starting with what I think is the highest priority.
After this, Zoom and Restore work as they should. Thanks Tal. I think reducing the flash annoyance would be enough to merge.
|
Sorry, something went wrong.
|
The newest change calculates and caches the needed info once per screen resolution. This will still misbehave slightly in truly rare edge-cases, such as changing the size or position of the taskbar/dock. |
Sorry, something went wrong.
IMO the number of users who actually use "zoom height" is small, so I don't think this justifies annoying 100% of the users with a maximized (i.e. almost full-screen) splash screen. I've been working around and through the limitations of Tk as far as possible, and have reached the limit of what is possible, to the best of my understanding and research. To do better would require using OS APIs directly, e.g. as done by the screeninfo library, but IMO this is not warranted in this case.
I've currently made "zoom height" be a no-op when the window isn't in the "normal" state, e.g. when it is maximized. I can handle the case where the screen is already maximized if you find the current "do nothing" behavior surprising. Or I can just add a
These days, with widespread use of laptops, it is very common: People connect and disconnect to/from external screens, using them instead of/in addition to the laptop screen. Also, multi-monitor desktop setups are increasingly common for developers, and often they do not have the same resolution, e.g. having one monitor situated in a "portrait" orientation.
The latest commit in the PR handles this properly. (Note that as far as Tk is concerned, scaling simply means a different resolution.) |
Sorry, something went wrong.
terryjreedy
left a comment
There was a problem hiding this comment.
I addressed my points 1 and 2 in the comments. Without a multiscreen setup, I cannot comment much on 3. I am willing to have zoomheight be imperfect if someone changes their taskbar or screen settings. I will add this also to the doc, something like "After the first zoom on a screen, zoomheight assumes that taskbar and screen settings remain the same."
I have not yet looked at the rest of the code of zoom_height and that of get_max..., but I expect this should get into 3.7.4b1 on 6/17.
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be poked with soft cushions! |
Sorry, something went wrong.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
|
@terryjreedy, indeed this appears ready to merge IMO, apart for my comment regarding the NEWS entry. |
Sorry, something went wrong.
|
Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
|
Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, something went wrong.
|
Sorry @taleinat and @terryjreedy, I had trouble checking out the |
Sorry, something went wrong.
|
Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
…-13678) Measure required height by quickly maximizing once per screen. A search for a better method failed.
…-13678) Measure required height by quickly maximizing once per screen. A search for a better method failed.
When "zoom height" is first activated, this implementation measures the window manager's size for maximized windows by maximizing IDLE, and from that point uses that size. Subsequent activations will use the cached value for the dimensions of maximized windows.
This avoids hard-coded values which aren't always correct, e.g. because docks/taskbars can be resized, moved or hidden and window-manager themes can be customized.
This does cause a one-time visual artifact on macOS, where on the first activation, the window is maximized, un-maximized, and then set to the maximum height. Subsequent activation uses cached information, so this doesn't happen again.
https://bugs.python.org/issue37039