diff options
author | Thomas Hofer <t.hofer@liwest.at> | 2008-07-09 09:08:20 +0000 |
---|---|---|
committer | Thomas Hofer <t.hofer@liwest.at> | 2008-07-09 09:08:20 +0000 |
commit | 7a5e93968e3aae8b34f5d624ba57a11e79a8a783 (patch) | |
tree | ab4fc170250df1f1c7d6b4c1cd0e9e681101d915 /src/net | |
parent | d510e6c75303905ad583cedaa93fc0e991f95d55 (diff) | |
download | jitsi-7a5e93968e3aae8b34f5d624ba57a11e79a8a783.zip jitsi-7a5e93968e3aae8b34f5d624ba57a11e79a8a783.tar.gz jitsi-7a5e93968e3aae8b34f5d624ba57a11e79a8a783.tar.bz2 |
fixed a bug on multi monitor systems
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java | 49 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommFrame.java | 49 |
2 files changed, 80 insertions, 18 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java index 07a5aab..90fd388 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java @@ -231,20 +231,51 @@ public abstract class SIPCommDialog extends JDialog y = this.getY(); } + // determine all screens and combine the coordinates + Rectangle virtualBounds = new Rectangle(); + GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + GraphicsDevice[] gs = ge.getScreenDevices(); + for (int j = 0; j < gs.length; j++) + { + GraphicsDevice gd = gs[j]; + GraphicsConfiguration[] gc = gd.getConfigurations(); + for (int i = 0; i < gc.length; i++) + { + virtualBounds = virtualBounds.union(gc[i].getBounds()); + } + } + // in case any of the sizes exceeds the screen size // we set default one - if(x + width > screenWidth || - y + height > screenHeight - 50) + if (!(virtualBounds.contains(x, y) && virtualBounds.contains(x + width, + y + height))) { - double aspect = (double)width/height; - int newHeight = screenHeight - 100; - int newWidth = (int)(newHeight * aspect); + if (x + width > virtualBounds.width) + { + // location of window is too far to the right + x = virtualBounds.width - width; + if (x < 20) + { + x = 20; + width = virtualBounds.width - 40; + } + } + if (y + height > virtualBounds.height) + { + // location of window is too far to the right + y = virtualBounds.height - height; + if (y < 20) + { + y = 20; + height = virtualBounds.height - 40; + } + } + this.setPreferredSize(new Dimension(width, height)); + this.setSize(width, height); + this.setLocation(x, y); - // change the preferred size as its like the original size - // and new size will not take effect - this.setPreferredSize(new Dimension(newWidth, newHeight)); - this.setSize(newWidth, newHeight); } } diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommFrame.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommFrame.java index 048b82e..317e2cc 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommFrame.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommFrame.java @@ -218,20 +218,51 @@ public abstract class SIPCommFrame y = this.getY(); } + // determine all screens and combine the coordinates + Rectangle virtualBounds = new Rectangle(); + GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + GraphicsDevice[] gs = ge.getScreenDevices(); + for (int j = 0; j < gs.length; j++) + { + GraphicsDevice gd = gs[j]; + GraphicsConfiguration[] gc = gd.getConfigurations(); + for (int i = 0; i < gc.length; i++) + { + virtualBounds = virtualBounds.union(gc[i].getBounds()); + } + } + // in case any of the sizes exceeds the screen size // we set default one - if(x + width > screenWidth || - y + height > screenHeight - 50) + if (!(virtualBounds.contains(x, y) && virtualBounds.contains(x + width, + y + height))) { - double aspect = (double)width/height; - int newHeight = screenHeight - 100; - int newWidth = (int)(newHeight * aspect); + if (x + width > virtualBounds.width) + { + // location of window is too far to the right + x = virtualBounds.width - width; + if (x < 20) + { + x = 20; + width = virtualBounds.width - 40; + } + } + if (y + height > virtualBounds.height) + { + // location of window is too far to the right + y = virtualBounds.height - height; + if (y < 20) + { + y = 20; + height = virtualBounds.height - 40; + } + } + this.setPreferredSize(new Dimension(width, height)); + this.setSize(width, height); + this.setLocation(x, y); - // change the preferred size as its like the original size - // and new size will not take effect - this.setPreferredSize(new Dimension(newWidth, newHeight)); - this.setSize(newWidth, newHeight); } } |