-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8254841: [macos] Enter and Exit events shouldn't be sent whilst resizing #5497
Conversation
Reviewed-by: alichung
👋 Welcome back alisenchung! A progress list of the required criteria for merging this PR into |
@alisenchung The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
test/jdk/java/awt/event/MouseEvent/SpuriousExitEnter/ResizeMouseExitEnterMisfire.java
Outdated
Show resolved
Hide resolved
dd8d591
to
e299142
Compare
test/jdk/java/awt/event/MouseEvent/SpuriousExitEnter/ResizeMouseExitEnterMisfire.java
Outdated
Show resolved
Hide resolved
I have some suggestion for test
|
…ava from ProblemList
Webrevs
|
Absent a compelling reason, please do not force push to a branch once you have create a PR from that branch. |
src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java
Outdated
Show resolved
Hide resolved
I have a general question about this bug, initially the test was added for https://bugs.openjdk.java.net/browse/JDK-6479820 and that bug was fixed because of this:
And in the current bug description:
So situation is different, if the mouse is moved faster than window is moving, then I do not see why we should not post an events. Especially if the native system did that. But the question is it really a problem of slow window, or may be we have some bug in the nativeSynthesizeMouseEnteredExitedEvents where we synthesize such events when we should not. |
test/jdk/java/awt/event/MouseEvent/ResizeMouseExitEnterMisfire/ResizeMouseExitEnterMisfire.java
Outdated
Show resolved
Hide resolved
test/jdk/java/awt/event/MouseEvent/ResizeMouseExitEnterMisfire/ResizeMouseExitEnterMisfire.java
Show resolved
Hide resolved
I think we don't synthesize these events, they come from native. |
In the original bug report, I believe the root cause of the bug is the same based on the comment in JBS: And I tried to keep the same idea for the fix in windows: So I guess my question is whether or not we should be posting these events in the first place during resizing? I still see the original bug fix in the windows files so I believe there currently is a mismatch in behavior across platforms. |
If the idea just align behavior to the Windows then you can just update the AWTWindow.m#_deliverMoveResizeEvent, same as on windows set your flag to true when the [self.nsWindow inLiveResize] is true, and then at the end of the method _deliverMoveResizeEvent sets the flag to false. Or just check that [self.nsWindow inLiveResize] flag before sending the mouse event. But note that [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows] is called in the _deliverMoveResizeEvent, so it is quite possible that these "additional" events are posted by our code and not by the macos. |
test/jdk/java/awt/event/MouseEvent/ResizeMouseExitEnterMisfire/ResizeMouseExitEnterMisfire.java
Outdated
Show resolved
Hide resolved
…eEvent in AWTWindow.m, updated test
Oh you're right, removing the line also removes the extra mouseEntered and mouseExit events. I thought it wasn't being called because a print statement I put in that function never showed up, but I must've messed something up. Was there a reason for the synthesizeMouseEnteredExitedEventsForAllWindows call? |
That was done as a fix for JDK-8028485. We have to generate the mouse enter/exit events if the window was moved/resized under the mouse(while the mouse pointer was not moved) |
Does it mean that after the fix we will post a few enter events w/o exit events? Then it is worse than posting enter/exit events that are paired, even if we will post many such pairs.
Just for the record did you check what is the inLiveResize value when the user maximizes the window, or moves it to the full screen/tile the window to the left/right? |
It always posts a single enter event without an exit event.
I checked for when the user maximizes the window and tiles to the left or right of the screen and both seem to work. I just ran all the tests and my test fails on both windows and linux platforms so I think this bug isn't platform specific. |
But what is the flag value? Is it true or false? If it's true and everything works maybe we do not need this line at all? |
Oh the flag is always true. And removing the line completely fixes the bug and doesn't have any problems with fullscreen or tiling. |
Surely that was there for a reason ? Looks like it might be important for the synthesized full screen mode ? Does the test from there still pass ? Any others fail ? |
Sergey did mention it was added as a fix for JDK-8028485 earlier too. Reverting the changes made by JDK-8028485 doesn't seem to reintroduce the fullscreen not firing mouseEntered bug, so I'm not exactly sure how that fix worked. Behavior seems to be the same regardless of the position of the [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows] line.
All manual and automatic tests are passing on macOS. |
OK. Unless someone else can point out what we are missing it seems like it should resolve this issue. |
I guess the only test which makes sense here is the test for JDK-8013468 and it is "problem listed" due to a reflection issue. I suggest checking how it works. |
This test fails both before and after the change. However, before the change if I'm constantly moving the mouse the test will pass whereas after the change it won't pass even if I'm moving my mouse. I re-added the synthesizeMouseEnteredExitedEventsForAllWindows with a check for in fullscreen mode which should only be true if its in true fullscreen mode (without title bar). This keeps the behavior from before the change, but the test won't pass if the mouse isn't moving during the fullscreen. |
It sound strange, isn't the "_deliverMoveResizeEvent" should be called on the resize only, why it affect the mouse move events which posted later? the new flag NSWindowStyleMaskFullScreen will work when the window was moved to the full screen, what about the case when the window will moved from the full screen -> the mouse will appier outside of the window? BTW we also have a call to synthesizeMouseEnteredExitedEventsForAllWindows in the windowDidEnterFullScreen which should do what you tried to achieve in the latest patch, why it does not work? |
It looks like the line was added for the previous bug only for when fullscreen mode is turned off and the mouse is outside the window. Entering fullscreen already posts a mouseEntered event.
I'm don't see windowDidEnterFullScreen calls when the window is being fullscreened. |
As far as I understand the windowDidEnterFullScreen should be called when the window moved to the fullscreen mode There are two fullscreen modes on macOS, one of them can be set via GraphicsDevice.setFullScreenWindow() and another one can be set by pressing the maximized button(https://support.apple.com/guide/mac-help/use-apps-in-full-screen-mchl9c21d2be/mac), which one did you test? |
I tested both. The maximized button works properly, but fullscreen mode set by GraphicsDevice.setFullScreenWindow() isn't working properly. |
And the windowDidEnterFullScreen is not called? Or the fullscreen mode work because this method is called? |
windowDIdEnterFullScreen isn't being called but entering fullscreen mode still posts a mouseEntered event. |
I think synthesizeMouseEnteredExitedEventsForAllWindows shouldn't be in deliverMoveResizeEvent since there shouldn't be any mouseEnter/Exit events during a resize or move and I can submit another bug for didWindowEnterFullscreen and didWindowExitFullscreen not being called/not posting mouseEvents that I can work on separately.. |
I have added a trace to the window WillEnterFullScreen and window DIdEnterFull Screen and see that both are called when the window is moved to the full screen mode via green button. |
Why do you think that if the window is moved/resized and/or appeared under the mouse then the mouse event should not be posted? I do not think so. We can try to minimize the number of events when the user drags/resizes the window, but we should not change the number of events if the macos/app moved/resized the window.
It should be called, I have checked that on macOS 11.5, but I do not think it depends on the version. |
I added a keyListener to SpuriousExitEnter test to enter and exit fullscreen with GraphicsDevice on a specific keypress and I wasn't able to get NSLog to show up in AWTWindow. What test were you able to see the trace and did it also post a mouseEntered/mouseExit event properly? |
I just added the fprintf(stderr, "windowDidEnterExitFullScreen\n"); |
I think mouseEvents are already posted by macos when the mouse enters the window thru fullscreen-resizing (green button) or tiling, so I think we don't need to synthesize additional events. I suggest we remove the line because it introduces another bug where dragging to move the window will post a mouseEntered event without the mouse ever entering the actual window. It also introduces the bug from the original bug report. |
If we do not need to synthesize additional events then why do you see a difference in behavior before/after the fix here:
But we should not introduce the new one. |
The case I tested is supposed to be covered by windowDidEnterFullscreen. Also it passed when I tested it manually, but only the automatic test has different behavior..
I meant that by removing the line 2 different bugs are fixed |
The windowDidEnterFullscreen is called before and after the fix, so If automatic test has a different behaviour means that the current change affects it in some unclear way, right? |
@alisenchung This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@alisenchung This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Added a resizing flag when the window is currently being resized to block mouseEntered and mouseExited events from being posted to that window.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5497/head:pull/5497
$ git checkout pull/5497
Update a local copy of the PR:
$ git checkout pull/5497
$ git pull https://git.openjdk.java.net/jdk pull/5497/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5497
View PR using the GUI difftool:
$ git pr show -t 5497
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5497.diff