1057 /* |
1057 /* |
1058 * Requests platform to set native focus on a frame/dialog. |
1058 * Requests platform to set native focus on a frame/dialog. |
1059 * In case of a simple window, triggers appropriate java focus change. |
1059 * In case of a simple window, triggers appropriate java focus change. |
1060 */ |
1060 */ |
1061 public boolean requestWindowFocus(CausedFocusEvent.Cause cause) { |
1061 public boolean requestWindowFocus(CausedFocusEvent.Cause cause) { |
1062 if (focusLog.isLoggable(PlatformLogger.FINE)) { |
1062 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
1063 focusLog.fine("requesting native focus to " + this); |
1063 focusLog.fine("requesting native focus to " + this); |
1064 } |
1064 } |
1065 |
1065 |
1066 if (!focusAllowedFor()) { |
1066 if (!focusAllowedFor()) { |
1067 focusLog.fine("focus is not allowed"); |
1067 focusLog.fine("focus is not allowed"); |
1083 LWWindowPeer owner = getOwnerFrameDialog(this); |
1083 LWWindowPeer owner = getOwnerFrameDialog(this); |
1084 |
1084 |
1085 // If owner is not natively active, request native |
1085 // If owner is not natively active, request native |
1086 // activation on it w/o sending events up to java. |
1086 // activation on it w/o sending events up to java. |
1087 if (owner != null && !owner.platformWindow.isActive()) { |
1087 if (owner != null && !owner.platformWindow.isActive()) { |
1088 if (focusLog.isLoggable(PlatformLogger.FINE)) { |
1088 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
1089 focusLog.fine("requesting native focus to the owner " + owner); |
1089 focusLog.fine("requesting native focus to the owner " + owner); |
1090 } |
1090 } |
1091 LWWindowPeer currentActivePeer = (currentActive != null ? |
1091 LWWindowPeer currentActivePeer = (currentActive != null ? |
1092 (LWWindowPeer)currentActive.getPeer() : null); |
1092 (LWWindowPeer)currentActive.getPeer() : null); |
1093 |
1093 |
1094 // Ensure the opposite is natively active and suppress sending events. |
1094 // Ensure the opposite is natively active and suppress sending events. |
1095 if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) { |
1095 if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) { |
1096 if (focusLog.isLoggable(PlatformLogger.FINE)) { |
1096 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
1097 focusLog.fine("the opposite is " + currentActivePeer); |
1097 focusLog.fine("the opposite is " + currentActivePeer); |
1098 } |
1098 } |
1099 currentActivePeer.skipNextFocusChange = true; |
1099 currentActivePeer.skipNextFocusChange = true; |
1100 } |
1100 } |
1101 owner.skipNextFocusChange = true; |
1101 owner.skipNextFocusChange = true; |
1148 |
1148 |
1149 /* |
1149 /* |
1150 * Changes focused window on java level. |
1150 * Changes focused window on java level. |
1151 */ |
1151 */ |
1152 protected void changeFocusedWindow(boolean becomesFocused, Window opposite) { |
1152 protected void changeFocusedWindow(boolean becomesFocused, Window opposite) { |
1153 if (focusLog.isLoggable(PlatformLogger.FINE)) { |
1153 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
1154 focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this); |
1154 focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this); |
1155 } |
1155 } |
1156 if (skipNextFocusChange) { |
1156 if (skipNextFocusChange) { |
1157 focusLog.fine("skipping focus change"); |
1157 focusLog.fine("skipping focus change"); |
1158 skipNextFocusChange = false; |
1158 skipNextFocusChange = false; |
1163 return; |
1163 return; |
1164 } |
1164 } |
1165 if (becomesFocused) { |
1165 if (becomesFocused) { |
1166 synchronized (getPeerTreeLock()) { |
1166 synchronized (getPeerTreeLock()) { |
1167 if (blocker != null) { |
1167 if (blocker != null) { |
1168 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
1168 if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) { |
1169 focusLog.finest("the window is blocked by " + blocker); |
1169 focusLog.finest("the window is blocked by " + blocker); |
1170 } |
1170 } |
1171 return; |
1171 return; |
1172 } |
1172 } |
1173 } |
1173 } |
1177 // - when the opposite (gaining focus) window is an owned/owner window. |
1177 // - when the opposite (gaining focus) window is an owned/owner window. |
1178 // - for a simple window in any case. |
1178 // - for a simple window in any case. |
1179 if (!becomesFocused && |
1179 if (!becomesFocused && |
1180 (isGrabbing() || getOwnerFrameDialog(grabbingWindow) == this)) |
1180 (isGrabbing() || getOwnerFrameDialog(grabbingWindow) == this)) |
1181 { |
1181 { |
1182 if (focusLog.isLoggable(PlatformLogger.FINE)) { |
1182 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
1183 focusLog.fine("ungrabbing on " + grabbingWindow); |
1183 focusLog.fine("ungrabbing on " + grabbingWindow); |
1184 } |
1184 } |
1185 // ungrab a simple window if its owner looses activation. |
1185 // ungrab a simple window if its owner looses activation. |
1186 grabbingWindow.ungrab(); |
1186 grabbingWindow.ungrab(); |
1187 } |
1187 } |