提交 482c09b4 编写于 作者: L lana

Merge

...@@ -598,29 +598,21 @@ public class LWWindowPeer ...@@ -598,29 +598,21 @@ public class LWWindowPeer
} }
/** /**
* Called by the delegate when any part of the window should be repainted. * Called by the {@code PlatformWindow} when any part of the window should
* be repainted.
*/ */
public void notifyExpose(final int x, final int y, final int w, final int h) { public final void notifyExpose(final Rectangle r) {
// TODO: there's a serious problem with Swing here: it handles repaintPeer(r);
// the exposition internally, so SwingPaintEventDispatcher always
// return null from createPaintEvent(). However, we flush the
// back buffer here unconditionally, so some flickering may appear.
// A possible solution is to split postPaintEvent() into two parts,
// and override that part which is only called after if
// createPaintEvent() returned non-null value and flush the buffer
// from the overridden method
flushOnscreenGraphics();
repaintPeer(new Rectangle(x, y, w, h));
} }
/** /**
* Called by the delegate when this window is moved/resized by user. * Called by the {@code PlatformWindow} when this window is moved/resized by
* There's no notifyReshape() in LWComponentPeer as the only * user. There's no notifyReshape() in LWComponentPeer as the only
* components which could be resized by user are top-level windows. * components which could be resized by user are top-level windows.
*/ */
public final void notifyReshape(int x, int y, int w, int h) { public final void notifyReshape(int x, int y, int w, int h) {
boolean moved = false; final boolean moved;
boolean resized = false; final boolean resized;
synchronized (getStateLock()) { synchronized (getStateLock()) {
moved = (x != sysX) || (y != sysY); moved = (x != sysX) || (y != sysY);
resized = (w != sysW) || (h != sysH); resized = (w != sysW) || (h != sysH);
...@@ -644,12 +636,13 @@ public class LWWindowPeer ...@@ -644,12 +636,13 @@ public class LWWindowPeer
flushOnscreenGraphics(); flushOnscreenGraphics();
} }
// Third, COMPONENT_MOVED/COMPONENT_RESIZED events // Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
if (moved) { if (moved) {
handleMove(x, y, true); handleMove(x, y, true);
} }
if (resized) { if (resized) {
handleResize(w, h,true); handleResize(w, h, true);
repaintPeer();
} }
} }
...@@ -682,8 +675,9 @@ public class LWWindowPeer ...@@ -682,8 +675,9 @@ public class LWWindowPeer
getLWToolkit().getCursorManager().updateCursorLater(this); getLWToolkit().getCursorManager().updateCursorLater(this);
} }
public void notifyActivation(boolean activation) { public void notifyActivation(boolean activation, LWWindowPeer opposite) {
changeFocusedWindow(activation); Window oppositeWindow = (opposite == null)? null : opposite.getTarget();
changeFocusedWindow(activation, oppositeWindow);
} }
// MouseDown in non-client area // MouseDown in non-client area
...@@ -1158,6 +1152,9 @@ public class LWWindowPeer ...@@ -1158,6 +1152,9 @@ public class LWWindowPeer
Window currentActive = KeyboardFocusManager. Window currentActive = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getActiveWindow(); getCurrentKeyboardFocusManager().getActiveWindow();
Window opposite = LWKeyboardFocusManagerPeer.getInstance().
getCurrentFocusedWindow();
// Make the owner active window. // Make the owner active window.
if (isSimpleWindow()) { if (isSimpleWindow()) {
LWWindowPeer owner = getOwnerFrameDialog(this); LWWindowPeer owner = getOwnerFrameDialog(this);
...@@ -1184,16 +1181,17 @@ public class LWWindowPeer ...@@ -1184,16 +1181,17 @@ public class LWWindowPeer
} }
// DKFM will synthesize all the focus/activation events correctly. // DKFM will synthesize all the focus/activation events correctly.
changeFocusedWindow(true); changeFocusedWindow(true, opposite);
return true; return true;
// In case the toplevel is active but not focused, change focus directly, // In case the toplevel is active but not focused, change focus directly,
// as requesting native focus on it will not have effect. // as requesting native focus on it will not have effect.
} else if (getTarget() == currentActive && !getTarget().hasFocus()) { } else if (getTarget() == currentActive && !getTarget().hasFocus()) {
changeFocusedWindow(true); changeFocusedWindow(true, opposite);
return true; return true;
} }
return platformWindow.requestWindowFocus(); return platformWindow.requestWindowFocus();
} }
...@@ -1223,7 +1221,7 @@ public class LWWindowPeer ...@@ -1223,7 +1221,7 @@ public class LWWindowPeer
/* /*
* Changes focused window on java level. * Changes focused window on java level.
*/ */
private void changeFocusedWindow(boolean becomesFocused) { private void changeFocusedWindow(boolean becomesFocused, Window opposite) {
if (focusLog.isLoggable(PlatformLogger.FINE)) { if (focusLog.isLoggable(PlatformLogger.FINE)) {
focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this); focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this);
} }
...@@ -1247,9 +1245,6 @@ public class LWWindowPeer ...@@ -1247,9 +1245,6 @@ public class LWWindowPeer
} }
} }
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
Window oppositeWindow = becomesFocused ? kfmPeer.getCurrentFocusedWindow() : null;
// Note, the method is not called: // Note, the method is not called:
// - when the opposite (gaining focus) window is an owned/owner window. // - when the opposite (gaining focus) window is an owned/owner window.
// - for a simple window in any case. // - for a simple window in any case.
...@@ -1261,10 +1256,11 @@ public class LWWindowPeer ...@@ -1261,10 +1256,11 @@ public class LWWindowPeer
grabbingWindow.ungrab(); grabbingWindow.ungrab();
} }
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null); kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null);
int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS; int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS;
WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, oppositeWindow, System.currentTimeMillis()); WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, opposite, System.currentTimeMillis());
// TODO: wrap in SequencedEvent // TODO: wrap in SequencedEvent
postEvent(windowEvent); postEvent(windowEvent);
......
...@@ -113,14 +113,14 @@ public class CEmbeddedFrame extends EmbeddedFrame { ...@@ -113,14 +113,14 @@ public class CEmbeddedFrame extends EmbeddedFrame {
public void handleFocusEvent(boolean focused) { public void handleFocusEvent(boolean focused) {
this.focused = focused; this.focused = focused;
if (parentWindowActive) { if (parentWindowActive) {
responder.handleWindowFocusEvent(focused); responder.handleWindowFocusEvent(focused, null);
} }
} }
public void handleWindowFocusEvent(boolean parentWindowActive) { public void handleWindowFocusEvent(boolean parentWindowActive) {
this.parentWindowActive = parentWindowActive; this.parentWindowActive = parentWindowActive;
if (focused) { if (focused) {
responder.handleWindowFocusEvent(parentWindowActive); responder.handleWindowFocusEvent(parentWindowActive, null);
} }
} }
......
...@@ -218,7 +218,7 @@ final class CPlatformResponder { ...@@ -218,7 +218,7 @@ final class CPlatformResponder {
} }
} }
void handleWindowFocusEvent(boolean gained) { void handleWindowFocusEvent(boolean gained, LWWindowPeer opposite) {
peer.notifyActivation(gained); peer.notifyActivation(gained, opposite);
} }
} }
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsConfig;
...@@ -202,12 +201,11 @@ public class CPlatformView extends CFRetainedResource { ...@@ -202,12 +201,11 @@ public class CPlatformView extends CFRetainedResource {
event.getCharactersIgnoringModifiers(), event.getKeyCode(), true); event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
} }
/**
* Called by the native delegate in layer backed view mode or in the simple
* NSView mode. See NSView.drawRect().
*/
private void deliverWindowDidExposeEvent() { private void deliverWindowDidExposeEvent() {
Rectangle r = peer.getBounds(); peer.notifyExpose(peer.getSize());
peer.notifyExpose(0, 0, r.width, r.height);
}
private void deliverWindowDidExposeEvent(float x, float y, float w, float h) {
peer.notifyExpose((int)x, (int)y, (int)w, (int)h);
} }
} }
...@@ -46,7 +46,7 @@ import com.apple.laf.*; ...@@ -46,7 +46,7 @@ import com.apple.laf.*;
import com.apple.laf.ClientPropertyApplicator.Property; import com.apple.laf.ClientPropertyApplicator.Property;
import com.sun.awt.AWTUtilities; import com.sun.awt.AWTUtilities;
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow { public final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h); private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data); private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr); private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
...@@ -199,7 +199,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -199,7 +199,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// In order to keep it up-to-date we will update them on // In order to keep it up-to-date we will update them on
// 1) setting native bounds via nativeSetBounds() call // 1) setting native bounds via nativeSetBounds() call
// 2) getting notification from the native level via deliverMoveResizeEvent() // 2) getting notification from the native level via deliverMoveResizeEvent()
private Rectangle nativeBounds; private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
private volatile boolean isFullScreenMode = false; private volatile boolean isFullScreenMode = false;
private Window target; private Window target;
...@@ -869,16 +869,24 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -869,16 +869,24 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
} }
} }
private void flushBuffers() {
if (isVisible() && !nativeBounds.isEmpty()) {
LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target);
}
}
/************************************************************* /*************************************************************
* Callbacks from the AWTWindow and AWTView objc classes. * Callbacks from the AWTWindow and AWTView objc classes.
*************************************************************/ *************************************************************/
private void deliverWindowFocusEvent(boolean gained){ private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
// Fix for 7150349: ingore "gained" notifications when the app is inactive. // Fix for 7150349: ingore "gained" notifications when the app is inactive.
if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) { if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
focusLogger.fine("the app is inactive, so the notification is ignored"); focusLogger.fine("the app is inactive, so the notification is ignored");
return; return;
} }
responder.handleWindowFocusEvent(gained);
LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
responder.handleWindowFocusEvent(gained, oppositePeer);
} }
private void deliverMoveResizeEvent(int x, int y, int width, int height) { private void deliverMoveResizeEvent(int x, int y, int width, int height) {
...@@ -886,10 +894,16 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -886,10 +894,16 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// move/resize notifications contain a bounds smaller than // move/resize notifications contain a bounds smaller than
// the whole screen and therefore we ignore the native notifications // the whole screen and therefore we ignore the native notifications
// and the content view itself creates correct synthetic notifications // and the content view itself creates correct synthetic notifications
if (isFullScreenMode) return; if (isFullScreenMode) {
return;
}
final Rectangle oldB = nativeBounds;
nativeBounds = new Rectangle(x, y, width, height); nativeBounds = new Rectangle(x, y, width, height);
peer.notifyReshape(x, y, width, height); peer.notifyReshape(x, y, width, height);
if (!oldB.getSize().equals(nativeBounds.getSize()) ) {
flushBuffers();
}
//TODO validateSurface already called from notifyReshape //TODO validateSurface already called from notifyReshape
validateSurface(); validateSurface();
} }
......
...@@ -150,6 +150,10 @@ public final class LWCToolkit extends LWToolkit { ...@@ -150,6 +150,10 @@ public final class LWCToolkit extends LWToolkit {
}); });
} }
public static LWCToolkit getLWCToolkit() {
return (LWCToolkit)Toolkit.getDefaultToolkit();
}
@Override @Override
protected PlatformWindow createPlatformWindow(PeerType peerType) { protected PlatformWindow createPlatformWindow(PeerType peerType) {
if (peerType == PeerType.EMBEDDEDFRAME) { if (peerType == PeerType.EMBEDDEDFRAME) {
...@@ -407,7 +411,6 @@ public final class LWCToolkit extends LWToolkit { ...@@ -407,7 +411,6 @@ public final class LWCToolkit extends LWToolkit {
return BUTTONS; return BUTTONS;
} }
@Override @Override
public boolean isTraySupported() { public boolean isTraySupported() {
return true; return true;
...@@ -489,6 +492,22 @@ public final class LWCToolkit extends LWToolkit { ...@@ -489,6 +492,22 @@ public final class LWCToolkit extends LWToolkit {
synchronized(ret) { return ret[0]; } synchronized(ret) { return ret[0]; }
} }
/**
* Just a wrapper for LWCToolkit.invokeAndWait. Posts an empty event to the
* appropriate event queue and waits for it to finish.
*/
public static void flushPendingEventsOnAppkit(final Component component) {
try {
invokeAndWait(new Runnable() {
@Override
public void run() {
}
}, component);
} catch (Exception e) {
e.printStackTrace();
}
}
// Kicks an event over to the appropriate eventqueue and waits for it to finish // Kicks an event over to the appropriate eventqueue and waits for it to finish
// To avoid deadlocking, we manually run the NSRunLoop while waiting // To avoid deadlocking, we manually run the NSRunLoop while waiting
// Any selector invoked using ThreadUtilities performOnMainThread will be processed in doAWTRunLoop // Any selector invoked using ThreadUtilities performOnMainThread will be processed in doAWTRunLoop
......
...@@ -86,11 +86,14 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -86,11 +86,14 @@ AWT_ASSERT_APPKIT_THREAD;
if (windowLayer != nil) { if (windowLayer != nil) {
self.cglLayer = windowLayer; self.cglLayer = windowLayer;
//Layer hosting view
[self setLayer: cglLayer];
[self setWantsLayer: YES]; [self setWantsLayer: YES];
[self.layer addSublayer: (CALayer *)cglLayer]; //Layer backed view
[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize]; //[self.layer addSublayer: (CALayer *)cglLayer];
[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft]; //[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable]; //[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
//[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
#ifdef REMOTELAYER #ifdef REMOTELAYER
CGLLayer *parentLayer = (CGLLayer*)self.cglLayer; CGLLayer *parentLayer = (CGLLayer*)self.cglLayer;
......
...@@ -69,6 +69,9 @@ ...@@ -69,6 +69,9 @@
- (BOOL) worksWhenModal; - (BOOL) worksWhenModal;
- (void)sendEvent:(NSEvent *)event; - (void)sendEvent:(NSEvent *)event;
+ (void) setLastKeyWindow:(AWTWindow *)window;
+ (AWTWindow *) lastKeyWindow;
@end @end
@interface AWTWindow_Normal : NSWindow @interface AWTWindow_Normal : NSWindow
......
...@@ -51,6 +51,14 @@ ...@@ -51,6 +51,14 @@
static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow"); static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
// Cocoa windowDidBecomeKey/windowDidResignKey notifications
// doesn't provide information about "opposite" window, so we
// have to do a bit of tracking. This variable points to a window
// which had been the key window just before a new key window
// was set. It would be nil if the new key window isn't an AWT
// window or the app currently has no key window.
static AWTWindow* lastKeyWindow = nil;
// -------------------------------------------------------------- // --------------------------------------------------------------
// NSWindow/NSPanel descendants implementation // NSWindow/NSPanel descendants implementation
#define AWT_NS_WINDOW_IMPLEMENTATION \ #define AWT_NS_WINDOW_IMPLEMENTATION \
...@@ -505,15 +513,17 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -505,15 +513,17 @@ AWT_ASSERT_APPKIT_THREAD;
[self _deliverIconify:JNI_FALSE]; [self _deliverIconify:JNI_FALSE];
} }
- (void) _deliverWindowFocusEvent:(BOOL)focused { - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
//AWT_ASSERT_APPKIT_THREAD; //AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
if (platformWindow != NULL) { if (platformWindow != NULL) {
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(Z)V"); jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused);
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
(*env)->DeleteLocalRef(env, platformWindow); (*env)->DeleteLocalRef(env, platformWindow);
(*env)->DeleteLocalRef(env, oppositeWindow);
} }
} }
...@@ -522,7 +532,10 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -522,7 +532,10 @@ AWT_ASSERT_APPKIT_THREAD;
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO]; [CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
[self _deliverWindowFocusEvent:YES]; AWTWindow *opposite = [AWTWindow lastKeyWindow];
[AWTWindow setLastKeyWindow:nil];
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
} }
- (void) windowDidResignKey: (NSNotification *) notification { - (void) windowDidResignKey: (NSNotification *) notification {
...@@ -530,7 +543,18 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -530,7 +543,18 @@ AWT_ASSERT_APPKIT_THREAD;
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];
[self.javaMenuBar deactivate]; [self.javaMenuBar deactivate];
[self _deliverWindowFocusEvent:NO];
// the new key window
NSWindow *keyWindow = [NSApp keyWindow];
AWTWindow *opposite = nil;
if ([AWTWindow isAWTWindow: keyWindow]) {
opposite = (AWTWindow *)[keyWindow delegate];
[AWTWindow setLastKeyWindow: self];
} else {
[AWTWindow setLastKeyWindow: nil];
}
[self _deliverWindowFocusEvent:NO oppositeWindow: opposite];
} }
- (void) windowDidBecomeMain: (NSNotification *) notification { - (void) windowDidBecomeMain: (NSNotification *) notification {
...@@ -684,6 +708,17 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -684,6 +708,17 @@ AWT_ASSERT_APPKIT_THREAD;
} }
} }
+ (void) setLastKeyWindow:(AWTWindow *)window {
[window retain];
[lastKeyWindow release];
lastKeyWindow = window;
}
+ (AWTWindow *) lastKeyWindow {
return lastKeyWindow;
}
@end // AWTWindow @end // AWTWindow
...@@ -1208,6 +1243,10 @@ JNF_COCOA_ENTER(env); ...@@ -1208,6 +1243,10 @@ JNF_COCOA_ENTER(env);
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
AWTWindow *window = (AWTWindow*)[nsWindow delegate]; AWTWindow *window = (AWTWindow*)[nsWindow delegate];
if ([AWTWindow lastKeyWindow] == window) {
[AWTWindow setLastKeyWindow: nil];
}
// AWTWindow holds a reference to the NSWindow in its nsWindow // AWTWindow holds a reference to the NSWindow in its nsWindow
// property. Unsetting the delegate allows it to be deallocated // property. Unsetting the delegate allows it to be deallocated
// which releases the reference. This, in turn, allows the window // which releases the reference. This, in turn, allows the window
......
...@@ -76,7 +76,7 @@ JNF_COCOA_ENTER(env); ...@@ -76,7 +76,7 @@ JNF_COCOA_ENTER(env);
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent]; NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
if ([currEvent type] == NSKeyDown) { if ([currEvent type] == NSKeyDown) {
NSString *menuKey = [sender keyEquivalent]; NSString *menuKey = [sender keyEquivalent];
NSString *eventKey = [currEvent characters]; NSString *eventKey = [currEvent charactersIgnoringModifiers];
if ([menuKey isEqualToString:eventKey]) { if ([menuKey isEqualToString:eventKey]) {
return; return;
} }
......
...@@ -57,9 +57,10 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -57,9 +57,10 @@ AWT_ASSERT_APPKIT_THREAD;
// NOTE: async=YES means that the layer is re-cached periodically // NOTE: async=YES means that the layer is re-cached periodically
self.asynchronous = FALSE; self.asynchronous = FALSE;
self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
self.contentsGravity = kCAGravityTopLeft; self.contentsGravity = kCAGravityTopLeft;
self.needsDisplayOnBoundsChange = YES; //Layer backed view
//self.needsDisplayOnBoundsChange = YES;
//self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
textureID = 0; // texture will be created by rendering pipe textureID = 0; // texture will be created by rendering pipe
target = 0; target = 0;
...@@ -109,6 +110,10 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -109,6 +110,10 @@ AWT_ASSERT_APPKIT_THREAD;
glDisable(target); glDisable(target);
} }
-(BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp{
return textureID == 0 ? NO : YES;
}
-(void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp -(void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
{ {
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
......
...@@ -31,6 +31,8 @@ import java.awt.Event; ...@@ -31,6 +31,8 @@ import java.awt.Event;
import java.awt.KeyEventPostProcessor; import java.awt.KeyEventPostProcessor;
import java.awt.Window; import java.awt.Window;
import java.awt.Toolkit; import java.awt.Toolkit;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
...@@ -133,10 +135,15 @@ public class WindowsRootPaneUI extends BasicRootPaneUI { ...@@ -133,10 +135,15 @@ public class WindowsRootPaneUI extends BasicRootPaneUI {
// window. If this time appears to be greater than the altRelease // window. If this time appears to be greater than the altRelease
// event time the event is skipped to avoid unexpected menu // event time the event is skipped to avoid unexpected menu
// activation. See 7121442. // activation. See 7121442.
// Also we must ensure that original source of key event belongs
// to the same window object as winAncestor. See 8001633.
boolean skip = false; boolean skip = false;
Toolkit tk = Toolkit.getDefaultToolkit(); Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) { if (tk instanceof SunToolkit) {
skip = ev.getWhen() <= ((SunToolkit)tk).getWindowDeactivationTime(winAncestor); Component originalSource = AWTAccessor.getKeyEventAccessor()
.getOriginalSource(ev);
skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
} }
if (menu != null && !skip) { if (menu != null && !skip) {
......
...@@ -930,6 +930,10 @@ public class KeyEvent extends InputEvent { ...@@ -930,6 +930,10 @@ public class KeyEvent extends InputEvent {
long extendedKeyCode) { long extendedKeyCode) {
ev.extendedKeyCode = extendedKeyCode; ev.extendedKeyCode = extendedKeyCode;
} }
public Component getOriginalSource( KeyEvent ev ) {
return ev.originalSource;
}
}); });
} }
...@@ -939,6 +943,14 @@ public class KeyEvent extends InputEvent { ...@@ -939,6 +943,14 @@ public class KeyEvent extends InputEvent {
*/ */
private static native void initIDs(); private static native void initIDs();
/**
* The original event source.
*
* Event source can be changed during processing, but in some cases
* we need to be able to obtain original source.
*/
private Component originalSource;
private KeyEvent(Component source, int id, long when, int modifiers, private KeyEvent(Component source, int id, long when, int modifiers,
int keyCode, char keyChar, int keyLocation, boolean isProxyActive) { int keyCode, char keyChar, int keyLocation, boolean isProxyActive) {
this(source, id, when, modifiers, keyCode, keyChar, keyLocation); this(source, id, when, modifiers, keyCode, keyChar, keyLocation);
...@@ -1023,6 +1035,7 @@ public class KeyEvent extends InputEvent { ...@@ -1023,6 +1035,7 @@ public class KeyEvent extends InputEvent {
} else if ((getModifiers() == 0) && (getModifiersEx() != 0)) { } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) {
setOldModifiers(); setOldModifiers();
} }
originalSource = source;
} }
/** /**
......
/* /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -45,7 +45,7 @@ import java.io.Serializable; ...@@ -45,7 +45,7 @@ import java.io.Serializable;
@SuppressWarnings("serial") @SuppressWarnings("serial")
class AncestorNotifier implements ComponentListener, PropertyChangeListener, Serializable class AncestorNotifier implements ComponentListener, PropertyChangeListener, Serializable
{ {
Component firstInvisibleAncestor; transient Component firstInvisibleAncestor;
EventListenerList listenerList = new EventListenerList(); EventListenerList listenerList = new EventListenerList();
JComponent root; JComponent root;
......
/* /*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -952,7 +952,7 @@ class Parser implements DTDConstants { ...@@ -952,7 +952,7 @@ class Parser implements DTDConstants {
ch = readCh(); ch = readCh();
break; break;
} }
char data[] = {mapNumericReference((char) n)}; char data[] = mapNumericReference(n);
return data; return data;
} }
addString('#'); addString('#');
...@@ -1021,7 +1021,7 @@ class Parser implements DTDConstants { ...@@ -1021,7 +1021,7 @@ class Parser implements DTDConstants {
} }
/** /**
* Converts numeric character reference to Unicode character. * Converts numeric character reference to char array.
* *
* Normally the code in a reference should be always converted * Normally the code in a reference should be always converted
* to the Unicode character with the same code, but due to * to the Unicode character with the same code, but due to
...@@ -1030,13 +1030,21 @@ class Parser implements DTDConstants { ...@@ -1030,13 +1030,21 @@ class Parser implements DTDConstants {
* to displayable characters with other codes. * to displayable characters with other codes.
* *
* @param c the code of numeric character reference. * @param c the code of numeric character reference.
* @return the character corresponding to the reference code. * @return a char array corresponding to the reference code.
*/ */
private char mapNumericReference(char c) { private char[] mapNumericReference(int c) {
if (c < 130 || c > 159) { char[] data;
return c; if (c >= 0xffff) { // outside unicode BMP.
try {
data = Character.toChars(c);
} catch (IllegalArgumentException e) {
data = new char[0];
}
} else {
data = new char[1];
data[0] = (c < 130 || c > 159) ? (char) c : cp1252Map[c - 130];
} }
return cp1252Map[c - 130]; return data;
} }
/** /**
......
...@@ -629,6 +629,11 @@ public final class AWTAccessor { ...@@ -629,6 +629,11 @@ public final class AWTAccessor {
* Sets extendedKeyCode field for KeyEvent * Sets extendedKeyCode field for KeyEvent
*/ */
void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode); void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
/**
* Gets original source for KeyEvent
*/
Component getOriginalSource(KeyEvent ev);
} }
/** /**
......
...@@ -111,7 +111,7 @@ public class ScreenUpdateManager { ...@@ -111,7 +111,7 @@ public class ScreenUpdateManager {
SurfaceData oldsd) SurfaceData oldsd)
{ {
SurfaceData surfaceData = peer.getSurfaceData(); SurfaceData surfaceData = peer.getSurfaceData();
if (surfaceData.isValid()) { if (surfaceData == null || surfaceData.isValid()) {
return surfaceData; return surfaceData;
} }
peer.replaceSurfaceData(); peer.replaceSurfaceData();
......
...@@ -150,6 +150,7 @@ AwtFont::AwtFont(int num, JNIEnv *env, jobject javaFont) ...@@ -150,6 +150,7 @@ AwtFont::AwtFont(int num, JNIEnv *env, jobject javaFont)
AwtFont::~AwtFont() AwtFont::~AwtFont()
{ {
delete[] m_hFont;
} }
void AwtFont::Dispose() { void AwtFont::Dispose() {
...@@ -160,11 +161,12 @@ void AwtFont::Dispose() { ...@@ -160,11 +161,12 @@ void AwtFont::Dispose() {
/* NOTE: delete of windows HFONT happens in FontCache::Remove /* NOTE: delete of windows HFONT happens in FontCache::Remove
only when the final reference to the font is disposed */ only when the final reference to the font is disposed */
} else if (font != NULL) { } else if (font != NULL) {
// if font was not in cache, its not shared and we delete it now // if font was not in cache, its not shared and we delete it now
VERIFY(::DeleteObject(font)); DASSERT(::GetObjectType(font) == OBJ_FONT);
VERIFY(::DeleteObject(font));
} }
m_hFont[i] = NULL;
} }
delete[] m_hFont;
AwtObject::Dispose(); AwtObject::Dispose();
} }
......
...@@ -534,7 +534,6 @@ BOOL AwtToolkit::Dispose() { ...@@ -534,7 +534,6 @@ BOOL AwtToolkit::Dispose() {
D3DInitializer::GetInstance().Clean(); D3DInitializer::GetInstance().Clean();
AwtObjectList::Cleanup(); AwtObjectList::Cleanup();
AwtFont::Cleanup();
awt_dnd_uninitialize(); awt_dnd_uninitialize();
awt_clipboard_uninitialize((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2)); awt_clipboard_uninitialize((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2));
...@@ -554,6 +553,8 @@ BOOL AwtToolkit::Dispose() { ...@@ -554,6 +553,8 @@ BOOL AwtToolkit::Dispose() {
::DispatchMessage(&msg); ::DispatchMessage(&msg);
} }
AwtFont::Cleanup();
HWND toolkitHWndToDestroy = tk.m_toolkitHWnd; HWND toolkitHWndToDestroy = tk.m_toolkitHWnd;
tk.m_toolkitHWnd = 0; tk.m_toolkitHWnd = 0;
VERIFY(::DestroyWindow(toolkitHWndToDestroy) != NULL); VERIFY(::DestroyWindow(toolkitHWndToDestroy) != NULL);
......
#!/bin/ksh -p #!/bin/ksh -p
# #
# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -39,7 +39,7 @@ status=1 ...@@ -39,7 +39,7 @@ status=1
#Call this from anywhere to fail the test with an error message #Call this from anywhere to fail the test with an error message
# usage: fail "reason why the test failed" # usage: fail "reason why the test failed"
fail() fail()
{ echo "The test failed :-(" { echo "The test failed :-("
echo "$*" 1>&2 echo "$*" 1>&2
echo "exit status was $status" echo "exit status was $status"
...@@ -48,7 +48,7 @@ fail() ...@@ -48,7 +48,7 @@ fail()
#Call this from anywhere to pass the test with a message #Call this from anywhere to pass the test with a message
# usage: pass "reason why the test passed if applicable" # usage: pass "reason why the test passed if applicable"
pass() pass()
{ echo "The test passed!!!" { echo "The test passed!!!"
echo "$*" 1>&2 echo "$*" 1>&2
exit 0 exit 0
...@@ -64,20 +64,42 @@ OS=`uname -s` ...@@ -64,20 +64,42 @@ OS=`uname -s`
case "$OS" in case "$OS" in
SunOS ) SunOS )
VAR="One value for Sun" VAR="One value for Sun"
DEFAULT_JDK=/usr/local/java/jdk1.2/solaris DEFAULT_JDK=/
FILESEP="/" FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;; ;;
Linux ) Linux )
VAR="A different value for Linux" VAR="A different value for Linux"
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 DEFAULT_JDK=/
FILESEP="/" FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;; ;;
Windows_95 | Windows_98 | Windows_NT | Windows_ME ) Darwin )
VAR="A different value for MacOSX"
DEFAULT_JDK=/usr
FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;;
Windows* )
VAR="A different value for Win32" VAR="A different value for Win32"
DEFAULT_JDK=/usr/local/java/jdk1.2/win32 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
FILESEP="\\" FILESEP="\\"
PATHSEP=";"
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
;;
CYGWIN* )
VAR="A different value for Cygwin"
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
FILESEP="/"
PATHSEP=";"
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
;; ;;
# catch all other OSs # catch all other OSs
...@@ -88,8 +110,8 @@ case "$OS" in ...@@ -88,8 +110,8 @@ case "$OS" in
esac esac
# Want this test to run standalone as well as in the harness, so do the # Want this test to run standalone as well as in the harness, so do the
# following to copy the test's directory into the harness's scratch directory # following to copy the test's directory into the harness's scratch directory
# and set all appropriate variables: # and set all appropriate variables:
if [ -z "${TESTJAVA}" ] ; then if [ -z "${TESTJAVA}" ] ; then
...@@ -104,7 +126,7 @@ if [ -z "${TESTJAVA}" ] ; then ...@@ -104,7 +126,7 @@ if [ -z "${TESTJAVA}" ] ; then
if [ -n "$1" ] ; if [ -n "$1" ] ;
then TESTJAVA=$1 then TESTJAVA=$1
else echo "no JDK specified on command line so using default!" else echo "no JDK specified on command line so using default!"
TESTJAVA=$DEFAULT_JDK TESTJAVA=$DEFAULT_JDK
fi fi
TESTSRC=. TESTSRC=.
TESTCLASSES=. TESTCLASSES=.
...@@ -113,25 +135,25 @@ fi ...@@ -113,25 +135,25 @@ fi
echo "JDK under test is: $TESTJAVA" echo "JDK under test is: $TESTJAVA"
#Deal with .class files: #Deal with .class files:
if [ -n "${STANDALONE}" ] ; if [ -n "${STANDALONE}" ] ;
then then
#if standalone, remind user to cd to dir. containing test before running it #if standalone, remind user to cd to dir. containing test before running it
echo "Just a reminder: cd to the dir containing this test when running it" echo "Just a reminder: cd to the dir containing this test when running it"
# then compile all .java files (if there are any) into .class files # then compile all .java files (if there are any) into .class files
if [ -a *.java ] ; if [ -a *.java ] ;
then echo "Reminder, this test should be in its own directory with all" then echo "Reminder, this test should be in its own directory with all"
echo "supporting files it needs in the directory with it." echo "supporting files it needs in the directory with it."
${TESTJAVA}/bin/javac ./*.java ; ${TESTJAVA}/bin/javac ./*.java ;
fi fi
# else in harness so copy all the class files from where jtreg put them # else in harness so copy all the class files from where jtreg put them
# over to the scratch directory this test is running in. # over to the scratch directory this test is running in.
else cp ${TESTCLASSES}/*.class . ; else cp ${TESTCLASSES}/*.class . ;
fi fi
#if in test harness, then copy the entire directory that the test is in over #if in test harness, then copy the entire directory that the test is in over
# to the scratch directory. This catches any support files needed by the test. # to the scratch directory. This catches any support files needed by the test.
if [ -z "${STANDALONE}" ] ; if [ -z "${STANDALONE}" ] ;
then cp ${TESTSRC}/* . then cp ${TESTSRC}/* .
fi fi
#Just before executing anything, make sure it has executable permission! #Just before executing anything, make sure it has executable permission!
......
# #
# Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -38,7 +38,7 @@ status=1 ...@@ -38,7 +38,7 @@ status=1
#Call this from anywhere to fail the test with an error message #Call this from anywhere to fail the test with an error message
# usage: fail "reason why the test failed" # usage: fail "reason why the test failed"
fail() fail()
{ echo "The test failed :-(" { echo "The test failed :-("
echo "$*" 1>&2 echo "$*" 1>&2
echo "exit status was $status" echo "exit status was $status"
...@@ -47,7 +47,7 @@ fail() ...@@ -47,7 +47,7 @@ fail()
#Call this from anywhere to pass the test with a message #Call this from anywhere to pass the test with a message
# usage: pass "reason why the test passed if applicable" # usage: pass "reason why the test passed if applicable"
pass() pass()
{ echo "The test passed!!!" { echo "The test passed!!!"
echo "$*" 1>&2 echo "$*" 1>&2
exit 0 exit 0
...@@ -99,20 +99,42 @@ OS=`uname -s` ...@@ -99,20 +99,42 @@ OS=`uname -s`
case "$OS" in case "$OS" in
SunOS ) SunOS )
VAR="One value for Sun" VAR="One value for Sun"
DEFAULT_JDK=/usr/local/java/jdk1.2.1/solaris DEFAULT_JDK=/
FILESEP="/" FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;; ;;
Linux ) Linux )
VAR="A different value for Linux" VAR="A different value for Linux"
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 DEFAULT_JDK=/
FILESEP="/" FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;; ;;
Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN_NT-5.1) Darwin )
VAR="A different value for MacOSX"
DEFAULT_JDK=/usr
FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;;
Windows* )
VAR="A different value for Win32" VAR="A different value for Win32"
DEFAULT_JDK=/usr/local/java/jdk1.2.1/win32 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
FILESEP="\\" FILESEP="\\"
PATHSEP=";"
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
;;
CYGWIN* )
VAR="A different value for Cygwin"
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
FILESEP="/"
PATHSEP=";"
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
;; ;;
# catch all other OSs # catch all other OSs
...@@ -132,12 +154,12 @@ fi ...@@ -132,12 +154,12 @@ fi
# note that the name of the executable is in the fail string as well. # note that the name of the executable is in the fail string as well.
# this is how to check for presence of the compiler, etc. # this is how to check for presence of the compiler, etc.
#RESOURCE=`whence SomeProgramOrFileNeeded` #RESOURCE=`whence SomeProgramOrFileNeeded`
#if [ "${RESOURCE}" = "" ] ; #if [ "${RESOURCE}" = "" ] ;
# then fail "Need SomeProgramOrFileNeeded to perform the test" ; # then fail "Need SomeProgramOrFileNeeded to perform the test" ;
#fi #fi
# Want this test to run standalone as well as in the harness, so do the # Want this test to run standalone as well as in the harness, so do the
# following to copy the test's directory into the harness's scratch directory # following to copy the test's directory into the harness's scratch directory
# and set all appropriate variables: # and set all appropriate variables:
if [ -z "${TESTJAVA}" ] ; then if [ -z "${TESTJAVA}" ] ; then
...@@ -152,7 +174,7 @@ if [ -z "${TESTJAVA}" ] ; then ...@@ -152,7 +174,7 @@ if [ -z "${TESTJAVA}" ] ; then
if [ -n "$1" ] ; if [ -n "$1" ] ;
then TESTJAVA=$1 then TESTJAVA=$1
else echo "no JDK specified on command line so using default!" else echo "no JDK specified on command line so using default!"
TESTJAVA=$DEFAULT_JDK TESTJAVA=$DEFAULT_JDK
fi fi
TESTSRC=. TESTSRC=.
TESTCLASSES=. TESTCLASSES=.
...@@ -161,25 +183,25 @@ fi ...@@ -161,25 +183,25 @@ fi
echo "JDK under test is: $TESTJAVA" echo "JDK under test is: $TESTJAVA"
#Deal with .class files: #Deal with .class files:
if [ -n "${STANDALONE}" ] ; if [ -n "${STANDALONE}" ] ;
then then
#if standalone, remind user to cd to dir. containing test before running it #if standalone, remind user to cd to dir. containing test before running it
echo "Just a reminder: cd to the dir containing this test when running it" echo "Just a reminder: cd to the dir containing this test when running it"
# then compile all .java files (if there are any) into .class files # then compile all .java files (if there are any) into .class files
if [ -a *.java ] ; if [ -a *.java ] ;
then echo "Reminder, this test should be in its own directory with all" then echo "Reminder, this test should be in its own directory with all"
echo "supporting files it needs in the directory with it." echo "supporting files it needs in the directory with it."
${TESTJAVA}/bin/javac ./*.java ; ${TESTJAVA}/bin/javac ./*.java ;
fi fi
# else in harness so copy all the class files from where jtreg put them # else in harness so copy all the class files from where jtreg put them
# over to the scratch directory this test is running in. # over to the scratch directory this test is running in.
else cp ${TESTCLASSES}/*.class . ; else cp ${TESTCLASSES}/*.class . ;
fi fi
#if in test harness, then copy the entire directory that the test is in over #if in test harness, then copy the entire directory that the test is in over
# to the scratch directory. This catches any support files needed by the test. # to the scratch directory. This catches any support files needed by the test.
#if [ -z "${STANDALONE}" ] ; #if [ -z "${STANDALONE}" ] ;
# then cp ${TESTSRC}/* . # then cp ${TESTSRC}/* .
#fi #fi
#Just before executing anything, make sure it has executable permission! #Just before executing anything, make sure it has executable permission!
...@@ -198,7 +220,7 @@ chmod 777 ./* ...@@ -198,7 +220,7 @@ chmod 777 ./*
# this shell test as appropriate ( 0 status is considered a pass here ) # this shell test as appropriate ( 0 status is considered a pass here )
# The test verifies that appletviewer correctly works with the different # The test verifies that appletviewer correctly works with the different
# names of the files, including relative and absolute paths # names of the files, including relative and absolute paths
# 6619458: exclude left brace from the name of the files managed by the VCS # 6619458: exclude left brace from the name of the files managed by the VCS
NAME='test.html' NAME='test.html'
......
#!/bin/ksh -p #!/bin/ksh -p
# #
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -78,28 +78,44 @@ OS=`uname -s` ...@@ -78,28 +78,44 @@ OS=`uname -s`
case "$OS" in case "$OS" in
SunOS ) SunOS )
VAR="One value for Sun" VAR="One value for Sun"
DEFAULT_JDK=/usr/local/java/jdk1.2/solaris DEFAULT_JDK=/
FILESEP="/" FILESEP="/"
PATHSEP=":" PATHSEP=":"
TMP="/tmp" TMP="/tmp"
;; ;;
Linux | Darwin ) Linux )
VAR="A different value for Linux" VAR="A different value for Linux"
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 DEFAULT_JDK=/
FILESEP="/" FILESEP="/"
PATHSEP=":" PATHSEP=":"
TMP="/tmp" TMP="/tmp"
;; ;;
Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN* ) Darwin )
VAR="A different value for MacOSX"
DEFAULT_JDK=/usr
FILESEP="/"
PATHSEP=":"
TMP="/tmp"
;;
Windows* )
VAR="A different value for Win32" VAR="A different value for Win32"
DEFAULT_JDK=/usr/local/java/jdk1.2/win32 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
FILESEP="\\" FILESEP="\\"
PATHSEP=";" PATHSEP=";"
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}` TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
;; ;;
CYGWIN* )
VAR="A different value for Cygwin"
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
FILESEP="/"
PATHSEP=";"
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
;;
# catch all other OSs # catch all other OSs
* ) * )
echo "Unrecognized system! $OS" echo "Unrecognized system! $OS"
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7193219
@summary JComboBox serialization fails in JDK 1.7
@author Anton Litvinov
*/
import java.io.*;
import javax.swing.*;
public class bug7193219 {
private static byte[] serializeGUI() {
// Create and set up the window.
JFrame frame = new JFrame("Serialization");
JPanel mainPanel = new JPanel();
/**
* If JComboBox is replaced with other component like JLabel
* The issue does not happen.
*/
JComboBox status = new JComboBox();
status.addItem("123");
mainPanel.add(status);
frame.getContentPane().add(mainPanel);
frame.pack();
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(mainPanel);
oos.flush();
frame.dispose();
return baos.toByteArray();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
private static void deserializeGUI(byte[] serializedData) {
try {
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serializedData));
JPanel mainPanel = (JPanel)ois.readObject();
JFrame frame = new JFrame("Deserialization");
frame.getContentPane().add(mainPanel);
frame.pack();
frame.dispose();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
deserializeGUI(serializeGUI());
}
});
}
}
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7160951
* @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
* @author vera.akulova@oracle.com
* @run main ActionListenerCalledTwiceTest
*/
import sun.awt.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ActionListenerCalledTwiceTest {
static volatile int listenerCallCounter = 0;
public static void main(String[] args) throws Exception {
if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
System.setProperty("apple.laf.useScreenMenuBar", "true");
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(100);
robot.keyPress(KeyEvent.VK_META);
robot.keyPress(KeyEvent.VK_E);
robot.keyRelease(KeyEvent.VK_E);
robot.keyRelease(KeyEvent.VK_META);
toolkit.realSync();
if (listenerCallCounter != 1) {
throw new Exception("Test failed: ActionListener called " + listenerCallCounter + " times instead of 1!");
}
}
private static void createAndShowGUI() {
JMenuItem newItem = new JMenuItem("Exit");
newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK));
newItem.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e) {
listenerCallCounter++;
}
}
);
JMenu menu = new JMenu("Menu");
menu.add(newItem);
JMenuBar bar = new JMenuBar();
bar.add(menu);
JFrame frame = new JFrame("Test");
frame.setJMenuBar(bar);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7186371
* @summary [macosx] Main menu shortcuts not displayed
* @author vera.akulova@oracle.com
* @run main/manual ShortcutNotDisplayedTest
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ShortcutNotDisplayedTest {
static volatile boolean done = false;
static volatile boolean pass = false;
static final String PASS_COMMAND = "pass";
public static void main(String[] args) throws Exception {
if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
System.setProperty("apple.laf.useScreenMenuBar", "true");
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
do { try { Thread.sleep(300); } catch (Exception e) {} } while (!done) ;
if (!pass) {
throw new Exception("Shortcuts not displayed as expected in the screen menu bar.");
}
}
private static void createAndShowGUI() {
JMenuItem newItem = new JMenuItem("Exit");
newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, java.awt.event.InputEvent.META_MASK));
JMenu menu = new JMenu("Test Frame Window Menu");
menu.setMnemonic(KeyEvent.VK_M);
menu.add(newItem);
JMenuBar bar = new JMenuBar();
bar.add(menu);
JTextArea text = new JTextArea(
" Please follow instructions:\n" +
" 1. You should see \"Test Frame Window Menu\" menu on the screen menu bar.\n" +
" 2. Open \"Test Frame Window Menu\" menu. \n" +
" Check that menu item \"Exit\" has a shortcut with image for Command Key and symbol \"E\". \n" +
" If you see the shortcut press \"Passed\". Otherwise press \"Failed\".\n"
);
text.setEditable(false);
JScrollPane sp = new JScrollPane(text);
sp.setSize(300,200);
JButton passBtn = new JButton("Pass");
passBtn.setActionCommand(PASS_COMMAND);
JButton failBtn = new JButton("Fail");
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(PASS_COMMAND)) {
pass = true;
}
done = true;
}
};
JFrame testFrame = new JFrame("Test Frame Window");
testFrame.setLayout(new FlowLayout());
testFrame.setBounds(100, 100, 600, 180);
testFrame.setJMenuBar(bar);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
passBtn.addActionListener(listener);
failBtn.addActionListener(listener);
testFrame.getContentPane().add(sp);
testFrame.getContentPane().add(passBtn);
testFrame.getContentPane().add(failBtn);
testFrame.setVisible(true);
}
}
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 8001633
@summary Wrong alt processing during switching between windows
@author mikhail.cherkasov@oracle.com
@run main WrongAltProcessing
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class WrongAltProcessing {
private static Robot robot;
private static JFrame firstFrame;
private static JFrame secondFrame;
private static JTextField mainFrameTf1;
private static JTextField mainFrameTf2;
private static JTextField secondFrameTf;
public static void main(String[] args) throws AWTException {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
return;// miss unsupported platforms.
}
createWindows();
initRobot();
runScript();
verify();
}
private static void verify() {
Component c = DefaultKeyboardFocusManager
.getCurrentKeyboardFocusManager().getFocusOwner();
if (!(c == mainFrameTf2)) {
throw new RuntimeException("Wrong focus owner.");
}
}
public static void sync() {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
}
public static void initRobot() throws AWTException {
robot = new Robot();
robot.setAutoDelay(100);
}
private static void clickWindowsTitle(JFrame frame) {
Point point = frame.getLocationOnScreen();
robot.mouseMove(point.x + (frame.getWidth() / 2), point.y + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void runScript() {
robot.delay(1000);
printABCD();
pressTab();
clickWindowsTitle(secondFrame);
robot.delay(500);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_ALT);
clickWindowsTitle(firstFrame);
sync();
}
private static void pressTab() {
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
}
private static void printABCD() {
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_B);
robot.keyRelease(KeyEvent.VK_B);
robot.keyPress(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_C);
robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);
}
public static void createWindows() {
firstFrame = new JFrame("Frame");
firstFrame.setLayout(new FlowLayout());
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem item = new JMenuItem("Save");
mainFrameTf1 = new JTextField(10);
mainFrameTf2 = new JTextField(10);
mainFrameTf1.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent EVT) {
if (EVT.getKeyChar() >= 'a' && EVT.getKeyChar() <= 'z') {
try {
// imitate some long processing
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
});
menu.add(item);
bar.add(menu);
firstFrame.setJMenuBar(bar);
firstFrame.add(mainFrameTf1);
firstFrame.add(mainFrameTf2);
firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
firstFrame.pack();
secondFrame = new JFrame("Frame 2");
secondFrame.setLocation(0, 150);
secondFrameTf = new JTextField(20);
secondFrame.add(secondFrameTf);
secondFrame.pack();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
secondFrame.setVisible(true);
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
firstFrame.setVisible(true);
}
});
mainFrameTf1.requestFocus();
sync();
}
}
/*
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6836089
* @summary Tests correct parsing of characters outside Base Multilingual Plane
* @author Vladislav Karnaukhov
*/
import javax.swing.*;
import javax.swing.text.html.*;
public class bug6836089 {
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JTextPane htmlPane = new JTextPane();
htmlPane.setEditorKit(new HTMLEditorKit());
htmlPane.setText("<html><head></head><body>&#131072;</body></html>");
String str = htmlPane.getText();
if (str.contains("&#0;")) {
throw new RuntimeException("Test failed");
}
}
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册