-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Disable hiding window while in MINIMIZED
, FULLSCREEN
or PRESENTATION
state and ignore no-op visibility requests
#3109
Disable hiding window while in MINIMIZED
, FULLSCREEN
or PRESENTATION
state and ignore no-op visibility requests
#3109
Conversation
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 addresses hide()
, but doesn't do anything for show()
- which is the actual use case that was a problem in #2096.
changes/3109.removal.rst
Outdated
@@ -0,0 +1 @@ | |||
Hiding of a window while in `MINIMIZED`, `FULLSCREEN` or `PRESENTATION` state is now disabled, in order to keep the API behavior consistent on all platforms. |
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.
Hiding of a window while in `MINIMIZED`, `FULLSCREEN` or `PRESENTATION` state is now disabled, in order to keep the API behavior consistent on all platforms. | |
The `show()` and `hide()` APIs can no longer be used on a window while it is in a `MINIMIZED`, `FULLSCREEN` or `PRESENTATION` state. |
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 think we do not need to mention show()
here, since calling window.show()
while in MINIMIZED
, FULLSCREEN
or PRESENTATION
state, will be a no-op(as window.visible
would be true in these cases), and window.show()
isn't specifically disabled for MINIMIZED
, FULLSCREEN
or PRESENTATION
cases.
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 agree it would be exceptionally difficult to get into this state, but it is possible if you invoke system native APIs.
At the very least, it's useful for completeness/symmetry in the docs.
Yes, I hadn't changed |
Co-authored-by: Russell Keith-Magee <[email protected]>
Co-authored-by: Russell Keith-Magee <[email protected]>
core/tests/window/test_window.py
Outdated
@@ -264,6 +264,7 @@ def test_show_hide(window, app): | |||
|
|||
def test_hide_show(window, app): | |||
"""The window can be hidden then shown.""" | |||
window.show() |
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.
The previously form of this test was:
toga/core/tests/window/test_window.py
Lines 265 to 274 in fbedd3f
def test_hide_show(window, app): | |
"""The window can be hidden then shown.""" | |
assert window.app == app | |
window.hide() | |
# The window has been assigned to the app, and is not visible | |
assert window.app == app | |
assert window in app.windows | |
assert_action_performed(window, "hide") | |
assert not window.visible |
Since windows are not visible at the start(since
window.show()
hadn't been called). Therefore assert_action_performed(window, "hide")
on line 273 would not be performed, as the call to window.hide()
will be a no-op(since window was already in hidden state.).
Hence, I have added the window.show()
call at the start.
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.
The fact that windows wasn't visible at the start of the test was literally this point of this test - to confirm that invoking hide() before show() didn't do anything internally stateful.
That's no longer possible/applicable because invoking hide() on a non-visible window now has different (state-specific) behavior.
So - test_hide_show
is no longer required. But the test you've added as "test_visilibity_noop" isn't testing the visibility property - it's checking the stateful behavior of show()
and hide()
.
These three tests (test_show_hide, test_hide_show, and test_visibility_noop) should be merged, testing the "show, show (no-op), hide, hide (no-op), show" sequence. The visibility
test then only needs to verify that assigning visibile = True
is an analog of show(), and visible = False
is an analog of hide().
Apologies for requesting a review, but it seems that I need to do more tests on iOS. |
Turns out the problem was that on iOS Requesting the same visibility as the current visibility state is a no-op and is ignored at the core level. But, the no-op checking at the core uses I have fixed the issue by actually checking if the window is hidden or not with |
MINIMIZED
, FULLSCREEN
or PRESENTATION
stateMINIMIZED
, FULLSCREEN
or PRESENTATION
state and ignore no-op visibility requests
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.
Yes, I hadn't changed show(), because I had thought calling show() on an already visible window would be no-op, but on macOS, the show() call was still calling makeKeyAndOrderFront_ even when called on a already shown window. So, I have blocked calls to the _impl show()/hide() methods when the window is already in the requested visibility state.
Yes... and that's a change in behavior that has been the direct cause of a known bug/design inconsistency. This is literally why we write regression tests.
Yes, the test that calling show() on a visible window exists in this PR, with 100% coverage of the code base. What we're trying to validate is that no matter what happens to the implementation, the same behavior is preserved. The interaction of window state is a key part of the bug as observed in the wild, Adding a test to make sure that when those same conditions exist the problem no longer occurs will not increase coverage - but it does validate that a specific problem that has been observed in the wild won't re-occur.
core/tests/window/test_window.py
Outdated
@@ -264,6 +264,7 @@ def test_show_hide(window, app): | |||
|
|||
def test_hide_show(window, app): | |||
"""The window can be hidden then shown.""" | |||
window.show() |
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.
The fact that windows wasn't visible at the start of the test was literally this point of this test - to confirm that invoking hide() before show() didn't do anything internally stateful.
That's no longer possible/applicable because invoking hide() on a non-visible window now has different (state-specific) behavior.
So - test_hide_show
is no longer required. But the test you've added as "test_visilibity_noop" isn't testing the visibility property - it's checking the stateful behavior of show()
and hide()
.
These three tests (test_show_hide, test_hide_show, and test_visibility_noop) should be merged, testing the "show, show (no-op), hide, hide (no-op), show" sequence. The visibility
test then only needs to verify that assigning visibile = True
is an analog of show(), and visible = False
is an analog of hide().
changes/3109.removal.rst
Outdated
@@ -0,0 +1 @@ | |||
Hiding of a window while in `MINIMIZED`, `FULLSCREEN` or `PRESENTATION` state is now disabled, in order to keep the API behavior consistent on all platforms. |
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 agree it would be exceptionally difficult to get into this state, but it is possible if you invoke system native APIs.
At the very least, it's useful for completeness/symmetry in the docs.
I have merged the 3 core tests. |
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.
You haven't added validation and tests for the show() case like I asked in my last review; but the tests are easy to add, so I've done it for you rather than go round another iteration of reviews.
Otherwise, this now looks good.
Thanks for adding them. I had thought that you had meant of keeping the symmetry only in the form of documentation, and not actually raise the error on show(). I will be more thorough with the reviews, from next time. |
As identified in #2096, the behavior of hiding a window while in MINIMIZED, FULLSCREEN or PRESENTATION state, is inconsistent on macOS:
window.hide()
window.show()
NORMAL
MINIMIZED
MAXIMIZED
FULLSCREEN
PRESENTATION
NSWindow.isVisible
reportsFalse
NSWindow.isVisible
reportsTrue
This behavior is also inconsistent when compared to other platforms. Therefore, to keep the behavior consistent on all platforms and to be able to implement a stable API on #2096, the hiding of window while in MINIMIZED, FULLSCREEN or PRESENTATION state is disabled.
Context:
on_gain_focus
,on_lose_focus
,on_show
&on_hide
handlers ontoga.Window
#2096 (comment)on_gain_focus
,on_lose_focus
,on_show
&on_hide
handlers ontoga.Window
#2096 (comment)PR Checklist: