Skip to content

Commit

Permalink
clientui: fix client repositioning on maximize
Browse files Browse the repository at this point in the history
Don't repositition the client on maximize or restore on Windows, as the resize is perform by the native ShowWindow method which always will have the window at the correct size and position.
  • Loading branch information
Adam- committed Dec 9, 2023
1 parent 5c2509e commit afaf57f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ public void mouseClicked(MouseEvent e)

private class Layout implements LayoutManager2
{
private int prevState;
private int previousContentWidth;

@Override
Expand Down Expand Up @@ -1144,6 +1145,9 @@ public Dimension minimumLayoutSize(Container content)
@Override
public void layoutContainer(Container content)
{
int changed = prevState ^ frame.getExtendedState();
prevState = frame.getExtendedState();

Component client = content.getComponent(0);
Component sidebar = content.getComponent(1);

Expand Down Expand Up @@ -1199,7 +1203,10 @@ public void layoutContainer(Container content)
sidebar.setBounds(clientWidth, 0, sidebarWidth, height);

frame.revalidateMinimumSize();
frame.containedSetSize(frame.getPreferredSize());
if (OSType.getOSType() != OSType.Windows || (changed & Frame.MAXIMIZED_BOTH) == 0)
{
frame.containedSetSize(frame.getPreferredSize());
}

log.trace("finishing layout - content={} client={} sidebar={} frame={}", content.getWidth(), client.getWidth(), sidebar.getWidth(), frame.getWidth());
}
Expand Down

0 comments on commit afaf57f

Please sign in to comment.