kmpoppe / noteSolver

JOSM Plugin: Automatically resolve notes after uploading a changeset.
https://wiki.openstreetmap.org/wiki/User:Kmpoppe/Plugins#noteSolver
GNU General Public License v3.0
12 stars 3 forks source link

Popup appears in other monitor when using multiples in MacOS #20

Closed angoca closed 1 year ago

angoca commented 2 years ago

I am using MacOS Catalina, with an external monitor (+ laptop monitor). When I click on a note, the popup appears in the laptop screen, even if JOSM is on the external monitor.

kmpoppe commented 2 years ago

Hi angoca,

what version of the plugin are you using?

angoca commented 1 year ago

notesolver (0.4.2)

angoca commented 1 year ago

I created a Trac issue to provide all the details: https://josm.openstreetmap.de/ticket/22371#ticket

kmpoppe commented 1 year ago

With https://josm.openstreetmap.de/ticket/22307, a new popup for the "notes" window was added. The team will look into adding methods for adding entries into that menu.

Could you tell me whether the popup window always opens in the wrong place, no matter if you click the note on the map or in the "notes" window?

angoca commented 1 year ago

I attached 2 images. One when rich clicking on the note and the meny appears on the other screen. The second, when right clicking on the view, which appears in the same screen.

Screen Shot 2022-09-15 at 12 08 30 AM Screen Shot 2022-09-15 at 12 08 46 AM

natrius commented 1 year ago

Same on WIndows. Laptop left, 2 screens right from it, JOSM on the most right screen. Clicking on the note - pupup appears on the most left screen - but in the right position :D If i move the map around and the note is on the bottom right, the popup apperars on the most left screen (laptop) on the bottom right. If i move the note somewhere else, the popup-position will change as well :D

But. the most left (Laptop) is marked as "Main" in Windows Settings.

ygra commented 1 year ago

It doesn't even need two screens. If you don't have JOSM maximized on the primary monitor the popup will appear out of place (presumably in desktop coordinates, not relative to the JOSM window). I'll look into it later and see whether I can fix it.

ygra commented 1 year ago

We're getting mouse coordinates relative to a component, but a context menu is shown in screen coordinates, at least when using setLocation. So we have to convert the desired point to screen coordinates first. I can't test right now, but the following patch might solve it:

diff --git a/notesolver/src/main/java/org/openstreetmap/josm/plugins/notesolver/NoteSolverPlugin.java b/notesolver/src/main/java/org/openstreetmap/josm/plugins/notesolver/NoteSolverPlugin.java
index 6fda01d..ec654fa 100644
--- a/notesolver/src/main/java/org/openstreetmap/josm/plugins/notesolver/NoteSolverPlugin.java
+++ b/notesolver/src/main/java/org/openstreetmap/josm/plugins/notesolver/NoteSolverPlugin.java
@@ -159,8 +159,10 @@ public class NoteSolverPlugin extends Plugin {
                JPopupMenu contextMenu = new JPopupMenu();
                for (JMenuItem menuItem : mainMenuEntries(menuTypes.MAIN)) 
                    contextMenu.add(menuItem);
-               Point p = MainApplication.getMainFrame().getMousePosition();
+               MainFrame frame = MainApplication.getMainFrame();
+               Point p = frame.getMousePosition();
                if (p != null) {
+                   SwingUtilities.convertPointToScreen(p, frame);
                    Component c = MainApplication.getMainFrame().getComponentAt(p);
                    JComponent jc = (JComponent)c;
                    if (c != null) {
kmpoppe commented 1 year ago

This is now in the released state, the plugin should automagically update within JOSM.