]> source.dussan.org Git - tigervnc.git/commitdiff
set dialog locations relative to parent window, otherwise dialogs appear on wrong...
authorBrian Hinz <bphinz@users.sourceforge.net>
Mon, 24 Oct 2011 02:11:53 +0000 (02:11 +0000)
committerBrian Hinz <bphinz@users.sourceforge.net>
Mon, 24 Oct 2011 02:11:53 +0000 (02:11 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4732 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/com/tigervnc/vncviewer/Dialog.java
java/com/tigervnc/vncviewer/F8Menu.java
java/com/tigervnc/vncviewer/ServerDialog.java

index d6fdd1bf07572d77279c67a90b832310426dd376..563a471dbe7a1865bfa29e5f7b20ba28e8f951f9 100644 (file)
@@ -41,15 +41,19 @@ class Dialog extends JFrame {
     //addWindowListener(this);
   }
 
-  public boolean showDialog() {
+  public boolean showDialog(Component c) {
     ok = false;
     done = false;
     initDialog();
-    Dimension dpySize = getToolkit().getScreenSize();
-    Dimension mySize = getSize();
-    int x = (dpySize.width - mySize.width) / 2;
-    int y = (dpySize.height - mySize.height) / 2;
-    setLocation(x, y);
+    if (c != null) {
+      setLocationRelativeTo(c);
+    } else {
+      Dimension dpySize = getToolkit().getScreenSize();
+      Dimension mySize = getSize();
+      int x = (dpySize.width - mySize.width) / 2;
+      int y = (dpySize.height - mySize.height) / 2;
+      setLocation(x, y);
+    }
     ClassLoader cl = this.getClass().getClassLoader();
     ImageIcon icon = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.ico"));
     setIconImage(icon.getImage());
@@ -69,6 +73,10 @@ class Dialog extends JFrame {
     return ok;
   }
 
+  public boolean showDialog() {
+    return showDialog(null);
+  }
+
   public void endDialog() {
     done = true;
     setVisible(false);
index 375849c172e062892228098a7181a107018ae576..15717617a93a38663e1147d83fdb34e17ae4697f 100644 (file)
@@ -96,7 +96,7 @@ public class F8Menu extends JPopupMenu implements ActionListener {
       if (cc.fullScreen) cc.toggleFullScreen();
       cc.viewport.setExtendedState(JFrame.MAXIMIZED_BOTH);
     } else if (actionMatch(ev, clipboard)) {
-      cc.clipboardDialog.showDialog();
+      cc.clipboardDialog.showDialog(cc.viewport);
     } else if (actionMatch(ev, f8)) {
       cc.writeKeyEvent(cc.menuKey, true);
       cc.writeKeyEvent(cc.menuKey, false);
@@ -112,7 +112,7 @@ public class F8Menu extends JPopupMenu implements ActionListener {
     } else if (actionMatch(ev, newConn)) {
       VncViewer.newViewer(cc.viewer);
     } else if (actionMatch(ev, options)) {
-      cc.options.showDialog();
+      cc.options.showDialog(cc.viewport);
     } else if (actionMatch(ev, info)) {
       cc.showInfo();
     } else if (actionMatch(ev, about)) {
index f5e5614119072f9122d8a65beaa78bc3a70310e0..0f32a96c20453e5064fdda5c8c8110e731099abe 100644 (file)
@@ -119,7 +119,7 @@ class ServerDialog extends Dialog implements
       ok = false;
       endDialog();
     } else if (s instanceof JButton && (JButton)s == optionsButton) {
-      options.showDialog();
+      options.showDialog(this);
     } else if (s instanceof JButton && (JButton)s == aboutButton) {
       cc.showAbout();
     } else if (s instanceof JComboBox && (JComboBox)s == server) {