--- old/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java 2016-09-23 15:42:24.320487679 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java 2016-09-23 15:42:24.176487684 +0300 @@ -308,6 +308,19 @@ super.handlePropertyNotify(xev); XPropertyEvent ev = xev.get_xproperty(); + if( !insets_corrected && isReparented() && + XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { + int state = XWM.getWM().getState(this); + if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) { + // Stop ignoring ConfigureNotify because no extents will be sent + // by WM for initially maximized decorated window. + // Re-request window bounds to ensure actual dimensions and + // notify the target with the initial size. + insets_corrected = true; + XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), + getWindow(), 0, 0); + } + } if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom() || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom()) { @@ -325,11 +338,30 @@ if (!isEmbedded() && !isTargetUndecorated()) { lastKnownInsets.put(getClass(), in); } - if (!in.equals(dimensions.getInsets()) || - !dimensions.isClientSizeSet()) { - handleCorrectInsets(in); + if (!in.equals(dimensions.getInsets())) { + if (insets_corrected || isMaximized()) { + currentInsets = in; + insets_corrected = true; + // insets were changed by WM. To handle this situation + // re-request window bounds because the current + // dimensions may be not actual as well. + XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), + getWindow(), 0, 0); + } else { + // recalculate dimensions when window is just created + // and the initially guessed insets were wrong + handleCorrectInsets(in); + } + } else if (!dimensions.isClientSizeSet()) { + insets_corrected = true; + // initial insets were guessed correctly. Re-request + // frame bounds because they may be changed by WM if the + // initial window position overlapped desktop's toolbars. + // This should initiate the final ConfigureNotify upon which + // the target will be notified with the final size. + XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), + getWindow(), 0, 0); } - insets_corrected = true; } } }