This is an automated email from the ASF dual-hosted git repository.

mcasters pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 72fe7e3d52 [HOP-4241] - Fixes context dialog position
     new fd6f2b021f Merge pull request #1706 from 
tanquetav/fix_context_window_position
72fe7e3d52 is described below

commit 72fe7e3d5276f2a336f44aa3611d797c22f6e17e
Author: George Tavares <[email protected]>
AuthorDate: Fri Sep 23 10:29:31 2022 -0300

    [HOP-4241] - Fixes context dialog position
    
    Fix the context dialog position to be opened on the same monitor HOP Gui is 
running
---
 .../apache/hop/ui/core/dialog/ContextDialog.java   | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/ui/src/main/java/org/apache/hop/ui/core/dialog/ContextDialog.java 
b/ui/src/main/java/org/apache/hop/ui/core/dialog/ContextDialog.java
index 2fe706d28f..53bc756721 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/ContextDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/ContextDialog.java
@@ -436,12 +436,26 @@ public class ContextDialog extends Dialog {
     if (location != null) {
       /*Adapt to the monitor */
       Monitor monitor = shell.getMonitor();
+      boolean fitOtherMonitors = false;
+      for(Monitor monitorCheck : shell.getDisplay().getMonitors()) {
+        org.eclipse.swt.graphics.Rectangle displayPositionCheck = 
monitorCheck.getBounds();
+        if (((location.x - displayPositionCheck.x) <= 
monitorCheck.getClientArea().width - width)
+            && (location.y - displayPositionCheck.y <= 
monitorCheck.getClientArea().height - height)
+                ) {
+          fitOtherMonitors = true;
+          break;
+        }
+        if (monitorCheck.getClientArea().contains(location.x, location.y)) {
+          monitor = monitorCheck;
+        }
+      }
       org.eclipse.swt.graphics.Rectangle displayPosition = monitor.getBounds();
-      if ((location.x - displayPosition.x) > monitor.getClientArea().width - 
width)
-        location.x = (monitor.getClientArea().width + displayPosition.x) - 
width;
-      if (location.y - displayPosition.y > monitor.getClientArea().height - 
height)
-        location.y = (monitor.getClientArea().height + displayPosition.y) - 
height;
-
+      if (!fitOtherMonitors) {
+        if ((location.x - displayPosition.x) > monitor.getClientArea().width - 
width)
+          location.x = (monitor.getClientArea().width + displayPosition.x) - 
width;
+        if (location.y - displayPosition.y > monitor.getClientArea().height - 
height)
+          location.y = (monitor.getClientArea().height + displayPosition.y) - 
height;
+      }
       shell.setSize(width, height);
       shell.setLocation(location.x, location.y);
     } else {

Reply via email to