1055 XToolkit.XSync();
1056 XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), window.getShell(),
1057 shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height);
1058 }
1059 if (!justChangeSize) { /* update decorations */
1060 setShellDecor(window);
1061 }
1062 } finally {
1063 XToolkit.awtUnlock();
1064 }
1065 }
1066
1067 /*****************************************************************************\
1068 * Protocols support
1069 */
1070 private HashMap<Class<?>, Collection<?>> protocolsMap = new HashMap<Class<?>, Collection<?>>();
1071 /**
1072 * Returns all protocols supporting given protocol interface
1073 */
1074 <T> Collection<T> getProtocols(Class<T> protocolInterface) {
1075 Collection<T> res = (Collection<T>) protocolsMap.get(protocolInterface);
1076 if (res != null) {
1077 return res;
1078 } else {
1079 return new LinkedList<T>();
1080 }
1081 }
1082
1083 private <T> void addProtocol(Class<T> protocolInterface, T protocol) {
1084 Collection<T> protocols = getProtocols(protocolInterface);
1085 protocols.add(protocol);
1086 protocolsMap.put(protocolInterface, protocols);
1087 }
1088
1089 boolean supportsDynamicLayout() {
1090 int wm = getWMID();
1091 switch (wm) {
1092 case XWM.ENLIGHTEN_WM:
1093 case XWM.KDE2_WM:
1094 case XWM.SAWFISH_WM:
1114 */
1115 boolean supportsExtendedState(int state) {
1116 switch (state) {
1117 case Frame.MAXIMIZED_VERT:
1118 case Frame.MAXIMIZED_HORIZ:
1119 /*
1120 * WMs that talk NET/WIN protocol, but do not support
1121 * unidirectional maximization.
1122 */
1123 if (getWMID() == METACITY_WM) {
1124 /* "This is a deliberate policy decision." -hp */
1125 return false;
1126 }
1127 /* FALLTROUGH */
1128 case Frame.MAXIMIZED_BOTH:
1129 for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
1130 if (proto.supportsState(state)) {
1131 return true;
1132 }
1133 }
1134 default:
1135 return false;
1136 }
1137 }
1138
1139 /*****************************************************************************\
1140 *
1141 * Reading state from different protocols
1142 *
1143 \*****************************************************************************/
1144
1145
1146 int getExtendedState(XWindowPeer window) {
1147 int state = 0;
1148 for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
1149 state |= proto.getState(window);
1150 }
1151 if (state != 0) {
1152 return state;
1153 } else {
1303 }
1304 if (net_protocol.doLayerProtocol()) {
1305 addProtocol(XLayerProtocol.class, net_protocol);
1306 }
1307 }
1308 }
1309
1310 XWINProtocol win = g_win_protocol;
1311 if (win != null) {
1312 if (win.active()) {
1313 if (win.doStateProtocol()) {
1314 addProtocol(XStateProtocol.class, win);
1315 }
1316 if (win.doLayerProtocol()) {
1317 addProtocol(XLayerProtocol.class, win);
1318 }
1319 }
1320 }
1321 }
1322
1323 HashMap storedInsets = new HashMap();
1324 Insets guessInsets(XDecoratedPeer window) {
1325 Insets res = (Insets)storedInsets.get(window.getClass());
1326 if (res == null) {
1327 switch (WMID) {
1328 case ENLIGHTEN_WM:
1329 res = new Insets(19, 4, 4, 4);
1330 break;
1331 case CDE_WM:
1332 res = new Insets(28, 6, 6, 6);
1333 break;
1334 case NO_WM:
1335 case LG3D_WM:
1336 res = zeroInsets;
1337 break;
1338 case MOTIF_WM:
1339 case OPENLOOK_WM:
1340 default:
1341 res = defaultInsets;
1342 }
1343 }
1344 if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
1345 insLog.finest("WM guessed insets: " + res);
|
1055 XToolkit.XSync();
1056 XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), window.getShell(),
1057 shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height);
1058 }
1059 if (!justChangeSize) { /* update decorations */
1060 setShellDecor(window);
1061 }
1062 } finally {
1063 XToolkit.awtUnlock();
1064 }
1065 }
1066
1067 /*****************************************************************************\
1068 * Protocols support
1069 */
1070 private HashMap<Class<?>, Collection<?>> protocolsMap = new HashMap<Class<?>, Collection<?>>();
1071 /**
1072 * Returns all protocols supporting given protocol interface
1073 */
1074 <T> Collection<T> getProtocols(Class<T> protocolInterface) {
1075 @SuppressWarnings("unchecked")
1076 Collection<T> res = (Collection<T>) protocolsMap.get(protocolInterface);
1077 if (res != null) {
1078 return res;
1079 } else {
1080 return new LinkedList<T>();
1081 }
1082 }
1083
1084 private <T> void addProtocol(Class<T> protocolInterface, T protocol) {
1085 Collection<T> protocols = getProtocols(protocolInterface);
1086 protocols.add(protocol);
1087 protocolsMap.put(protocolInterface, protocols);
1088 }
1089
1090 boolean supportsDynamicLayout() {
1091 int wm = getWMID();
1092 switch (wm) {
1093 case XWM.ENLIGHTEN_WM:
1094 case XWM.KDE2_WM:
1095 case XWM.SAWFISH_WM:
1115 */
1116 boolean supportsExtendedState(int state) {
1117 switch (state) {
1118 case Frame.MAXIMIZED_VERT:
1119 case Frame.MAXIMIZED_HORIZ:
1120 /*
1121 * WMs that talk NET/WIN protocol, but do not support
1122 * unidirectional maximization.
1123 */
1124 if (getWMID() == METACITY_WM) {
1125 /* "This is a deliberate policy decision." -hp */
1126 return false;
1127 }
1128 /* FALLTROUGH */
1129 case Frame.MAXIMIZED_BOTH:
1130 for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
1131 if (proto.supportsState(state)) {
1132 return true;
1133 }
1134 }
1135 /* FALLTROUGH */
1136 default:
1137 return false;
1138 }
1139 }
1140
1141 /*****************************************************************************\
1142 *
1143 * Reading state from different protocols
1144 *
1145 \*****************************************************************************/
1146
1147
1148 int getExtendedState(XWindowPeer window) {
1149 int state = 0;
1150 for (XStateProtocol proto : getProtocols(XStateProtocol.class)) {
1151 state |= proto.getState(window);
1152 }
1153 if (state != 0) {
1154 return state;
1155 } else {
1305 }
1306 if (net_protocol.doLayerProtocol()) {
1307 addProtocol(XLayerProtocol.class, net_protocol);
1308 }
1309 }
1310 }
1311
1312 XWINProtocol win = g_win_protocol;
1313 if (win != null) {
1314 if (win.active()) {
1315 if (win.doStateProtocol()) {
1316 addProtocol(XStateProtocol.class, win);
1317 }
1318 if (win.doLayerProtocol()) {
1319 addProtocol(XLayerProtocol.class, win);
1320 }
1321 }
1322 }
1323 }
1324
1325 HashMap<Class<?>, Insets> storedInsets = new HashMap<>();
1326 Insets guessInsets(XDecoratedPeer window) {
1327 Insets res = storedInsets.get(window.getClass());
1328 if (res == null) {
1329 switch (WMID) {
1330 case ENLIGHTEN_WM:
1331 res = new Insets(19, 4, 4, 4);
1332 break;
1333 case CDE_WM:
1334 res = new Insets(28, 6, 6, 6);
1335 break;
1336 case NO_WM:
1337 case LG3D_WM:
1338 res = zeroInsets;
1339 break;
1340 case MOTIF_WM:
1341 case OPENLOOK_WM:
1342 default:
1343 res = defaultInsets;
1344 }
1345 }
1346 if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
1347 insLog.finest("WM guessed insets: " + res);
|