提交 ef7fa499 编写于 作者: L lana

Merge

...@@ -220,3 +220,5 @@ a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92 ...@@ -220,3 +220,5 @@ a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92
4a5d3cf2b3af1660db0237e8da324c140e534fa4 jdk8-b96 4a5d3cf2b3af1660db0237e8da324c140e534fa4 jdk8-b96
978a95239044f26dcc8a6d59246be07ad6ca6be2 jdk8-b97 978a95239044f26dcc8a6d59246be07ad6ca6be2 jdk8-b97
c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98 c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
6a099a36589bd933957272ba63e5263bede29971 jdk8-b99
5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100
...@@ -32,6 +32,7 @@ import java.util.List; ...@@ -32,6 +32,7 @@ import java.util.List;
import javax.swing.RootPaneContainer; import javax.swing.RootPaneContainer;
import com.apple.eawt.AppEvent.FullScreenEvent; import com.apple.eawt.AppEvent.FullScreenEvent;
import sun.awt.SunToolkit;
import java.lang.annotation.Native; import java.lang.annotation.Native;
...@@ -75,7 +76,7 @@ final class FullScreenHandler { ...@@ -75,7 +76,7 @@ final class FullScreenHandler {
static void handleFullScreenEventFromNative(final Window window, final int type) { static void handleFullScreenEventFromNative(final Window window, final int type) {
if (!(window instanceof RootPaneContainer)) return; // handles null if (!(window instanceof RootPaneContainer)) return; // handles null
EventQueue.invokeLater(new Runnable() { SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
public void run() { public void run() {
final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window); final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window);
if (handler != null) handler.notifyListener(new FullScreenEvent(window), type); if (handler != null) handler.notifyListener(new FullScreenEvent(window), type);
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2013, 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
...@@ -31,6 +31,8 @@ import java.io.File; ...@@ -31,6 +31,8 @@ import java.io.File;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import com.apple.eawt.AppEvent.*; import com.apple.eawt.AppEvent.*;
...@@ -269,11 +271,9 @@ class _AppEventHandler { ...@@ -269,11 +271,9 @@ class _AppEventHandler {
} }
class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReOpenedListener> { class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReOpenedListener> {
void performOnListeners(final List<AppReOpenedListener> listeners, final _NativeEvent event) { void performOnListener(AppReOpenedListener listener, final _NativeEvent event) {
final AppReOpenedEvent e = new AppReOpenedEvent(); final AppReOpenedEvent e = new AppReOpenedEvent();
for (final AppReOpenedListener listener : listeners) { listener.appReOpened(e);
listener.appReOpened(e);
}
} }
} }
...@@ -415,50 +415,67 @@ class _AppEventHandler { ...@@ -415,50 +415,67 @@ class _AppEventHandler {
} }
abstract class _AppEventMultiplexor<L> { abstract class _AppEventMultiplexor<L> {
final List<L> _listeners = new ArrayList<L>(0); private final Map<L, AppContext> listenerToAppContext =
new IdentityHashMap<L, AppContext>();
boolean nativeListenerRegistered; boolean nativeListenerRegistered;
// called from AppKit Thread-0 // called from AppKit Thread-0
void dispatch(final _NativeEvent event, final Object... args) { void dispatch(final _NativeEvent event, final Object... args) {
// grab a local ref to the listeners // grab a local ref to the listeners and its contexts as an array of the map's entries
final List<L> localListeners; final ArrayList<Map.Entry<L, AppContext>> localEntries;
synchronized (this) { synchronized (this) {
if (_listeners.size() == 0) return; if (listenerToAppContext.size() == 0) {
localListeners = new ArrayList<L>(_listeners); return;
}
localEntries = new ArrayList<Map.Entry<L, AppContext>>(listenerToAppContext.size());
localEntries.addAll(listenerToAppContext.entrySet());
} }
EventQueue.invokeLater(new Runnable() { for (final Map.Entry<L, AppContext> e : localEntries) {
public void run() { final L listener = e.getKey();
performOnListeners(localListeners, event); final AppContext listenerContext = e.getValue();
} SunToolkit.invokeLaterOnAppContext(listenerContext, new Runnable() {
}); public void run() {
performOnListener(listener, event);
}
});
}
} }
synchronized void addListener(final L listener) { synchronized void addListener(final L listener) {
setListenerContext(listener, AppContext.getAppContext());
if (!nativeListenerRegistered) { if (!nativeListenerRegistered) {
registerNativeListener(); registerNativeListener();
nativeListenerRegistered = true; nativeListenerRegistered = true;
} }
_listeners.add(listener);
} }
synchronized void removeListener(final L listener) { synchronized void removeListener(final L listener) {
_listeners.remove(listener); listenerToAppContext.remove(listener);
} }
abstract void performOnListeners(final List<L> listeners, final _NativeEvent event); abstract void performOnListener(L listener, final _NativeEvent event);
void registerNativeListener() { } void registerNativeListener() { }
private void setListenerContext(L listener, AppContext listenerContext) {
if (listenerContext == null) {
throw new RuntimeException(
"Attempting to add a listener from a thread group without AppContext");
}
listenerToAppContext.put(listener, AppContext.getAppContext());
}
} }
abstract class _BooleanAppEventMultiplexor<L, E> extends _AppEventMultiplexor<L> { abstract class _BooleanAppEventMultiplexor<L, E> extends _AppEventMultiplexor<L> {
@Override @Override
void performOnListeners(final List<L> listeners, final _NativeEvent event) { void performOnListener(L listener, final _NativeEvent event) {
final boolean isTrue = Boolean.TRUE.equals(event.get(0)); final boolean isTrue = Boolean.TRUE.equals(event.get(0));
final E e = createEvent(isTrue); final E e = createEvent(isTrue);
if (isTrue) { if (isTrue) {
for (final L listener : listeners) performTrueEventOn(listener, e); performTrueEventOn(listener, e);
} else { } else {
for (final L listener : listeners) performFalseEventOn(listener, e); performFalseEventOn(listener, e);
} }
} }
...@@ -479,30 +496,34 @@ class _AppEventHandler { ...@@ -479,30 +496,34 @@ class _AppEventHandler {
*/ */
abstract class _AppEventDispatcher<H> { abstract class _AppEventDispatcher<H> {
H _handler; H _handler;
AppContext handlerContext;
// called from AppKit Thread-0 // called from AppKit Thread-0
void dispatch(final _NativeEvent event) { void dispatch(final _NativeEvent event) {
EventQueue.invokeLater(new Runnable() { // grab a local ref to the handler
public void run() { final H localHandler;
// grab a local ref to the handler final AppContext localHandlerContext;
final H localHandler; synchronized (_AppEventDispatcher.this) {
synchronized (_AppEventDispatcher.this) { localHandler = _handler;
localHandler = _handler; localHandlerContext = handlerContext;
} }
// invoke the handler outside of the synchronized block if (localHandler == null) {
if (localHandler == null) { performDefaultAction(event);
performDefaultAction(event); } else {
} else { SunToolkit.invokeLaterOnAppContext(localHandlerContext, new Runnable() {
public void run() {
performUsing(localHandler, event); performUsing(localHandler, event);
} }
} });
}); }
} }
synchronized void setHandler(final H handler) { synchronized void setHandler(final H handler) {
this._handler = handler; this._handler = handler;
setHandlerContext(AppContext.getAppContext());
// if a new handler is installed, block addition of legacy ApplicationListeners // if a new handler is installed, block addition of legacy ApplicationListeners
if (handler == legacyHandler) return; if (handler == legacyHandler) return;
legacyHandler.blockLegacyAPI(); legacyHandler.blockLegacyAPI();
...@@ -510,6 +531,15 @@ class _AppEventHandler { ...@@ -510,6 +531,15 @@ class _AppEventHandler {
void performDefaultAction(final _NativeEvent event) { } // by default, do nothing void performDefaultAction(final _NativeEvent event) { } // by default, do nothing
abstract void performUsing(final H handler, final _NativeEvent event); abstract void performUsing(final H handler, final _NativeEvent event);
protected void setHandlerContext(AppContext ctx) {
if (ctx == null) {
throw new RuntimeException(
"Attempting to set a handler from a thread group without AppContext");
}
handlerContext = ctx;
}
} }
abstract class _QueuingAppEventDispatcher<H> extends _AppEventDispatcher<H> { abstract class _QueuingAppEventDispatcher<H> extends _AppEventDispatcher<H> {
...@@ -531,6 +561,8 @@ class _AppEventHandler { ...@@ -531,6 +561,8 @@ class _AppEventHandler {
synchronized void setHandler(final H handler) { synchronized void setHandler(final H handler) {
this._handler = handler; this._handler = handler;
setHandlerContext(AppContext.getAppContext());
// dispatch any events in the queue // dispatch any events in the queue
if (queuedEvents != null) { if (queuedEvents != null) {
// grab a local ref to the queue, so the real one can be nulled out // grab a local ref to the queue, so the real one can be nulled out
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package com.apple.eawt.event; package com.apple.eawt.event;
import sun.awt.SunToolkit;
import java.awt.*; import java.awt.*;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
...@@ -70,7 +72,7 @@ final class GestureHandler { ...@@ -70,7 +72,7 @@ final class GestureHandler {
static void handleGestureFromNative(final Window window, final int type, final double x, final double y, final double a, final double b) { static void handleGestureFromNative(final Window window, final int type, final double x, final double y, final double a, final double b) {
if (window == null) return; // should never happen... if (window == null) return; // should never happen...
EventQueue.invokeLater(new Runnable() { SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
public void run() { public void run() {
final Component component = SwingUtilities.getDeepestComponentAt(window, (int)x, (int)y); final Component component = SwingUtilities.getDeepestComponentAt(window, (int)x, (int)y);
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2013, 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
...@@ -32,6 +32,7 @@ import java.util.Hashtable; ...@@ -32,6 +32,7 @@ import java.util.Hashtable;
import javax.swing.*; import javax.swing.*;
import sun.awt.SunToolkit;
import sun.lwawt.LWToolkit; import sun.lwawt.LWToolkit;
import sun.lwawt.macosx.*; import sun.lwawt.macosx.*;
...@@ -144,7 +145,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S ...@@ -144,7 +145,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S
updateItems(); updateItems();
fItemBounds = new Rectangle[invoker.getMenuComponentCount()]; fItemBounds = new Rectangle[invoker.getMenuComponentCount()];
} }
}, null); }, invoker);
} catch (final Exception e) { } catch (final Exception e) {
System.err.println(e); System.err.println(e);
e.printStackTrace(); e.printStackTrace();
...@@ -172,7 +173,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S ...@@ -172,7 +173,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S
fItemBounds = null; fItemBounds = null;
} }
}, null); }, invoker);
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -200,7 +201,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S ...@@ -200,7 +201,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S
if (kind == 0) return; if (kind == 0) return;
if (fItemBounds == null) return; if (fItemBounds == null) return;
SwingUtilities.invokeLater(new Runnable() { SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
@Override @Override
public void run() { public void run() {
Component target = null; Component target = null;
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2013, 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
...@@ -53,7 +53,7 @@ public class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuItemPeer ...@@ -53,7 +53,7 @@ public class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuItemPeer
public void handleAction(final boolean state) { public void handleAction(final boolean state) {
final CheckboxMenuItem target = (CheckboxMenuItem)getTarget(); final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
EventQueue.invokeLater(new Runnable() { SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
public void run() { public void run() {
target.setState(state); target.setState(state);
} }
......
...@@ -107,10 +107,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { ...@@ -107,10 +107,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
loc = rootComponent.getLocation(); loc = rootComponent.getLocation();
} }
//It sure will be LWComponentPeer instance as rootComponent is a Window
PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
// If there isn't any drag image make one of default appearance: // If there isn't any drag image make one of default appearance:
if (fDragImage == null) if (fDragImage == null)
this.setDefaultDragImage(component); this.setDefaultDragImage(component);
...@@ -137,6 +133,11 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { ...@@ -137,6 +133,11 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
} }
try { try {
//It sure will be LWComponentPeer instance as rootComponent is a Window
PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
if (nativeViewPtr == 0L) throw new InvalidDnDOperationException("Unsupported platform window implementation");
// Create native dragging source: // Create native dragging source:
final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent, final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent,
(int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers, (int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers,
......
...@@ -52,6 +52,8 @@ public final class CDropTarget { ...@@ -52,6 +52,8 @@ public final class CDropTarget {
fPeer = peer; fPeer = peer;
long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow()); long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin)
// Create native dragging destination: // Create native dragging destination:
fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer); fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
if (fNativeDropTarget == 0) { if (fNativeDropTarget == 0) {
......
...@@ -479,12 +479,14 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -479,12 +479,14 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
deliverZoom(true); deliverZoom(true);
this.normalBounds = peer.getBounds(); this.normalBounds = peer.getBounds();
long screen = CWrapper.NSWindow.screen(getNSWindowPtr());
Rectangle toBounds = CWrapper.NSScreen.visibleFrame(screen).getBounds(); GraphicsConfiguration config = getPeer().getGraphicsConfiguration();
// Flip the y coordinate Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets();
Rectangle frame = CWrapper.NSScreen.frame(screen).getBounds(); Rectangle toBounds = config.getBounds();
toBounds.y = frame.height - toBounds.y - toBounds.height; setBounds(toBounds.x + i.left,
setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height); toBounds.y + i.top,
toBounds.width - i.left - i.right,
toBounds.height - i.top - i.bottom);
} }
} }
...@@ -751,13 +753,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -751,13 +753,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// the move/size notification from the underlying system comes // the move/size notification from the underlying system comes
// but it contains a bounds smaller than the whole screen // but it contains a bounds smaller than the whole screen
// and therefore we need to create the synthetic notifications // and therefore we need to create the synthetic notifications
Rectangle screenBounds; Rectangle screenBounds = getPeer().getGraphicsConfiguration().getBounds();
final long screenPtr = CWrapper.NSWindow.screen(getNSWindowPtr());
try {
screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds();
} finally {
CWrapper.NSObject.release(screenPtr);
}
peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width, peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width,
screenBounds.height); screenBounds.height);
} }
...@@ -900,8 +896,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -900,8 +896,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView(); nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
} else if (platformWindow instanceof CViewPlatformEmbeddedFrame){ } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr(); nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
} else {
throw new IllegalArgumentException("Unsupported platformWindow implementation");
} }
return nativePeer; return nativePeer;
} }
...@@ -932,25 +926,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -932,25 +926,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
final Rectangle oldB = nativeBounds; final Rectangle oldB = nativeBounds;
nativeBounds = new Rectangle(x, y, width, height); nativeBounds = new Rectangle(x, y, width, height);
final GraphicsConfiguration oldGC = peer.getGraphicsConfiguration();
final GraphicsConfiguration newGC = peer.getGraphicsConfiguration();
// System-dependent appearance optimization.
if (peer != null) { if (peer != null) {
peer.notifyReshape(x, y, width, height); peer.notifyReshape(x, y, width, height);
} // System-dependent appearance optimization.
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize())) || isFullScreenAnimationOn) {
|| isFullScreenAnimationOn || !Objects.equals(newGC, oldGC)) { flushBuffers();
flushBuffers(); }
} }
} }
private void deliverWindowClosingEvent() { private void deliverWindowClosingEvent() {
if (peer != null) { if (peer != null && peer.getBlocker() == null) {
if (peer.getBlocker() == null) { peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
}
} }
} }
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2013, 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
...@@ -96,7 +96,7 @@ public class CViewEmbeddedFrame extends EmbeddedFrame { ...@@ -96,7 +96,7 @@ public class CViewEmbeddedFrame extends EmbeddedFrame {
validate(); validate();
setVisible(true); setVisible(true);
} }
}, null); }, this);
} catch (InterruptedException | InvocationTargetException ex) {} } catch (InterruptedException | InvocationTargetException ex) {}
} }
} }
...@@ -71,8 +71,6 @@ public final class CWrapper { ...@@ -71,8 +71,6 @@ public final class CWrapper {
public static native void zoom(long window); public static native void zoom(long window);
public static native void makeFirstResponder(long window, long responder); public static native void makeFirstResponder(long window, long responder);
public static native long screen(long window);
} }
public static final class NSView { public static final class NSView {
...@@ -95,12 +93,6 @@ public final class CWrapper { ...@@ -95,12 +93,6 @@ public final class CWrapper {
public static native void release(long object); public static native void release(long object);
} }
public static final class NSScreen {
public static native Rectangle2D frame(long screen);
public static native Rectangle2D visibleFrame(long screen);
public static native long screenByDisplayId(int displayID);
}
public static final class NSColor { public static final class NSColor {
public static native long clearColor(); public static native long clearColor();
} }
......
...@@ -82,8 +82,13 @@ JNF_COCOA_ENTER(env); ...@@ -82,8 +82,13 @@ JNF_COCOA_ENTER(env);
// keys, so we need to do the same translation here that we do // keys, so we need to do the same translation here that we do
// for the regular key down events // for the regular key down events
if ([eventKey length] == 1) { if ([eventKey length] == 1) {
unichar ch = NsCharToJavaChar([eventKey characterAtIndex:0], 0); unichar origChar = [eventKey characterAtIndex:0];
eventKey = [NSString stringWithCharacters: &ch length: 1]; unichar newChar = NsCharToJavaChar(origChar, 0);
if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
newChar = origChar;
}
eventKey = [NSString stringWithCharacters: &newChar length: 1];
} }
if ([menuKey isEqualToString:eventKey]) { if ([menuKey isEqualToString:eventKey]) {
......
...@@ -396,31 +396,6 @@ JNF_COCOA_ENTER(env); ...@@ -396,31 +396,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/*
* Class: sun_lwawt_macosx_CWrapper$NSWindow
* Method: screen
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_screen
(JNIEnv *env, jclass cls, jlong windowPtr)
{
__block jlong screenPtr = 0L;
JNF_COCOA_ENTER(env);
AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
const NSScreen *screen = [window screen];
CFRetain(screen); // GC
screenPtr = ptr_to_jlong(screen);
}];
JNF_COCOA_EXIT(env);
return screenPtr;
}
/* /*
* Method: miniaturize * Method: miniaturize
* Signature: (J)V * Signature: (J)V
...@@ -690,92 +665,6 @@ JNF_COCOA_ENTER(env); ...@@ -690,92 +665,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/*
* Class: sun_lwawt_macosx_CWrapper$NSScreen
* Method: frame
* Signature: (J)Ljava/awt/Rectangle;
*/
JNIEXPORT jobject JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSScreen_frame
(JNIEnv *env, jclass cls, jlong screenPtr)
{
jobject jRect = NULL;
JNF_COCOA_ENTER(env);
__block NSRect rect = NSZeroRect;
NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
rect = [screen frame];
}];
jRect = NSToJavaRect(env, rect);
JNF_COCOA_EXIT(env);
return jRect;
}
/*
* Class: sun_lwawt_macosx_CWrapper_NSScreen
* Method: visibleFrame
* Signature: (J)Ljava/awt/geom/Rectangle2D;
*/
JNIEXPORT jobject JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSScreen_visibleFrame
(JNIEnv *env, jclass cls, jlong screenPtr)
{
jobject jRect = NULL;
JNF_COCOA_ENTER(env);
__block NSRect rect = NSZeroRect;
NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
rect = [screen visibleFrame];
}];
jRect = NSToJavaRect(env, rect);
JNF_COCOA_EXIT(env);
return jRect;
}
/*
* Class: sun_lwawt_macosx_CWrapper_NSScreen
* Method: screenByDisplayId
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSScreen_screenByDisplayId
(JNIEnv *env, jclass cls, jint displayID)
{
__block jlong screenPtr = 0L;
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
NSArray *screens = [NSScreen screens];
for (NSScreen *screen in screens) {
NSDictionary *screenInfo = [screen deviceDescription];
NSNumber *screenID = [screenInfo objectForKey:@"NSScreenNumber"];
if ([screenID intValue] == displayID){
CFRetain(screen); // GC
screenPtr = ptr_to_jlong(screen);
break;
}
}
}];
JNF_COCOA_EXIT(env);
return screenPtr;
}
/* /*
* Class: sun_lwawt_macosx_CWrapper$NSColor * Class: sun_lwawt_macosx_CWrapper$NSColor
* Method: clearColor * Method: clearColor
......
...@@ -102,7 +102,7 @@ horizontal=horizontal ...@@ -102,7 +102,7 @@ horizontal=horizontal
# #
# accessible actions # accessible actions
# #
toggle expand=toggle expand toggleexpand=toggle expand
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=horizontal ...@@ -102,7 +102,7 @@ horizontal=horizontal
# #
# accessible actions # accessible actions
# #
toggle expand=ein-/ausblenden toggleexpand=ein-/ausblenden
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=horizontal ...@@ -102,7 +102,7 @@ horizontal=horizontal
# #
# accessible actions # accessible actions
# #
toggle expand=activar/desactivar ampliaci\u00F3n toggleexpand=activar/desactivar ampliaci\u00F3n
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=horizontal ...@@ -102,7 +102,7 @@ horizontal=horizontal
# #
# accessible actions # accessible actions
# #
toggle expand=basculer le d\u00E9veloppement toggleexpand=basculer le d\u00E9veloppement
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=orizzontale ...@@ -102,7 +102,7 @@ horizontal=orizzontale
# #
# accessible actions # accessible actions
# #
toggle expand=abilita/disabilita espansione toggleexpand=abilita/disabilita espansione
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73 ...@@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73
# #
# accessible actions # accessible actions
# #
toggle expand=\u5C55\u958B\u306E\u30C8\u30B0\u30EB toggleexpand=\u5C55\u958B\u306E\u30C8\u30B0\u30EB
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=\uAC00\uB85C ...@@ -102,7 +102,7 @@ horizontal=\uAC00\uB85C
# #
# accessible actions # accessible actions
# #
toggle expand=\uD1A0\uAE00 \uD655\uC7A5 toggleexpand=\uD1A0\uAE00 \uD655\uC7A5
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=horizontal ...@@ -102,7 +102,7 @@ horizontal=horizontal
# #
# accessible actions # accessible actions
# #
toggle expand=alternar expans\u00E3o toggleexpand=alternar expans\u00E3o
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=horisontell ...@@ -102,7 +102,7 @@ horizontal=horisontell
# #
# accessible actions # accessible actions
# #
toggle expand=v\u00E4xla ut\u00F6ka toggleexpand=v\u00E4xla ut\u00F6ka
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73 ...@@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73
# #
# accessible actions # accessible actions
# #
toggle expand=\u5207\u6362\u5C55\u5F00 toggleexpand=\u5207\u6362\u5C55\u5F00
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73 ...@@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73
# #
# accessible actions # accessible actions
# #
toggle expand=\u5207\u63DB\u64F4\u5C55 toggleexpand=\u5207\u63DB\u64F4\u5C55
# new relations, roles and states for J2SE 1.5.0 # new relations, roles and states for J2SE 1.5.0
......
...@@ -296,6 +296,12 @@ public abstract class GraphicsDevice { ...@@ -296,6 +296,12 @@ public abstract class GraphicsDevice {
bgColor.getBlue(), 255); bgColor.getBlue(), 255);
w.setBackground(bgColor); w.setBackground(bgColor);
} }
// Check if this window is in fullscreen mode on another device.
final GraphicsConfiguration gc = w.getGraphicsConfiguration();
if (gc != null && gc.getDevice() != this
&& gc.getDevice().getFullScreenWindow() == w) {
gc.getDevice().setFullScreenWindow(null);
}
} }
if (fullScreenWindow != null && windowedModeBounds != null) { if (fullScreenWindow != null && windowedModeBounds != null) {
// if the window went into fs mode before it was realized it may // if the window went into fs mode before it was realized it may
......
...@@ -652,11 +652,12 @@ public class Introspector { ...@@ -652,11 +652,12 @@ public class Introspector {
} }
} else { } else {
if (pd.getReadMethod() != null) { if (pd.getReadMethod() != null) {
String pdName = pd.getReadMethod().getName();
if (gpd != null) { if (gpd != null) {
// Don't replace the existing read // Don't replace the existing read
// method if it starts with "is" // method if it starts with "is"
Method method = gpd.getReadMethod(); String gpdName = gpd.getReadMethod().getName();
if (!method.getName().startsWith(IS_PREFIX)) { if (gpdName.equals(pdName) || !gpdName.startsWith(IS_PREFIX)) {
gpd = new PropertyDescriptor(gpd, pd); gpd = new PropertyDescriptor(gpd, pd);
} }
} else { } else {
......
...@@ -54,7 +54,7 @@ public interface AccessibleAction { ...@@ -54,7 +54,7 @@ public interface AccessibleAction {
* @since 1.5 * @since 1.5
*/ */
public static final String TOGGLE_EXPAND = public static final String TOGGLE_EXPAND =
new String ("toggle expand"); new String ("toggleexpand");
/** /**
* An action which increments a value. * An action which increments a value.
......
...@@ -170,8 +170,8 @@ public final class ContentModel implements Serializable { ...@@ -170,8 +170,8 @@ public final class ContentModel implements Serializable {
case '&': { case '&': {
Element e = (Element) token; Element e = (Element) token;
if (valSet == null) { if (valSet == null) {
valSet = new boolean[Element.maxIndex + 1]; valSet = new boolean[Element.getMaxIndex() + 1];
val = new boolean[Element.maxIndex + 1]; val = new boolean[valSet.length];
// All Element instances are created before this ever executes // All Element instances are created before this ever executes
} }
if (valSet[e.index]) { if (valSet[e.index]) {
......
...@@ -28,6 +28,7 @@ package javax.swing.text.html.parser; ...@@ -28,6 +28,7 @@ package javax.swing.text.html.parser;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.BitSet; import java.util.BitSet;
import java.io.*; import java.io.*;
import sun.awt.AppContext;
/** /**
* An element as described in a DTD using the ELEMENT construct. * An element as described in a DTD using the ELEMENT construct.
...@@ -51,8 +52,6 @@ class Element implements DTDConstants, Serializable { ...@@ -51,8 +52,6 @@ class Element implements DTDConstants, Serializable {
public ContentModel content; public ContentModel content;
public AttributeList atts; public AttributeList atts;
static int maxIndex = 0;
/** /**
* A field to store user data. Mostly used to store * A field to store user data. Mostly used to store
* style sheets. * style sheets.
...@@ -68,7 +67,18 @@ class Element implements DTDConstants, Serializable { ...@@ -68,7 +67,18 @@ class Element implements DTDConstants, Serializable {
Element(String name, int index) { Element(String name, int index) {
this.name = name; this.name = name;
this.index = index; this.index = index;
maxIndex = Math.max(maxIndex, index); if (index > getMaxIndex()) {
AppContext.getAppContext().put(MAX_INDEX_KEY, index);
}
}
private static final Object MAX_INDEX_KEY = new Object();
static int getMaxIndex() {
Integer value = (Integer) AppContext.getAppContext().get(MAX_INDEX_KEY);
return (value != null)
? value.intValue()
: 0;
} }
/** /**
......
...@@ -1795,20 +1795,10 @@ public final class SunGraphics2D ...@@ -1795,20 +1795,10 @@ public final class SunGraphics2D
} }
public Rectangle getClipBounds() { public Rectangle getClipBounds() {
Rectangle r;
if (clipState == CLIP_DEVICE) { if (clipState == CLIP_DEVICE) {
r = null; return null;
} else if (transformState <= TRANSFORM_INT_TRANSLATE) {
if (usrClip instanceof Rectangle) {
r = new Rectangle((Rectangle) usrClip);
} else {
r = usrClip.getBounds();
}
r.translate(-transX, -transY);
} else {
r = getClip().getBounds();
} }
return r; return getClipBounds(new Rectangle());
} }
public Rectangle getClipBounds(Rectangle r) { public Rectangle getClipBounds(Rectangle r) {
...@@ -1817,11 +1807,11 @@ public final class SunGraphics2D ...@@ -1817,11 +1807,11 @@ public final class SunGraphics2D
if (usrClip instanceof Rectangle) { if (usrClip instanceof Rectangle) {
r.setBounds((Rectangle) usrClip); r.setBounds((Rectangle) usrClip);
} else { } else {
r.setBounds(usrClip.getBounds()); r.setFrame(usrClip.getBounds2D());
} }
r.translate(-transX, -transY); r.translate(-transX, -transY);
} else { } else {
r.setBounds(getClip().getBounds()); r.setFrame(getClip().getBounds2D());
} }
} else if (r == null) { } else if (r == null) {
throw new NullPointerException("null rectangle parameter"); throw new NullPointerException("null rectangle parameter");
...@@ -1996,10 +1986,10 @@ public final class SunGraphics2D ...@@ -1996,10 +1986,10 @@ public final class SunGraphics2D
matrix[2] = matrix[0] + rect.getWidth(); matrix[2] = matrix[0] + rect.getWidth();
matrix[3] = matrix[1] + rect.getHeight(); matrix[3] = matrix[1] + rect.getHeight();
tx.transform(matrix, 0, matrix, 0, 2); tx.transform(matrix, 0, matrix, 0, 2);
rect = new Rectangle2D.Float(); fixRectangleOrientation(matrix, rect);
rect.setFrameFromDiagonal(matrix[0], matrix[1], return new Rectangle2D.Double(matrix[0], matrix[1],
matrix[2], matrix[3]); matrix[2] - matrix[0],
return rect; matrix[3] - matrix[1]);
} }
if (tx.isIdentity()) { if (tx.isIdentity()) {
...@@ -2009,6 +1999,22 @@ public final class SunGraphics2D ...@@ -2009,6 +1999,22 @@ public final class SunGraphics2D
return tx.createTransformedShape(clip); return tx.createTransformedShape(clip);
} }
/**
* Sets orientation of the rectangle according to the clip.
*/
private static void fixRectangleOrientation(double[] m, Rectangle2D clip) {
if (clip.getWidth() > 0 != (m[2] - m[0] > 0)) {
double t = m[0];
m[0] = m[2];
m[2] = t;
}
if (clip.getHeight() > 0 != (m[3] - m[1] > 0)) {
double t = m[1];
m[1] = m[3];
m[3] = t;
}
}
public void clipRect(int x, int y, int w, int h) { public void clipRect(int x, int y, int w, int h) {
clip(new Rectangle(x, y, w, h)); clip(new Rectangle(x, y, w, h));
} }
......
...@@ -548,6 +548,10 @@ cmsBool FixWhiteMisalignment(cmsPipeline* Lut, cmsColorSpaceSignature EntryColor ...@@ -548,6 +548,10 @@ cmsBool FixWhiteMisalignment(cmsPipeline* Lut, cmsColorSpaceSignature EntryColor
for (i=0; i < nOuts; i++) { for (i=0; i < nOuts; i++) {
cmsToneCurve* InversePostLin = cmsReverseToneCurve(Curves[i]); cmsToneCurve* InversePostLin = cmsReverseToneCurve(Curves[i]);
if (InversePostLin == NULL) {
WhiteOut[i] = 0;
continue;
}
WhiteOut[i] = cmsEvalToneCurve16(InversePostLin, WhitePointOut[i]); WhiteOut[i] = cmsEvalToneCurve16(InversePostLin, WhitePointOut[i]);
cmsFreeToneCurve(InversePostLin); cmsFreeToneCurve(InversePostLin);
} }
......
...@@ -105,9 +105,15 @@ public final class XErrorHandlerUtil { ...@@ -105,9 +105,15 @@ public final class XErrorHandlerUtil {
* Unsets a current synthetic error handler. Must be called with the acquired AWT lock. * Unsets a current synthetic error handler. Must be called with the acquired AWT lock.
*/ */
public static void RESTORE_XERROR_HANDLER() { public static void RESTORE_XERROR_HANDLER() {
RESTORE_XERROR_HANDLER(true);
}
private static void RESTORE_XERROR_HANDLER(boolean doXSync) {
// Wait until all requests are processed by the X server // Wait until all requests are processed by the X server
// and only then uninstall the error handler. // and only then uninstall the error handler.
XSync(); if (doXSync) {
XSync();
}
current_error_handler = null; current_error_handler = null;
} }
......
...@@ -1029,7 +1029,16 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { ...@@ -1029,7 +1029,16 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
// now supports collation and that most OS has a way // now supports collation and that most OS has a way
// of setting it, it is a safe assumption to just always // of setting it, it is a safe assumption to just always
// include SheetCollate as supported attribute. // include SheetCollate as supported attribute.
catList.add(SheetCollate.class);
/*
In Linux, we use Postscript for rendering but Linux still
has issues in propagating Postscript-embedded setpagedevice
setting like collation. Therefore, we temporarily exclude
Linux.
*/
if (!UnixPrintServiceLookup.isLinux()) {
catList.add(SheetCollate.class);
}
} }
// With the assumption that Chromaticity is equivalent to // With the assumption that Chromaticity is equivalent to
......
...@@ -123,6 +123,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -123,6 +123,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
return osname.equals("SunOS"); return osname.equals("SunOS");
} }
static boolean isLinux() {
return (osname.equals("Linux"));
}
static boolean isBSD() { static boolean isBSD() {
return (osname.equals("Linux") || return (osname.equals("Linux") ||
osname.contains("OS X")); osname.contains("OS X"));
......
...@@ -46,11 +46,11 @@ ...@@ -46,11 +46,11 @@
/* /*
* Expected types of arguments of the macro. * Expected types of arguments of the macro.
* (JNIEnv*) * (JNIEnv*, jboolean)
*/ */
#define RESTORE_XERROR_HANDLER(env) do { \ #define RESTORE_XERROR_HANDLER(env, doXSync) do { \
JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \ JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \
"RESTORE_XERROR_HANDLER", "()V"); \ "RESTORE_XERROR_HANDLER", "(Z)V", doXSync); \
} while (0) } while (0)
/* /*
...@@ -64,8 +64,18 @@ ...@@ -64,8 +64,18 @@
do { \ do { \
code; \ code; \
} while (0); \ } while (0); \
RESTORE_XERROR_HANDLER(env); \ RESTORE_XERROR_HANDLER(env, JNI_TRUE); \
if (handlerHasFlag == JNI_TRUE) { \ if (handlerHasFlag == JNI_TRUE) { \
GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag); \
} \
} while (0)
/*
* Expected types of arguments of the macro.
* (JNIEnv*, jobject, jboolean)
*/
#define GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag) do { \
if (handlerRef != NULL) { \
errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", \ errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", \
"()Z").z; \ "()Z").z; \
} \ } \
......
...@@ -392,10 +392,12 @@ Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer ...@@ -392,10 +392,12 @@ Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
attrlist[3] = height; attrlist[3] = height;
errorOccurredFlag = JNI_FALSE; errorOccurredFlag = JNI_FALSE;
EXEC_WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler", WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler",
"()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE, "()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE, errorHandlerRef);
errorHandlerRef, errorOccurredFlag, pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist);
pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist)); XSync(awt_display, False);
RESTORE_XERROR_HANDLER(env, JNI_FALSE);
GET_HANDLER_ERROR_OCCURRED_FLAG(env, errorHandlerRef, errorOccurredFlag);
if ((pbuffer == 0) || errorOccurredFlag) { if ((pbuffer == 0) || errorOccurredFlag) {
J2dRlsTraceLn(J2D_TRACE_ERROR, J2dRlsTraceLn(J2D_TRACE_ERROR,
......
/*
* Copyright (c) 2013, 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.
*/
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.image.BufferedImage;
import sun.java2d.SunGraphics2D;
/**
* @test
* @bug 8004859
* @summary getClipBounds/getClip should return equivalent bounds.
* @author Sergey Bylokhov
*/
public final class Test8004859 {
private static Shape[] clips = {new Rectangle(0, 0, 1, 1), new Rectangle(
100, 100, -100, -100)};
private static boolean status = true;
public static void main(final String[] args)
throws NoninvertibleTransformException {
final BufferedImage bi = new BufferedImage(300, 300,
BufferedImage.TYPE_INT_RGB);
final Graphics2D g = (Graphics2D) bi.getGraphics();
test(g);
g.translate(2.0, 2.0);
test(g);
g.translate(-4.0, -4.0);
test(g);
g.scale(2.0, 2.0);
test(g);
g.scale(-4.0, -4.0);
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.dispose();
if (!status) {
throw new RuntimeException("Test failed");
}
}
private static void test(final Graphics2D g) {
for (final Shape clip : clips) {
g.setClip(clip);
if (!g.getClip().equals(clip)) {
System.err.println("Expected clip: " + clip);
System.err.println("Actual clip: " + g.getClip());
System.err.println("bounds="+g.getClip().getBounds2D());
System.err.println("bounds="+g.getClip().getBounds());
status = false;
}
final Rectangle bounds = g.getClipBounds();
if (!clip.equals(bounds)) {
System.err.println("Expected getClipBounds(): " + clip);
System.err.println("Actual getClipBounds(): " + bounds);
status = false;
}
g.getClipBounds(bounds);
if (!clip.equals(bounds)) {
System.err.println("Expected getClipBounds(r): " + clip);
System.err.println("Actual getClipBounds(r): " + bounds);
status = false;
}
if (!clip.getBounds2D().isEmpty() && ((SunGraphics2D) g).clipRegion
.isEmpty()) {
System.err.println("clipRegion should not be empty");
status = false;
}
}
}
}
/*
* Copyright (c) 2013, 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.
*/
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import sun.awt.SunToolkit;
/**
* @test
* @bug 8019587
* @author Sergey Bylokhov
*/
public class IncorrectDisplayModeExitFullscreen {
public static void main(final String[] args) {
final GraphicsDevice[] devices =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getScreenDevices();
if (devices.length < 2 || devices[0].getDisplayModes().length < 2
|| !devices[0].isFullScreenSupported()
|| !devices[1].isFullScreenSupported()) {
System.err.println("Testcase is not applicable");
return;
}
final DisplayMode defaultDM = devices[0].getDisplayMode();
final DisplayMode[] dms = devices[0].getDisplayModes();
DisplayMode nonDefaultDM = null;
for (final DisplayMode dm : dms) {
if (!dm.equals(defaultDM)) {
nonDefaultDM = dm;
break;
}
}
if (nonDefaultDM == null) {
System.err.println("Testcase is not applicable");
return;
}
final Frame frame = new Frame();
frame.setBackground(Color.GREEN);
frame.setUndecorated(true);
try {
devices[0].setFullScreenWindow(frame);
sleep();
devices[0].setDisplayMode(nonDefaultDM);
sleep();
devices[1].setFullScreenWindow(frame);
sleep();
if (!defaultDM.equals(devices[0].getDisplayMode())) {
throw new RuntimeException("DisplayMode is not restored");
}
} finally {
// cleaning up
devices[0].setFullScreenWindow(null);
devices[1].setFullScreenWindow(null);
frame.dispose();
}
}
private static void sleep() {
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
try {
Thread.sleep(1500);
} catch (InterruptedException ignored) {
}
}
}
/*
* Copyright (c) 2013, 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 @summary JVM crash if the frame maximized from offscreen
* @author Petr Pchelko
* @library ../../regtesthelpers
* @build Util
* @compile MaximizeOffscreenTest.java
* @run main/othervm MaximizeOffscreenTest
*/
import test.java.awt.regtesthelpers.Util;
import javax.swing.*;
import java.awt.*;
public class MaximizeOffscreenTest {
private static JFrame frame;
public static void main(String[] args) throws Throwable {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
constructTestUI();
}
});
Util.waitForIdle(null);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
}
});
Util.waitForIdle(null);
}
private static void constructTestUI() {
frame = new JFrame("Test frame");
frame.setUndecorated(true);
frame.setBounds(-1000, -1000, 100, 100);
frame.setVisible(true);
}
}
/*
* Copyright (c) 2013, 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.
*/
import java.beans.PropertyDescriptor;
/*
* @test
* @bug 6707231
* @summary Tests the boolean getter
* @author Sergey Malenkov
*/
public class Test6707231 {
public static void main(String[] args) throws Exception {
test(Bean.class, Bean.class);
test(Public.class, Public.class);
test(Private.class, Bean.class);
}
public static class Bean {
private boolean value;
public boolean isValue() {
return this.value;
}
public void setValue(boolean value) {
this.value = value;
}
}
public static class Public extends Bean {
public boolean isValue() {
return super.isValue();
}
public void setValue(boolean value) {
super.setValue(value);
}
}
private static class Private extends Bean {
public boolean isValue() {
return super.isValue();
}
public void setValue(boolean value) {
super.setValue(value);
}
}
private static void test(Class<?> actual, Class<?> expected) {
PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(actual, "value");
Class<?> getter = pd.getReadMethod().getDeclaringClass();
Class<?> setter = pd.getWriteMethod().getDeclaringClass();
if ((getter != expected) || (setter != expected)) {
throw new Error(actual.getName());
}
}
}
...@@ -35,10 +35,11 @@ import java.awt.event.*; ...@@ -35,10 +35,11 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
public class ActionListenerCalledTwiceTest { public class ActionListenerCalledTwiceTest {
static String menuItems[] = { "Item1", "Item2" }; static String menuItems[] = { "Item1", "Item2", "Item3" };
static KeyStroke keyStrokes[] = { static KeyStroke keyStrokes[] = {
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0) KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
}; };
static volatile int listenerCallCounter = 0; static volatile int listenerCallCounter = 0;
......
/*
* Copyright (c) 2013, 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.
*/
import java.util.Vector;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.parser.DTD;
import javax.swing.text.html.parser.Element;
import sun.awt.SunToolkit;
/*
* @test
* @bug 8017492
* @run main/othervm Test8017492
* @summary Tests for OutOfMemoryError/NegativeArraySizeException
* @author Sergey Malenkov
*/
public class Test8017492 {
public static void main(String[] args) throws Exception {
Runnable task = new Runnable() {
@Override
public void run() {
try {
SunToolkit.createNewAppContext();
DTD dtd = DTD.getDTD("dtd");
dtd.elements = new Vector<Element>() {
@Override
public synchronized int size() {
return Integer.MAX_VALUE;
}
};
dtd.getElement("element");
}
catch (Exception exception) {
throw new Error("unexpected", exception);
}
}
};
// run task with different AppContext
Thread thread = new Thread(new ThreadGroup("$$$"), task);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
throwable.printStackTrace();
System.exit(1);
}
});
thread.start();
thread.join();
// add error handling
HTMLDocument document = new HTMLDocument() {
@Override
public HTMLEditorKit.ParserCallback getReader(int pos) {
return getReader(pos, 0, 0, null);
}
@Override
public HTMLEditorKit.ParserCallback getReader(int pos, int popDepth, int pushDepth, HTML.Tag insertTag) {
return new HTMLDocument.HTMLReader(pos, popDepth, pushDepth, insertTag) {
@Override
public void handleError(String error, int pos) {
throw new Error(error);
}
};
}
};
// run parser
new HTMLEditorKit().insertHTML(document, 0, "<html><body>text", 0, 0, null);
}
}
/* /*
* Copyright 2013 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2013, 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
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
* 2 along with this work; if not, write to the Free Software Foundation, * 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* CA 95054 USA or visit www.sun.com if you need additional information or * or visit www.oracle.com if you need additional information or have any
* have any questions. * questions.
*/ */
/* /*
* @test * @test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册