< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java

Print this page




 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 


1182             if (insets.equals(newInsets)) {
1183                 return false;
1184             }
1185             insets = newInsets;
1186         }
1187         return true;
1188     }
1189 
1190     public static LWWindowPeer getWindowUnderCursor() {
1191         return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null;
1192     }
1193 
1194     public static LWComponentPeer<?, ?> getPeerUnderCursor() {
1195         return lastCommonMouseEventPeer;
1196     }
1197 
1198     /*
1199      * Requests platform to set native focus on a frame/dialog.
1200      * In case of a simple window, triggers appropriate java focus change.
1201      */
1202     public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
1203         if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
1204             focusLog.fine("requesting native focus to " + this);
1205         }
1206 
1207         if (!focusAllowedFor()) {
1208             focusLog.fine("focus is not allowed");
1209             return false;
1210         }
1211 
1212         if (platformWindow.rejectFocusRequest(cause)) {
1213             return false;
1214         }
1215 
1216         AppContext targetAppContext = AWTAccessor.getComponentAccessor().getAppContext(getTarget());
1217         KeyboardFocusManager kfm = AWTAccessor.getKeyboardFocusManagerAccessor()
1218                 .getCurrentKeyboardFocusManager(targetAppContext);
1219         Window currentActive = kfm.getActiveWindow();
1220 
1221 
1222         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 


1182             if (insets.equals(newInsets)) {
1183                 return false;
1184             }
1185             insets = newInsets;
1186         }
1187         return true;
1188     }
1189 
1190     public static LWWindowPeer getWindowUnderCursor() {
1191         return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null;
1192     }
1193 
1194     public static LWComponentPeer<?, ?> getPeerUnderCursor() {
1195         return lastCommonMouseEventPeer;
1196     }
1197 
1198     /*
1199      * Requests platform to set native focus on a frame/dialog.
1200      * In case of a simple window, triggers appropriate java focus change.
1201      */
1202     public boolean requestWindowFocus(FocusEvent.Cause cause) {
1203         if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
1204             focusLog.fine("requesting native focus to " + this);
1205         }
1206 
1207         if (!focusAllowedFor()) {
1208             focusLog.fine("focus is not allowed");
1209             return false;
1210         }
1211 
1212         if (platformWindow.rejectFocusRequest(cause)) {
1213             return false;
1214         }
1215 
1216         AppContext targetAppContext = AWTAccessor.getComponentAccessor().getAppContext(getTarget());
1217         KeyboardFocusManager kfm = AWTAccessor.getKeyboardFocusManagerAccessor()
1218                 .getCurrentKeyboardFocusManager(targetAppContext);
1219         Window currentActive = kfm.getActiveWindow();
1220 
1221 
1222         Window opposite = LWKeyboardFocusManagerPeer.getInstance().


< prev index next >