804 // first, check if _NET_WM_STRUT or _NET_WM_STRUT_PARTIAL are present 805 // if both are set on the window, _NET_WM_STRUT_PARTIAL is used (see _NET spec) 806 boolean strutPresent = XA_NET_WM_STRUT_PARTIAL.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4); 807 if (!strutPresent) 808 { 809 strutPresent = XA_NET_WM_STRUT.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4); 810 } 811 if (strutPresent) 812 { 813 // second, verify that window is located on the proper screen 814 Rectangle windowBounds = XlibUtil.getWindowGeometry(window); 815 if (windowLevel > 1) 816 { 817 windowBounds = XlibUtil.translateCoordinates(window, root, windowBounds); 818 } 819 // if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect 820 // if the struts area intersects with screenBounds, however some window 821 // managers don't set this hint correctly, so we just get intersection with windowBounds 822 if (windowBounds != null && windowBounds.intersects(screenBounds)) 823 { 824 insets.left = Math.max((int)Native.getLong(native_ptr, 0), insets.left); 825 insets.right = Math.max((int)Native.getLong(native_ptr, 1), insets.right); 826 insets.top = Math.max((int)Native.getLong(native_ptr, 2), insets.top); 827 insets.bottom = Math.max((int)Native.getLong(native_ptr, 3), insets.bottom); 828 } 829 } 830 } 831 finally 832 { 833 XlibWrapper.unsafe.freeMemory(native_ptr); 834 } 835 836 if (windowLevel < MAX_NESTED_LEVEL) 837 { 838 Set<Long> children = XlibUtil.getChildWindows(window); 839 for (long child : children) 840 { 841 search.add(child); 842 search.add(windowLevel + 1); 843 } 844 } 845 } 846 847 return insets; | 804 // first, check if _NET_WM_STRUT or _NET_WM_STRUT_PARTIAL are present 805 // if both are set on the window, _NET_WM_STRUT_PARTIAL is used (see _NET spec) 806 boolean strutPresent = XA_NET_WM_STRUT_PARTIAL.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4); 807 if (!strutPresent) 808 { 809 strutPresent = XA_NET_WM_STRUT.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4); 810 } 811 if (strutPresent) 812 { 813 // second, verify that window is located on the proper screen 814 Rectangle windowBounds = XlibUtil.getWindowGeometry(window); 815 if (windowLevel > 1) 816 { 817 windowBounds = XlibUtil.translateCoordinates(window, root, windowBounds); 818 } 819 // if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect 820 // if the struts area intersects with screenBounds, however some window 821 // managers don't set this hint correctly, so we just get intersection with windowBounds 822 if (windowBounds != null && windowBounds.intersects(screenBounds)) 823 { 824 int left = (int)Native.getLong(native_ptr, 0); 825 int right = (int)Native.getLong(native_ptr, 1); 826 int top = (int)Native.getLong(native_ptr, 2); 827 int bottom = (int)Native.getLong(native_ptr, 3); 828 829 /* 830 * struts could be relative to root window bounds, so 831 * make them relative to the screen bounds in this case 832 */ 833 left = rootBounds.x + left > screenBounds.x ? 834 rootBounds.x + left - screenBounds.x : 0; 835 right = rootBounds.x + rootBounds.width - right < 836 screenBounds.x + screenBounds.width ? 837 screenBounds.x + screenBounds.width - 838 (rootBounds.x + rootBounds.width - right) : 0; 839 top = rootBounds.y + top > screenBounds.y ? 840 rootBounds.y + top - screenBounds.y : 0; 841 bottom = rootBounds.y + rootBounds.height - bottom < 842 screenBounds.y + screenBounds.height ? 843 screenBounds.y + screenBounds.height - 844 (rootBounds.y + rootBounds.height - bottom) : 0; 845 846 insets.left = Math.max(left, insets.left); 847 insets.right = Math.max(right, insets.right); 848 insets.top = Math.max(top, insets.top); 849 insets.bottom = Math.max(bottom, insets.bottom); 850 } 851 } 852 } 853 finally 854 { 855 XlibWrapper.unsafe.freeMemory(native_ptr); 856 } 857 858 if (windowLevel < MAX_NESTED_LEVEL) 859 { 860 Set<Long> children = XlibUtil.getChildWindows(window); 861 for (long child : children) 862 { 863 search.add(child); 864 search.add(windowLevel + 1); 865 } 866 } 867 } 868 869 return insets; |