JDK-8220272: Found the problem + possible fix
Michael Paus
mp at jugs.org
Mon Apr 15 10:17:08 UTC 2019
If you want to report a bug go here: https://bugreport.java.com/bugreport/
Without the proper permissions you can't create a bug report directly
via the link
you have mentioned. Once submitted it takes about 1-2 days until the bug
gets
entered into the bug database and after that you can search for it via
your link.
Michael
Am 15.04.19 um 11:54 schrieb Jason Shattu:
> Forgive my ignorance, but I can't work out how to submit an OpenJFX
> bug report.
>
> The link you've sent ultimately brings you to this page:
> https://bugs.openjdk.java.net/secure/Dashboard.jspa
>
> but I don't see any thing for JavaFX here.
>
> Thanks,
> Jason
>
> ------ Original Message ------
> From: "Nir Lisker" <nlisker at gmail.com>
> To: "Thiago Milczarek Sayao" <thiago.sayao at clamed.com.br>
> Cc: "openjfx-dev at openjdk.java.net" <openjfx-dev at openjdk.java.net>
> Sent: 15/04/2019 10:45:36
> Subject: Re: JDK-8220272: Found the problem + possible fix
>
>> Hi Thiago,
>>
>> Anyone can create a PR on GitHub, see
>> https://github.com/javafxports/openjdk-jfx/blob/develop/.github/CONTRIBUTING.md
>>
>> .
>>
>> - Nir
>>
>> On Mon, Apr 15, 2019 at 3:47 AM Thiago Milczarek Sayao <
>> thiago.sayao at clamed.com.br> wrote:
>>
>>> * THE PROBLEM *
>>>
>>> In GlassApplication.cpp, the GDK_FOCUS_CHANGE event gets called
>>> from the
>>> last window to the first on my setup (I suspect "out-of-order" on some
>>> setups and even occasionally in the expected order). So the code to
>>> keep
>>> the latest enabled window fails (refering to WindowStage.java
>>> activeWindows) - that's why the "First Window" (on the code to
>>> reproduce
>>> the bug report) shows on top - because openjfx thinks it was the
>>> latest
>>> window. In WindowStage.java:
>>>
>>> final void handleFocusDisabled() {
>>> if (activeWindows.isEmpty()) {
>>> return;
>>> }
>>> WindowStage window = activeWindows.get(activeWindows.size()
>>> - 1);
>>> //<-- HERE!!
>>> window.setIconified(false);
>>> window.requestToFront();
>>> window.requestFocus();
>>> }
>>>
>>> When there is a WINDOW_MODAL this code gets called because the modal
>>> window disable it's parents (so they do not get events - it's
>>> correct). So
>>> openjfx brings up what it thinks it's the latest window - but since
>>> the out
>>> of order GDK_FOCUS_CHANGE - it's the wrong window (activeWindows
>>> list has
>>> not the correct order).
>>>
>>> The Gtk docs states GDK_FOCUS_CHANGE is true "if the window has
>>> gained the
>>> keyboard focus" which may not be directly correlated to openjfx's
>>> WindowEvent.FOCUS_GAINED.
>>>
>>> * THE FIX *
>>>
>>> To fix this, WindowEvent.FOCUS_GAINED must be called in order of which
>>> window is shown (because the window is inserted on activeWindows at
>>> this
>>> event).
>>>
>>> So I have modified glass_window.cpp to immediately call
>>> WindowEvent.FOCUS_GAINED when showing the window:
>>>
>>> void WindowContextBase::set_visible(bool visible) {
>>> if (visible) {
>>> gtk_widget_show_all(gtk_widget);
>>>
>>> //JDK-8220272 - fire event first because GDK_FOCUS_CHANGE
>>> is not
>>> always in order
>>> if(jwindow && isEnabled()) {
>>> mainEnv->CallVoidMethod(jwindow, jWindowNotifyFocus,
>>> com_sun_glass_events_WindowEvent_FOCUS_GAINED);
>>> }
>>> } else {
>>> gtk_widget_hide(gtk_widget);
>>> if (jview && is_mouse_entered) {
>>> is_mouse_entered = false;
>>> mainEnv->CallVoidMethod(jview, jViewNotifyMouse,
>>> com_sun_glass_events_MouseEvent_EXIT,
>>> com_sun_glass_events_MouseEvent_BUTTON_NONE,
>>> 0, 0,
>>> 0, 0,
>>> 0,
>>> JNI_FALSE,
>>> JNI_FALSE);
>>> CHECK_JNI_EXCEPTION(mainEnv)
>>> }
>>> }
>>> }
>>>
>>> Did some tests and it seems to fix the problem.
>>>
>>> I do not have permission to make a PR, so posting the fix here. Will
>>> happily do the PR if required.
>>>
>>> Thanks.
>>>
>>>
More information about the openjfx-dev
mailing list