Merge remote-tracking branch 'Twiglet1022/bring-client-to-front' into bring-client-to-front
This commit is contained in:
@@ -602,6 +602,36 @@ public class ClientUI
|
|||||||
{
|
{
|
||||||
OSXUtil.requestFocus();
|
OSXUtil.requestFocus();
|
||||||
}
|
}
|
||||||
|
// The workaround for Windows is to minimise and then un-minimise the client to bring
|
||||||
|
// it to the front because java.awt.Window#toFront doesn't work reliably.
|
||||||
|
else if (OSType.getOSType() == OSType.Windows && !frame.isFocused())
|
||||||
|
{
|
||||||
|
if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH)
|
||||||
|
{
|
||||||
|
SwingUtilities.invokeLater(() ->
|
||||||
|
{
|
||||||
|
frame.setExtendedState(JFrame.ICONIFIED);
|
||||||
|
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SwingUtilities.invokeLater(() ->
|
||||||
|
{
|
||||||
|
// If the client is snapped to the top and bottom edges of the screen, setExtendedState will
|
||||||
|
// will reset it so setSize and setLocation ensure that the client doesn't move or resize.
|
||||||
|
// It is done this way because Windows does not support JFrame.MAXIMIZED_VERT
|
||||||
|
int x = frame.getLocation().x;
|
||||||
|
int y = frame.getLocation().y;
|
||||||
|
int width = frame.getWidth();
|
||||||
|
int height = frame.getHeight();
|
||||||
|
frame.setExtendedState(JFrame.ICONIFIED);
|
||||||
|
frame.setExtendedState(JFrame.NORMAL);
|
||||||
|
frame.setLocation(x, y);
|
||||||
|
frame.setSize(width, height);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
frame.requestFocus();
|
frame.requestFocus();
|
||||||
giveClientFocus();
|
giveClientFocus();
|
||||||
|
|||||||
Reference in New Issue
Block a user