提交 3a75e3fb 编写于 作者: Y yan

Merge

......@@ -27,6 +27,7 @@ package sun.awt.X11;
import java.awt.*;
import java.awt.peer.*;
import sun.awt.X11GraphicsConfig;
import sun.awt.SunToolkit;
class XRobotPeer implements RobotPeer {
private X11GraphicsConfig xgc = null;
......@@ -38,7 +39,8 @@ class XRobotPeer implements RobotPeer {
XRobotPeer(GraphicsConfiguration gc) {
this.xgc = (X11GraphicsConfig)gc;
setup();
SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
setup(tk.getNumberOfButtons());
}
public void dispose() {
......@@ -81,7 +83,7 @@ class XRobotPeer implements RobotPeer {
return pixelArray;
}
private static native synchronized void setup();
private static native synchronized void setup(int numberOfButtons);
private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
private static native synchronized void mousePressImpl(int buttons);
......
......@@ -51,9 +51,8 @@
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
extern int32_t getNumButtons();
static jint * masks;
static jint num_buttons;
static int32_t isXTestAvailable() {
int32_t major_opcode, first_event, first_error;
......@@ -164,34 +163,34 @@ static XImage *getWindowImage(Display * display, Window window,
/*********************************************************************************************/
// this should be called from XRobotPeer constructor
JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons) {
int32_t xtestAvailable;
// this should be called from XRobotPeer constructor
DTRACE_PRINTLN("RobotPeer: setup()");
num_buttons = numberOfButtons;
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
jsize len = (*env)->GetArrayLength(env, obj);
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
masks = (jint *)malloc(sizeof(jint)*len);
masks = (jint *)malloc(sizeof(jint) * num_buttons);
if (masks == (jint *) NULL) {
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
goto finally;
}
int i;
for (i = 0; i < len; i++) {
for (i = 0; i < num_buttons; i++) {
masks[i] = tmp[i];
}
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
(*env)->DeleteLocalRef(env, obj);
DTRACE_PRINTLN("RobotPeer: setup()");
AWT_LOCK();
xtestAvailable = isXTestAvailable();
DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
if (!xtestAvailable) {
......@@ -338,8 +337,6 @@ void mouseAction(JNIEnv *env,
{
AWT_LOCK();
int32_t num_buttons = getNumButtons(); //from XToolkit.c
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
......
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2008-2009 Sun Microsystems, Inc. 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
......@@ -23,7 +23,7 @@
/* @test
*
* @bug 6638195
* @bug 6638195 6844297
* @author Igor Kushnirskiy
* @summary tests if EventQueueDelegate.Delegate is invoked.
*/
......@@ -47,11 +47,22 @@ public class bug6638195 {
}
private static void runTest(MyEventQueueDelegate delegate) throws Exception {
// We need an empty runnable here, so the next event is
// processed with a new EventQueueDelegate. See 6844297
// for details
EventQueue.invokeLater(
new Runnable() {
public void run() {
}
});
// The following event is expected to be processed by
// the EventQueueDelegate instance
EventQueue.invokeLater(
new Runnable() {
public void run() {
}
});
// Finally, proceed on the main thread
final CountDownLatch latch = new CountDownLatch(1);
EventQueue.invokeLater(
new Runnable() {
......@@ -60,7 +71,7 @@ public class bug6638195 {
}
});
latch.await();
if (! delegate.allInvoked()) {
if (!delegate.allInvoked()) {
throw new RuntimeException("failed");
}
}
......@@ -125,6 +136,7 @@ public class bug6638195 {
return objectMap;
}
static class MyEventQueueDelegate implements EventQueueDelegate.Delegate {
private volatile boolean getNextEventInvoked = false;
private volatile boolean beforeDispatchInvoked = false;
......
/*
* Copyright 2009 Red Hat, Inc. All Rights Reserved.
* Portions Copyright 2009 Sun Microsystems, Inc. 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
......@@ -37,35 +38,62 @@
* Test fails if size of window is wrong
*/
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.*;
public class TestFrameSize {
static Dimension desiredDimensions = new Dimension(200, 200);
static int ERROR_MARGIN = 15;
static Frame mainWindow;
public static void drawGui() {
mainWindow = new Frame("");
mainWindow.setPreferredSize(desiredDimensions);
mainWindow.pack();
Dimension actualDimensions = mainWindow.getSize();
System.out.println("Desired dimensions: " + desiredDimensions.toString());
System.out.println("Actual dimensions: " + actualDimensions.toString());
if (Math.abs(actualDimensions.height - desiredDimensions.height) > ERROR_MARGIN) {
throw new RuntimeException("Incorrect widow size");
}
static Dimension desiredDimensions = new Dimension(200, 200);
static Frame mainWindow;
private static Dimension getClientSize(Frame window) {
Dimension size = window.getSize();
Insets insets = window.getInsets();
System.out.println("getClientSize() for " + window);
System.out.println(" size: " + size);
System.out.println(" insets: " + insets);
return new Dimension(
size.width - insets.left - insets.right,
size.height - insets.top - insets.bottom);
}
public static void drawGui() {
mainWindow = new Frame("");
mainWindow.setPreferredSize(desiredDimensions);
mainWindow.pack();
Dimension actualDimensions = mainWindow.getSize();
System.out.println("Desired dimensions: " + desiredDimensions.toString());
System.out.println("Actual dimensions: " + actualDimensions.toString());
if (!actualDimensions.equals(desiredDimensions)) {
throw new RuntimeException("Incorrect widow size");
}
// pack() guarantees to preserve the size of the client area after
// showing the window.
Dimension clientSize1 = getClientSize(mainWindow);
System.out.println("Client size before showing: " + clientSize1);
mainWindow.setVisible(true);
((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
Dimension clientSize2 = getClientSize(mainWindow);
System.out.println("Client size after showing: " + clientSize2);
if (!clientSize2.equals(clientSize1)) {
throw new RuntimeException("Incorrect client area size.");
}
}
public static void main(String[] args) {
try {
drawGui();
} finally {
if (mainWindow != null) {
mainWindow.dispose();
}
}
public static void main(String[] args) {
try {
drawGui();
} finally {
if (mainWindow != null) {
mainWindow.dispose();
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册