-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use standard subplot window in macosx backend #21663
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
Conversation
Works for me (on a retina screen), but looks like some tests are failing on CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some weird interaction going on with dual monitors here, as if the window stays a part of the parent window and can't span both.
- When I move the subplots window to my other display it immediately hides itself from view. When I go back and click on the original figure window, the subplots window reappears at half transparency when I drag it around.
- When I close the main figure window, the subplot window stays around and keeps the process alive.
I will try and look into this a little more in the next day or two, but writing this down in case anyone else has a look before that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently opens a new window every time I click the subplots_param button. On qt5agg
clicking the button closes the old window and brings up a new one for me. So, it might be nice to try and add that in here as well if possible.
Of course, I'm only finding other bugs in the review here ;) this does indeed solve the HiDPI scaling issue.
src/_macosx.m
Outdated
PyGILState_Release(gstate); | ||
NSWindow* parent = [((FigureCanvas*)canvas)->view window]; | ||
NSWindow* child = [((FigureCanvas*)subplot_canvas)->view window]; | ||
[parent addChildWindow: child ordered: NSWindowAbove]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the addChildWindow
here. When it is attached to the parent the window will move around relative to it when dragged. This causes issues on dual monitors, where it is hidden from view when I drag the subplots window onto a new monitor. Removing this makes it behave as expected still I think, so I'm not sure there is a real benefit to attaching them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But does it close when you close the figure window? Even with multiple figures open?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see Qt doesn't handle that properly either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is a tricky one. I suggested the easy way out here ;) I think you could go down a rabbit hole that probably isn't super critical.
As it currently is, closing the figure window does close the subplot window as well, but the event-loop keeps running for some reason, so my Python process doesn't end.
Then I go and click on the still-running Python process to bring it back up and all of a sudden two windows appear again, with a phantom figure window that I can't do anything with and the subplots window that does work. I can then close the subplots window and it closes the entire session then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I changed it to only set a utility window style, though I'm not sure it really had much effect.
I'll open a separate PR for the subplot window lifetime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you even need that?
I get some logs output saying it isn't supported. (It didn't fail, just logged)
python[68679:18018136] NSWindow does not support utility styleMask 0x10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're right; I missed that when testing. The docs don't seem to say that's a requirement, but okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now. I'll open some new issues with the other things we found here.
Dismissing based on this PR actually solving the HiDPI issue.
4896d83
to
d1017e0
Compare
You can also deprecate prepare_configure_subplots on the Python side. |
src/_macosx.m
Outdated
NSRect rect; | ||
int width, height; | ||
{ | ||
PyObject *mod = NULL, *base_class = NULL, *ret = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the way-too-complicated original patch; actually, because the method has not been overridden on Python's side, you can even directly call it, I think:
{ PyObject* result;
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
result = PyObject_CallMethod(toolbar, "configure_subplots", "");
if(result)
Py_DECREF(result);
else
PyErr_Print();
PyGILState_Release(gstate);
}
i.e. the same implementation as home, back, etc. (I plan to merge all of these together in a single helper, in a later PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you're right; it seems to work on the test Mac anyway.
Yes perhaps, but not for 3.5.1 |
d1017e0
to
b4392d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving on general grounds, but it would be good if a mac user checked (even if it's @greglucas again).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that it works as expected for me still with multi-dpi monitors.
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
Backport PR #21663 on branch v3.5.x (Use standard subplot window in macosx backend)
PR Summary
This seems to compile and work, but the test mac is kind of slow, so not sure if it'll break anything. It also doesn't have a retina display, so I can't actually confirm that the content is not quarter sized.
Fixes #21648
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).