提交 16f29c08 编写于 作者: G goetz

Merge

/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, 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
......@@ -324,6 +324,8 @@ class SubTasksDone: public CHeapObj<mtInternal> {
// Set all tasks to unclaimed.
void clear();
NONCOPYABLE(SubTasksDone);
public:
// Initializes "this" to a state in which there are "n" tasks to be
// processed, none of the which are originally claimed. The number of
......
......@@ -640,7 +640,7 @@ public:
AbstractGangTask("Parallel Safepoint Cleanup"),
_cleanup_threads_cl(ParallelSPCleanupThreadClosure(counters)),
_num_workers(num_workers),
_subtasks(SubTasksDone(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS)),
_subtasks(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS),
_counters(counters) {}
void work(uint worker_id) {
......
......@@ -46,6 +46,19 @@
// This file holds all globally used constants & types, class (forward)
// declarations and a few frequently used utility functions.
// Declare the named class to be noncopyable. This macro must be used in
// a private part of the class's definition, followed by a semi-colon.
// Doing so provides private declarations for the class's copy constructor
// and assignment operator. Because these operations are private, most
// potential callers will fail to compile because they are inaccessible.
// The operations intentionally lack a definition, to provoke link-time
// failures for calls from contexts where they are accessible, e.g. from
// within the class or from a friend of the class.
// Note: The lack of definitions is still not completely bullet-proof, as
// an apparent call might be optimized away by copy elision.
// For C++11 the declarations should be changed to deleted definitions.
#define NONCOPYABLE(C) C(C const&); C& operator=(C const&) /* next token must be ; */
//----------------------------------------------------------------------------------------------------
// Printf-style formatters for fixed- and variable-width types as pointers and
// integers. These are derived from the definitions in inttypes.h. If the platform
......
......@@ -67,6 +67,7 @@ static NSTimeInterval gsLastClickTime;
// happen with z-order.
static int gsEventNumber;
static int* gsButtonEventNumber;
static NSTimeInterval gNextKeyEventTime;
static inline CGKeyCode GetCGKeyCode(jint javaKeyCode);
......@@ -84,6 +85,28 @@ CreateJavaException(JNIEnv* env, CGError err)
[s UTF8String]);
}
/**
* Saves the "safe moment" when the NEXT event can be posted by the robot safely
* and sleeps for some time if the "safe moment" for the CURRENT event is not
* reached.
*
* We need to sleep to give time for the macOS to update the state.
*
* The "mouse move" events are skipped, because it is not a big issue if we lost
* some of them, the latest coordinates are saved in the peer and will be used
* for clicks.
*/
static inline void autoDelay(BOOL isMove) {
if (!isMove){
NSTimeInterval now = [[NSDate date] timeIntervalSinceReferenceDate];
NSTimeInterval delay = gNextKeyEventTime - now;
if (delay > 0) {
[NSThread sleepForTimeInterval:delay];
}
}
gNextKeyEventTime = [[NSDate date] timeIntervalSinceReferenceDate] + 0.050;
}
/*
* Class: sun_lwawt_macosx_CRobot
* Method: initRobot
......@@ -119,6 +142,7 @@ Java_sun_lwawt_macosx_CRobot_initRobot
gsClickCount = 0;
gsLastClickTime = 0;
gNextKeyEventTime = 0;
gsEventNumber = ROBOT_EVENT_NUMBER_START;
gsButtonEventNumber = (int*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(int), gNumberOfButtons);
......@@ -145,6 +169,7 @@ Java_sun_lwawt_macosx_CRobot_mouseEvent
jboolean isButtonsDownState, jboolean isMouseMove)
{
JNF_COCOA_ENTER(env);
autoDelay(isMouseMove);
// This is the native method called when Robot mouse events occur.
// The CRobot tracks the mouse position, and which button was
......@@ -241,14 +266,19 @@ JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CRobot_mouseWheel
(JNIEnv *env, jobject peer, jint wheelAmt)
{
autoDelay(NO);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
CGEventRef event = CGEventCreateScrollWheelEvent(NULL,
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef event = CGEventCreateScrollWheelEvent(source,
kCGScrollEventUnitLine,
k_JAVA_ROBOT_WHEEL_COUNT, wheelAmt);
if (event != NULL) {
CGEventPost(kCGSessionEventTap, event);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
}
if (source != NULL) {
CFRelease(source);
}
}];
}
......@@ -261,13 +291,18 @@ JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CRobot_keyEvent
(JNIEnv *env, jobject peer, jint javaKeyCode, jboolean keyPressed)
{
autoDelay(NO);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGKeyCode keyCode = GetCGKeyCode(javaKeyCode);
CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed);
CGEventRef event = CGEventCreateKeyboardEvent(source, keyCode, keyPressed);
if (event != NULL) {
CGEventPost(kCGSessionEventTap, event);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
}
if (source != NULL) {
CFRelease(source);
}
}];
}
......@@ -338,13 +373,17 @@ static void PostMouseEvent(const CGPoint point, CGMouseButton button,
CGEventType type, int clickCount, int eventNumber)
{
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
CGEventRef mouseEvent = CGEventCreateMouseEvent(NULL, type, point, button);
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef mouseEvent = CGEventCreateMouseEvent(source, type, point, button);
if (mouseEvent != NULL) {
CGEventSetIntegerValueField(mouseEvent, kCGMouseEventClickState, clickCount);
CGEventSetIntegerValueField(mouseEvent, kCGMouseEventNumber, eventNumber);
CGEventPost(kCGSessionEventTap, mouseEvent);
CGEventPost(kCGHIDEventTap, mouseEvent);
CFRelease(mouseEvent);
}
if (source != NULL) {
CFRelease(source);
}
}];
}
......
......@@ -168,7 +168,6 @@ java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java 6829264
java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java 8080982 generic-all
java/awt/datatransfer/SystemFlavorMap/AddFlavorTest.java 8079268 linux-all
java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java 6829250 windows-all
java/awt/Toolkit/RealSync/Test.java 6849383 macosx-all
java/awt/LightweightComponent/LightweightEventTest/LightweightEventTest.java 8159252 windows-all
java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java 8203047 macosx-all
java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html 8073636 macosx-all
......@@ -195,7 +194,7 @@ java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java 8196017 windo
java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWheelTest.java 8196018 windows-all,linux-all
java/awt/TrayIcon/ActionCommand/ActionCommand.java 8150540 windows-all
java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 8150540 windows-all
java/awt/TrayIcon/ActionEventTest/ActionEventTest.java 8150540 windows-all
java/awt/TrayIcon/ActionEventTest/ActionEventTest.java 8150540,8242801 windows-all,macosx-all
java/awt/TrayIcon/ModalityTest/ModalityTest.java 8150540 windows-all,macosx-all
java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 8150540 windows-all
java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 8150540 windows-all
......@@ -503,6 +502,7 @@ java/awt/Window/WindowResizing/DoubleClickTitleBarTest.java 8233557 macosx-all
java/awt/Window/WindowOwnedByEmbeddedFrameTest/WindowOwnedByEmbeddedFrameTest.java 8233558 macosx-all
java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java 8233564 macosx-all
java/awt/Modal/NullModalityDialogTest/NullModalityDialogTest.java 8233565 macosx-all
java/awt/keyboard/AllKeyCode/AllKeyCode.java 8242930 macosx-all
java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java 8233566 macosx-all
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogTest/EnqueueWithDialogTest.java 8233566 macosx-all
java/awt/FullScreen/8013581/bug8013581.java 8169471 macosx-all
......
......@@ -23,7 +23,7 @@
/*
@test
@bug 6252005
@bug 6252005 8242174
@key headful
@summary Tests that realSync feature works
@author denis.mikhalkin: area=awt.toolkit
......@@ -31,16 +31,17 @@
@run main/timeout=6000 Test
*/
import java.awt.Frame;
import java.awt.Point;
import java.awt.Robot;
import java.awt.*;
import java.awt.event.*;
import java.util.LinkedList;
import java.util.Collections;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.LinkedList;
import javax.swing.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
/**
* Tests various problematic areas and how they are fixed using real-sync API:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册