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

Print this page




 162     XFocusProxyWindow createFocusProxy() {
 163         return new XFocusProxyWindow(this);
 164     }
 165 
 166     protected XAtomList getWMProtocols() {
 167         XAtomList protocols = super.getWMProtocols();
 168         protocols.add(wm_delete_window);
 169         protocols.add(wm_take_focus);
 170         return protocols;
 171     }
 172 
 173     public Graphics getGraphics() {
 174         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
 175         return getGraphics(content.surfaceData,
 176                            compAccessor.getForeground(target),
 177                            compAccessor.getBackground(target),
 178                            compAccessor.getFont(target));
 179     }
 180 
 181     public void setTitle(String title) {
 182         if (log.isLoggable(PlatformLogger.FINE)) log.fine("Title is " + title);


 183         winAttr.title = title;
 184         updateWMName();
 185     }
 186 
 187     protected String getWMName() {
 188         if (winAttr.title == null || winAttr.title.trim().equals("")) {
 189             return " ";
 190         } else {
 191             return winAttr.title;
 192         }
 193     }
 194 
 195     void updateWMName() {
 196         super.updateWMName();
 197         String name = getWMName();
 198         XToolkit.awtLock();
 199         try {
 200             if (name == null || name.trim().equals("")) {
 201                 name = "Java";
 202             }


 210     }
 211 
 212     // NOTE: This method may be called by privileged threads.
 213     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 214     public void handleIconify() {
 215         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
 216     }
 217 
 218     // NOTE: This method may be called by privileged threads.
 219     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 220     public void handleDeiconify() {
 221         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
 222     }
 223 
 224     public void handleFocusEvent(XEvent xev) {
 225         super.handleFocusEvent(xev);
 226         XFocusChangeEvent xfe = xev.get_xfocus();
 227 
 228         // If we somehow received focus events forward it instead to proxy
 229         // FIXME: Shouldn't we instead check for inferrior?

 230         focusLog.finer("Received focus event on shell: " + xfe);

 231 //         focusProxy.xRequestFocus();
 232    }
 233 
 234 /***************************************************************************************
 235  *                             I N S E T S   C O D E
 236  **************************************************************************************/
 237 
 238     protected boolean isInitialReshape() {
 239         return false;
 240     }
 241 
 242     private static Insets difference(Insets i1, Insets i2) {
 243         return new Insets(i1.top-i2.top, i1.left - i2.left, i1.bottom-i2.bottom, i1.right-i2.right);
 244     }
 245 
 246     private static boolean isNull(Insets i) {
 247         return (i == null) || ((i.left | i.top | i.right | i.bottom) == 0);
 248     }
 249 
 250     private static Insets copy(Insets i) {


 279 
 280     private void resetWMSetInsets() {
 281         wm_set_insets = null;
 282     }
 283 
 284     public void handlePropertyNotify(XEvent xev) {
 285         super.handlePropertyNotify(xev);
 286 
 287         XPropertyEvent ev = xev.get_xproperty();
 288         if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom()
 289             || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
 290         {
 291             getWMSetInsets(XAtom.get(ev.get_atom()));
 292         }
 293     }
 294 
 295     long reparent_serial = 0;
 296 
 297     public void handleReparentNotifyEvent(XEvent xev) {
 298         XReparentEvent  xe = xev.get_xreparent();
 299         if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine(xe.toString());


 300         reparent_serial = xe.get_serial();
 301         XToolkit.awtLock();
 302         try {
 303             long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
 304 
 305             if (isEmbedded()) {
 306                 setReparented(true);
 307                 insets_corrected = true;
 308                 return;
 309             }
 310             Component t = (Component)target;
 311             if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
 312                 setReparented(true);
 313                 insets_corrected = true;
 314                 reshape(dimensions, SET_SIZE, false);
 315             } else if (xe.get_parent() == root) {
 316                 configure_seen = false;
 317                 insets_corrected = false;
 318 
 319                 /*


 365     }
 366 
 367     protected void handleCorrectInsets(Insets correctWM) {
 368         XToolkit.awtLock();
 369         try {
 370             /*
 371              * Ok, now see if we need adjust window size because
 372              * initial insets were wrong (most likely they were).
 373              */
 374             Insets correction = difference(correctWM, currentInsets);
 375             insLog.finest("Corrention {0}", correction);
 376             if (!isNull(correction)) {
 377                 currentInsets = copy(correctWM);
 378                 applyGuessedInsets();
 379 
 380                 //Fix for 6318109: PIT: Min Size is not honored properly when a
 381                 //smaller size is specified in setSize(), XToolkit
 382                 //update minimum size hints
 383                 updateMinSizeHints();
 384             }
 385             if (insLog.isLoggable(PlatformLogger.FINER)) insLog.finer("Dimensions before reparent: " + dimensions);


 386 
 387             dimensions.setInsets(getRealInsets());
 388             insets_corrected = true;
 389 
 390             if (isMaximized()) {
 391                 return;
 392             }
 393 
 394             /*
 395              * If this window has been sized by a pack() we need
 396              * to keep the interior geometry intact.  Since pack()
 397              * computed width and height with wrong insets, we
 398              * must adjust the target dimensions appropriately.
 399              */
 400             if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
 401                 reshape(dimensions, SET_BOUNDS, false);
 402             } else {
 403                 reshape(dimensions, SET_SIZE, false);
 404             }
 405         } finally {


 718 
 719         Point newLocation = targetBounds.getLocation();
 720         if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
 721             // Location, Client size + insets
 722             newLocation = new Point(xe.get_x() - currentInsets.left, xe.get_y() - currentInsets.top);
 723         } else {
 724             // ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
 725             // a window is resized but the client can not tell if the window was
 726             // moved or not. The client should consider the position as unkown
 727             // and use TranslateCoordinates to find the actual position.
 728             //
 729             // TODO this should be the default for every case.
 730             switch (XWM.getWMID()) {
 731                 case XWM.CDE_WM:
 732                 case XWM.MOTIF_WM:
 733                 case XWM.METACITY_WM:
 734                 case XWM.MUTTER_WM:
 735                 case XWM.SAWFISH_WM:
 736                 {
 737                     Point xlocation = queryXLocation();
 738                     if (log.isLoggable(PlatformLogger.FINE)) log.fine("New X location: {0}", xlocation);


 739                     if (xlocation != null) {
 740                         newLocation = xlocation;
 741                     }
 742                     break;
 743                 }
 744                 default:
 745                     break;
 746             }
 747         }
 748 
 749         WindowDimensions newDimensions =
 750                 new WindowDimensions(newLocation,
 751                 new Dimension(xe.get_width(), xe.get_height()),
 752                 copy(currentInsets),
 753                 true);
 754 
 755         insLog.finer("Insets are {0}, new dimensions {1}",
 756                      currentInsets, newDimensions);
 757 
 758         checkIfOnNewScreen(newDimensions.getBounds());


 771     private void checkShellRectSize(Rectangle shellRect) {
 772         shellRect.width = Math.max(MIN_SIZE, shellRect.width);
 773         shellRect.height = Math.max(MIN_SIZE, shellRect.height);
 774     }
 775 
 776     private void checkShellRectPos(Rectangle shellRect) {
 777         int wm = XWM.getWMID();
 778         if (wm == XWM.MOTIF_WM || wm == XWM.CDE_WM) {
 779             if (shellRect.x == 0 && shellRect.y == 0) {
 780                 shellRect.x = shellRect.y = 1;
 781             }
 782         }
 783     }
 784 
 785     private void checkShellRect(Rectangle shellRect) {
 786         checkShellRectSize(shellRect);
 787         checkShellRectPos(shellRect);
 788     }
 789 
 790     public void setShellBounds(Rectangle rec) {
 791         if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting shell bounds on " +
 792                                                                 this + " to " + rec);

 793         XToolkit.awtLock();
 794         try {
 795             updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 796             XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
 797             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y);
 798         }
 799         finally {
 800             XToolkit.awtUnlock();
 801         }
 802     }
 803     public void setShellSize(Rectangle rec) {
 804         if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting shell size on " +
 805                                                                 this + " to " + rec);

 806         XToolkit.awtLock();
 807         try {
 808             updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 809             XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
 810         }
 811         finally {
 812             XToolkit.awtUnlock();
 813         }
 814     }
 815     public void setShellPosition(Rectangle rec) {
 816         if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting shell position on " +
 817                                                                 this + " to " + rec);

 818         XToolkit.awtLock();
 819         try {
 820             updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 821             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y);
 822         }
 823         finally {
 824             XToolkit.awtUnlock();
 825         }
 826     }
 827 
 828     void initResizability() {
 829         setResizable(winAttr.initialResizability);
 830     }
 831     public void setResizable(boolean resizable) {
 832         int fs = winAttr.functions;
 833         if (!isResizable() && resizable) {
 834             currentInsets = new Insets(0, 0, 0, 0);
 835             resetWMSetInsets();
 836             if (!isEmbedded()) {
 837                 setReparented(false);


1000             } else if (cl.get_data(0) == wm_take_focus.getAtom()) {
1001                 handleWmTakeFocus(cl);
1002             }
1003         }
1004     }
1005 
1006     private void handleWmTakeFocus(XClientMessageEvent cl) {
1007         focusLog.fine("WM_TAKE_FOCUS on {0}", this);
1008         requestWindowFocus(cl.get_data(1), true);
1009     }
1010 
1011     /**
1012      * Requests focus to this decorated top-level by requesting X input focus
1013      * to the shell window.
1014      */
1015     protected void requestXFocus(long time, boolean timeProvided) {
1016         // We have proxied focus mechanism - instead of shell the focus is held
1017         // by "proxy" - invisible mapped window. When we want to set X input focus to
1018         // toplevel set it on proxy instead.
1019         if (focusProxy == null) {
1020             if (focusLog.isLoggable(PlatformLogger.FINE)) focusLog.warning("Focus proxy is null for " + this);


1021         } else {
1022             if (focusLog.isLoggable(PlatformLogger.FINE)) focusLog.fine("Requesting focus to proxy: " + focusProxy);


1023             if (timeProvided) {
1024                 focusProxy.xRequestFocus(time);
1025             } else {
1026                 focusProxy.xRequestFocus();
1027             }
1028         }
1029     }
1030 
1031     XFocusProxyWindow getFocusProxy() {
1032         return focusProxy;
1033     }
1034 
1035     public void handleQuit() {
1036         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
1037     }
1038 
1039     final void dumpMe() {
1040         System.err.println(">>> Peer: " + x + ", " + y + ", " + width + ", " + height);
1041     }
1042 


