=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java'
--- old/src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java	2025-01-29 21:25:12 +0000
+++ new/src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java	2025-01-30 14:27:16 +0000
@@ -1742,15 +1742,17 @@
                GraphicsConfiguration config = device.getDefaultConfiguration();
                Rectangle bounds = config.getBounds();
 
-               // TODO: this does not correctly find the intersection because the child window position
-               // is x=0,y=0 which is incorrect.
                Rectangle intersection = windowBounds.intersection(bounds);
-               int area = intersection.width * intersection.height;
-               if (area > maxArea)
+               // 0 or negative width or height indicate no intersection
+               if (intersection.width > 0 && intersection.height > 0)
                {
-                  maxArea = area;
-                  targetConfig = config;
-                  targetBounds = bounds;
+                  int area = intersection.width * intersection.height;
+                  if (area > maxArea)
+                  {
+                     maxArea = area;
+                     targetConfig = config;
+                     targetBounds = bounds;
+                  }
                }
             }
          }

