< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java

Print this page




 249     private static Insets difference(Insets i1, Insets i2) {
 250         return new Insets(i1.top-i2.top, i1.left - i2.left, i1.bottom-i2.bottom, i1.right-i2.right);
 251     }
 252 
 253     private static boolean isNull(Insets i) {
 254         return (i == null) || ((i.left | i.top | i.right | i.bottom) == 0);
 255     }
 256 
 257     private static Insets copy(Insets i) {
 258         return new Insets(i.top, i.left, i.bottom, i.right);
 259     }
 260 
 261     // insets which we get from WM (e.g from _NET_FRAME_EXTENTS)
 262     private Insets wm_set_insets;
 263 
 264     private Insets getWMSetInsets(XAtom changedAtom) {
 265         if (isEmbedded()) {
 266             return null;
 267         }
 268 
 269         if (wm_set_insets != null) {
 270             return wm_set_insets;
 271         }
 272 
 273         if (changedAtom == null) {
 274             wm_set_insets = XWM.getInsetsFromExtents(getWindow());
 275         } else {
 276             wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom);



 277         }
 278 
 279         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 280             insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets);
 281         }
 282 
 283         if (wm_set_insets != null) {
 284             wm_set_insets = copy(wm_set_insets);
 285         }
 286         return wm_set_insets;
 287     }
 288 
 289     private void resetWMSetInsets() {
 290         wm_set_insets = null;
 291     }
 292 
 293     public void handlePropertyNotify(XEvent xev) {
 294         super.handlePropertyNotify(xev);
 295 
 296         XPropertyEvent ev = xev.get_xproperty();


 328                 insets_corrected = false;
 329 
 330                 /*
 331                  * We can be repareted to root for two reasons:
 332                  *   . setVisible(false)
 333                  *   . WM exited
 334                  */
 335                 if (isVisible()) { /* WM exited */
 336                     /* Work around 4775545 */
 337                     XWM.getWM().unshadeKludge(this);
 338                     insLog.fine("- WM exited");
 339                 } else {
 340                     insLog.fine(" - reparent due to hide");
 341                 }
 342             } else { /* reparented to WM frame, figure out our insets */
 343                 setReparented(true);
 344                 insets_corrected = false;
 345 
 346                 // Check if we have insets provided by the WM
 347                 Insets correctWM = getWMSetInsets(null);
 348                 if (correctWM != null) {
 349                     if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 350                         insLog.finer("wm-provided insets {0}", correctWM);
 351                     }
 352                     // If these insets are equal to our current insets - no actions are necessary
 353                     Insets dimInsets = dimensions.getInsets();
 354                     if (correctWM.equals(dimInsets)) {
 355                         insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
 356                         no_reparent_artifacts = true;
 357                         insets_corrected = true;
 358                         applyGuessedInsets();
 359                         return;
 360                     }
 361                 } else {
 362                     correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
 363 
 364                     if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 365                         if (correctWM != null) {
 366                             insLog.finer("correctWM {0}", correctWM);
 367                         } else {
 368                             insLog.finer("correctWM insets are not available, waiting for configureNotify");
 369                         }
 370                     }
 371                 }
 372 
 373                 if (correctWM != null) {
 374                     handleCorrectInsets(correctWM);
 375                 }
 376             }
 377         } finally {
 378             XToolkit.awtUnlock();
 379         }
 380     }
 381 
 382     protected void handleCorrectInsets(Insets correctWM) {
 383         XToolkit.awtLock();
 384         try {
 385             /*
 386              * Ok, now see if we need adjust window size because
 387              * initial insets were wrong (most likely they were).
 388              */
 389             Insets correction = difference(correctWM, currentInsets);
 390             if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
 391                 insLog.finest("Corrention {0}", correction);
 392             }
 393             if (!isNull(correction)) {
 394                 currentInsets = copy(correctWM);
 395                 applyGuessedInsets();
 396 
 397                 //Fix for 6318109: PIT: Min Size is not honored properly when a
 398                 //smaller size is specified in setSize(), XToolkit
 399                 //update minimum size hints
 400                 updateMinSizeHints();


 401             }
 402             if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 403                 insLog.finer("Dimensions before reparent: " + dimensions);
 404             }
 405 
 406             dimensions.setInsets(getRealInsets());






 407             insets_corrected = true;
 408 
 409             if (isMaximized()) {
 410                 return;
 411             }
 412 
 413             /*
 414              * If this window has been sized by a pack() we need
 415              * to keep the interior geometry intact.  Since pack()
 416              * computed width and height with wrong insets, we
 417              * must adjust the target dimensions appropriately.
 418              */
 419             if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
 420                 reshape(dimensions, SET_BOUNDS, false);
 421             } else {
 422                 reshape(dimensions, SET_SIZE, false);
 423             }
 424         } finally {
 425             XToolkit.awtUnlock();
 426         }


 699 
 700         /*
 701          * Some window managers configure before we are reparented and
 702          * the send event flag is set! ugh... (Enlighetenment for one,
 703          * possibly MWM as well).  If we haven't been reparented yet
 704          * this is just the WM shuffling us into position.  Ignore
 705          * it!!!! or we wind up in a bogus location.
 706          */
 707         int runningWM = XWM.getWMID();
 708         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
 709             insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}",
 710                         isReparented(), isVisible(), runningWM, getDecorations());
 711         }
 712         if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
 713                 &&  !XWM.isNonReparentingWM()
 714                 && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
 715             insLog.fine("- visible but not reparented, skipping");
 716             return;
 717         }
 718         //Last chance to correct insets
 719         if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
 720             long parent = XlibUtil.getParentWindow(window);
 721             Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
 722             if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 723                 if (correctWM != null) {
 724                     insLog.finer("Configure notify - insets : " + correctWM);
 725                 } else {
 726                     insLog.finer("Configure notify - insets are still not available");
 727                 }
 728             }
 729             if (correctWM != null) {
 730                 handleCorrectInsets(correctWM);
 731             } else {
 732                 //Only one attempt to correct insets is made (to lower risk)
 733                 //if insets are still not available we simply set the flag
 734                 insets_corrected = true;
 735             }
 736         }
 737 
 738         updateChildrenSizes();
 739 
 740         Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
 741         WindowDimensions newDimensions =
 742                 new WindowDimensions(newLocation,
 743                                      new Dimension(scaleDown(xe.get_width()),
 744                                                    scaleDown(xe.get_height())),
 745                                      copy(currentInsets), true);
 746 
 747         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 748             insLog.finer("Insets are {0}, new dimensions {1}",
 749                      currentInsets, newDimensions);




 249     private static Insets difference(Insets i1, Insets i2) {
 250         return new Insets(i1.top-i2.top, i1.left - i2.left, i1.bottom-i2.bottom, i1.right-i2.right);
 251     }
 252 
 253     private static boolean isNull(Insets i) {
 254         return (i == null) || ((i.left | i.top | i.right | i.bottom) == 0);
 255     }
 256 
 257     private static Insets copy(Insets i) {
 258         return new Insets(i.top, i.left, i.bottom, i.right);
 259     }
 260 
 261     // insets which we get from WM (e.g from _NET_FRAME_EXTENTS)
 262     private Insets wm_set_insets;
 263 
 264     private Insets getWMSetInsets(XAtom changedAtom) {
 265         if (isEmbedded()) {
 266             return null;
 267         }
 268 
 269         if (wm_set_insets != null && !isNull(wm_set_insets)) {
 270             return wm_set_insets;
 271         }
 272 
 273         if (changedAtom == null) {
 274             wm_set_insets = XWM.getInsetsFromExtents(getWindow());
 275         } else {
 276             Insets insets = XWM.getInsetsFromProp(getWindow(), changedAtom);
 277             if (insets != null && !isNull(insets)) {
 278                 wm_set_insets = insets;
 279             }
 280         }
 281 
 282         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 283             insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets);
 284         }
 285 
 286         if (wm_set_insets != null) {
 287             wm_set_insets = copy(wm_set_insets);
 288         }
 289         return wm_set_insets;
 290     }
 291 
 292     private void resetWMSetInsets() {
 293         wm_set_insets = null;
 294     }
 295 
 296     public void handlePropertyNotify(XEvent xev) {
 297         super.handlePropertyNotify(xev);
 298 
 299         XPropertyEvent ev = xev.get_xproperty();


 331                 insets_corrected = false;
 332 
 333                 /*
 334                  * We can be repareted to root for two reasons:
 335                  *   . setVisible(false)
 336                  *   . WM exited
 337                  */
 338                 if (isVisible()) { /* WM exited */
 339                     /* Work around 4775545 */
 340                     XWM.getWM().unshadeKludge(this);
 341                     insLog.fine("- WM exited");
 342                 } else {
 343                     insLog.fine(" - reparent due to hide");
 344                 }
 345             } else { /* reparented to WM frame, figure out our insets */
 346                 setReparented(true);
 347                 insets_corrected = false;
 348 
 349                 // Check if we have insets provided by the WM
 350                 Insets correctWM = getWMSetInsets(null);
 351                 if (correctWM != null && !isNull(correctWM)) {
 352                     if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 353                         insLog.finer("wm-provided insets {0}", correctWM);
 354                     }
 355                     // If these insets are equal to our current insets - no actions are necessary
 356                     Insets dimInsets = dimensions.getInsets();
 357                     if (correctWM.equals(dimInsets)) {
 358                         insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
 359                         no_reparent_artifacts = true;
 360                         insets_corrected = true;
 361                         applyGuessedInsets();
 362                         return;
 363                     }
 364                 } else {
 365                     correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
 366 
 367                     if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 368                         if (correctWM != null) {
 369                             insLog.finer("correctWM {0}", correctWM);
 370                         } else {
 371                             insLog.finer("correctWM insets are not available, waiting for configureNotify");
 372                         }
 373                     }
 374                 }
 375 
 376                 if (correctWM != null && !isNull(correctWM)) {
 377                     handleCorrectInsets(correctWM);
 378                 }
 379             }
 380         } finally {
 381             XToolkit.awtUnlock();
 382         }
 383     }
 384 
 385     protected void handleCorrectInsets(Insets correctWM) {
 386         XToolkit.awtLock();
 387         try {
 388             /*
 389              * Ok, now see if we need adjust window size because
 390              * initial insets were wrong (most likely they were).
 391              */
 392             Insets correction = difference(correctWM, currentInsets);
 393             if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
 394                 insLog.finest("Corrention {0}", correction);
 395             }
 396             if (!isNull(correction)) {
 397                 currentInsets = copy(correctWM);
 398                 applyGuessedInsets();
 399 
 400                 //Fix for 6318109: PIT: Min Size is not honored properly when a
 401                 //smaller size is specified in setSize(), XToolkit
 402                 //update minimum size hints
 403                 updateMinSizeHints();
 404             } else {
 405                 return;
 406             }
 407             if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 408                 insLog.finer("Dimensions before reparent: " + dimensions);
 409             }
 410 
 411             dimensions.setInsets(correctWM);
 412             if (dimensions.isClientSizeSet()) {
 413                 Dimension cs = dimensions.getClientSize();
 414                 dimensions.setClientSize(
 415                         cs.width - correction.left - correction.right,
 416                         cs.height - correction.top - correction.bottom);
 417             }
 418             insets_corrected = true;
 419 
 420             if (isMaximized()) {
 421                 return;
 422             }
 423 
 424             /*
 425              * If this window has been sized by a pack() we need
 426              * to keep the interior geometry intact.  Since pack()
 427              * computed width and height with wrong insets, we
 428              * must adjust the target dimensions appropriately.
 429              */
 430             if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
 431                 reshape(dimensions, SET_BOUNDS, false);
 432             } else {
 433                 reshape(dimensions, SET_SIZE, false);
 434             }
 435         } finally {
 436             XToolkit.awtUnlock();
 437         }


 710 
 711         /*
 712          * Some window managers configure before we are reparented and
 713          * the send event flag is set! ugh... (Enlighetenment for one,
 714          * possibly MWM as well).  If we haven't been reparented yet
 715          * this is just the WM shuffling us into position.  Ignore
 716          * it!!!! or we wind up in a bogus location.
 717          */
 718         int runningWM = XWM.getWMID();
 719         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
 720             insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}",
 721                         isReparented(), isVisible(), runningWM, getDecorations());
 722         }
 723         if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
 724                 &&  !XWM.isNonReparentingWM()
 725                 && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
 726             insLog.fine("- visible but not reparented, skipping");
 727             return;
 728         }
 729         //Last chance to correct insets
 730         if (getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
 731             long parent = XlibUtil.getParentWindow(window);
 732             Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
 733             if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 734                 if (correctWM != null) {
 735                     insLog.finer("Configure notify - insets : " + correctWM);
 736                 } else {
 737                     insLog.finer("Configure notify - insets are still not available");
 738                 }
 739             }
 740             if (correctWM != null && !isNull(correctWM)) {
 741                 handleCorrectInsets(correctWM);
 742             } else {
 743                 //Only one attempt to correct insets is made (to lower risk)
 744                 //if insets are still not available we simply set the flag
 745                 insets_corrected = true;
 746             }
 747         }
 748 
 749         updateChildrenSizes();
 750 
 751         Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
 752         WindowDimensions newDimensions =
 753                 new WindowDimensions(newLocation,
 754                                      new Dimension(scaleDown(xe.get_width()),
 755                                                    scaleDown(xe.get_height())),
 756                                      copy(currentInsets), true);
 757 
 758         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 759             insLog.finer("Insets are {0}, new dimensions {1}",
 760                      currentInsets, newDimensions);


< prev index next >