1119         while (toFocus.nextTransientFor != null) {
1120             toFocus = toFocus.nextTransientFor;
1121         }
1122         if (toFocus == null || !toFocus.focusAllowedFor()) {
1123             // This might change when WM will have property to determine focus policy.
1124             // Right now, because policy is unknown we can't be sure we succedded
1125             return false;
1126         }
1127         if (this == toFocus) {
1128             if (isWMStateNetHidden()) {
1129                 focusLog.fine("The window is unmapped, so rejecting the request");
1130                 return false;
1131             }
1132             if (target == activeWindow && target != focusedWindow) {
1133                 // Happens when an owned window is currently focused
1134                 focusLog.fine("Focus is on child window - transfering it back to the owner");
1135                 handleWindowFocusInSync(-1);
1136                 return true;
1137             }
1138             Window realNativeFocusedWindow = XWindowPeer.getNativeFocusedWindow();

1139             focusLog.finest("Real native focused window: " + realNativeFocusedWindow +
1140                             "\nKFM's focused window: " + focusedWindow);

1141 
1142             // See 6522725, 6613426.
1143             if (target == realNativeFocusedWindow) {

1144                 focusLog.fine("The window is already natively focused.");

1145                 return true;
1146             }
1147         }

1148         focusLog.fine("Requesting focus to " + (this == toFocus ? "this window" : toFocus));

