Introduce a property to let the OS window manager position dialogs when their saved position is outside the screen

cusax-fix
Ingo Bauersachs 14 years ago
parent c05b12614e
commit 4a0003edfd

@ -244,9 +244,17 @@ private void setSizeAndLocation()
this.setSize(width, height);
if(xString != null && yString != null)
this.setLocation(
Integer.parseInt(xString),
Integer.parseInt(yString));
{
int x = Integer.parseInt(xString);
int y = Integer.parseInt(yString);
if(ScreenInformation.
isTitleOnScreen(new Rectangle(x, y, width, height))
|| config.getBoolean(
SIPCommFrame.PNAME_CALCULATED_POSITIONING, true))
{
this.setLocation(x, y);
}
}
else
this.setCenterLocation();
}
@ -265,12 +273,16 @@ private void setCenterLocation()
*/
private void ensureOnScreenLocationAndSize()
{
ConfigurationService config = UtilActivator.getConfigurationService();
if(!config.getBoolean(SIPCommFrame.PNAME_CALCULATED_POSITIONING, true))
return;
int x = this.getX();
int y = this.getY();
int width = this.getWidth();
int height = this.getHeight();
Rectangle virtualBounds = ScreenInformation.getScreenBounds();
// the default distance to the screen border

@ -33,6 +33,16 @@ public class SIPCommFrame
extends JFrame
implements Observer
{
/**
* Property that disables the automatic resizing and positioning when a
* window's top edge is outside the visible area of the screen.
* <p>
* <tt>true</tt> use automatic repositioning (default)<br/>
* <tt>false</tt> rely on the window manager to place the window
*/
static final String PNAME_CALCULATED_POSITIONING
= "net.sip.communicator.util.swing.USE_CALCULATED_POSITIONING";
/**
* The <tt>Logger</tt> used by the <tt>SIPCommFrame</tt> class and its
* instances for logging output.
@ -352,7 +362,13 @@ public void setSizeAndLocation()
x = Integer.parseInt(xString);
y = Integer.parseInt(yString);
this.setLocation(x, y);
if(ScreenInformation.
isTitleOnScreen(new Rectangle(x, y, width, height))
|| configService.getBoolean(
SIPCommFrame.PNAME_CALCULATED_POSITIONING, true))
{
this.setLocation(x, y);
}
}
else
{
@ -374,6 +390,10 @@ private void setCenterLocation()
*/
private void ensureOnScreenLocationAndSize()
{
ConfigurationService config = UtilActivator.getConfigurationService();
if(!config.getBoolean(SIPCommFrame.PNAME_CALCULATED_POSITIONING, true))
return;
int x = this.getX();
int y = this.getY();

Loading…
Cancel
Save