mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-10 03:19:40 +01:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86d5657ce5 | ||
|
|
d0bf9a35a7 | ||
|
|
2e2cae243c | ||
|
|
7a2a7986be | ||
|
|
5839539379 | ||
|
|
1b04112158 | ||
|
|
a5dcce7541 | ||
|
|
976c97f409 | ||
|
|
4ef573bfb7 | ||
|
|
0efbe5d9b9 | ||
|
|
7a2ccfc521 | ||
|
|
969255904b | ||
|
|
27d2f21f65 | ||
|
|
7f032e3fe7 | ||
|
|
6b50fc8871 | ||
|
|
81d989b511 | ||
|
|
acdc0ea38e | ||
|
|
4cd8e27964 | ||
|
|
8445f53d85 | ||
|
|
eaa04303a7 | ||
|
|
29c8d3fecf | ||
|
|
41e89505be | ||
|
|
30d479fbd4 | ||
|
|
4399dc382c | ||
|
|
e21bc70e8f | ||
|
|
08ea095216 | ||
|
|
7884d54f48 | ||
|
|
483234fe7d | ||
|
|
6790353282 | ||
|
|
0fb5c9ed61 | ||
|
|
5a63351d2a | ||
|
|
eae772aca9 | ||
|
|
b3c4cc9e52 | ||
|
|
57e46e5dcd | ||
|
|
ba69b0d47d | ||
|
|
e1c6172e9a | ||
|
|
322526458a | ||
|
|
8ae0be8eb6 | ||
|
|
4b09614a0e | ||
|
|
08ae9ff034 | ||
|
|
251068294e | ||
|
|
cce5c34181 | ||
|
|
ec241e4a0a | ||
|
|
f42e6bb30b | ||
|
|
b3dacc9146 | ||
|
|
a2059db21b | ||
|
|
5119eeee12 |
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.apple.eawt.event;
|
||||
|
||||
/**
|
||||
* Event indicating a swipe was performed by the user.
|
||||
*
|
||||
* @see PressureListener
|
||||
*
|
||||
* @since Java for Mac OS X 10.10 Update 3, JDK 8
|
||||
*/
|
||||
public class PressureEvent extends GestureEvent {
|
||||
|
||||
public double getPressure() {
|
||||
return pressure;
|
||||
}
|
||||
|
||||
public double getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
private double pressure;
|
||||
private double stage;
|
||||
|
||||
PressureEvent(double pressure, double stage) {
|
||||
this.pressure = pressure;
|
||||
this.stage = stage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.apple.eawt.event;
|
||||
|
||||
/**
|
||||
* Listener interface for receiving pressure events.
|
||||
*
|
||||
* @see PressureEvent
|
||||
* @see GestureUtilities
|
||||
*
|
||||
* @since Java for Mac OS X 10.5 Update 7, Java for Mac OS X 10.6 Update 2
|
||||
*/
|
||||
public interface PressureListener extends GestureListener {
|
||||
public void pressure(final PressureEvent e);
|
||||
}
|
||||
@@ -877,46 +877,21 @@ public class CInputMethod extends InputMethodAdapter {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void await(CountDownLatch latch) {
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Executed on AppKit
|
||||
static void invoke(Runnable runnable, sun.awt.im.InputContext inputContext, Component targetToAppContext) throws InvocationTargetException {
|
||||
CountDownLatch edtLatch = new CountDownLatch(1);
|
||||
CountDownLatch tkLatch = new CountDownLatch(1);
|
||||
AtomicBoolean runOnAppKit = new AtomicBoolean(false);
|
||||
|
||||
// Emulate EventQueue.invokeAndWait(runnable) for the runnable that delegates execution
|
||||
// back to AppKit (JavaFX Event thread), without running secondary loop on AppKit.
|
||||
|
||||
InvocationEvent event = new InvocationEvent(targetToAppContext, () -> {
|
||||
try {
|
||||
runOnAppKit.set(instanceofJFXPanel(getClientComponent(inputContext)));
|
||||
if (!runOnAppKit.get()) {
|
||||
runnable.run();
|
||||
}
|
||||
} finally {
|
||||
edtLatch.countDown();
|
||||
await(tkLatch);
|
||||
}
|
||||
});
|
||||
assert targetToAppContext != null;
|
||||
AppContext appContext = SunToolkit.targetToAppContext(targetToAppContext);
|
||||
SunToolkit.postEvent(appContext, event);
|
||||
SunToolkit.flushPendingEvents(appContext);
|
||||
|
||||
await(edtLatch);
|
||||
try {
|
||||
if (runOnAppKit.get()) {
|
||||
// 1) Do not run secondary msg loop in this case.
|
||||
// 2) Delegate runnable back to FX when applicable.
|
||||
LWCToolkit.invokeAndWait(() -> {
|
||||
runOnAppKit.set(instanceofJFXPanel(getClientComponent(inputContext)));
|
||||
if (!runOnAppKit.get()) {
|
||||
runnable.run();
|
||||
}
|
||||
} finally {
|
||||
tkLatch.countDown();
|
||||
}, targetToAppContext);
|
||||
|
||||
if (runOnAppKit.get()) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,7 +480,9 @@ public final class LWCToolkit extends LWToolkit {
|
||||
|
||||
@Override
|
||||
public Insets getScreenInsets(final GraphicsConfiguration gc) {
|
||||
return ((CGraphicsConfig) gc).getDevice().getScreenInsets();
|
||||
CGraphicsDevice gd = ((CGraphicsConfig) gc).getDevice();
|
||||
// Avoid deadlock with input methods
|
||||
return LWCToolkit.SelectorPerformer.perform(gd::getScreenInsets);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -748,19 +750,21 @@ public final class LWCToolkit extends LWToolkit {
|
||||
assert EventQueue.isDispatchThread();
|
||||
if (executor == null) {
|
||||
// init on EDT
|
||||
executor = new ThreadPoolExecutor(1, Integer.MAX_VALUE,
|
||||
60L, TimeUnit.SECONDS,
|
||||
new SynchronousQueue<>(),
|
||||
new ThreadFactory() {
|
||||
private ThreadFactory factory = Executors.privilegedThreadFactory();
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = factory.newThread(r);
|
||||
t.setDaemon(true);
|
||||
t.setName("AWT-SelectorPerformer " + t.getName());
|
||||
return t;
|
||||
}
|
||||
});
|
||||
AccessController.doPrivileged((PrivilegedAction<?>)() ->
|
||||
executor = new ThreadPoolExecutor(1, Integer.MAX_VALUE,
|
||||
60L, TimeUnit.SECONDS,
|
||||
new SynchronousQueue<>(),
|
||||
new ThreadFactory() {
|
||||
private ThreadFactory factory = Executors.privilegedThreadFactory();
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = factory.newThread(r);
|
||||
t.setDaemon(true);
|
||||
t.setName("AWT-SelectorPerformer " + t.getName());
|
||||
return t;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
LinkedBlockingQueue<InvocationEvent> currentQueue;
|
||||
synchronized (invocations) {
|
||||
|
||||
@@ -64,6 +64,7 @@ static BOOL shouldUsePressAndHold() {
|
||||
return shouldUsePressAndHold;
|
||||
}
|
||||
|
||||
extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, NSString * chars);
|
||||
|
||||
@implementation AWTView
|
||||
|
||||
@@ -362,9 +363,7 @@ static BOOL shouldUsePressAndHold() {
|
||||
NSUInteger deviceIndependentModifierFlagsMask =
|
||||
[event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
|
||||
|
||||
return ((deviceIndependentModifierFlagsMask == NSCommandKeyMask)
|
||||
|| (deviceIndependentModifierFlagsMask == (NSCommandKeyMask & NSShiftKeyMask)))
|
||||
&& [[event characters] isEqualToString:@"`"];
|
||||
return isSystemShortcut_NextWindowInApplication(deviceIndependentModifierFlagsMask, [event characters]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -165,6 +165,15 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||
b:[event deltaY]];
|
||||
}
|
||||
|
||||
- (void)pressureChangeWithEvent:(NSEvent *)event {
|
||||
float pressure = event.pressure;
|
||||
[self postGesture:event
|
||||
as:com_apple_eawt_event_GestureHandler_PRESSURE
|
||||
a:pressure
|
||||
b:(([event respondsToSelector:@selector(stage)]) ? ((NSInteger)[event stage]) : -1)
|
||||
];
|
||||
}
|
||||
|
||||
@end
|
||||
@implementation AWTWindow_Panel
|
||||
AWT_NS_WINDOW_IMPLEMENTATION
|
||||
@@ -331,12 +340,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
[self.nsWindow setTitleVisibility:NSWindowTitleHidden];
|
||||
}
|
||||
|
||||
if (IS(self.styleBits, DARK)) {
|
||||
[self.nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
|
||||
} else {
|
||||
[self.nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -978,6 +981,16 @@ JNF_COCOA_ENTER(env);
|
||||
NSView *contentView = OBJC(contentViewPtr);
|
||||
NSRect frameRect = NSMakeRect(x, y, w, h);
|
||||
AWTWindow *owner = [OBJC(ownerPtr) delegate];
|
||||
|
||||
BOOL isIgnoreMouseEvents = NO;
|
||||
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
|
||||
jobject awtWindow = JNFGetObjectField(env, obj, jf_target);
|
||||
if (awtWindow != NULL) {
|
||||
static JNF_CLASS_CACHE(jc_Window, "java/awt/Window");
|
||||
static JNF_MEMBER_CACHE(jm_isIgnoreMouseEvents, jc_Window, "isIgnoreMouseEvents", "()Z");
|
||||
isIgnoreMouseEvents = JNFCallBooleanMethod(env, awtWindow, jm_isIgnoreMouseEvents) == JNI_TRUE ? YES : NO;
|
||||
(*env)->DeleteLocalRef(env, awtWindow);
|
||||
}
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
|
||||
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
|
||||
@@ -987,7 +1000,12 @@ JNF_COCOA_ENTER(env);
|
||||
contentView:contentView];
|
||||
// the window is released is CPlatformWindow.nativeDispose()
|
||||
|
||||
if (window) [window.nsWindow retain];
|
||||
if (window) {
|
||||
[window.nsWindow retain];
|
||||
if (isIgnoreMouseEvents) {
|
||||
[window.nsWindow setIgnoresMouseEvents:YES];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
@@ -1025,6 +1043,12 @@ JNF_COCOA_ENTER(env);
|
||||
}
|
||||
|
||||
window.styleBits = newBits;
|
||||
|
||||
if (IS(window.styleBits, DARK)) {
|
||||
[nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
|
||||
} else {
|
||||
[nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
|
||||
}
|
||||
}];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
@@ -165,22 +165,37 @@ canChooseDirectories:(BOOL)inChooseDirectories
|
||||
[CMenuBar activate:menuBar modallyDisabled:isDisabled];
|
||||
}
|
||||
|
||||
[thePanel beginSheetModalForWindow:fOwner completionHandler:^(NSInteger result) {}];
|
||||
[thePanel setAppearance:fOwner.appearance];
|
||||
|
||||
NSModalResponse modalResponse = [thePanel runModal];
|
||||
if (modalResponse == NSModalResponseOK) {
|
||||
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
|
||||
fURLs = (fMode == java_awt_FileDialog_LOAD)
|
||||
? [openPanel URLs]
|
||||
: [NSArray arrayWithObject:[openPanel URL]];
|
||||
void (^onComplete)(BOOL, BOOL) = ^(BOOL responseOK, BOOL doStopModal) {
|
||||
if (responseOK) {
|
||||
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
|
||||
fURLs = (fMode == java_awt_FileDialog_LOAD)
|
||||
? [openPanel URLs]
|
||||
: [NSArray arrayWithObject:[openPanel URL]];
|
||||
|
||||
fPanelResult = NSFileHandlingPanelOKButton;
|
||||
fPanelResult = NSFileHandlingPanelOKButton;
|
||||
} else {
|
||||
fURLs = [NSArray array];
|
||||
}
|
||||
[fURLs retain];
|
||||
if (doStopModal)
|
||||
[NSApp stopModal];
|
||||
if (menuBar != nil) {
|
||||
[CMenuBar activate:menuBar modallyDisabled:NO];
|
||||
}
|
||||
};
|
||||
|
||||
NSInteger osversion = [[NSProcessInfo processInfo] operatingSystemVersion].minorVersion; // NOTE: will be removed soon (when native file-chooser fixed on catalina)
|
||||
if (osversion >= 15) {
|
||||
[thePanel beginSheetModalForWindow:fOwner completionHandler:^(NSInteger result) {}];
|
||||
NSModalResponse modalResponse = [thePanel runModal];
|
||||
onComplete(modalResponse == NSModalResponseOK, NO);
|
||||
} else {
|
||||
fURLs = [NSArray array];
|
||||
}
|
||||
[fURLs retain];
|
||||
if (menuBar != nil) {
|
||||
[CMenuBar activate:menuBar modallyDisabled:NO];
|
||||
[thePanel beginSheetModalForWindow:fOwner completionHandler:^(NSInteger result) {
|
||||
onComplete(result == NSFileHandlingPanelOKButton, YES);
|
||||
}];
|
||||
[NSApp runModalForWindow:thePanel];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -59,8 +59,17 @@ extern jint* gButtonDownMasks;
|
||||
#define kCFCoreFoundationVersionNumber10_13_Max 1499
|
||||
#endif
|
||||
|
||||
#ifndef kCFCoreFoundationVersionNumber10_14_Max
|
||||
#define kCFCoreFoundationVersionNumber10_14_Max 1599
|
||||
#endif
|
||||
|
||||
#ifndef IS_OSX_GT10_13
|
||||
#define IS_OSX_GT10_13 (floor(kCFCoreFoundationVersionNumber) > \
|
||||
kCFCoreFoundationVersionNumber10_13_Max)
|
||||
#endif
|
||||
|
||||
#ifndef IS_OSX_GT10_14
|
||||
#define IS_OSX_GT10_14 (floor(kCFCoreFoundationVersionNumber) > \
|
||||
kCFCoreFoundationVersionNumber10_14_Max)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "CRobotKeyCode.h"
|
||||
#import "java_awt_event_KeyEvent.h"
|
||||
@@ -18,31 +19,16 @@ enum LOG_LEVEL {
|
||||
LL_ERROR
|
||||
};
|
||||
|
||||
void plogImpl(jobject platformLogger, int logLevel, const char * msg) {
|
||||
void plog(int logLevel, const char *formatMsg, ...) {
|
||||
if (!jvm)
|
||||
return;
|
||||
if (logLevel < LL_TRACE || logLevel > LL_ERROR || msg == NULL)
|
||||
if (logLevel < LL_TRACE || logLevel > LL_ERROR || formatMsg == NULL)
|
||||
return;
|
||||
|
||||
const char * methodName = "finest";
|
||||
switch (logLevel) {
|
||||
case LL_DEBUG: methodName = "fine"; break;
|
||||
case LL_INFO: methodName = "info"; break;
|
||||
case LL_WARNING: methodName = "warning"; break;
|
||||
case LL_ERROR: methodName = "severe"; break;
|
||||
}
|
||||
|
||||
JNIEnv* env;
|
||||
jstring jstr;
|
||||
(*jvm)->AttachCurrentThreadAsDaemon(jvm, (void**)&env, NULL);
|
||||
jstr = (*env)->NewStringUTF(env, msg);
|
||||
JNU_CallMethodByName(env, NULL, platformLogger, methodName, "(Ljava/lang/String;)V", jstr);
|
||||
(*env)->DeleteLocalRef(env, jstr);
|
||||
}
|
||||
|
||||
void plog(int logLevel, const char *formatMsg, ...) {
|
||||
// TODO: check whether current logLevel is enabled in PlatformLogger
|
||||
static jobject loggerObject = NULL;
|
||||
static jclass clazz = NULL;
|
||||
static jmethodID midTrace = NULL, midDebug = NULL, midInfo = NULL, midWarn = NULL, midError = NULL;
|
||||
|
||||
if (loggerObject == NULL) {
|
||||
JNIEnv* env;
|
||||
@@ -54,6 +40,31 @@ void plog(int logLevel, const char *formatMsg, ...) {
|
||||
if (fieldId == NULL)
|
||||
return;
|
||||
loggerObject = (*env)->GetStaticObjectField(env, shkClass, fieldId);
|
||||
loggerObject = (*env)->NewGlobalRef(env, loggerObject);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, loggerObject);
|
||||
if (clazz == NULL) {
|
||||
NSLog(@"plogImpl: can't find PlatformLogger class");
|
||||
return;
|
||||
}
|
||||
|
||||
midTrace = (*env)->GetMethodID(env, clazz, "finest", "(Ljava/lang/String;)V");
|
||||
midDebug = (*env)->GetMethodID(env, clazz, "fine", "(Ljava/lang/String;)V");
|
||||
midInfo = (*env)->GetMethodID(env, clazz, "info", "(Ljava/lang/String;)V");
|
||||
midWarn = (*env)->GetMethodID(env, clazz, "warning", "(Ljava/lang/String;)V");
|
||||
midError = (*env)->GetMethodID(env, clazz, "severe", "(Ljava/lang/String;)V");
|
||||
}
|
||||
|
||||
jmethodID mid = midTrace;
|
||||
switch (logLevel) {
|
||||
case LL_DEBUG: mid = midDebug; break;
|
||||
case LL_INFO: mid = midInfo; break;
|
||||
case LL_WARNING: mid = midWarn; break;
|
||||
case LL_ERROR: mid = midError; break;
|
||||
}
|
||||
if (mid == NULL) {
|
||||
NSLog(@"plogImpl: undefined log-method for level %d", logLevel);
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
@@ -63,7 +74,13 @@ void plog(int logLevel, const char *formatMsg, ...) {
|
||||
vsnprintf(buf, bufSize, formatMsg, args);
|
||||
va_end(args);
|
||||
|
||||
plogImpl(loggerObject, logLevel, buf);
|
||||
JNIEnv* env;
|
||||
jstring jstr;
|
||||
(*jvm)->AttachCurrentThreadAsDaemon(jvm, (void**)&env, NULL);
|
||||
jstr = (*env)->NewStringUTF(env, buf);
|
||||
|
||||
(*env)->CallVoidMethod(env, loggerObject, mid, jstr);
|
||||
(*env)->DeleteLocalRef(env, jstr);
|
||||
}
|
||||
|
||||
static const char * toCString(id obj) {
|
||||
@@ -163,6 +180,23 @@ static NSString * getAppleSymbolicHotKeysDescription(int hotKeyId) {
|
||||
return [hotkeyId2DescMap objectForKey : [NSNumber numberWithInt : hotKeyId]];
|
||||
}
|
||||
|
||||
@interface DefaultParams: NSObject
|
||||
@property (assign) BOOL enabled;
|
||||
@property (strong) NSString *key_equivalent;
|
||||
+(DefaultParams *) create:(NSString *)key_equivalent enabled:(BOOL)enabled;
|
||||
@end
|
||||
|
||||
@implementation DefaultParams
|
||||
+(DefaultParams *) create:(NSString *)key_equivalent enabled:(BOOL)enabled {
|
||||
DefaultParams * result = [[[DefaultParams alloc] init] autorelease];
|
||||
result.enabled = enabled;
|
||||
result.key_equivalent = key_equivalent;
|
||||
return result;
|
||||
}
|
||||
@end
|
||||
|
||||
static NSMutableDictionary * createDefaultParams();
|
||||
|
||||
static int NSModifiers2java(int mask) {
|
||||
int result = 0;
|
||||
if (mask & shiftKey)
|
||||
@@ -171,16 +205,55 @@ static int NSModifiers2java(int mask) {
|
||||
result |= AWT_CTRL_DOWN_MASK;
|
||||
if (mask & optionKey)
|
||||
result |= AWT_ALT_DOWN_MASK;
|
||||
if (mask & shiftKey)
|
||||
if (mask & cmdKey)
|
||||
result |= AWT_META_DOWN_MASK;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, jobject reader) {
|
||||
jclass clsReader = (*env)->GetObjectClass(env, reader);
|
||||
jmethodID methodAdd = (*env)->GetMethodID(env, clsReader, "add", "(ILjava/lang/String;ILjava/lang/String;)V");
|
||||
static int javaModifiers2NS(int jmask) {
|
||||
int result = 0;
|
||||
if (jmask & AWT_SHIFT_DOWN_MASK)
|
||||
result |= NSShiftKeyMask;
|
||||
if (jmask & AWT_CTRL_DOWN_MASK)
|
||||
result |= NSControlKeyMask;
|
||||
if (jmask & AWT_ALT_DOWN_MASK)
|
||||
result |= NSAlternateKeyMask;
|
||||
if (jmask & AWT_META_DOWN_MASK)
|
||||
result |= NSCommandKeyMask;
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef bool (^ Visitor)(int, const char *, int, const char *, int);
|
||||
|
||||
static void visitServicesShortcut(Visitor visitorBlock, NSString * key_equivalent, NSString * desc) {
|
||||
// @ - command
|
||||
// $ - shift
|
||||
// ^ - control
|
||||
// ~ - alt(option)
|
||||
const bool modIsSHIFT = [key_equivalent containsString:@"$"];
|
||||
const bool modIsCONTROL = [key_equivalent containsString:@"^"];
|
||||
const bool modIsOPTION = [key_equivalent containsString:@"~"];
|
||||
const bool modIsCMD = [key_equivalent containsString:@"@"];
|
||||
int modifiers = 0;
|
||||
if (modIsSHIFT)
|
||||
modifiers |= AWT_SHIFT_DOWN_MASK;
|
||||
if (modIsCONTROL)
|
||||
modifiers |= AWT_CTRL_DOWN_MASK;
|
||||
if (modIsOPTION)
|
||||
modifiers |= AWT_ALT_DOWN_MASK;
|
||||
if (modIsCMD)
|
||||
modifiers |= AWT_META_DOWN_MASK;
|
||||
|
||||
NSCharacterSet * excludeSet = [NSCharacterSet characterSetWithCharactersInString:@"@$^~"];
|
||||
NSString * keyChar = [key_equivalent stringByTrimmingCharactersInSet:excludeSet];
|
||||
|
||||
visitorBlock(-1, keyChar.UTF8String, modifiers, desc.UTF8String, -1);
|
||||
}
|
||||
|
||||
void readSystemHotkeysImpl(Visitor visitorBlock) {
|
||||
// 1. read from com.apple.symbolichotkeys.plist (domain with custom (user defined) shortcuts)
|
||||
@try {
|
||||
|
||||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSDictionary<NSString *,id> * shk = [defaults persistentDomainForName:@"com.apple.symbolichotkeys"];
|
||||
if (shk != nil) {
|
||||
@@ -239,6 +312,11 @@ void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, job
|
||||
}
|
||||
|
||||
NSArray *parameters = objParams;
|
||||
if ([parameters count] < 3) {
|
||||
plog(LL_DEBUG, "too small lenght of parameters %d", [parameters count]);
|
||||
continue;
|
||||
}
|
||||
|
||||
id p0 = parameters[0];
|
||||
id p1 = parameters[1];
|
||||
id p2 = parameters[2];
|
||||
@@ -260,20 +338,14 @@ void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, job
|
||||
int vkeyCode = p1 == nil ? -1 : [p1 intValue];
|
||||
int modifiers = p2 == nil ? 0 : [p2 intValue];
|
||||
|
||||
jstring jkeyChar = NULL;
|
||||
char keyCharBuf[64];
|
||||
const char * keyCharStr = keyCharBuf;
|
||||
if (asciiCode >= 0 && asciiCode <= 0xFF) {
|
||||
char keyCharBuf[64];
|
||||
sprintf(keyCharBuf, "%c", asciiCode);
|
||||
jkeyChar = (*env)->NewStringUTF(env, keyCharBuf);
|
||||
}
|
||||
|
||||
} else
|
||||
keyCharStr = NULL;
|
||||
NSString * description = getAppleSymbolicHotKeysDescription([hkNumber intValue]);
|
||||
jstring jdesc = description == nil ? NULL : (*env)->NewStringUTF(env, description.UTF8String);
|
||||
(*env)->CallVoidMethod(
|
||||
env, reader, methodAdd, (jint)vkeyCode,
|
||||
jkeyChar, (jint)symbolicHotKeysModifiers2java(modifiers),
|
||||
jdesc
|
||||
);
|
||||
visitorBlock(vkeyCode, keyCharStr, symbolicHotKeysModifiers2java(modifiers), description == nil ? NULL : description.UTF8String, [hkNumber intValue]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -281,6 +353,7 @@ void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, job
|
||||
}
|
||||
|
||||
// 2. read from Pbs (domain with services shortcuts)
|
||||
NSMutableDictionary * allDefParams = createDefaultParams();
|
||||
NSDictionary<NSString *,id> * pbs = [defaults persistentDomainForName:@"pbs"];
|
||||
if (pbs) {
|
||||
// NSServicesStatus = {
|
||||
@@ -298,6 +371,7 @@ void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, job
|
||||
// };
|
||||
// };
|
||||
// }
|
||||
|
||||
NSDictionary<NSString *, id> *services = [pbs valueForKey:@"NSServicesStatus"];
|
||||
if (services) {
|
||||
for (NSString *key in services) {
|
||||
@@ -306,41 +380,40 @@ void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, job
|
||||
plog(LL_DEBUG, "'%s' isn't instance of NSDictionary (class=%s)", toCString(value), [value className].UTF8String);
|
||||
continue;
|
||||
}
|
||||
// NOTE: unchanged default params will not appear here, check allDefParams at the end of this loop
|
||||
DefaultParams * defParams = [allDefParams objectForKey:key];
|
||||
[allDefParams removeObjectForKey:key];
|
||||
|
||||
NSDictionary<NSString *, id> *sdict = value;
|
||||
NSString *key_equivalent = sdict[@"key_equivalent"];
|
||||
if (!key_equivalent && defParams != nil) {
|
||||
key_equivalent = defParams.key_equivalent;
|
||||
}
|
||||
if (!key_equivalent)
|
||||
continue;
|
||||
|
||||
// @ - command
|
||||
// $ - shift
|
||||
// ^ - control
|
||||
// ~ - alt(option)
|
||||
const bool modIsSHIFT = [key_equivalent containsString:@"$"];
|
||||
const bool modIsCONTROL = [key_equivalent containsString:@"^"];
|
||||
const bool modIsOPTION = [key_equivalent containsString:@"~"];
|
||||
const bool modIsCMD = [key_equivalent containsString:@"@"];
|
||||
int modifiers = 0;
|
||||
if (modIsSHIFT)
|
||||
modifiers |= AWT_SHIFT_DOWN_MASK;
|
||||
if (modIsCONTROL)
|
||||
modifiers |= AWT_CTRL_DOWN_MASK;
|
||||
if (modIsOPTION)
|
||||
modifiers |= AWT_ALT_DOWN_MASK;
|
||||
if (modIsCMD)
|
||||
modifiers |= AWT_META_DOWN_MASK;
|
||||
NSString *enabled = sdict[@"enabled_services_menu"];
|
||||
if (enabled != nil && [enabled boolValue] == NO) {
|
||||
continue;
|
||||
}
|
||||
if (enabled == nil && defParams != nil && !defParams.enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSCharacterSet * excludeSet = [NSCharacterSet characterSetWithCharactersInString:@"@$^~"];
|
||||
NSString * keyChar = [key_equivalent stringByTrimmingCharactersInSet:excludeSet];
|
||||
|
||||
(*env)->CallVoidMethod(
|
||||
env, reader, methodAdd, -1,
|
||||
(*env)->NewStringUTF(env, keyChar.UTF8String), modifiers,
|
||||
(*env)->NewStringUTF(env, key.UTF8String)
|
||||
);
|
||||
visitServicesShortcut(visitorBlock, key_equivalent, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through rest of allDefParams
|
||||
for (NSString* key in allDefParams) {
|
||||
DefaultParams * defParams = allDefParams[key];
|
||||
if (!defParams.enabled) {
|
||||
continue;
|
||||
}
|
||||
visitServicesShortcut(visitorBlock, defParams.key_equivalent, key);
|
||||
}
|
||||
|
||||
#ifdef USE_CARBON_CopySymbolicHotKeys
|
||||
// 3. read from core services
|
||||
CFArrayRef registeredHotKeys;
|
||||
@@ -360,16 +433,60 @@ void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, job
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
(*env)->CallVoidMethod(
|
||||
env, reader, methodAdd, (int)vkeyCode,
|
||||
NULL, NSModifiers2java(keyModifiers),
|
||||
NULL
|
||||
);
|
||||
visitorBlock(vkeyCode, NULL, NSModifiers2java(keyModifiers), NULL, -1);
|
||||
}
|
||||
|
||||
CFRelease(registeredHotKeys);
|
||||
}
|
||||
#endif // USE_CARBON_CopySymbolicHotKeys
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSLog(@"readSystemHotkeys: catched exception, reason '%@'", exception.reason);
|
||||
}
|
||||
}
|
||||
|
||||
bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, NSString * chars) {
|
||||
const int shortcutUid_NextWindowInApplication = 27;
|
||||
static NSString * shortcutCharacter = nil;
|
||||
static int shortcutMask = 0;
|
||||
if (shortcutCharacter == nil) {
|
||||
readSystemHotkeysImpl(
|
||||
^bool(int vkeyCode, const char * keyCharStr, int jmodifiers, const char * descriptionStr, int hotkeyUid) {
|
||||
if (hotkeyUid != shortcutUid_NextWindowInApplication)
|
||||
return true;
|
||||
|
||||
if (keyCharStr != NULL) {
|
||||
shortcutCharacter = [[NSString stringWithFormat:@"%s", keyCharStr] retain];
|
||||
shortcutMask = javaModifiers2NS(jmodifiers);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
if (shortcutCharacter == nil) {
|
||||
shortcutCharacter = @"`";
|
||||
shortcutMask = NSCommandKeyMask;
|
||||
}
|
||||
}
|
||||
|
||||
return ((modifiersMask == shortcutMask)
|
||||
|| (modifiersMask == (shortcutMask & NSShiftKeyMask)))
|
||||
&& [chars isEqualToString:shortcutCharacter];
|
||||
}
|
||||
|
||||
void Java_java_awt_desktop_SystemHotkeyReader_readSystemHotkeys(JNIEnv* env, jobject reader) {
|
||||
jclass clsReader = (*env)->GetObjectClass(env, reader);
|
||||
jmethodID methodAdd = (*env)->GetMethodID(env, clsReader, "add", "(ILjava/lang/String;ILjava/lang/String;)V");
|
||||
|
||||
readSystemHotkeysImpl(
|
||||
^bool(int vkeyCode, const char * keyCharStr, int jmodifiers, const char * descriptionStr, int hotkeyUid){
|
||||
jstring jkeyChar = keyCharStr == NULL ? NULL : (*env)->NewStringUTF(env, keyCharStr);
|
||||
jstring jdesc = descriptionStr == NULL ? NULL : (*env)->NewStringUTF(env, descriptionStr);
|
||||
(*env)->CallVoidMethod(
|
||||
env, reader, methodAdd, (jint)vkeyCode, jkeyChar, (jint)jmodifiers, jdesc
|
||||
);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
jint Java_java_awt_desktop_SystemHotkeyReader_osx2java(JNIEnv* env, jclass clazz, jint osxKeyCode) {
|
||||
@@ -633,3 +750,32 @@ jstring Java_java_awt_desktop_SystemHotkey_osxKeyCodeDescription(JNIEnv* env, jc
|
||||
|
||||
return (*env)->NewStringUTF(env, val.UTF8String);
|
||||
}
|
||||
|
||||
static NSDictionary * getDefaultParams() {
|
||||
static NSDictionary * sid2defaults = nil;
|
||||
if (sid2defaults == nil) {
|
||||
sid2defaults = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[DefaultParams create:@"@$b" enabled:NO], @"com.apple.BluetoothFileExchange - Send File To Bluetooth Device - sendFileUsingBluetoothOBEXService",
|
||||
[DefaultParams create:@"@^$c" enabled:YES], @"com.apple.ChineseTextConverterService - Convert Text from Simplified to Traditional Chinese - convertTextToTraditionalChinese",
|
||||
[DefaultParams create:@"@~^$c" enabled:YES], @"com.apple.ChineseTextConverterService - Convert Text from Traditional to Simplified Chinese - convertTextToSimplifiedChinese",
|
||||
[DefaultParams create:@"@$l" enabled:YES], @"com.apple.Safari - Search With %WebSearchProvider@ - searchWithWebSearchProvider",
|
||||
[DefaultParams create:@"@*" enabled:NO], @"com.apple.ScriptEditor2 - Script Editor/Get Result of AppleScript - runAsAppleScript",
|
||||
[DefaultParams create:@"@$f" enabled:NO], @"com.apple.SpotlightService - SEARCH_WITH_SPOTLIGHT - doSearchWithSpotlight",
|
||||
[DefaultParams create:@"@$y" enabled:YES], @"com.apple.Stickies - Make Sticky - makeStickyFromTextService",
|
||||
[DefaultParams create:@"@$m" enabled:YES], @"com.apple.Terminal - Open man Page in Terminal - openManPage",
|
||||
[DefaultParams create:@"@$a" enabled:YES], @"com.apple.Terminal - Search man Page Index in Terminal - searchManPages",
|
||||
nil
|
||||
];
|
||||
|
||||
[sid2defaults retain];
|
||||
}
|
||||
|
||||
return sid2defaults;
|
||||
}
|
||||
|
||||
static NSMutableDictionary * createDefaultParams() {
|
||||
NSDictionary * sid2defaults = getDefaultParams();
|
||||
NSMutableDictionary * result = [NSMutableDictionary dictionaryWithCapacity:[sid2defaults count]];
|
||||
[result setDictionary:sid2defaults];
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#import "fontscalerdefs.h" // contains the definition of GlyphInfo struct
|
||||
|
||||
#import "sun_awt_SunHints.h"
|
||||
#import "LWCToolkit.h"
|
||||
|
||||
//#define USE_IMAGE_ALIGNED_MEMORY 1
|
||||
//#define CGGI_DEBUG 1
|
||||
@@ -628,7 +629,8 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||
static inline void
|
||||
CGGI_CreateImageForGlyph
|
||||
(CGFontRef cgFont, CGGI_GlyphCanvas *canvas, const CGGlyph glyph,
|
||||
GlyphInfo *info, const CGGI_GlyphInfoDescriptor *glyphDescriptor, const AWTStrike *strike)
|
||||
GlyphInfo *info, const CGGI_GlyphInfoDescriptor *glyphDescriptor, const AWTStrike *strike,
|
||||
const bool isCatalinaOrAbove)
|
||||
{
|
||||
if (isnan(info->topLeftX) || isnan(info->topLeftY)) {
|
||||
// Explicitly set glyphInfo width/height to be 0 to ensure
|
||||
@@ -648,7 +650,7 @@ CGGI_CreateImageForGlyph
|
||||
CGFloat x = -info->topLeftX;
|
||||
CGFloat y = canvas->image->height + info->topLeftY;
|
||||
|
||||
if (glyphDescriptor == &argb) {
|
||||
if (isCatalinaOrAbove || glyphDescriptor == &argb) {
|
||||
CGAffineTransform matrix = CGContextGetTextMatrix(canvas->context);
|
||||
CGFloat fontSize = sqrt(fabs(matrix.a * matrix.d - matrix.b * matrix.c));
|
||||
CTFontRef font = CTFontCreateWithGraphicsFont(cgFont, fontSize, NULL, NULL);
|
||||
@@ -692,7 +694,8 @@ CGGI_CreateImageForGlyph
|
||||
static inline GlyphInfo *
|
||||
CGGI_CreateImageForUnicode
|
||||
(CGGI_GlyphCanvas *canvas, const AWTStrike *strike,
|
||||
const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar)
|
||||
const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar,
|
||||
const bool isCatalinaOrAbove)
|
||||
{
|
||||
// save the state of the world
|
||||
CGContextSaveGState(canvas->context);
|
||||
@@ -737,7 +740,7 @@ CGGI_CreateImageForUnicode
|
||||
CFRelease(cgFallback);
|
||||
|
||||
// clean the canvas - align, strike, and copy the glyph from the canvas into the info
|
||||
CGGI_CreateImageForGlyph(cgFallback, canvas, glyph, info, glyphDescriptor, strike);
|
||||
CGGI_CreateImageForGlyph(cgFallback, canvas, glyph, info, glyphDescriptor, strike, isCatalinaOrAbove);
|
||||
|
||||
// restore the state of the world
|
||||
CGContextRestoreGState(canvas->context);
|
||||
@@ -782,14 +785,15 @@ CGGI_FillImagesForGlyphsWithSizedCanvas(CGGI_GlyphCanvas *canvas,
|
||||
|
||||
CGGI_GlyphInfoDescriptor* mainFontDescriptor = CGGI_GetGlyphInfoDescriptor(mode, strike->fAWTFont->fNativeCGFont);
|
||||
|
||||
const bool isCatalinaOrAbove = IS_OSX_GT10_14;
|
||||
CFIndex i;
|
||||
for (i = 0; i < len; i++) {
|
||||
GlyphInfo *info = (GlyphInfo *)jlong_to_ptr(glyphInfos[i]);
|
||||
if (info != NULL) {
|
||||
CGGI_CreateImageForGlyph(strike->fAWTFont->fNativeCGFont,
|
||||
canvas, glyphs[i], info, mainFontDescriptor, strike);
|
||||
canvas, glyphs[i], info, mainFontDescriptor, strike, isCatalinaOrAbove);
|
||||
} else {
|
||||
info = CGGI_CreateImageForUnicode(canvas, strike, mode, uniChars[i]);
|
||||
info = CGGI_CreateImageForUnicode(canvas, strike, mode, uniChars[i], isCatalinaOrAbove);
|
||||
glyphInfos[i] = ptr_to_jlong(info);
|
||||
}
|
||||
#ifdef CGGI_DEBUG
|
||||
|
||||
@@ -615,7 +615,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
*/
|
||||
long eventMask = AWTEvent.INPUT_METHODS_ENABLED_MASK;
|
||||
|
||||
private static final boolean INPUT_METHODS_DISABLED;
|
||||
private static boolean INPUT_METHODS_DISABLED;
|
||||
|
||||
/**
|
||||
* Static properties for incremental drawing.
|
||||
@@ -10530,5 +10530,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
void updateZOrder() {
|
||||
peer.setZOrder(getHWPeerAboveMe());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable IM-events dispatching (global).
|
||||
* Usage of IM under Linux can cause freezes and crashes, disabling increases stability
|
||||
*/
|
||||
public static void disableInputMethodSupport() {
|
||||
INPUT_METHODS_DISABLED = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3984,6 +3984,19 @@ public class Window extends Container implements Accessible {
|
||||
hasCustomDecoration = true;
|
||||
}
|
||||
|
||||
private volatile boolean ignoreMouseEvents;
|
||||
|
||||
boolean isIgnoreMouseEvents() {
|
||||
return ignoreMouseEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set via reflection (JB JdkEx API).
|
||||
*/
|
||||
void setIgnoreMouseEvents(boolean ignore) {
|
||||
ignoreMouseEvents = ignore;
|
||||
}
|
||||
|
||||
// ************************** MIXING CODE *******************************
|
||||
|
||||
// A window has an owner, but it does NOT have a container
|
||||
|
||||
@@ -496,18 +496,9 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (isPaint) {
|
||||
// Fallback to normal painting in undecorated non-opaque dialogs
|
||||
// and frames to resolve black background problem
|
||||
Window window = SunToolkit.getContainingWindow(c);
|
||||
if ((window instanceof Dialog && ((Dialog)window).isUndecorated() ||
|
||||
window instanceof Frame && ((Frame)window).isUndecorated()) &&
|
||||
bsg != null && !window.isOpaque() &&
|
||||
((SunGraphics2D)bsg).getSurfaceData().getTransparency() ==
|
||||
Transparency.OPAQUE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (bsg != null && !c.isOpaque() &&
|
||||
((SunGraphics2D)bsg).getSurfaceData().getTransparency() ==
|
||||
Transparency.OPAQUE) return false;
|
||||
|
||||
if (isPaint && c == rootJ && x == 0 && y == 0 &&
|
||||
c.getWidth() == w && c.getHeight() == h) {
|
||||
|
||||
@@ -692,11 +692,11 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
*/
|
||||
protected void modelChanged() {
|
||||
// create a view hierarchy
|
||||
rootViewInitialized = false;
|
||||
ViewFactory f = rootView.getViewFactory();
|
||||
Document doc = editor.getDocument();
|
||||
Element elem = doc.getDefaultRootElement();
|
||||
setView(f.create(elem));
|
||||
rootViewNeedsLayout = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -942,11 +942,10 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
if ((d.width > (i.left + i.right + caretMargin)) && (d.height > (i.top + i.bottom))) {
|
||||
rootView.setSize(d.width - i.left - i.right -
|
||||
caretMargin, d.height - i.top - i.bottom);
|
||||
}
|
||||
else if (!rootViewInitialized && (d.width <= 0 || d.height <= 0)) {
|
||||
} if (!rootViewNeedsLayout) {
|
||||
// Probably haven't been layed out yet, force some sort of
|
||||
// initial sizing.
|
||||
rootViewInitialized = true;
|
||||
rootViewNeedsLayout = true;
|
||||
rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
d.width = (int) Math.min((long) rootView.getPreferredSpan(View.X_AXIS) +
|
||||
@@ -1398,7 +1397,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
private static final Position.Bias[] discardBias = new Position.Bias[1];
|
||||
private DefaultCaret dropCaret;
|
||||
private int caretMargin;
|
||||
private boolean rootViewInitialized;
|
||||
private boolean rootViewNeedsLayout;
|
||||
|
||||
/**
|
||||
* Root view that acts as a gateway between the component
|
||||
@@ -1961,7 +1960,6 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
* @see DocumentListener#insertUpdate
|
||||
*/
|
||||
public final void insertUpdate(DocumentEvent e) {
|
||||
rootViewInitialized = false;
|
||||
Document doc = e.getDocument();
|
||||
Object o = doc.getProperty("i18n");
|
||||
if (o instanceof Boolean) {
|
||||
@@ -1977,6 +1975,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
// normal insert update
|
||||
Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
|
||||
rootView.insertUpdate(e, alloc, rootView.getViewFactory());
|
||||
rootViewNeedsLayout = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1990,9 +1989,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
* @see DocumentListener#removeUpdate
|
||||
*/
|
||||
public final void removeUpdate(DocumentEvent e) {
|
||||
rootViewInitialized = false;
|
||||
Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
|
||||
rootView.removeUpdate(e, alloc, rootView.getViewFactory());
|
||||
rootViewNeedsLayout = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2006,9 +2005,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
||||
* @see DocumentListener#changedUpdate(DocumentEvent)
|
||||
*/
|
||||
public final void changedUpdate(DocumentEvent e) {
|
||||
rootViewInitialized = false;
|
||||
Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
|
||||
rootView.changedUpdate(e, alloc, rootView.getViewFactory());
|
||||
rootViewNeedsLayout = false;
|
||||
}
|
||||
|
||||
// --- LayoutManager2 methods --------------------------------
|
||||
|
||||
@@ -422,6 +422,10 @@ public class FileFontStrike extends PhysicalStrike {
|
||||
long getGlyphImageFromWindows(int glyphCode) {
|
||||
String family = fileFont.getFamilyName(null);
|
||||
FontFamily fontFamily = FontFamily.getFamily(family);
|
||||
if (fontFamily != null && fontFamily.hasMultipleCandidatesForSameStyle()) {
|
||||
// we cannot unambiguously specify font by its family name and style
|
||||
return 0;
|
||||
}
|
||||
int style = desc.style & Font.BOLD | desc.style & Font.ITALIC
|
||||
| fileFont.getStyle();
|
||||
if (fontFamily != null && fontFamily.getFont(style) != fileFont) {
|
||||
|
||||
@@ -55,15 +55,16 @@ public abstract class Font2D {
|
||||
public static final int DEFAULT_RANK = 4;
|
||||
|
||||
private static final String[] boldNames = {
|
||||
"bold", "demibold", "demi-bold", "demi bold", "negreta", "demi", };
|
||||
"bold", "demibold", "demi-bold", "demi bold", "negreta", "demi", "black", "coder-b"};
|
||||
|
||||
private static final String[] italicNames = {
|
||||
"italic", "cursiva", "oblique", "inclined", };
|
||||
"italic", "cursiva", "oblique", "inclined", "-it", "-lightit", "coder-i"};
|
||||
|
||||
private static final String[] boldItalicNames = {
|
||||
"bolditalic", "bold-italic", "bold italic",
|
||||
"boldoblique", "bold-oblique", "bold oblique",
|
||||
"demibold italic", "negreta cursiva","demi oblique", };
|
||||
"demibold italic", "negreta cursiva","demi oblique",
|
||||
"-boldit", "-blackit", "coder-bi"};
|
||||
|
||||
private static final FontRenderContext DEFAULT_FRC =
|
||||
new FontRenderContext(null, false, false);
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FontFamily {
|
||||
private static final byte CONFLICTING_STYLES = 0x10;
|
||||
|
||||
private static ConcurrentHashMap<String, FontFamily>
|
||||
familyNameMap = new ConcurrentHashMap<String, FontFamily>();
|
||||
@@ -50,6 +51,7 @@ public class FontFamily {
|
||||
private boolean initialized = false;
|
||||
protected boolean logicalFont = false;
|
||||
protected int familyRank;
|
||||
private byte stylesMask;
|
||||
|
||||
public static FontFamily getFamily(String name) {
|
||||
return familyNameMap.get(name.toLowerCase(Locale.ENGLISH));
|
||||
@@ -71,6 +73,16 @@ public class FontFamily {
|
||||
return;
|
||||
}
|
||||
family.ensureFontsLoaded();
|
||||
if (FontUtilities.isWindows) {
|
||||
synchronized (family.fontSequence) {
|
||||
if (family.stylesMask != CONFLICTING_STYLES &&
|
||||
(family.plain == font2D || family.bold == font2D ||
|
||||
family.italic == font2D || family.bolditalic == font2D)) {
|
||||
byte styleBit = getWinFontStyleBit(font2D);
|
||||
family.stylesMask = (byte) (family.stylesMask & ~styleBit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (family.plain == font2D) {
|
||||
family.plain = null;
|
||||
}
|
||||
@@ -295,6 +307,12 @@ public class FontFamily {
|
||||
return;
|
||||
}
|
||||
|
||||
if (FontUtilities.isWindows && stylesMask != CONFLICTING_STYLES) {
|
||||
byte styleBit = getWinFontStyleBit(font);
|
||||
byte newMask = (byte) (stylesMask | styleBit);
|
||||
stylesMask = newMask == stylesMask ? CONFLICTING_STYLES : newMask;
|
||||
}
|
||||
|
||||
switch (style) {
|
||||
|
||||
case Font.PLAIN:
|
||||
@@ -326,6 +344,12 @@ public class FontFamily {
|
||||
}
|
||||
}
|
||||
|
||||
private static byte getWinFontStyleBit(Font2D font) {
|
||||
// Windows seems to ignore bold attribute from fsSelection field, and consider only font's weight
|
||||
int winFontStyle = (font.getWeight() >= 410 ? 1 : 0) | (font.getStyle() & Font.ITALIC);
|
||||
return (byte) (1 << winFontStyle);
|
||||
}
|
||||
|
||||
public Font2D getFontWithExactStyleMatch(int style) {
|
||||
ensureFontsLoaded();
|
||||
switch (style) {
|
||||
@@ -475,6 +499,10 @@ public class FontFamily {
|
||||
return families.toArray(new FontFamily[0]);
|
||||
}
|
||||
|
||||
boolean hasMultipleCandidatesForSameStyle() {
|
||||
return stylesMask == CONFLICTING_STYLES;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return
|
||||
"Font family: " + familyName +
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -25,23 +25,7 @@
|
||||
|
||||
package sun.awt.X11;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.Window;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.InvocationEvent;
|
||||
@@ -52,6 +36,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
@@ -1302,9 +1287,20 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
*/
|
||||
if (isSimpleWindow()) {
|
||||
if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) {
|
||||
Window owner = getDecoratedOwner((Window)target);
|
||||
((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).
|
||||
requestWindowFocus(() -> {}, () -> {});
|
||||
// fix for: JBR-1762 Flotating navigation bar closes on navigate
|
||||
// Use the same logic as in MacOS (see LWWindowPeer, was introduced in:
|
||||
// 54bb2dd097 'JBR-1417 JBR 11 does not support chain of popups)'
|
||||
Window targetOwner = ((Window)target).getOwner();
|
||||
while (targetOwner != null && (targetOwner.getOwner() != null && !targetOwner.isFocusableWindow())) {
|
||||
targetOwner = targetOwner.getOwner();
|
||||
}
|
||||
|
||||
if (targetOwner != null) {
|
||||
final XWindowPeer xwndpeer = ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(targetOwner));
|
||||
if (xwndpeer != null) {
|
||||
xwndpeer.requestWindowFocus(() -> {}, () -> {});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
private boolean shutdownHookRegistered;
|
||||
private int scale;
|
||||
private final AtomicBoolean isScaleFactorDefault = new AtomicBoolean(false);
|
||||
private static final int XRM_XFT_DPI;
|
||||
private static volatile int XFT_DPI;
|
||||
private static volatile int xrmXftDpi;
|
||||
private static volatile int xftDpi;
|
||||
private static final int GDK_SCALE;
|
||||
private static final double GDK_DPI_SCALE;
|
||||
private static final double GDK_SCALE_MULTIPLIER;
|
||||
@@ -91,7 +91,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
initIDs();
|
||||
}
|
||||
XRM_XFT_DPI = getXrmXftDpi(-1);
|
||||
xrmXftDpi = getXrmXftDpi(-1);
|
||||
GDK_SCALE = (int)getGdkScale("GDK_SCALE", -1);
|
||||
GDK_DPI_SCALE = getGdkScale("GDK_DPI_SCALE", -1);
|
||||
GDK_SCALE_MULTIPLIER = GDK_SCALE != -1 ? GDK_SCALE * (GDK_DPI_SCALE != -1 ? GDK_DPI_SCALE : 1) : 1;
|
||||
@@ -505,6 +505,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
* X11GraphicsEnvironment when the display mode has been changed.
|
||||
*/
|
||||
public synchronized void displayChanged() {
|
||||
xrmXftDpi = getXrmXftDpi(-1);
|
||||
scale = initScaleFactor(1);
|
||||
// On X11 the visuals do not change, and therefore we don't need
|
||||
// to reset the defaultConfig, config, doubleBufferVisuals,
|
||||
@@ -540,9 +541,9 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
}
|
||||
|
||||
public static void setXftDpi(int dpi) {
|
||||
XFT_DPI = dpi;
|
||||
xftDpi = dpi;
|
||||
boolean uiScaleEnabled = SunGraphicsEnvironment.isUIScaleEnabled(dpi);
|
||||
double xftDpiScale = uiScaleEnabled ? XFT_DPI / 96.0 : 1.0;
|
||||
double xftDpiScale = uiScaleEnabled ? xftDpi / 96.0 : 1.0;
|
||||
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
|
||||
X11GraphicsDevice x11gd = (X11GraphicsDevice)gd;
|
||||
synchronized (x11gd.isScaleFactorDefault) {
|
||||
@@ -567,11 +568,11 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
if (nativeScale > 0) {
|
||||
return (int)Math.round(nativeScale * gdkScaleMult);
|
||||
}
|
||||
if (XRM_XFT_DPI > 0) {
|
||||
return (int)Math.round((XRM_XFT_DPI / 96.0) * gdkScaleMult);
|
||||
if (xrmXftDpi > 0) {
|
||||
return (int)Math.round((xrmXftDpi / 96.0) * gdkScaleMult);
|
||||
}
|
||||
if (XFT_DPI > 0) {
|
||||
return (int)Math.round((XFT_DPI / 96.0) * gdkScaleMult);
|
||||
if (xftDpi > 0) {
|
||||
return (int)Math.round((xftDpi / 96.0) * gdkScaleMult);
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
@@ -581,8 +582,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
* Used externally for diagnostic purpose.
|
||||
*/
|
||||
public String[][] getDpiInfo() {
|
||||
int xftDpi = XRM_XFT_DPI != -1 ? XRM_XFT_DPI : XFT_DPI;
|
||||
String xftDpiStr = xftDpi != -1 ? String.valueOf(xftDpi) : "undefined";
|
||||
int dpi = xrmXftDpi != -1 ? xrmXftDpi : xftDpi;
|
||||
String xftDpiStr = dpi != -1 ? String.valueOf(dpi) : "undefined";
|
||||
double gsettingsScale = getNativeScaleFactor(screen, -1);
|
||||
String gsettingsScaleStr = gsettingsScale != -1 ? String.valueOf(gsettingsScale) : "undefined";
|
||||
String gdkScaleStr = GDK_SCALE != -1 ? String.valueOf(GDK_SCALE) : "undefined";
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "awt_IconCursor.h"
|
||||
#include "awt_Win32GraphicsDevice.h"
|
||||
#include "ComCtl32Util.h"
|
||||
#include "shellapi.h"
|
||||
|
||||
#include <windowsx.h>
|
||||
#include <uxtheme.h>
|
||||
@@ -780,6 +781,24 @@ AwtFrame::Show()
|
||||
} else {
|
||||
::ShowWindow(hwnd, SW_SHOWMAXIMIZED);
|
||||
}
|
||||
|
||||
// [tav] Workaround for unclear platform behaviour.
|
||||
// When a custom decor frame is being shown maximized at the moment
|
||||
// some another AWT window is still foreground - the frame can go
|
||||
// in background when shown if:
|
||||
// 1) the other AWT window is closed the moment after frame's show
|
||||
// 2) some another maximized window is behind the frame, it steals activation
|
||||
if (HasCustomDecoration()) {
|
||||
HWND fgHWnd = ::GetForegroundWindow();
|
||||
if (fgHWnd != NULL &&
|
||||
GetComponent(fgHWnd) != NULL && // it's awt window
|
||||
IsFocusableWindow() &&
|
||||
IsAutoRequestFocus() &&
|
||||
!::IsWindow(GetModalBlocker(GetHWnd())))
|
||||
{
|
||||
::SetForegroundWindow(GetHWnd());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_isInputMethodWindow) {
|
||||
// Don't activate input methow window
|
||||
@@ -1824,7 +1843,15 @@ MsgRouting AwtFrame::WmNcCalcSize(BOOL wParam, LPNCCALCSIZE_PARAMS lpncsp, LRESU
|
||||
// [moklev] Workaround for RIDER-27069, IDEA-211327
|
||||
if (!this->IsUndecorated()) {
|
||||
rect->right += this->ScaleUpX(1);
|
||||
rect->bottom -= 1;
|
||||
// [tav] Decrement NC bottom only when taskbar is bottom/autohide (JBR-1786)
|
||||
APPBARDATA abData;
|
||||
abData.cbSize = sizeof(abData);
|
||||
if (::SHAppBarMessage(ABM_GETTASKBARPOS, &abData) &&
|
||||
abData.uEdge == ABE_BOTTOM &&
|
||||
::SHAppBarMessage(ABM_GETSTATE, &abData) == ABS_AUTOHIDE)
|
||||
{
|
||||
rect->bottom -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -42,18 +42,20 @@ applications/jcstress/acqrel/Test.java generic-all
|
||||
|
||||
# :hotspot_compiler
|
||||
|
||||
compiler/ciReplay/TestSAServer.java 8029528 generic-all
|
||||
compiler/codecache/stress/OverloadCompileQueueTest.java 8166554 generic-all
|
||||
compiler/codegen/Test6896617.java 8193479 generic-all
|
||||
compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java 8140405 generic-all
|
||||
compiler/jvmci/compilerToVM/GetFlagValueTest.java 8204459 generic-all
|
||||
compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java 8158860 generic-all
|
||||
compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java 8163894 generic-all
|
||||
compiler/tiered/LevelTransitionTest.java 8067651 generic-all
|
||||
compiler/types/correctness/CorrectnessTest.java 8066173 generic-all
|
||||
compiler/types/correctness/OffTest.java 8066173 generic-all
|
||||
compiler/ciReplay/TestSAServer.java 8029528 generic-all
|
||||
compiler/codecache/stress/OverloadCompileQueueTest.java 8166554 generic-all
|
||||
compiler/codegen/Test6896617.java 8193479 generic-all
|
||||
compiler/codegen/aes/TestCipherBlockChainingEncrypt.java 8219513 generic-all
|
||||
compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java 8140405 generic-all
|
||||
compiler/jsr292/ContinuousCallSiteTargetChange.java 8222030 generic-all
|
||||
compiler/jvmci/compilerToVM/GetFlagValueTest.java 8204459 generic-all
|
||||
compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java 8158860 generic-all
|
||||
compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java 8163894 generic-all
|
||||
compiler/tiered/LevelTransitionTest.java 8067651 generic-all
|
||||
compiler/types/correctness/CorrectnessTest.java 8066173 generic-all
|
||||
compiler/types/correctness/OffTest.java 8066173 generic-all
|
||||
|
||||
compiler/c2/Test6852078.java 8194310 generic-all
|
||||
compiler/c2/Test6852078.java 8194310 generic-all
|
||||
|
||||
applications/ctw/modules/java_desktop.java 8189604 windows-all
|
||||
applications/ctw/modules/java_desktop_2.java 8189604,8204842 generic-all
|
||||
@@ -65,14 +67,15 @@ compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java 8190680 generic-all
|
||||
|
||||
# :hotspot_gc
|
||||
|
||||
gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java 8156755 generic-all
|
||||
gc/survivorAlignment/TestPromotionToSurvivor.java 8129886 generic-all
|
||||
gc/g1/logging/TestG1LoggingFailure.java 8169634 generic-all
|
||||
gc/g1/humongousObjects/TestHeapCounters.java 8178918 generic-all
|
||||
gc/stress/gclocker/TestGCLockerWithParallel.java 8180622 generic-all
|
||||
gc/stress/gclocker/TestGCLockerWithG1.java 8180622 generic-all
|
||||
gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java 8177765 generic-all
|
||||
gc/stress/TestJNIBlockFullGC/TestJNIBlockFullGC.java 8192647 generic-all
|
||||
gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java 8156755 generic-all
|
||||
gc/survivorAlignment/TestPromotionToSurvivor.java 8129886 generic-all
|
||||
gc/g1/logging/TestG1LoggingFailure.java 8169634 generic-all
|
||||
gc/g1/humongousObjects/TestHeapCounters.java 8178918 generic-all
|
||||
gc/stress/gclocker/TestGCLockerWithParallel.java 8180622 generic-all
|
||||
gc/stress/gclocker/TestGCLockerWithG1.java 8180622 generic-all
|
||||
gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java 8177765 generic-all
|
||||
gc/stress/TestJNIBlockFullGC/TestJNIBlockFullGC.java 8192647 generic-all
|
||||
gc/stress/TestReclaimStringsLeaksMemory.java 8224847 generic-all
|
||||
|
||||
#############################################################################
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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
|
||||
* @key headful
|
||||
* @bug 8226513
|
||||
* @summary JEditorPane is shown with incorrect size
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.0 JEditorPaneLayoutTest
|
||||
*/
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Robot;
|
||||
|
||||
public class JEditorPaneLayoutTest {
|
||||
|
||||
public static final String TEXT =
|
||||
"some text some text some text <br> some text";
|
||||
static JFrame frame;
|
||||
static JEditorPane editorPane;
|
||||
static Dimension size1;
|
||||
static Dimension size2;
|
||||
static Dimension size3;
|
||||
static Dimension size4;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
frame = new JFrame();
|
||||
editorPane = new JEditorPane("text/html", TEXT);
|
||||
size1 = editorPane.getPreferredSize();
|
||||
editorPane.setText(TEXT);
|
||||
frame.add(editorPane);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.delay(300);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
size2 = editorPane.getSize();
|
||||
frame.dispose();
|
||||
|
||||
frame = new JFrame();
|
||||
editorPane = new JEditorPane("text/html", TEXT);
|
||||
editorPane.getPreferredSize();
|
||||
editorPane.setText(TEXT);
|
||||
frame.add(editorPane);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.delay(300);
|
||||
|
||||
if (!size1.equals(size2)) {
|
||||
SwingUtilities.invokeLater(frame::dispose);
|
||||
throw new RuntimeException("Wrong size " + size2 +
|
||||
" expected " + size1);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
editorPane.setText(TEXT);
|
||||
frame.pack();
|
||||
size3 = editorPane.getSize();
|
||||
frame.dispose();
|
||||
|
||||
frame = new JFrame();
|
||||
editorPane = new JEditorPane("text/html", TEXT);
|
||||
editorPane.getPreferredSize();
|
||||
editorPane.setSize(1, 1);
|
||||
Document doc = new HTMLEditorKit().createDefaultDocument();
|
||||
try {
|
||||
doc.insertString(0, TEXT, null);
|
||||
} catch (BadLocationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
editorPane.setDocument(doc);
|
||||
editorPane.setText(TEXT);
|
||||
frame.add(editorPane);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.delay(300);
|
||||
|
||||
if (!size1.equals(size3)) {
|
||||
SwingUtilities.invokeLater(frame::dispose);
|
||||
throw new RuntimeException("Wrong size " + size3 +
|
||||
" expected " + size1);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
size4 = editorPane.getSize();
|
||||
frame.dispose();
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.delay(300);
|
||||
|
||||
if (!size1.equals(size4)) {
|
||||
SwingUtilities.invokeLater(frame::dispose);
|
||||
throw new RuntimeException("Wrong size " + size4 +
|
||||
" expected " + size1);
|
||||
}
|
||||
}
|
||||
}
|
||||
180
test/jdk/jb/java/awt/Focus/ChainOfPopupsFocusTest.java
Normal file
180
test/jdk/jb/java/awt/Focus/ChainOfPopupsFocusTest.java
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright 2000-2019 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.PopupFactory;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.FocusTraversalPolicy;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-1417: JBR 11 does not support chain of popups
|
||||
* @requires (jdk.version.major >= 8)
|
||||
* @run main ChainOfPopupsFocusTest
|
||||
*/
|
||||
|
||||
/*
|
||||
* Description: Test checks that focus goes to the parent popup when child popup is closed.
|
||||
* Test opens several popups one by one, setting current popup as a parent for the next one.
|
||||
* Then the popups are closed one by one. Test fails if the main frame gets closed or
|
||||
* if the number of closed popups is not equal to the number of open popups.
|
||||
* It means that focus went somewhere else than the parent popup.
|
||||
*/
|
||||
|
||||
public class ChainOfPopupsFocusTest implements Runnable, ActionListener {
|
||||
|
||||
private static final int DEPTH = 5;
|
||||
|
||||
private static volatile boolean frameHidden = false;
|
||||
private static volatile int popupsHidden = 0;
|
||||
private static volatile Component focusOwner;
|
||||
private static Robot robot;
|
||||
private JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
ChainOfPopupsFocusTest test = new ChainOfPopupsFocusTest();
|
||||
SwingUtilities.invokeAndWait(test);
|
||||
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
for (int i = 0; i < DEPTH; i++) pressCtrlKey(KeyEvent.VK_N);
|
||||
robot.delay(2000);
|
||||
for (int i = 0; i < DEPTH; i++) pressCtrlKey(KeyEvent.VK_X);
|
||||
robot.delay(2000);
|
||||
|
||||
try {
|
||||
if(frameHidden) {
|
||||
System.err.println("Error: frameHidden=" + frameHidden);
|
||||
throw new RuntimeException("Test FAILED: Focus went to the main frame instead of the parent popup");
|
||||
}
|
||||
if(popupsHidden != DEPTH) {
|
||||
System.err.println("Error: frameHidden=" + frameHidden + " popupsHidden=" + popupsHidden);
|
||||
SwingUtilities.invokeAndWait(() -> focusOwner = test.frame.getFocusOwner());
|
||||
throw new RuntimeException("Test FAILED: Focus went to " + focusOwner + " instead of the parent popup");
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> test.frame.dispose());
|
||||
robot.delay(2000);
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
|
||||
private static void pressCtrlKey(int vk) {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(vk);
|
||||
robot.keyRelease(vk);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
frame = new JFrame(getClass().getSimpleName());
|
||||
frame.add(new JScrollPane(createTextArea()));
|
||||
frame.pack();
|
||||
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent event) {
|
||||
frameHidden = true;
|
||||
}
|
||||
});
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private JTextArea createTextArea() {
|
||||
JTextArea area = new JTextArea(20, 40);
|
||||
area.registerKeyboardAction(this, "show", KeyStroke.getKeyStroke("control N"), JComponent.WHEN_FOCUSED);
|
||||
area.registerKeyboardAction(event -> SwingUtilities.getWindowAncestor((Component) event.getSource()).setVisible(false), KeyStroke.getKeyStroke("control X"), JComponent.WHEN_FOCUSED);
|
||||
area.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentShown(ComponentEvent event) {
|
||||
area.requestFocus();
|
||||
}
|
||||
});
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
Component source = (Component) event.getSource();
|
||||
switch (event.getActionCommand()) {
|
||||
case "show":
|
||||
Point point = source.getLocationOnScreen();
|
||||
Component area = createTextArea();
|
||||
Popup popup = PopupFactory.getSharedInstance().getPopup(source, new JScrollPane(area), point.x + 10, point.y + 10);
|
||||
Window window = SwingUtilities.getWindowAncestor(area);
|
||||
window.setAutoRequestFocus(true);
|
||||
window.setFocusable(true);
|
||||
window.setFocusableWindowState(true);
|
||||
window.setFocusTraversalPolicy(new FocusTraversalPolicy() {
|
||||
@Override
|
||||
public Component getComponentAfter(Container container, Component component) {
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponentBefore(Container container, Component component) {
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getFirstComponent(Container container) {
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getLastComponent(Container container) {
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDefaultComponent(Container container) {
|
||||
return area;
|
||||
}
|
||||
});
|
||||
window.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent event) {
|
||||
popupsHidden++;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
break;
|
||||
case "hide":
|
||||
SwingUtilities.getWindowAncestor(source).setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ java/awt/BasicStroke/DashZeroWidth.java
|
||||
java/awt/Choice/ItemStateChangeTest/ItemStateChangeTest.java 8169108 windows-all
|
||||
java/awt/Choice/ChoiceGeneratesItemEvents/ChoiceGeneratesItemEvents.html 8047703 generic-all
|
||||
java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.html 6849922 macosx-all,windows-all
|
||||
java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java 7100044 macosx-all,windows-all,linux-all
|
||||
java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java 7100044 macosx-all,windows-all
|
||||
java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java 8202931 macosx-all,linux-all,windows-all
|
||||
java/awt/Choice/GrabLockTest/GrabLockTest.java JRE-839 windows-all,macosx-all,linux-all
|
||||
java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html 8194045 generic-all
|
||||
@@ -137,6 +137,8 @@ java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java
|
||||
java/awt/Debug/DumpOnKey/DumpOnKey.java 8202667 windows-all,linux-all
|
||||
java/awt/Dialog/DialogAboveFrame/DialogAboveFrame.java 8214923 windows-all,macosx-all
|
||||
java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java 8215105 macosx-all,windows-all
|
||||
java/awt/Dialog/NestedDialogs/Modeless/NestedModelessDialogTest.java 8225790 linux-all
|
||||
java/awt/Dialog/SiblingChildOrder/SiblingChildOrderTest.java 8215105,8221383 macosx-all,windows-all
|
||||
java/awt/EmbeddedFrame/EmbeddedFrameGrabTest/EmbeddedFrameGrabTest.java 8159069 windows-all
|
||||
java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java 8203047 macosx-all,linux-all,windows-all
|
||||
java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html 8073636 macosx-all
|
||||
@@ -197,6 +199,7 @@ java/awt/FontMetrics/MaxAdvanceIsMax.java
|
||||
java/awt/Frame/DisposeParentGC/DisposeParentGC.java 8079786,8055833 macosx-all,linux-all
|
||||
java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java 8198237 macosx-all
|
||||
java/awt/Frame/FramesGC/FramesGC.java 8079069 macosx-all
|
||||
java/awt/Frame/FrameLocation/FrameLocation.java 8019803 macosx-all
|
||||
java/awt/Frame/InvisibleOwner/InvisibleOwner.java 8169111 macosx-all,windows-all
|
||||
java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java 8169472 windows-all
|
||||
java/awt/Frame/MaximizedUndecorated/MaximizedUndecorated.java 8022302 generic-all
|
||||
@@ -209,25 +212,27 @@ java/awt/FullScreen/8013581/bug8013581.java
|
||||
java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java 8047218 generic-all
|
||||
java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java 8169469 windows-all,linux-all (linux: NPE commit testing)
|
||||
java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java 7019055 windows-all,linux-all,macosx-all
|
||||
java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java 8169468 windows-all
|
||||
java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java 8169468 windows-all,macosx-all
|
||||
java/awt/FullScreen/UninitializedDisplayModeChangeTest/UninitializedDisplayModeChangeTest.java 7188711 macosx-all
|
||||
java/awt/Graphics/CopyScaledArea/CopyScaledAreaTest.java 8153299 windows-all
|
||||
java/awt/Graphics/LineClipTest.java JRE-898 macosx-all
|
||||
java/awt/Graphics2D/CopyAreaOOB.java 7001973 windows-all,macosx-all
|
||||
java/awt/Graphics2D/CopyAreaOOB.java 7001973 windows-all,macosx-all,linux-all
|
||||
java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java 8197796 generic-all
|
||||
java/awt/Graphics2D/DrawString/RotTransText.java 8197797 generic-all
|
||||
java/awt/Graphics2D/DrawString/TextRenderingTest.java 8169464 windows-all
|
||||
java/awt/Graphics2D/FillTexturePaint/FillTexturePaint.java 8169463 windows-all
|
||||
java/awt/Graphics2D/FlipDrawImage/FlipDrawImage.java 8169462 windows-all
|
||||
java/awt/Graphics2D/ScaledTransform/ScaledTransform.java 8165951 windows-all,linux-all
|
||||
java/awt/GraphicsDevice/CheckDisplayModes.java 8213119 macosx-all
|
||||
java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java 8197814 macosx-all,linux-all,windows-all
|
||||
java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8197814 macosx-all,linux-all,windows-all
|
||||
java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java 8000171 windows-all
|
||||
java/awt/JAWT/JAWT.sh 8197798 windows-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.html JRE-898 macosx-all,linux-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java 8198623 macosx-all,windows-all,linux-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/FreezeTest/FreezeTest.java 8198623 macosx-all,windows-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/FreezeTest/FreezeTest.java 8198623 macosx-all,windows-all,linux-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.html 8198624 macosx-all,linux-all,windows-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.html 8198626 macosx-all,windows-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.html 8198626 macosx-all,windows-all,linux-all
|
||||
java/awt/LightweightComponent/LightweightEventTest/LightweightEventTest.java 8159252 generic-all
|
||||
java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html 8169461 windows-all
|
||||
java/awt/List/KeyEventsTest/KeyEventsTest.html 8047703 windows-all
|
||||
@@ -529,7 +534,7 @@ java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java
|
||||
java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java 8196441 macosx-all,windows-all,linux-all
|
||||
java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java 8196441 macosx-all,windows-all,linux-all
|
||||
java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java 8196441 macosx-all,windows-all,linux-all
|
||||
java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java 8177326 macosx-all,windows-all
|
||||
java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java 8177326 macosx-all,windows-all,linux-all
|
||||
java/awt/Mouse/EnterExitEvents/DragWindowTest.java 8023562 macosx-all,windows-all,linux-all
|
||||
java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java JRE-898 macosx-all,windows-all,linux-all
|
||||
java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java 8005021 macosx-all,windows-all,linux-all
|
||||
@@ -547,6 +552,7 @@ java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick.html
|
||||
java/awt/MouseInfo/GetPointerInfoTest.java 8158798 windows-all
|
||||
java/awt/Multiscreen/LocationRelativeToTest/LocationRelativeToTest.java 7124230 generic-all
|
||||
java/awt/Multiscreen/MultiScreenLocationTest/MultiScreenLocationTest.java 8155744 windows-all,linux-all
|
||||
java/awt/Multiscreen/WindowGCChangeTest/WindowGCChangeTest.html 8168132 macosx-all,linux-all
|
||||
java/awt/Paint/PaintNativeOnUpdate.java 8028000 generic-all
|
||||
java/awt/Paint/bug8024864.java 8176512 windows-all,macosx-all,linux-all
|
||||
java/awt/PrintJob/PrinterException.java 8194045 generic-all
|
||||
@@ -594,6 +600,7 @@ java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java
|
||||
java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java 8078999,8198690 macosx-all,linux-all,windows-all
|
||||
java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucentWindowClick.java 8013450 macosx-all,linux-all,windows-all (windows: commit testing time out)
|
||||
java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java 8198690,8165218 macosx-all,linux-all,windows-all
|
||||
java/awt/Window/ShapedAndTranslucentWindows/Translucent.java 8222328 linux-all,windows-all
|
||||
java/awt/Window/ShapedAndTranslucentWindows/TranslucentChoice.java 8194129 macosx-all,windows-all,linux-all
|
||||
java/awt/Window/ShapedAndTranslucentWindows/TranslucentWindowClick.java 8194129 macosx-all,windows-all,linux-all
|
||||
java/awt/Window/AlwaysOnTop/AutoTestOnTop.java 6847593,8194045 macosx-all,windows-all,linux-all
|
||||
@@ -917,7 +924,7 @@ javax/swing/JColorChooser/Test6541987.java
|
||||
javax/swing/JColorChooser/Test6827032.java 8197825 windows-all
|
||||
javax/swing/JColorChooser/Test7194184.java 8194126,8072110 linux-all,macosx-all,windows-all
|
||||
javax/swing/JColorChooser/Test8051548.java 8197552 macosx-all,windows-all,linux-all
|
||||
javax/swing/JComboBox/4743225/bug4743225.java 8171302 windows-all,macosx-all
|
||||
javax/swing/JComboBox/4743225/bug4743225.java 8171302 windows-all,macosx-all,linux-all
|
||||
javax/swing/JComboBox/6236162/bug6236162.java 8028707 windows-all,macosx-all
|
||||
javax/swing/JComboBox/6559152/bug6559152.java 8196090 windows-all,macosx-all,linux-all
|
||||
javax/swing/JComboBox/6607130/bug6607130.java 8196091 windows-all
|
||||
@@ -954,6 +961,7 @@ javax/swing/JFileChooser/DeserializedJFileChooser/DeserializedJFileChooserTest.j
|
||||
javax/swing/JFrame/8016356/bug8016356.java 8169955 windows-all
|
||||
javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java 8193942 generic-all
|
||||
javax/swing/JInternalFrame/5066752/bug5066752.java 8207850 macosx-all,windows-all
|
||||
javax/swing/JInternalFrame/8020708/bug8020708.java 8226230 linux-all
|
||||
javax/swing/JInternalFrame/8069348/bug8069348.java 8208570 macosx-all,windows-all,linux-all
|
||||
javax/swing/JInternalFrame/8145060/TestJInternalFrameMinimize.java 8203918 windows-all,linux-all
|
||||
javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java 8194944 macosx-all,windows-all,linux-all
|
||||
@@ -961,7 +969,7 @@ javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java
|
||||
javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java 8186513 generic-all
|
||||
javax/swing/JInternalFrame/DockIconRepaint/DockIconRepaint.java 8208289 macosx-all
|
||||
javax/swing/JInternalFrame/Test6325652.java 8160880,8196467 linux-all,macosx-all,windows-all
|
||||
javax/swing/JInternalFrame/Test6505027.java 8172535 macosx-all,windows-all
|
||||
javax/swing/JInternalFrame/Test6505027.java 8172535 macosx-all,windows-all,linux-all
|
||||
javax/swing/JLabel/6596966/bug6596966.java 8197552,8040914 macosx-all,windows-all,linux-all
|
||||
javax/swing/JList/6462008/bug6462008.java 7156347 generic-all
|
||||
javax/swing/JMenu/4213634/bug4213634.java 8197552 macosx-all,windows-all,linux-all
|
||||
@@ -976,7 +984,7 @@ javax/swing/JMenuItem/4171437/bug4171437.java
|
||||
javax/swing/JMenuItem/4654927/bug4654927.java 8172536 macosx-all,windows-all,linux-all
|
||||
javax/swing/JMenuItem/6209975/bug6209975.java 8204062 macosx-all,windows-all
|
||||
javax/swing/JMenuItem/6249972/bug6249972.java 8197552 macosx-all,windows-all,linux-all
|
||||
javax/swing/JPopupMenu/4458079/bug4458079.java 8040917 macosx-all,windows-all
|
||||
javax/swing/JPopupMenu/4458079/bug4458079.java 8040917 macosx-all,windows-all,linux-all
|
||||
javax/swing/JPopupMenu/4769039/bug4769039.java 8194045 generic-all
|
||||
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all
|
||||
javax/swing/JPopupMenu/4966112/bug4966112.java 8064915,7151826 macosx-all,linux-all
|
||||
@@ -1021,7 +1029,7 @@ javax/swing/JTextArea/TextViewOOM/TextViewOOM.java
|
||||
javax/swing/JTextField/4306756/bug4306756.java 8194045 generic-all
|
||||
javax/swing/JTextField/8036819/bug8036819.java 8197552 macosx-all,windows-all,linux-all
|
||||
javax/swing/JToolTip/4846413/bug4846413.java 8172407 macosx-all,windows-all
|
||||
javax/swing/JTree/4330357/bug4330357.java 8029682,8003839 macosx-all,windows-all
|
||||
javax/swing/JTree/4330357/bug4330357.java 8029682,8003839 macosx-all,windows-all,linux-all
|
||||
javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all
|
||||
javax/swing/JTree/4908142/bug4908142.java 8197552,8172065 macosx-all,windows-all,linux-all
|
||||
javax/swing/JTree/4927934/bug4927934.java 8197552,8172063 macosx-all,windows-all,linux-all
|
||||
@@ -1043,7 +1051,7 @@ javax/swing/Popup/TaskbarPositionTest.java
|
||||
javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java 8065099,8208565 macosx-all,windows-all,linux-all
|
||||
javax/swing/PopupFactory/8048506/bug8048506.java 8202660 windows-all
|
||||
javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java 8197552 macosx-all,windows-all,linux-all
|
||||
javax/swing/RepaintManager/IconifyTest/IconifyTest.java 8072110 linux-all,windows-all
|
||||
javax/swing/RepaintManager/IconifyTest/IconifyTest.java 8072110,8221903 linux-all,windows-all
|
||||
javax/swing/SpringLayout/4726194/bug4726194.java 8198399 generic-all
|
||||
javax/swing/SwingUtilities/4917669/bug4917669.java 8197552,8172064 macosx-all,windows-all,linux-all
|
||||
javax/swing/SwingUtilities/6797139/bug6797139.java 8198400 generic-all
|
||||
|
||||
@@ -2,12 +2,12 @@ java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java
|
||||
java/awt/Choice/DragMouseOutAndRelease/DragMouseOutAndRelease.java nobug macosx-all,windows-all
|
||||
java/awt/Choice/GetSizeTest/GetSizeTest.java nobug macosx-all,windows-all
|
||||
java/awt/Choice/ResizeAutoClosesChoice/ResizeAutoClosesChoice.java nobug windows-all,linux-all
|
||||
java/awt/Choice/UnfocusableCB_ERR/UnfocusableCB_ERR.java nobug macosx-all
|
||||
java/awt/Component/F10TopToplevel/F10TopToplevel.html nobug linux-all
|
||||
java/awt/Component/PaintAll/PaintAll.java nobug linux-all
|
||||
java/awt/Container/isRemoveNotifyNeeded/JInternalFrameTest.java nobug generic-all
|
||||
java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java nobug macosx-all,windows-all
|
||||
java/awt/Dialog/NestedDialogs/Modal/NestedModalDialogTest.java nobug macosx-all,windows-all
|
||||
java/awt/Dialog/NestedDialogs/Modeless/NestedModelessDialogTest.java nobug macosx-all,windows-all,linux-all
|
||||
java/awt/Dialog/NonResizableDialogSysMenuResize/NonResizableDialogSysMenuResize.java nobug macosx-all,windows-all
|
||||
java/awt/Dialog/SiblingChildOrder/SiblingChildOrderTest.java nobug macosx-all,windows-all
|
||||
java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html nobug macosx-all,windows-all
|
||||
@@ -29,6 +29,7 @@ java/awt/Focus/NonFocusableResizableTooSmall/NonFocusableResizableTooSmall.java
|
||||
java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java nobug macosx-all,windows-all,linux-all
|
||||
java/awt/Focus/RemoveAfterRequest/RemoveAfterRequest.java nobug macosx-all
|
||||
java/awt/Focus/RequestFocusAndHideTest/RequestFocusAndHideTest.java nobug macosx-all
|
||||
java/awt/Focus/RequestFocusByCause/RequestFocusByCauseTest.java nobug linux-all,macosx-all,windows-all reproduced with Adopt, OpenJDK
|
||||
java/awt/Focus/WindowIsFocusableAccessByThreadsTest/WindowIsFocusableAccessByThreadsTest.java nobug macosx-all,windows-all
|
||||
java/awt/Frame/8158918/SetExtendedState.java nobug linux-all
|
||||
java/awt/Frame/FrameLocation/FrameLocation.java nobug linux-all
|
||||
@@ -142,6 +143,7 @@ java/awt/hidpi/properties/HiDPIPropertiesUnixTest.java
|
||||
java/awt/hidpi/properties/HiDPIPropertiesWindowsTest.java nobug windows-all
|
||||
java/awt/image/DrawImage/EABlitTest.java nobug windows-all
|
||||
java/awt/image/DrawImage/IncorrectOffset.java nobug windows-all
|
||||
java/awt/image/DrawImage/UnmanagedDrawImagePerformance.java JBR-1801 windows-all
|
||||
java/awt/image/VolatileImage/DrawBufImgOp.java nobug windows-all
|
||||
java/awt/image/VolatileImage/DrawHugeImageTest.java nobug windows-all
|
||||
java/awt/image/VolatileImage/TransparentVImage.java nobug windows-all
|
||||
@@ -172,6 +174,7 @@ javax/swing/JLabel/7004134/bug7004134.java
|
||||
javax/swing/JList/6510999/bug6510999.java nobug linux-all,macosx-all,windows-all
|
||||
javax/swing/JList/BasicListTest.java nobug macosx-all
|
||||
javax/swing/JMenu/6538132/bug6538132.java nobug windows-all
|
||||
javax/swing/JMenu/8178430/LabelDotTest.java nobug linux-all
|
||||
javax/swing/JMenuItem/8139169/ScreenMenuBarInputTwice.java nobug macosx-all
|
||||
javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java nobug windows-all
|
||||
javax/swing/JOptionPane/6428694/bug6428694.java nobug windows-all
|
||||
@@ -184,22 +187,24 @@ javax/swing/JRadioButton/8041561/bug8041561.java
|
||||
javax/swing/JScrollBar/7163696/Test7163696.java nobug windows-all
|
||||
javax/swing/JScrollBar/bug4202954/bug4202954.java nobug windows-all
|
||||
javax/swing/JSlider/6401380/bug6401380.java nobug windows-all
|
||||
javax/swing/JTabbedPane/7161568/bug7161568.java nobug windows-all
|
||||
javax/swing/JTabbedPane/7161568/bug7161568.java nobug windows-all,linux-all
|
||||
javax/swing/JTabbedPane/7170310/bug7170310.java nobug macosx-all,linux-all
|
||||
javax/swing/JTextArea/8149849/DNDTextToScaledArea.java nobug windows-all
|
||||
javax/swing/JToolTip/6219960/bug6219960.java nobug macosx-all,windows-all
|
||||
javax/swing/JTree/4633594/JTreeFocusTest.java nobug macosx-all,windows-all
|
||||
javax/swing/JTree/6578666/bug6578666.java nobug macosx-all
|
||||
javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucent.java nobug windows-all
|
||||
javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java nobug windows-all
|
||||
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java nobug macosx-all,linux-all,windows-all
|
||||
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java nobug macosx-all,windows-all
|
||||
javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java nobug windows-all
|
||||
javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentWindowClickSwing.java nobug windows-all
|
||||
javax/swing/RepaintManager/IconifyTest/IconifyTest.java nobug macosx-all reproduced with Adopt
|
||||
javax/swing/event/RightAltKeyTest.java nobug windows-all
|
||||
javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java nobug linux-all,windows-all
|
||||
javax/swing/plaf/nimbus/8041642/ScrollBarThumbVisibleTest.java nobug windows-all
|
||||
javax/swing/plaf/nimbus/8041642/bug8041642.java nobug windows-all
|
||||
javax/swing/plaf/nimbus/8057791/bug8057791.java nobug windows-all
|
||||
javax/swing/plaf/nimbus/8057791/bug8057791.java nobug windows-all,linux-all
|
||||
javax/swing/plaf/nimbus/TestNimbusOverride.java nobug windows-all
|
||||
javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java nobug windows-all
|
||||
javax/swing/plaf/synth/SynthScrollbarThumbPainter/SynthScrollbarThumbPainterTest.java nobug windows-all
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.awt.geom.QuadCurve2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -44,6 +45,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class RenderPerfTest {
|
||||
private final static int N = 1000;
|
||||
private final static int K = 5;
|
||||
private final static float WIDTH = 800;
|
||||
private final static float HEIGHT = 800;
|
||||
private final static float R = 25;
|
||||
@@ -187,6 +189,32 @@ public class RenderPerfTest {
|
||||
}
|
||||
}
|
||||
|
||||
static class RandomTextParticleRenderer extends TextParticleRenderer {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Random rnd = new Random();
|
||||
int sLen;
|
||||
|
||||
|
||||
RandomTextParticleRenderer(int n, int k, float r, Object hint) {
|
||||
super(n, r, hint);
|
||||
sLen = k;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Graphics2D g2d, int id, float[] x, float[] y, float[] vx, float[] vy) {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, hint);
|
||||
|
||||
setPaint(g2d, id);
|
||||
buffer.setLength(0);
|
||||
for (int i = 0; i < sLen; i++) {
|
||||
buffer.appendCodePoint(0x20 + (Math.abs(rnd.nextInt()) % 0xfd0));
|
||||
}
|
||||
|
||||
g2d.drawString(buffer.toString(),
|
||||
(int)(x[id] - r), (int)(y[id] - r));
|
||||
}
|
||||
|
||||
}
|
||||
static class FlatOvalRotParticleRenderer extends FlatParticleRenderer {
|
||||
|
||||
|
||||
@@ -516,6 +544,8 @@ public class RenderPerfTest {
|
||||
private static final ParticleRenderer whiteTextRendererGray =
|
||||
new WhiteTextParticleRenderer(R, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
private static final ParticleRenderer randomTextRendererGray =
|
||||
new RandomTextParticleRenderer(N, K, R, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
@Test
|
||||
public void testFlatBubbles() throws Exception {
|
||||
@@ -752,6 +782,25 @@ public class RenderPerfTest {
|
||||
report("TextLCD", fps);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomTextBubblesGray() throws Exception {
|
||||
|
||||
double fps = (new PerfMeter()).exec(new Renderable() {
|
||||
@Override
|
||||
public void render(Graphics2D g2d) {
|
||||
balls.render(g2d, randomTextRendererGray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
balls.update();
|
||||
}
|
||||
});
|
||||
|
||||
report("RandomTextGray", fps);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextBubblesGray() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user