112 content = XContentWindow.createContent(this); 113 114 if (warningWindow != null) { 115 warningWindow.toFront(); 116 } 117 focusProxy = createFocusProxy(); 118 } 119 120 void setIconHints(java.util.List<IconInfo> icons) { 121 if (!XWM.getWM().setNetWMIcon(this, icons)) { 122 if (icons.size() > 0) { 123 if (iconWindow == null) { 124 iconWindow = new XIconWindow(this); 125 } 126 iconWindow.setIconImages(icons); 127 } 128 } 129 } 130 131 public void updateMinimumSize() { 132 super.updateMinimumSize(); 133 updateMinSizeHints(); 134 } 135 136 private void updateMinSizeHints() { 137 if (isResizable()) { 138 Dimension minimumSize = getTargetMinimumSize(); 139 if (minimumSize != null) { 140 Insets insets = getRealInsets(); 141 int minWidth = minimumSize.width - insets.left - insets.right; 142 int minHeight = minimumSize.height - insets.top - insets.bottom; 143 if (minWidth < 0) minWidth = 0; 144 if (minHeight < 0) minHeight = 0; 145 setSizeHints(XUtilConstants.PMinSize | (isLocationByPlatform()?0:(XUtilConstants.PPosition | XUtilConstants.USPosition)), 146 getX(), getY(), minWidth, minHeight); 147 if (isVisible()) { 148 Rectangle bounds = getShellBounds(); 149 int nw = (bounds.width < minWidth) ? minWidth : bounds.width; 150 int nh = (bounds.height < minHeight) ? minHeight : bounds.height; 151 if (nw != bounds.width || nh != bounds.height) { 152 setShellSize(new Rectangle(0, 0, nw, nh)); 153 } 287 if (changedAtom == null) { 288 wm_set_insets = XWM.getInsetsFromExtents(getWindow()); 289 } else { 290 wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom); 291 } 292 293 if (insLog.isLoggable(PlatformLogger.Level.FINER)) { 294 insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets); 295 } 296 297 if (wm_set_insets != null) { 298 wm_set_insets = copyAndScaleDown(wm_set_insets); 299 } 300 return wm_set_insets; 301 } 302 303 private void resetWMSetInsets() { 304 if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { 305 currentInsets = new Insets(0, 0, 0, 0); 306 wm_set_insets = null; 307 } 308 } 309 310 public void handlePropertyNotify(XEvent xev) { 311 super.handlePropertyNotify(xev); 312 313 XPropertyEvent ev = xev.get_xproperty(); 314 if( !insets_corrected && isReparented() && 315 XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { 316 int state = XWM.getWM().getState(this); 317 if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) { 318 // Stop ignoring ConfigureNotify because no extents will be sent 319 // by WM for initially maximized decorated window. 320 // Re-request window bounds to ensure actual dimensions and 321 // notify the target with the initial size. 322 insets_corrected = true; 323 XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), 324 getWindow(), 0, 0); 325 } 326 } 327 if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom() 328 || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom()) 329 { 330 if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { 331 getWMSetInsets(XAtom.get(ev.get_atom())); 332 } else { 333 if(!isReparented()) { 334 return; 335 } 336 wm_set_insets = null; 337 Insets in = getWMSetInsets(XAtom.get(ev.get_atom())); 338 if (isNull(in)) { 339 return; 340 } 341 if (!isEmbedded() && !isTargetUndecorated()) { 342 lastKnownInsets.put(getClass(), in); 343 } 344 if (!in.equals(dimensions.getInsets())) { 345 if (insets_corrected || isMaximized()) { 346 currentInsets = in; 347 insets_corrected = true; 348 // insets were changed by WM. To handle this situation 349 // re-request window bounds because the current 350 // dimensions may be not actual as well. 351 XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), 352 getWindow(), 0, 0); 353 } else { 354 // recalculate dimensions when window is just created 355 // and the initially guessed insets were wrong 356 handleCorrectInsets(in); 357 } 358 } else if (!insets_corrected || !dimensions.isClientSizeSet()) { 359 insets_corrected = true; 360 // initial insets were guessed correctly. Re-request 361 // frame bounds because they may be changed by WM if the 362 // initial window position overlapped desktop's toolbars. 363 // This should initiate the final ConfigureNotify upon which 364 // the target will be notified with the final size. 365 XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), 366 getWindow(), 0, 0); 367 } 368 } 369 } 370 } 371 372 long reparent_serial = 0; 373 374 public void handleReparentNotifyEvent(XEvent xev) { 375 XReparentEvent xe = xev.get_xreparent(); 376 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 377 insLog.fine(xe.toString()); 378 } 379 reparent_serial = xe.get_serial(); 380 XToolkit.awtLock(); 381 try { 382 long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); 383 384 if (isEmbedded()) { 385 setReparented(true); 386 insets_corrected = true; 387 return; 665 } 666 } else { 667 XWM.setShellNotResizable(this, newDimensions, shellRect, true); 668 if (op == SET_BOUNDS) { 669 setShellPosition(shellRect); 670 } 671 } 672 673 reconfigureContentWindow(newDimensions); 674 } finally { 675 XToolkit.awtUnlock(); 676 } 677 } 678 679 /** 680 * @param x, y, width, heith - dimensions of the window with insets 681 */ 682 private void reshape(int x, int y, int width, int height, int operation, 683 boolean userReshape) 684 { 685 Rectangle newRec; 686 boolean setClient = false; 687 WindowDimensions dims = new WindowDimensions(dimensions); 688 switch (operation & (~NO_EMBEDDED_CHECK)) { 689 case SET_LOCATION: 690 // Set location always sets bounds location. However, until the window is mapped we 691 // should use client coordinates 692 dims.setLocation(x, y); 693 break; 694 case SET_SIZE: 695 // Set size sets bounds size. However, until the window is mapped we 696 // should use client coordinates 697 dims.setSize(width, height); 698 break; 699 case SET_CLIENT_SIZE: { 700 // Sets client rect size. Width and height contain insets. 701 Insets in = currentInsets; 702 width -= in.left+in.right; 703 height -= in.top+in.bottom; 704 dims.setClientSize(width, height); 705 break; 706 } 707 case SET_BOUNDS: 708 default: 709 dims.setLocation(x, y); 710 dims.setSize(width, height); 711 break; 712 } 713 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 714 insLog.fine("For the operation {0} new dimensions are {1}", 715 operationToString(operation), dims); 716 } 717 718 reshape(dims, operation, userReshape); 719 } 720 721 // This method gets overriden in XFramePeer & XDialogPeer. 722 abstract boolean isTargetUndecorated(); 723 724 /** 725 * @see java.awt.peer.ComponentPeer#setBounds 726 */ 727 public void setBounds(int x, int y, int width, int height, int op) { 728 // TODO: Rewrite with WindowDimensions 729 reshape(x, y, width, height, op, true); 730 validateSurface(); 731 } 732 733 // Coordinates are that of the shell 734 void reconfigureContentWindow(WindowDimensions dims) { 735 if (content == null) { 736 insLog.fine("WARNING: Content window is null"); 737 return; 738 } 739 content.setContentBounds(dims); 740 } 741 742 boolean no_reparent_artifacts = false; 743 public void handleConfigureNotifyEvent(XEvent xev) { 744 if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM && !insets_corrected) { 745 return; 746 } 747 assert (SunToolkit.isAWTLockHeldByCurrentThread()); 748 XConfigureEvent xe = xev.get_xconfigure(); 749 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 750 insLog.fine("Configure notify {0}", xe); 751 } 752 753 // XXX: should really only consider synthetic events, but 754 if (isReparented()) { 755 configure_seen = true; 756 } 757 758 if (!isMaximized() 759 && (xe.get_serial() == reparent_serial || xe.get_window() != getShell()) 760 && !no_reparent_artifacts) 761 { 762 insLog.fine("- reparent artifact, skipping"); 763 return; 764 } 765 no_reparent_artifacts = false; 766 767 /** 768 * When there is a WM we receive some CN before being visible and after. 769 * We should skip all CN which are before being visible, because we assume 770 * the gravity is in action while it is not yet. 771 * 772 * When there is no WM we receive CN only _before_ being visible. 773 * We should process these CNs. 774 */ 775 if (!isVisible() && XWM.getWMID() != XWM.NO_WM) { 776 insLog.fine(" - not visible, skipping"); 777 return; 778 } 779 780 /* 781 * Some window managers configure before we are reparented and 782 * the send event flag is set! ugh... (Enlighetenment for one, 783 * possibly MWM as well). If we haven't been reparented yet 784 * this is just the WM shuffling us into position. Ignore 785 * it!!!! or we wind up in a bogus location. 786 */ 787 int runningWM = XWM.getWMID(); 788 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 789 insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}", 790 isReparented(), isVisible(), runningWM, getDecorations()); 791 } 792 if (!isReparented() && isVisible() && runningWM != XWM.NO_WM 793 && !XWM.isNonReparentingWM() 794 && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { 795 insLog.fine("- visible but not reparented, skipping"); 796 return; 797 } 798 //Last chance to correct insets 799 if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { 800 long parent = XlibUtil.getParentWindow(window); 801 Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; 802 if (insLog.isLoggable(PlatformLogger.Level.FINER)) { 803 if (correctWM != null) { 804 insLog.finer("Configure notify - insets : " + correctWM); 805 } else { 806 insLog.finer("Configure notify - insets are still not available"); 807 } 808 } 809 if (correctWM != null) { 810 handleCorrectInsets(copyAndScaleDown(correctWM)); 811 } else { 812 //Only one attempt to correct insets is made (to lower risk) 813 //if insets are still not available we simply set the flag 814 insets_corrected = true; 815 } 816 } 817 818 updateChildrenSizes(); 819 820 Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top); 821 WindowDimensions newDimensions = 822 new WindowDimensions(newLocation, 823 new Dimension(scaleDown(xe.get_width()), 824 scaleDown(xe.get_height())), 825 copy(currentInsets), true); 826 827 if (insLog.isLoggable(PlatformLogger.Level.FINER)) { 828 insLog.finer("Insets are {0}, new dimensions {1}", 829 currentInsets, newDimensions); 830 } 831 832 checkIfOnNewScreen(newDimensions.getBounds()); 833 834 Point oldLocation = getLocation(); 835 dimensions = newDimensions; 836 if (!newLocation.equals(oldLocation)) { 837 handleMoved(newDimensions); 838 } 839 reconfigureContentWindow(newDimensions); 840 updateChildrenSizes(); 841 842 repositionSecurityWarning(); 843 } 844 845 private void checkShellRectSize(Rectangle shellRect) { 846 shellRect.width = Math.max(MIN_SIZE, shellRect.width); 847 shellRect.height = Math.max(MIN_SIZE, shellRect.height); 848 } 849 850 private void checkShellRectPos(Rectangle shellRect) { 851 int wm = XWM.getWMID(); 852 if (wm == XWM.MOTIF_WM || wm == XWM.CDE_WM) { 853 if (shellRect.x == 0 && shellRect.y == 0) { 854 shellRect.x = shellRect.y = 1; 855 } 856 } 857 } 858 859 private void checkShellRect(Rectangle shellRect) { 860 checkShellRectSize(shellRect); 861 checkShellRectPos(shellRect); 862 } 892 } 893 public void setShellPosition(Rectangle rec) { 894 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 895 insLog.fine("Setting shell position on " + this + " to " + rec); 896 } 897 XToolkit.awtLock(); 898 try { 899 updateSizeHints(rec.x, rec.y, rec.width, rec.height); 900 XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), 901 scaleUp(rec.x), scaleUp(rec.y)); 902 } 903 finally { 904 XToolkit.awtUnlock(); 905 } 906 } 907 908 void initResizability() { 909 setResizable(winAttr.initialResizability); 910 } 911 public void setResizable(boolean resizable) { 912 int fs = winAttr.functions; 913 if (!isResizable() && resizable) { 914 resetWMSetInsets(); 915 if (!isEmbedded()) { 916 setReparented(false); 917 } 918 winAttr.isResizable = resizable; 919 if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { 920 fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); 921 } else { 922 fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); 923 } 924 winAttr.functions = fs; 925 XWM.setShellResizable(this); 926 } else if (isResizable() && !resizable) { 927 resetWMSetInsets(); 928 if (!isEmbedded()) { 929 setReparented(false); 930 } 931 winAttr.isResizable = resizable; 932 if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { 933 fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); 934 } else { 935 fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); 936 } 937 winAttr.functions = fs; 938 XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false); 939 } 940 } 941 942 Rectangle getShellBounds() { 943 return dimensions.getClientRect(); 944 } 945 946 public Rectangle getBounds() { 947 return dimensions.getBounds(); 948 } 949 950 public Dimension getSize() { 951 return dimensions.getSize(); 952 } 953 954 public int getX() { 955 return dimensions.getLocation().x; 956 } 957 958 public int getY() { | 112 content = XContentWindow.createContent(this); 113 114 if (warningWindow != null) { 115 warningWindow.toFront(); 116 } 117 focusProxy = createFocusProxy(); 118 } 119 120 void setIconHints(java.util.List<IconInfo> icons) { 121 if (!XWM.getWM().setNetWMIcon(this, icons)) { 122 if (icons.size() > 0) { 123 if (iconWindow == null) { 124 iconWindow = new XIconWindow(this); 125 } 126 iconWindow.setIconImages(icons); 127 } 128 } 129 } 130 131 public void updateMinimumSize() { 132 XToolkit.awtLock(); 133 try { 134 super.updateMinimumSize(); 135 updateMinSizeHints(); 136 } finally { 137 XToolkit.awtUnlock(); 138 } 139 } 140 141 private void updateMinSizeHints() { 142 if (isResizable()) { 143 Dimension minimumSize = getTargetMinimumSize(); 144 if (minimumSize != null) { 145 Insets insets = getRealInsets(); 146 int minWidth = minimumSize.width - insets.left - insets.right; 147 int minHeight = minimumSize.height - insets.top - insets.bottom; 148 if (minWidth < 0) minWidth = 0; 149 if (minHeight < 0) minHeight = 0; 150 setSizeHints(XUtilConstants.PMinSize | (isLocationByPlatform()?0:(XUtilConstants.PPosition | XUtilConstants.USPosition)), 151 getX(), getY(), minWidth, minHeight); 152 if (isVisible()) { 153 Rectangle bounds = getShellBounds(); 154 int nw = (bounds.width < minWidth) ? minWidth : bounds.width; 155 int nh = (bounds.height < minHeight) ? minHeight : bounds.height; 156 if (nw != bounds.width || nh != bounds.height) { 157 setShellSize(new Rectangle(0, 0, nw, nh)); 158 } 292 if (changedAtom == null) { 293 wm_set_insets = XWM.getInsetsFromExtents(getWindow()); 294 } else { 295 wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom); 296 } 297 298 if (insLog.isLoggable(PlatformLogger.Level.FINER)) { 299 insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets); 300 } 301 302 if (wm_set_insets != null) { 303 wm_set_insets = copyAndScaleDown(wm_set_insets); 304 } 305 return wm_set_insets; 306 } 307 308 private void resetWMSetInsets() { 309 if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { 310 currentInsets = new Insets(0, 0, 0, 0); 311 wm_set_insets = null; 312 } else { 313 insets_corrected = false; 314 } 315 } 316 317 public void handlePropertyNotify(XEvent xev) { 318 super.handlePropertyNotify(xev); 319 320 XPropertyEvent ev = xev.get_xproperty(); 321 if( !insets_corrected && isReparented() && 322 XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { 323 int state = XWM.getWM().getState(this); 324 if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) { 325 // Stop ignoring ConfigureNotify because no extents will be sent 326 // by WM for initially maximized decorated window. 327 // Re-request window bounds to ensure actual dimensions and 328 // notify the target with the initial size. 329 insets_corrected = true; 330 XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), 331 getWindow(), 0, 0); 332 } 333 } 334 if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom() 335 || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom()) 336 { 337 if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { 338 getWMSetInsets(XAtom.get(ev.get_atom())); 339 } else { 340 if (!isReparented()) { 341 return; 342 } 343 XToolkit.awtLock(); 344 try { 345 wm_set_insets = null; 346 Insets in = getWMSetInsets(XAtom.get(ev.get_atom())); 347 if (isNull(in)) { 348 return; 349 } 350 if (!isEmbedded() && !isTargetUndecorated()) { 351 lastKnownInsets.put(getClass(), in); 352 } 353 if (!in.equals(dimensions.getInsets())) { 354 if (insets_corrected || isMaximized()) { 355 currentInsets = in; 356 insets_corrected = true; 357 // insets were changed by WM. To handle this 358 // situation re-request window bounds because the 359 // current dimensions may be not actual as well. 360 XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), 361 getWindow(), 0, 0); 362 } else { 363 // recalculate dimensions when window is just 364 // created and the initially guessed insets were 365 // wrong 366 handleCorrectInsets(in); 367 } 368 } else if (!insets_corrected || 369 !dimensions.isClientSizeSet()) { 370 insets_corrected = true; 371 // initial insets were guessed correctly. Re-request 372 // frame bounds because they may be changed by WM if 373 // the initial window position overlapped desktop's 374 // toolbars. This should initiate the final 375 // ConfigureNotify upon which the target will be 376 // notified with the final size. 377 XlibWrapper.XConfigureWindow(XToolkit.getDisplay(), 378 getWindow(), 0, 0); 379 } 380 } finally { 381 XToolkit.awtUnlock(); 382 } 383 } 384 } 385 } 386 387 long reparent_serial = 0; 388 389 public void handleReparentNotifyEvent(XEvent xev) { 390 XReparentEvent xe = xev.get_xreparent(); 391 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 392 insLog.fine(xe.toString()); 393 } 394 reparent_serial = xe.get_serial(); 395 XToolkit.awtLock(); 396 try { 397 long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); 398 399 if (isEmbedded()) { 400 setReparented(true); 401 insets_corrected = true; 402 return; 680 } 681 } else { 682 XWM.setShellNotResizable(this, newDimensions, shellRect, true); 683 if (op == SET_BOUNDS) { 684 setShellPosition(shellRect); 685 } 686 } 687 688 reconfigureContentWindow(newDimensions); 689 } finally { 690 XToolkit.awtUnlock(); 691 } 692 } 693 694 /** 695 * @param x, y, width, heith - dimensions of the window with insets 696 */ 697 private void reshape(int x, int y, int width, int height, int operation, 698 boolean userReshape) 699 { 700 XToolkit.awtLock(); 701 try { 702 WindowDimensions dims = new WindowDimensions(dimensions); 703 switch (operation & (~NO_EMBEDDED_CHECK)) { 704 case SET_LOCATION: 705 // Set location always sets bounds location. However, until the window is mapped we 706 // should use client coordinates 707 dims.setLocation(x, y); 708 break; 709 case SET_SIZE: 710 // Set size sets bounds size. However, until the window is mapped we 711 // should use client coordinates 712 dims.setSize(width, height); 713 break; 714 case SET_CLIENT_SIZE: { 715 // Sets client rect size. Width and height contain insets. 716 Insets in = currentInsets; 717 width -= in.left + in.right; 718 height -= in.top + in.bottom; 719 dims.setClientSize(width, height); 720 break; 721 } 722 case SET_BOUNDS: 723 default: 724 dims.setLocation(x, y); 725 dims.setSize(width, height); 726 break; 727 } 728 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 729 insLog.fine("For the operation {0} new dimensions are {1}", 730 operationToString(operation), dims); 731 } 732 733 reshape(dims, operation, userReshape); 734 } finally { 735 XToolkit.awtUnlock(); 736 } 737 } 738 739 // This method gets overriden in XFramePeer & XDialogPeer. 740 abstract boolean isTargetUndecorated(); 741 742 /** 743 * @see java.awt.peer.ComponentPeer#setBounds 744 */ 745 public void setBounds(int x, int y, int width, int height, int op) { 746 // TODO: Rewrite with WindowDimensions 747 reshape(x, y, width, height, op, true); 748 validateSurface(); 749 } 750 751 // Coordinates are that of the shell 752 void reconfigureContentWindow(WindowDimensions dims) { 753 if (content == null) { 754 insLog.fine("WARNING: Content window is null"); 755 return; 756 } 757 content.setContentBounds(dims); 758 } 759 760 boolean no_reparent_artifacts = false; 761 public void handleConfigureNotifyEvent(XEvent xev) { 762 if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM && !insets_corrected) { 763 return; 764 } 765 assert (SunToolkit.isAWTLockHeldByCurrentThread()); 766 XConfigureEvent xe = xev.get_xconfigure(); 767 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 768 insLog.fine("Configure notify {0}", xe); 769 } 770 771 // XXX: should really only consider synthetic events, but 772 if (isReparented()) { 773 configure_seen = true; 774 } 775 XToolkit.awtLock(); 776 try { 777 if (!isMaximized() 778 && (xe.get_serial() == reparent_serial 779 || xe.get_window() != getShell()) 780 && !no_reparent_artifacts) { 781 insLog.fine("- reparent artifact, skipping"); 782 return; 783 } 784 no_reparent_artifacts = false; 785 786 /** 787 * When there is a WM we receive some CN before being visible and 788 * after. We should skip all CN which are before being visible, 789 * because we assume the gravity is in action while it is not yet. 790 * 791 * When there is no WM we receive CN only _before_ being visible. 792 * We should process these CNs. 793 */ 794 if (!isVisible() && XWM.getWMID() != XWM.NO_WM) { 795 insLog.fine(" - not visible, skipping"); 796 return; 797 } 798 799 /* 800 * Some window managers configure before we are reparented and 801 * the send event flag is set! ugh... (Enlighetenment for one, 802 * possibly MWM as well). If we haven't been reparented yet 803 * this is just the WM shuffling us into position. Ignore 804 * it!!!! or we wind up in a bogus location. 805 */ 806 int runningWM = XWM.getWMID(); 807 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 808 insLog.fine("reparented={0}, visible={1}, WM={2}, " + 809 "decorations={3}", isReparented(), isVisible(), 810 runningWM, getDecorations()); 811 } 812 if (!isReparented() && isVisible() && runningWM != XWM.NO_WM 813 && !XWM.isNonReparentingWM() && getDecorations() != 814 XWindowAttributesData.AWT_DECOR_NONE) { 815 insLog.fine("- visible but not reparented, skipping"); 816 return; 817 } 818 //Last chance to correct insets 819 if (!insets_corrected && getDecorations() != 820 XWindowAttributesData.AWT_DECOR_NONE) { 821 long parent = XlibUtil.getParentWindow(window); 822 Insets correctWM = (parent != -1) ? XWM.getWM(). 823 getInsets(this, window, parent) : null; 824 if (insLog.isLoggable(PlatformLogger.Level.FINER)) { 825 if (correctWM != null) { 826 insLog.finer("Configure notify - insets : " 827 + correctWM); 828 } else { 829 insLog.finer("Configure notify - insets are still " + 830 " not available"); 831 } 832 } 833 if (correctWM != null) { 834 handleCorrectInsets(copyAndScaleDown(correctWM)); 835 } else { 836 //Only one attempt to correct insets is made (to lower risk) 837 //if insets are still not available we simply set the flag 838 insets_corrected = true; 839 } 840 } 841 842 updateChildrenSizes(); 843 844 Point newLocation = getNewLocation(xe, currentInsets.left, 845 currentInsets.top); 846 WindowDimensions newDimensions = 847 new WindowDimensions(newLocation, 848 new Dimension(scaleDown(xe.get_width()), 849 scaleDown(xe.get_height())), 850 copy(currentInsets), true); 851 852 if (insLog.isLoggable(PlatformLogger.Level.FINER)) { 853 insLog.finer("Insets are {0}, new dimensions {1}", 854 currentInsets, newDimensions); 855 } 856 857 checkIfOnNewScreen(newDimensions.getBounds()); 858 859 Point oldLocation = getLocation(); 860 dimensions = newDimensions; 861 if (!newLocation.equals(oldLocation)) { 862 handleMoved(newDimensions); 863 } 864 reconfigureContentWindow(newDimensions); 865 updateChildrenSizes(); 866 867 repositionSecurityWarning(); 868 } finally { 869 XToolkit.awtUnlock(); 870 } 871 } 872 873 private void checkShellRectSize(Rectangle shellRect) { 874 shellRect.width = Math.max(MIN_SIZE, shellRect.width); 875 shellRect.height = Math.max(MIN_SIZE, shellRect.height); 876 } 877 878 private void checkShellRectPos(Rectangle shellRect) { 879 int wm = XWM.getWMID(); 880 if (wm == XWM.MOTIF_WM || wm == XWM.CDE_WM) { 881 if (shellRect.x == 0 && shellRect.y == 0) { 882 shellRect.x = shellRect.y = 1; 883 } 884 } 885 } 886 887 private void checkShellRect(Rectangle shellRect) { 888 checkShellRectSize(shellRect); 889 checkShellRectPos(shellRect); 890 } 920 } 921 public void setShellPosition(Rectangle rec) { 922 if (insLog.isLoggable(PlatformLogger.Level.FINE)) { 923 insLog.fine("Setting shell position on " + this + " to " + rec); 924 } 925 XToolkit.awtLock(); 926 try { 927 updateSizeHints(rec.x, rec.y, rec.width, rec.height); 928 XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), 929 scaleUp(rec.x), scaleUp(rec.y)); 930 } 931 finally { 932 XToolkit.awtUnlock(); 933 } 934 } 935 936 void initResizability() { 937 setResizable(winAttr.initialResizability); 938 } 939 public void setResizable(boolean resizable) { 940 XToolkit.awtLock(); 941 try { 942 int fs = winAttr.functions; 943 if (!isResizable() && resizable) { 944 resetWMSetInsets(); 945 if (!isEmbedded()) { 946 setReparented(false); 947 } 948 winAttr.isResizable = resizable; 949 if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { 950 fs &= ~(MWMConstants.MWM_FUNC_RESIZE 951 | MWMConstants.MWM_FUNC_MAXIMIZE); 952 } else { 953 fs |= (MWMConstants.MWM_FUNC_RESIZE 954 | MWMConstants.MWM_FUNC_MAXIMIZE); 955 } 956 winAttr.functions = fs; 957 XWM.setShellResizable(this); 958 } else if (isResizable() && !resizable) { 959 resetWMSetInsets(); 960 if (!isEmbedded()) { 961 setReparented(false); 962 } 963 winAttr.isResizable = resizable; 964 if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { 965 fs |= (MWMConstants.MWM_FUNC_RESIZE 966 | MWMConstants.MWM_FUNC_MAXIMIZE); 967 } else { 968 fs &= ~(MWMConstants.MWM_FUNC_RESIZE 969 | MWMConstants.MWM_FUNC_MAXIMIZE); 970 } 971 winAttr.functions = fs; 972 XWM.setShellNotResizable(this, dimensions, 973 XWM.getWMID() == XWM.UNITY_COMPIZ_WM && configure_seen ? 974 dimensions.getScreenBounds() : 975 dimensions.getBounds(), false); 976 } 977 } finally { 978 XToolkit.awtUnlock(); 979 } 980 } 981 982 Rectangle getShellBounds() { 983 return dimensions.getClientRect(); 984 } 985 986 public Rectangle getBounds() { 987 return dimensions.getBounds(); 988 } 989 990 public Dimension getSize() { 991 return dimensions.getSize(); 992 } 993 994 public int getX() { 995 return dimensions.getLocation().x; 996 } 997 998 public int getY() { |