239
240 platformWindow.dispose();
241 super.disposeImpl();
242 }
243
244 @Override
245 protected void setVisibleImpl(final boolean visible) {
246 if (!visible && warningWindow != null) {
247 warningWindow.setVisible(false, false);
248 }
249 updateFocusableWindowState();
250 super.setVisibleImpl(visible);
251 // TODO: update graphicsConfig, see 4868278
252 platformWindow.setVisible(visible);
253 if (isSimpleWindow()) {
254 KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
255 if (visible) {
256 if (!getTarget().isAutoRequestFocus()) {
257 return;
258 } else {
259 requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
260 }
261 // Focus the owner in case this window is focused.
262 } else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
263 // Transfer focus to the owner.
264 LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
265 if (owner != null) {
266 owner.requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
267 }
268 }
269 }
270 }
271
272 @Override
273 public final GraphicsConfiguration getGraphicsConfiguration() {
274 synchronized (getStateLock()) {
275 return graphicsConfig;
276 }
277 }
278
279 @Override
280 public boolean updateGraphicsData(GraphicsConfiguration gc) {
281 setGraphicsConfig(gc);
282 return false;
283 }
284
285 protected final Graphics getOnscreenGraphics(Color fg, Color bg, Font f) {
286 if (getSurfaceData() == null) {
831 if (id == MouseEvent.MOUSE_PRESSED) {
832
833 // Ungrab only if this window is not an owned window of the grabbing one.
834 if (!isGrabbing() && grabbingWindow != null &&
835 !grabbingWindow.isOneOfOwnersOf(this))
836 {
837 grabbingWindow.ungrab();
838 }
839 if (otherButtonsPressed == 0) {
840 mouseClickButtons = eventButtonMask;
841 } else {
842 mouseClickButtons |= eventButtonMask;
843 }
844
845 // The window should be focused on mouse click. If it gets activated by the native platform,
846 // this request will be no op. It will take effect when:
847 // 1. A simple not focused window is clicked.
848 // 2. An active but not focused owner frame/dialog is clicked.
849 // The mouse event then will trigger a focus request "in window" to the component, so the window
850 // should gain focus before.
851 requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
852
853 mouseDownTarget[targetIdx] = targetPeer;
854 } else if (id == MouseEvent.MOUSE_DRAGGED) {
855 // Cocoa dragged event has the information about which mouse
856 // button is being dragged. Use it to determine the peer that
857 // should receive the dragged event.
858 targetPeer = mouseDownTarget[targetIdx];
859 mouseClickButtons &= ~modifiers;
860 } else if (id == MouseEvent.MOUSE_RELEASED) {
861 // TODO: currently, mouse released event goes to the same component
862 // that received corresponding mouse pressed event. For most cases,
863 // it's OK, however, we need to make sure that our behavior is consistent
864 // with 1.6 for cases where component in question have been
865 // hidden/removed in between of mouse pressed/released events.
866 targetPeer = mouseDownTarget[targetIdx];
867
868 if ((modifiers & eventButtonMask) == 0) {
869 mouseDownTarget[targetIdx] = null;
870 }
871
1180 if (insets.equals(newInsets)) {
1181 return false;
1182 }
1183 insets = newInsets;
1184 }
1185 return true;
1186 }
1187
1188 public static LWWindowPeer getWindowUnderCursor() {
1189 return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null;
1190 }
1191
1192 public static LWComponentPeer<?, ?> getPeerUnderCursor() {
1193 return lastCommonMouseEventPeer;
1194 }
1195
1196 /*
1197 * Requests platform to set native focus on a frame/dialog.
1198 * In case of a simple window, triggers appropriate java focus change.
1199 */
1200 public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
1201 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
1202 focusLog.fine("requesting native focus to " + this);
1203 }
1204
1205 if (!focusAllowedFor()) {
1206 focusLog.fine("focus is not allowed");
1207 return false;
1208 }
1209
1210 if (platformWindow.rejectFocusRequest(cause)) {
1211 return false;
1212 }
1213
1214 AppContext targetAppContext = AWTAccessor.getComponentAccessor().getAppContext(getTarget());
1215 KeyboardFocusManager kfm = AWTAccessor.getKeyboardFocusManagerAccessor()
1216 .getCurrentKeyboardFocusManager(targetAppContext);
1217 Window currentActive = kfm.getActiveWindow();
1218
1219
1220 Window opposite = LWKeyboardFocusManagerPeer.getInstance().
|
239
240 platformWindow.dispose();
241 super.disposeImpl();
242 }
243
244 @Override
245 protected void setVisibleImpl(final boolean visible) {
246 if (!visible && warningWindow != null) {
247 warningWindow.setVisible(false, false);
248 }
249 updateFocusableWindowState();
250 super.setVisibleImpl(visible);
251 // TODO: update graphicsConfig, see 4868278
252 platformWindow.setVisible(visible);
253 if (isSimpleWindow()) {
254 KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
255 if (visible) {
256 if (!getTarget().isAutoRequestFocus()) {
257 return;
258 } else {
259 requestWindowFocus(FocusEvent.Cause.ACTIVATION);
260 }
261 // Focus the owner in case this window is focused.
262 } else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
263 // Transfer focus to the owner.
264 LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
265 if (owner != null) {
266 owner.requestWindowFocus(FocusEvent.Cause.ACTIVATION);
267 }
268 }
269 }
270 }
271
272 @Override
273 public final GraphicsConfiguration getGraphicsConfiguration() {
274 synchronized (getStateLock()) {
275 return graphicsConfig;
276 }
277 }
278
279 @Override
280 public boolean updateGraphicsData(GraphicsConfiguration gc) {
281 setGraphicsConfig(gc);
282 return false;
283 }
284
285 protected final Graphics getOnscreenGraphics(Color fg, Color bg, Font f) {
286 if (getSurfaceData() == null) {
831 if (id == MouseEvent.MOUSE_PRESSED) {
832
833 // Ungrab only if this window is not an owned window of the grabbing one.
834 if (!isGrabbing() && grabbingWindow != null &&
835 !grabbingWindow.isOneOfOwnersOf(this))
836 {
837 grabbingWindow.ungrab();
838 }
839 if (otherButtonsPressed == 0) {
840 mouseClickButtons = eventButtonMask;
841 } else {
842 mouseClickButtons |= eventButtonMask;
843 }
844
845 // The window should be focused on mouse click. If it gets activated by the native platform,
846 // this request will be no op. It will take effect when:
847 // 1. A simple not focused window is clicked.
848 // 2. An active but not focused owner frame/dialog is clicked.
849 // The mouse event then will trigger a focus request "in window" to the component, so the window
850 // should gain focus before.
851 requestWindowFocus(FocusEvent.Cause.MOUSE_EVENT);
852
853 mouseDownTarget[targetIdx] = targetPeer;
854 } else if (id == MouseEvent.MOUSE_DRAGGED) {
855 // Cocoa dragged event has the information about which mouse
856 // button is being dragged. Use it to determine the peer that
857 // should receive the dragged event.
858 targetPeer = mouseDownTarget[targetIdx];
859 mouseClickButtons &= ~modifiers;
860 } else if (id == MouseEvent.MOUSE_RELEASED) {
861 // TODO: currently, mouse released event goes to the same component
862 // that received corresponding mouse pressed event. For most cases,
863 // it's OK, however, we need to make sure that our behavior is consistent
864 // with 1.6 for cases where component in question have been
865 // hidden/removed in between of mouse pressed/released events.
866 targetPeer = mouseDownTarget[targetIdx];
867
868 if ((modifiers & eventButtonMask) == 0) {
869 mouseDownTarget[targetIdx] = null;
870 }
871
1180 if (insets.equals(newInsets)) {
1181 return false;
1182 }
1183 insets = newInsets;
1184 }
1185 return true;
1186 }
1187
1188 public static LWWindowPeer getWindowUnderCursor() {
1189 return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null;
1190 }
1191
1192 public static LWComponentPeer<?, ?> getPeerUnderCursor() {
1193 return lastCommonMouseEventPeer;
1194 }
1195
1196 /*
1197 * Requests platform to set native focus on a frame/dialog.
1198 * In case of a simple window, triggers appropriate java focus change.
1199 */
1200 public boolean requestWindowFocus(FocusEvent.Cause cause) {
1201 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
1202 focusLog.fine("requesting native focus to " + this);
1203 }
1204
1205 if (!focusAllowedFor()) {
1206 focusLog.fine("focus is not allowed");
1207 return false;
1208 }
1209
1210 if (platformWindow.rejectFocusRequest(cause)) {
1211 return false;
1212 }
1213
1214 AppContext targetAppContext = AWTAccessor.getComponentAccessor().getAppContext(getTarget());
1215 KeyboardFocusManager kfm = AWTAccessor.getKeyboardFocusManagerAccessor()
1216 .getCurrentKeyboardFocusManager(targetAppContext);
1217 Window currentActive = kfm.getActiveWindow();
1218
1219
1220 Window opposite = LWKeyboardFocusManagerPeer.getInstance().
|