There's an open PR, Check for EnvVar/SysProp for preferred screen https://github.com/apache/netbeans/pull/4714, which references this thread.

In particular, I've identified two types of "dialog goes to wrong screen",

1. Random, don't know how to reproduce
2. Consistent, due to not specifying parent when dialog is opened

If any one knows how to reproduce 1. with higher probability, I hope you'll share...

-ernie


On 4/22/22 8:36 AM, Patrik Karlström wrote:
Thanks Neil,
inspired by that I created a small example and stepped it back all the way to RELEASE90. My problem occured all the way, so no recent regression involved in my issue.

Digging a bit further though I realised my problem stemmed from lack of window focus (and maybe some other yet to be confirmed situations) when displaying dialogs.
In combination with DropTargetDropEvent that is.

So, a multi monitor setup is not the cause of the problem.

Depending on how a file is dragged and dropped from other applications, this problem occurs, or not. On Windows it's possible to drag a file from Explorer without Explorer gaining focus, getting activated.
Knowing that, I solved it with the following code in my Drop listener:
SwingUtilities.invokeLater(() -> {
SwingUtilities.getWindowAncestor(MapTopComponent.this).requestFocus();
    SwingUtilities.invokeLater(() -> {
        //Display the dialog
    });
});

But, back on linux, the problem was still there.
It was because of the focus stealing prevention setting of KDE Plasma's kwin.
For good or bad, I resorted to the sledge hammer awt.Robot and created
public static void requestWindowFocusAndRun(Component c, Runnable r)

https://github.com/trixon/almond/blob/7c22ec5888557ff1afc991e701c84a8f212fe526/util/src/main/java/se/trixon/almond/util/swing/SwingHelper.java#L248


Unless it's possible to add a notify(descriptor, parent) to DialogDisplayer I don't think of this as a NetBeans problem but perhaps NB can provide a good solution, or better yet, it might be solved in swing/awt.

/Patrik


Den ons 20 apr. 2022 kl 10:43 skrev Neil C Smith <neilcsm...@apache.org>:

    On Tue, 19 Apr 2022 at 08:04, Patrik Karlström <pat...@trixon.se>
    wrote:
    >
    > I'm trying to find a way to improve my platform applications'
    handling of dialogs.
    > Developed on a laptop, I was not aware that dialogs did not
    follow the main window, instead they are displayed on the main screen.
    >
    > I use descriptors and display them with
    > DialogDisplayer.getDefault().notify(d)
    >
    > And I can't find a way to specify the dialog parent with that
    approach.
    > I did find createDialog(DialogDescriptor descriptor, Frame
    parent) but I'm not really sure what I should do with the returned
    dialog since I want an easy way to get the clicked button, if any.
    >
    > What is the best way to create and manage dialog wrt parents in
    a platform app?

    IIRC the default implementation is in core.windows. I'd step through
    in the debugger and see what it's doing, because I don't think that's
    the expected behaviour.  Vague recollection of this being mentioned
    with regards to the IDE too fairly recently.

    
https://github.com/apache/netbeans/blob/master/platform/core.windows/src/org/netbeans/core/windows/services/DialogDisplayerImpl.java

    Best wishes,

    Neil

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
    For additional commands, e-mail: users-h...@netbeans.apache.org

    For further information about the NetBeans mailing lists, visit:
    https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to