1149 
1150         if (timeProvided) {
1151             toFocus.requestXFocus(time);
1152         } else {
1153             toFocus.requestXFocus();
1154         }
1155         return (this == toFocus);
1156     }
1157 
1158     XWindowPeer actualFocusedWindow = null;
1159     void setActualFocusedWindow(XWindowPeer actualFocusedWindow) {
1160         synchronized(getStateLock()) {
1161             this.actualFocusedWindow = actualFocusedWindow;
1162         }
1163     }
1164 
1165     boolean requestWindowFocus(XWindowPeer actualFocusedWindow,
1166                                long time, boolean timeProvided)
1167     {
1168         setActualFocusedWindow(actualFocusedWindow);




 162     XFocusProxyWindow createFocusProxy() {
 163         return new XFocusProxyWindow(this);
 164     }
 165 
 166     protected XAtomList getWMProtocols() {
 167         XAtomList protocols = super.getWMProtocols();
 168         protocols.add(wm_delete_window);
 169         protocols.add(wm_take_focus);
 170         return protocols;
 171     }
 172 
 173     public Graphics getGraphics() {
 174         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
 175         return getGraphics(content.surfaceData,
 176                            compAccessor.getForeground(target),
 177                            compAccessor.getBackground(target),
 178                            compAccessor.getFont(target));
 179     }
 180 
 181     public void setTitle(String title) {
 182         if (log.isLoggable(PlatformLogger.FINE)) {
 183             log.fine("Title is " + title);
 184         }
 185         winAttr.title = title;
 186         updateWMName();
 187     }
 188 
 189     protected String getWMName() {
 190         if (winAttr.title == null || winAttr.title.trim().equals("")) {
 191             return " ";
 192         } else {
 193             return winAttr.title;
 194         }
 195     }
 196 
 197     void updateWMName() {
 198         super.updateWMName();
 199         String name = getWMName();
 200         XToolkit.awtLock();
 201         try {
 202             if (name == null || name.trim().equals("")) {
 203                 name = "Java";
 204             }


 212     }
 213 
 214     // NOTE: This method may be called by privileged threads.
 215     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 216     public void handleIconify() {
 217         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
 218     }
 219 
 220     // NOTE: This method may be called by privileged threads.
 221     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 222     public void handleDeiconify() {
 223         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
 224     }
 225 
 226     public void handleFocusEvent(XEvent xev) {
 227         super.handleFocusEvent(xev);
 228         XFocusChangeEvent xfe = xev.get_xfocus();
 229 
 230         // If we somehow received focus events forward it instead to proxy
 231         // FIXME: Shouldn't we instead check for inferrior?
 232         if (focusLog.isLoggable(PlatformLogger.FINER)) {
 233             focusLog.finer("Received focus event on shell: " + xfe);
 234         }
 235 //         focusProxy.xRequestFocus();
 236    }
 237 
 238 /***************************************************************************************
 239  *                             I N S E T S   C O D E
 240  **************************************************************************************/
 241 
 242     protected boolean isInitialReshape() {
 243         return false;
 244     }
 245 
 246     private static Insets difference(Insets i1, Insets i2) {
 247         return new Insets(i1.top-i2.top, i1.left - i2.left, i1.bottom-i2.bottom, i1.right-i2.right);
 248     }
 249 
 250     private static boolean isNull(Insets i) {
 251         return (i == null) || ((i.left | i.top | i.right | i.bottom) == 0);
 252     }
 253 
 254     private static Insets copy(Insets i) {


 283 
 284     private void resetWMSetInsets() {
 285         wm_set_insets = null;
 286     }
 287 
 288     public void handlePropertyNotify(XEvent xev) {
 289         super.handlePropertyNotify(xev);
 290 
 291         XPropertyEvent ev = xev.get_xproperty();
 292         if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom()
 293             || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
 294         {
 295             getWMSetInsets(XAtom.get(ev.get_atom()));
 296         }
 297     }
 298 
 299     long reparent_serial = 0;
 300 
 301     public void handleReparentNotifyEvent(XEvent xev) {
 302         XReparentEvent  xe = xev.get_xreparent();
 303         if (insLog.isLoggable(PlatformLogger.FINE)) {
 304             insLog.fine(xe.toString());
 305         }
 306         reparent_serial = xe.get_serial();
 307         XToolkit.awtLock();
 308         try {
 309             long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
 310 
 311             if (isEmbedded()) {
 312                 setReparented(true);
 313                 insets_corrected = true;
 314                 return;
 315             }
 316             Component t = (Component)target;
 317             if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
 318                 setReparented(true);
 319                 insets_corrected = true;
 320                 reshape(dimensions, SET_SIZE, false);
 321             } else if (xe.get_parent() == root) {
 322                 configure_seen = false;
 323                 insets_corrected = false;
 324 
 325                 /*


 371     }
 372 
 373     protected void handleCorrectInsets(Insets correctWM) {
 374         XToolkit.awtLock();
 375         try {
 376             /*
 377              * Ok, now see if we need adjust window size because
 378              * initial insets were wrong (most likely they were).
 379              */
 380             Insets correction = difference(correctWM, currentInsets);
 381             insLog.finest("Corrention {0}", correction);
 382             if (!isNull(correction)) {
 383                 currentInsets = copy(correctWM);
 384                 applyGuessedInsets();
 385 
 386                 //Fix for 6318109: PIT: Min Size is not honored properly when a
 387                 //smaller size is specified in setSize(), XToolkit
 388                 //update minimum size hints
 389                 updateMinSizeHints();
 390             }
 391             if (insLog.isLoggable(PlatformLogger.FINER)) {
 392                 insLog.finer("Dimensions before reparent: " + dimensions);
 393             }
 394 
 395             dimensions.setInsets(getRealInsets());
 396             insets_corrected = true;
 397 
 398             if (isMaximized()) {
 399                 return;
 400             }
 401 
 402             /*
 403              * If this window has been sized by a pack() we need
 404              * to keep the interior geometry intact.  Since pack()
 405              * computed width and height with wrong insets, we
 406              * must adjust the target dimensions appropriately.
 407              */
 408             if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
 409                 reshape(dimensions, SET_BOUNDS, false);
 410             } else {
 411                 reshape(dimensions, SET_SIZE, false);
 412             }
 413         } finally {


 726 
 727         Point newLocation = targetBounds.getLocation();
 728         if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
 729             // Location, Client size + insets
 730             newLocation = new Point(xe.get_x() - currentInsets.left, xe.get_y() - currentInsets.top);
 731         } else {
 732             // ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
 733             // a window is resized but the client can not tell if the window was
 734             // moved or not. The client should consider the position as unkown
 735             // and use TranslateCoordinates to find the actual position.
 736             //
 737             // TODO this should be the default for every case.
 738             switch (XWM.getWMID()) {
 739                 case XWM.CDE_WM:
 740                 case XWM.MOTIF_WM:
 741                 case XWM.METACITY_WM:
 742                 case XWM.MUTTER_WM:
 743                 case XWM.SAWFISH_WM:
 744                 {
 745                     Point xlocation = queryXLocation();
 746                     if (log.isLoggable(PlatformLogger.FINE)) {
 747                         log.fine("New X location: {0}", xlocation);
 748                     }
 749                     if (xlocation != null) {
 750                         newLocation = xlocation;
 751                     }
 752                     break;
 753                 }
 754                 default:
 755                     break;
 756             }
 757         }
 758 
 759         WindowDimensions newDimensions =
 760                 new WindowDimensions(newLocation,
 761                 new Dimension(xe.get_width(), xe.get_height()),
 762                 copy(currentInsets),
 763                 true);
 764 
 765         insLog.finer("Insets are {0}, new dimensions {1}",
 766                      currentInsets, newDimensions);
 767 
 768         checkIfOnNewScreen(newDimensions.getBounds());


 781     private void checkShellRectSize(Rectangle shellRect) {
 782         shellRect.width = Math.max(MIN_SIZE, shellRect.width);
 783         shellRect.height = Math.max(MIN_SIZE, shellRect.height);
 784     }
 785 
 786     private void checkShellRectPos(Rectangle shellRect) {
 787         int wm = XWM.getWMID();
 788         if (wm == XWM.MOTIF_WM || wm == XWM.CDE_WM) {
 789             if (shellRect.x == 0 && shellRect.y == 0) {
 790                 shellRect.x = shellRect.y = 1;
 791             }
 792         }
 793     }
 794 
 795     private void checkShellRect(Rectangle shellRect) {
 796         checkShellRectSize(shellRect);
 797         checkShellRectPos(shellRect);
 798     }
 799 
 800     public void setShellBounds(Rectangle rec) {
 801         if (insLog.isLoggable(PlatformLogger.FINE)) {
 802             insLog.fine("Setting shell bounds on " + this + " to " + rec);
 803         }
 804         XToolkit.awtLock();
 805         try {
 806             updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 807             XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
 808             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y);
 809         }
 810         finally {
 811             XToolkit.awtUnlock();
 812         }
 813     }
 814     public void setShellSize(Rectangle rec) {
 815         if (insLog.isLoggable(PlatformLogger.FINE)) {
 816             insLog.fine("Setting shell size on " + this + " to " + rec);
 817         }
 818         XToolkit.awtLock();
 819         try {
 820             updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 821             XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
 822         }
 823         finally {
 824             XToolkit.awtUnlock();
 825         }
 826     }
 827     public void setShellPosition(Rectangle rec) {
 828         if (insLog.isLoggable(PlatformLogger.FINE)) {
 829             insLog.fine("Setting shell position on " + this + " to " + rec);
 830         }
 831         XToolkit.awtLock();
 832         try {
 833             updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 834             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y);
 835         }
 836         finally {
 837             XToolkit.awtUnlock();
 838         }
 839     }
 840 
 841     void initResizability() {
 842         setResizable(winAttr.initialResizability);
 843     }
 844     public void setResizable(boolean resizable) {
 845         int fs = winAttr.functions;
 846         if (!isResizable() && resizable) {
 847             currentInsets = new Insets(0, 0, 0, 0);
 848             resetWMSetInsets();
 849             if (!isEmbedded()) {
 850                 setReparented(false);


1013             } else if (cl.get_data(0) == wm_take_focus.getAtom()) {
1014                 handleWmTakeFocus(cl);
1015             }
1016         }
1017     }
1018 
1019     private void handleWmTakeFocus(XClientMessageEvent cl) {
1020         focusLog.fine("WM_TAKE_FOCUS on {0}", this);
1021         requestWindowFocus(cl.get_data(1), true);
1022     }
1023 
1024     /**
1025      * Requests focus to this decorated top-level by requesting X input focus
1026      * to the shell window.
1027      */
1028     protected void requestXFocus(long time, boolean timeProvided) {
1029         // We have proxied focus mechanism - instead of shell the focus is held
1030         // by "proxy" - invisible mapped window. When we want to set X input focus to
1031         // toplevel set it on proxy instead.
1032         if (focusProxy == null) {
1033             if (focusLog.isLoggable(PlatformLogger.WARNING)) {
1034                 focusLog.warning("Focus proxy is null for " + this);
1035             }
1036         } else {
1037             if (focusLog.isLoggable(PlatformLogger.FINE)) {
1038                 focusLog.fine("Requesting focus to proxy: " + focusProxy);
1039             }
1040             if (timeProvided) {
1041                 focusProxy.xRequestFocus(time);
1042             } else {
1043                 focusProxy.xRequestFocus();
1044             }
1045         }
1046     }
1047 
1048     XFocusProxyWindow getFocusProxy() {
1049         return focusProxy;
1050     }
1051 
1052     public void handleQuit() {
1053         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
1054     }
1055 
1056     final void dumpMe() {
1057         System.err.println(">>> Peer: " + x + ", " + y + ", " + width + ", " + height);
1058     }
1059 


1136         while (toFocus.nextTransientFor != null) {
1137             toFocus = toFocus.nextTransientFor;
1138         }
1139         if (toFocus == null || !toFocus.focusAllowedFor()) {
1140             // This might change when WM will have property to determine focus policy.
1141             // Right now, because policy is unknown we can't be sure we succedded
1142             return false;
1143         }
1144         if (this == toFocus) {
1145             if (isWMStateNetHidden()) {
1146                 focusLog.fine("The window is unmapped, so rejecting the request");
1147                 return false;
1148             }
1149             if (target == activeWindow && target != focusedWindow) {
1150                 // Happens when an owned window is currently focused
1151                 focusLog.fine("Focus is on child window - transfering it back to the owner");
1152                 handleWindowFocusInSync(-1);
1153                 return true;
1154             }
1155             Window realNativeFocusedWindow = XWindowPeer.getNativeFocusedWindow();
1156             if (focusLog.isLoggable(PlatformLogger.FINEST)) {
1157                 focusLog.finest("Real native focused window: " + realNativeFocusedWindow +
1158                             "\nKFM's focused window: " + focusedWindow);
1159             }
1160 
1161             // See 6522725, 6613426.
1162             if (target == realNativeFocusedWindow) {
1163                 if (focusLog.isLoggable(PlatformLogger.FINE)) {
1164                     focusLog.fine("The window is already natively focused.");
1165                 }
1166                 return true;
1167             }
1168         }
1169         if (focusLog.isLoggable(PlatformLogger.FINE)) {
1170             focusLog.fine("Requesting focus to " + (this == toFocus ? "this window" : toFocus));
1171         }
1172 
1173         if (timeProvided) {
1174             toFocus.requestXFocus(time);
1175         } else {
1176             toFocus.requestXFocus();
1177         }
1178         return (this == toFocus);
1179     }
1180 
1181     XWindowPeer actualFocusedWindow = null;
1182     void setActualFocusedWindow(XWindowPeer actualFocusedWindow) {
1183         synchronized(getStateLock()) {
1184             this.actualFocusedWindow = actualFocusedWindow;
1185         }
1186     }
1187 
1188     boolean requestWindowFocus(XWindowPeer actualFocusedWindow,
1189                                long time, boolean timeProvided)
1190     {
1191         setActualFocusedWindow(actualFocusedWindow);