src/solaris/classes/sun/awt/X11/XDecoratedPeer.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 301         }
 302     }
 303 
 304     long reparent_serial = 0;
 305 
 306     public void handleReparentNotifyEvent(XEvent xev) {
 307         XReparentEvent  xe = xev.get_xreparent();
 308         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
 309             insLog.fine(xe.toString());
 310         }
 311         reparent_serial = xe.get_serial();
 312         XToolkit.awtLock();
 313         try {
 314             long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
 315 
 316             if (isEmbedded()) {
 317                 setReparented(true);
 318                 insets_corrected = true;
 319                 return;
 320             }
 321             Component t = (Component)target;
 322             if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
 323                 setReparented(true);
 324                 insets_corrected = true;
 325                 reshape(dimensions, SET_SIZE, false);
 326             } else if (xe.get_parent() == root) {
 327                 configure_seen = false;
 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                 }


 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         }
 427     }
 428 
 429     public void handleMoved(WindowDimensions dims) {
 430         Point loc = dims.getLocation();
 431         AWTAccessor.getComponentAccessor().setLocation((Component)target, loc.x, loc.y);
 432         postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
 433     }
 434 
 435 
 436     protected Insets guessInsets() {
 437         if (isEmbedded() || isTargetUndecorated()) {
 438             return new Insets(0, 0, 0, 0);
 439         } else {
 440             if (!isNull(currentInsets)) {
 441                 /* insets were set on wdata by System Properties */
 442                 return copy(currentInsets);
 443             } else {
 444                 Insets res = getWMSetInsets(null);
 445                 if (res == null) {
 446                     res = XWM.getWM().guessInsets(this);
 447                 }
 448                 return res;
 449             }
 450         }
 451     }


 519                 newBounds = new Rectangle(newBounds.x, newBounds.y,
 520                                           newBounds.width - insets.left - insets.right,
 521                                           newBounds.height - insets.top - insets.bottom);
 522             }
 523             newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
 524         }
 525         XToolkit.awtLock();
 526         try {
 527             if (!isReparented() || !isVisible()) {
 528                 if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
 529                     insLog.fine("- not reparented({0}) or not visible({1}), default reshape",
 530                            Boolean.valueOf(isReparented()), Boolean.valueOf(visible));
 531                 }
 532 
 533                 // Fix for 6323293.
 534                 // This actually is needed to preserve compatibility with previous releases -
 535                 // some of licensees are expecting componentMoved event on invisible one while
 536                 // its location changes.
 537                 Point oldLocation = getLocation();
 538 
 539                 Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX((Component)target),
 540                                               AWTAccessor.getComponentAccessor().getY((Component)target));
 541 
 542                 if (!newLocation.equals(oldLocation)) {
 543                     handleMoved(newDimensions);
 544                 }
 545 
 546                 dimensions = new WindowDimensions(newDimensions);
 547                 updateSizeHints(dimensions);
 548                 Rectangle client = dimensions.getClientRect();
 549                 checkShellRect(client);
 550                 setShellBounds(client);
 551                 if (content != null &&
 552                     !content.getSize().equals(newDimensions.getSize()))
 553                 {
 554                     reconfigureContentWindow(newDimensions);
 555                 }
 556                 return;
 557             }
 558 
 559             int wm = XWM.getWMID();
 560             updateChildrenSizes();


 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         // Bounds of the window
 741         Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds((Component)target);
 742 
 743         Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
 744 
 745         WindowDimensions newDimensions =
 746                 new WindowDimensions(newLocation,
 747                 new Dimension(xe.get_width(), xe.get_height()),
 748                 copy(currentInsets),
 749                 true);
 750 
 751         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 752             insLog.finer("Insets are {0}, new dimensions {1}",
 753                      currentInsets, newDimensions);
 754         }
 755 
 756         checkIfOnNewScreen(newDimensions.getBounds());
 757 
 758         Point oldLocation = getLocation();
 759         dimensions = newDimensions;
 760         if (!newLocation.equals(oldLocation)) {
 761             handleMoved(newDimensions);


1035             } else {
1036                 focusProxy.xRequestFocus();
1037             }
1038         }
1039     }
1040 
1041     XFocusProxyWindow getFocusProxy() {
1042         return focusProxy;
1043     }
1044 
1045     public void handleQuit() {
1046         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
1047     }
1048 
1049     final void dumpMe() {
1050         System.err.println(">>> Peer: " + x + ", " + y + ", " + width + ", " + height);
1051     }
1052 
1053     final void dumpTarget() {
1054         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
1055         int getWidth = compAccessor.getWidth((Component)target);
1056         int getHeight = compAccessor.getHeight((Component)target);
1057         int getTargetX = compAccessor.getX((Component)target);
1058         int getTargetY = compAccessor.getY((Component)target);
1059         System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
1060     }
1061 
1062     final void dumpShell() {
1063         dumpWindow("Shell", getShell());
1064     }
1065     final void dumpContent() {
1066         dumpWindow("Content", getContentWindow());
1067     }
1068     final void dumpParent() {
1069         long parent = XlibUtil.getParentWindow(getShell());
1070         if (parent != 0)
1071         {
1072             dumpWindow("Parent", parent);
1073         }
1074         else
1075         {
1076             System.err.println(">>> NO PARENT");
1077         }
1078     }


   1 /*
   2  * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 301         }
 302     }
 303 
 304     long reparent_serial = 0;
 305 
 306     public void handleReparentNotifyEvent(XEvent xev) {
 307         XReparentEvent  xe = xev.get_xreparent();
 308         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
 309             insLog.fine(xe.toString());
 310         }
 311         reparent_serial = xe.get_serial();
 312         XToolkit.awtLock();
 313         try {
 314             long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
 315 
 316             if (isEmbedded()) {
 317                 setReparented(true);
 318                 insets_corrected = true;
 319                 return;
 320             }
 321             Component t = target;
 322             if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
 323                 setReparented(true);
 324                 insets_corrected = true;
 325                 reshape(dimensions, SET_SIZE, false);
 326             } else if (xe.get_parent() == root) {
 327                 configure_seen = false;
 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                 }


 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         }
 427     }
 428 
 429     public void handleMoved(WindowDimensions dims) {
 430         Point loc = dims.getLocation();
 431         AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y);
 432         postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
 433     }
 434 
 435 
 436     protected Insets guessInsets() {
 437         if (isEmbedded() || isTargetUndecorated()) {
 438             return new Insets(0, 0, 0, 0);
 439         } else {
 440             if (!isNull(currentInsets)) {
 441                 /* insets were set on wdata by System Properties */
 442                 return copy(currentInsets);
 443             } else {
 444                 Insets res = getWMSetInsets(null);
 445                 if (res == null) {
 446                     res = XWM.getWM().guessInsets(this);
 447                 }
 448                 return res;
 449             }
 450         }
 451     }


 519                 newBounds = new Rectangle(newBounds.x, newBounds.y,
 520                                           newBounds.width - insets.left - insets.right,
 521                                           newBounds.height - insets.top - insets.bottom);
 522             }
 523             newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
 524         }
 525         XToolkit.awtLock();
 526         try {
 527             if (!isReparented() || !isVisible()) {
 528                 if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
 529                     insLog.fine("- not reparented({0}) or not visible({1}), default reshape",
 530                            Boolean.valueOf(isReparented()), Boolean.valueOf(visible));
 531                 }
 532 
 533                 // Fix for 6323293.
 534                 // This actually is needed to preserve compatibility with previous releases -
 535                 // some of licensees are expecting componentMoved event on invisible one while
 536                 // its location changes.
 537                 Point oldLocation = getLocation();
 538 
 539                 Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target),
 540                                               AWTAccessor.getComponentAccessor().getY(target));
 541 
 542                 if (!newLocation.equals(oldLocation)) {
 543                     handleMoved(newDimensions);
 544                 }
 545 
 546                 dimensions = new WindowDimensions(newDimensions);
 547                 updateSizeHints(dimensions);
 548                 Rectangle client = dimensions.getClientRect();
 549                 checkShellRect(client);
 550                 setShellBounds(client);
 551                 if (content != null &&
 552                     !content.getSize().equals(newDimensions.getSize()))
 553                 {
 554                     reconfigureContentWindow(newDimensions);
 555                 }
 556                 return;
 557             }
 558 
 559             int wm = XWM.getWMID();
 560             updateChildrenSizes();


 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         // Bounds of the window
 741         Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds(target);
 742 
 743         Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
 744 
 745         WindowDimensions newDimensions =
 746                 new WindowDimensions(newLocation,
 747                 new Dimension(xe.get_width(), xe.get_height()),
 748                 copy(currentInsets),
 749                 true);
 750 
 751         if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
 752             insLog.finer("Insets are {0}, new dimensions {1}",
 753                      currentInsets, newDimensions);
 754         }
 755 
 756         checkIfOnNewScreen(newDimensions.getBounds());
 757 
 758         Point oldLocation = getLocation();
 759         dimensions = newDimensions;
 760         if (!newLocation.equals(oldLocation)) {
 761             handleMoved(newDimensions);


1035             } else {
1036                 focusProxy.xRequestFocus();
1037             }
1038         }
1039     }
1040 
1041     XFocusProxyWindow getFocusProxy() {
1042         return focusProxy;
1043     }
1044 
1045     public void handleQuit() {
1046         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
1047     }
1048 
1049     final void dumpMe() {
1050         System.err.println(">>> Peer: " + x + ", " + y + ", " + width + ", " + height);
1051     }
1052 
1053     final void dumpTarget() {
1054         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
1055         int getWidth = compAccessor.getWidth(target);
1056         int getHeight = compAccessor.getHeight(target);
1057         int getTargetX = compAccessor.getX(target);
1058         int getTargetY = compAccessor.getY(target);
1059         System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
1060     }
1061 
1062     final void dumpShell() {
1063         dumpWindow("Shell", getShell());
1064     }
1065     final void dumpContent() {
1066         dumpWindow("Content", getContentWindow());
1067     }
1068     final void dumpParent() {
1069         long parent = XlibUtil.getParentWindow(getShell());
1070         if (parent != 0)
1071         {
1072             dumpWindow("Parent", parent);
1073         }
1074         else
1075         {
1076             System.err.println(">>> NO PARENT");
1077         }
1078     }