Compare commits

...

27 Commits
1031 ... 1108

Author SHA1 Message Date
Artem Semenov
54bb49caeb Review JR-CR-645 JBR-2504 A11y Create a test to test the accessibility of lists on MAc
(cherry picked from commit 92e40bf92c00fb5ce46dff41fc23ad39e460fcc1)
2020-09-25 12:55:34 +03:00
Vitaly Provodin
9c0afe3a7d updated JTreg exclude list 2020-09-24 05:04:33 +07:00
Dmitry Batrak
6dd334f9f0 JBR-2648 Cannot input Japanese and Chinese text in Search Everywhere
code being removed (added to fix JRE-665) is not needed after JBR-2533 fix, as 'simple' windows are natively focused now
2020-09-23 17:27:37 +03:00
Dmitry Batrak
96dd8fcf48 JBR-2735 PopupIncomingFocusTest is failing on KDE when launched via jtreg 2020-09-23 12:47:19 +03:00
Egor Ushakov
9b960dd02a navigation to issues from vcs log 2020-09-16 15:38:20 +03:00
Mikhail Grishchenko
6b7d5fd58c updated JTreg exclude list 2020-09-16 16:25:07 +07:00
Dmitry Batrak
ebcdeb7d80 JBR-2698 setAutoRequestFocus(false) breaks focus logic under i3 window manager on Linux 2020-09-11 11:11:17 +03:00
Vitaly Provodin
67870df19e updated JTreg exclude list 2020-09-11 10:36:59 +07:00
Nikita Gubarkov
afd19dbefd JBR-2614 Fixed LCD glyph width to include both left & right padding, so that rowBytes = width * 3 2020-09-10 15:45:25 +03:00
Nikita Gubarkov
a55097289b Revert "JBR-2614 Passed real glyph type from native code instead of guessing on rowBytes & width"
This reverts commit 8de39b80
2020-09-10 15:39:00 +03:00
Nikita Gubarkov
8de39b80cd JBR-2614 Passed real glyph type from native code instead of guessing on rowBytes & width 2020-09-10 01:50:34 +03:00
Dmitry Batrak
0f038754e5 JBR-2696 Log focus API invocations with stack traces 2020-09-07 14:19:43 +03:00
Vitaly Provodin
4aa278e4a0 Revert "JBR-2577 implemented precise CompilationMXBean#getTotalCompilationTime"
This reverts commit 89163e73
2020-09-07 16:44:40 +07:00
Vitaly Provodin
e3562ecc99 Revert "thread.cpp:4574:43: error: ‘nullptr’ quick fix"
This reverts commit 82a36017
2020-09-07 16:44:20 +07:00
Vitaly Provodin
b62d47da9c updated JTreg exclude list 2020-09-06 06:27:20 +07:00
Vitaly Provodin
e748f39e20 updated JTreg exclude list 2020-08-26 11:41:35 +07:00
Brian Burkhalter
428ade4fd8 8221852: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE should be selected at runtime, not build time
Reviewed-by: alanb, shade
2020-08-24 11:36:15 +07:00
Alexey Ushakov
e28ff71e97 JBR-2617 Text with opacity renders black
Some more adjustments in font thickness for dark text. Added JVM properties for fine tuning
2020-08-21 23:52:21 +03:00
Elena Sayapina
f826eb992e IDEA-242347: [TESTUPDATE] Added a comment 2020-08-20 18:10:47 +07:00
Denis Konoplev
ba3f14c83a JBR-2669: set unicode for both keyCode and extendedKeyCode 2020-08-19 21:56:51 +03:00
Alexey Titov
82a3601748 thread.cpp:4574:43: error: ‘nullptr’ quick fix 2020-08-19 14:58:35 +03:00
Kirill Kirichenko
eeab5252e6 JBR-2667 Post review: rename win.darkTheme.on to win.lightTheme.on and reversed the logic 2020-08-19 11:32:58 +03:00
Alexey Ushakov
838bbedd1a Merge pull request #33 from JetBrains/alexey.titov/precise-compilation-time
JBR-2577 implemented precise CompilationMXBean#getTotalCompilationTime
2020-08-18 17:40:47 +03:00
Kirill Kirichenko
0e4ad056dd JBR-2667 Add new AWT desktop property for light/dark theme detection on Windows 10 2020-08-18 14:12:37 +03:00
Alexey Titov
89163e73d0 JBR-2577 implemented precise CompilationMXBean#getTotalCompilationTime 2020-08-13 15:37:22 +03:00
Dmitry Batrak
665ebc5d47 JBR-2652 Window is not focused in some cases on Linux 2020-08-11 13:44:58 +03:00
denis.konoplev
32b1c35305 IDEA-242347: Remove sun.awt.event.KeyEvent import 2020-08-10 12:25:10 +03:00
22 changed files with 601 additions and 80 deletions

14
.idea/vcs.xml generated
View File

@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="IssueNavigationConfiguration">
<option name="links">
<list>
<IssueNavigationLink>
<option name="issueRegexp" value="[A-Z]+\-\d+" />
<option name="linkRegexp" value="http://youtrack.jetbrains.com/issue/$0" />
</IssueNavigationLink>
<IssueNavigationLink>
<option name="issueRegexp" value="(\d+)\:" />
<option name="linkRegexp" value="https://bugs.openjdk.java.net/browse/JDK-$1" />
</IssueNavigationLink>
</list>
</option>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@@ -75,6 +75,7 @@ class WindowsConstants {
public static final int IO_REPARSE_TAG_SYMLINK = 0xA000000C;
public static final int MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024;
public static final int SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1;
public static final int SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2;
// volume flags
public static final int FILE_CASE_SENSITIVE_SEARCH = 0x00000001;
@@ -104,6 +105,7 @@ class WindowsConstants {
public static final int ERROR_MORE_DATA = 234;
public static final int ERROR_DIRECTORY = 267;
public static final int ERROR_NOTIFY_ENUM_DIR = 1022;
public static final int ERROR_PRIVILEGE_NOT_HELD = 1314;
public static final int ERROR_NONE_MAPPED = 1332;
public static final int ERROR_NOT_A_REPARSE_POINT = 4390;
public static final int ERROR_INVALID_REPARSE_DATA = 4392;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@@ -29,6 +29,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import jdk.internal.misc.Unsafe;
import static sun.nio.fs.WindowsConstants.*;
/**
* Win32 and library calls.
*/
@@ -920,6 +922,12 @@ class WindowsNativeDispatcher {
* LPCWSTR lpTargetFileName,
* DWORD dwFlags
* )
*
* Creates a symbolic link, conditionally retrying with the addition of
* the flag SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE if the initial
* attempt fails with ERROR_PRIVILEGE_NOT_HELD. If the retry fails, throw
* the original exception due to ERROR_PRIVILEGE_NOT_HELD. The retry will
* succeed only on Windows build 14972 or later if Developer Mode is on.
*/
static void CreateSymbolicLink(String link, String target, int flags)
throws WindowsException
@@ -929,6 +937,19 @@ class WindowsNativeDispatcher {
try {
CreateSymbolicLink0(linkBuffer.address(), targetBuffer.address(),
flags);
} catch (WindowsException x) {
if (x.lastError() == ERROR_PRIVILEGE_NOT_HELD) {
flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
try {
CreateSymbolicLink0(linkBuffer.address(),
targetBuffer.address(), flags);
return;
} catch (WindowsException ignored) {
// Will fail with ERROR_INVALID_PARAMETER for Windows
// builds older than 14972.
}
}
throw x;
} finally {
targetBuffer.release();
linkBuffer.release();

View File

@@ -1056,17 +1056,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env,
LPCWSTR link = jlong_to_ptr(linkAddress);
LPCWSTR target = jlong_to_ptr(targetAddress);
// Allow creation of symbolic links when the process is not elevated.
// Developer Mode must be enabled for this option to function, otherwise
// it will be ignored. Check that symbol is available in current build SDK.
DWORD dwFlags = (DWORD)flags;
#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
dwFlags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
#endif
// On Windows 64-bit this appears to succeed even when there are
// insufficient privileges
if (CreateSymbolicLinkW(link, target, dwFlags) == 0)
if (CreateSymbolicLinkW(link, target, (DWORD)flags) == 0)
throwWindowsException(env, GetLastError());
}

View File

@@ -297,18 +297,6 @@ public class CInputMethod extends InputMethodAdapter {
if (component.getInputMethodRequests() == null) {
imInstance = null;
}
LWWindowPeer windowPeer = peer.getPlatformWindow().getPeer();
if (windowPeer.isSimpleWindow()) {
// A simple window gains focus. Cocoa won't dispatch IME events into the simple window, but into its owner.
// This IM represents the focused component in the simple window. We will use the owner as IME proxy.
// For that, this IM is set for the owner and is dropped for the simple window.
Window owner = windowPeer.getTarget().getOwner();
assert owner != null && owner.isActive();
long ownerPtr = getNativeViewPtr((LWComponentPeer)AWTAccessor.getComponentAccessor().getPeer(owner));
nativeNotifyPeer(ownerPtr, this);
imInstance = null;
}
}
if (peer != null) {

View File

@@ -33,7 +33,6 @@
#import "java_awt_event_InputEvent.h"
#import "java_awt_event_KeyEvent.h"
#import "sun_awt_event_KeyEvent.h"
#import "LWCToolkit.h"
#import "jni_util.h"

View File

@@ -95,8 +95,6 @@ import sun.awt.AppContext;
import sun.awt.ComponentFactory;
import sun.security.action.GetBooleanAction;
import sun.security.action.GetPropertyAction;
import sun.awt.AppContext;
import sun.awt.AWTAccessor;
import sun.awt.ConstrainableGraphics;
import sun.awt.EmbeddedFrame;
import sun.awt.RequestFocusController;
@@ -112,7 +110,6 @@ import sun.java2d.SunGraphics2D;
import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.pipe.Region;
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
import sun.security.action.GetPropertyAction;
import sun.swing.SwingAccessor;
import sun.util.logging.PlatformLogger;
@@ -226,6 +223,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.Component");
private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.Component");
private static final PlatformLogger mixingLog = PlatformLogger.getLogger("java.awt.mixing.Component");
private static final PlatformLogger focusRequestLog = PlatformLogger.getLogger("jb.focus.requests");
/**
* The peer of the component. The peer implements the component's
@@ -7958,6 +7956,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
boolean focusedWindowChangeAllowed,
FocusEvent.Cause cause)
{
if (focusRequestLog.isLoggable(PlatformLogger.Level.FINE)) {
focusRequestLog.fine("requestFocus("
+ (temporary ? "temporary," : "")
+ (focusedWindowChangeAllowed ? "" : "inWindow,")
+ cause + ") for " + this, new Throwable());
}
// 1) Check if the event being dispatched is a system-generated mouse event.
AWTEvent currentEvent = EventQueue.getCurrentEvent();
if (currentEvent instanceof MouseEvent &&

View File

@@ -382,6 +382,7 @@ public class Window extends Container implements Accessible {
private static final long serialVersionUID = 4497834738069338734L;
private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Window");
private static final PlatformLogger focusRequestLog = PlatformLogger.getLogger("jb.focus.requests");
private static final boolean locationByPlatformProp;
@@ -1308,6 +1309,9 @@ public class Window extends Container implements Accessible {
// This functionality is implemented in a final package-private method
// to insure that it cannot be overridden by client subclasses.
final void toFront_NoClientCode() {
if (focusRequestLog.isLoggable(PlatformLogger.Level.FINE)) {
focusRequestLog.fine("toFront() for" + this, new Throwable());
}
if (visible) {
WindowPeer peer = (WindowPeer)this.peer;
if (peer != null) {
@@ -1351,6 +1355,9 @@ public class Window extends Container implements Accessible {
// This functionality is implemented in a final package-private method
// to insure that it cannot be overridden by client subclasses.
final void toBack_NoClientCode() {
if (focusRequestLog.isLoggable(PlatformLogger.Level.FINE)) {
focusRequestLog.fine("toBack() for " + this, new Throwable());
}
if(isAlwaysOnTop()) {
try {
setAlwaysOnTop(false);

View File

@@ -109,13 +109,6 @@ typedef struct {
} GrayRenderHints;
static GrayRenderHints grayRenderHints[] = {
// hints for "use font smoothing" option
// disabled
{1.0f/0.6f, 1.0f/3.0f, 1.0f, 1.2f},
// enabled
{1.0f/0.6f, 1.0f/3.0f, 1.0f/2.2f, 1.2f}
};
/**
* This value tracks the previous LCD contrast setting, so if the contrast
@@ -395,6 +388,99 @@ OGLTR_CreateLCDTextProgram()
return lcdTextProgram;
}
static int JVM_GetIntProperty(const char* name, int defaultValue) {
JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
static jclass systemCls = NULL;
if (systemCls == NULL) {
systemCls = (*env)->FindClass(env, "java/lang/System");
if (systemCls == NULL) {
return defaultValue;
}
}
static jmethodID mid = NULL;
if (mid == NULL) {
mid = (*env)->GetStaticMethodID(env, systemCls, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;");
if (mid == NULL) {
return defaultValue;
}
}
jstring jName = (*env)->NewStringUTF(env, name);
if (jName == NULL) {
return defaultValue;
}
int result = defaultValue;
jstring jvalue = (*env)->CallStaticObjectMethod(env, systemCls, mid, jName);
if (jvalue != NULL) {
const char *utf8string = (*env)->GetStringUTFChars(env, jvalue, NULL);
if (utf8string != NULL) {
const int parsedVal = atoi(utf8string);
if (parsedVal > 0) {
result = parsedVal;
}
}
(*env)->ReleaseStringUTFChars(env, jvalue, utf8string);
}
(*env)->DeleteLocalRef(env, jName);
return result;
}
static GrayRenderHints* getGrayRenderHints() {
static GrayRenderHints *hints = NULL;
static GrayRenderHints defaultRenderHints[] = {
// hints for "use font smoothing" option
// disabled
{1.666f, 0.333f, 1.0f, 1.25f},
// enabled
{1.666f, 0.333f, 0.454f, 1.4f}
};
if (hints == NULL) {
// read from VM-properties
int val = JVM_GetIntProperty("awt.font.nosm.light_gamma", 0);
if (val > 0) {
defaultRenderHints[0].light_gamma = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.nosm.dark_gamma", 0);
if (val > 0) {
defaultRenderHints[0].dark_gamma = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.nosm.light_exp", 0);
if (val > 0) {
defaultRenderHints[0].light_exp = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.nosm.dark_exp", 0);
if (val > 0) {
defaultRenderHints[0].dark_exp = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.sm.light_gamma", 0);
if (val > 0) {
defaultRenderHints[1].light_gamma = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.sm.dark_gamma", 0);
if (val > 0) {
defaultRenderHints[1].dark_gamma = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.sm.light_exp", 0);
if (val > 0) {
defaultRenderHints[1].light_exp = val / 1000.0;
}
val = JVM_GetIntProperty("awt.font.sm.dark_exp", 0);
if (val > 0) {
defaultRenderHints[1].dark_exp = val / 1000.0;
}
hints = defaultRenderHints;
}
return hints;
}
/**
* Compiles and links the LCD text shader program. If successful, this
* function returns a handle to the newly created shader program; otherwise
@@ -419,7 +505,7 @@ OGLTR_CreateGrayTextProgram(jboolean useFontSmoothing)
// "use" the program object temporarily so that we can set the uniforms
j2d_glUseProgramObjectARB(grayTextProgram);
GrayRenderHints *hints = &grayRenderHints[useFontSmoothing];
GrayRenderHints *hints = &(getGrayRenderHints()[useFontSmoothing]);
J2dTraceLn5(J2D_TRACE_INFO,
"OGLTR_CreateGrayTextProgram: useFontSmoothing=%d "
"light_gamma=%f dark_gamma=%f light_exp=%f dark_exp=%f",

View File

@@ -1726,7 +1726,7 @@ static jlong
if (ftglyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD && width > 0) {
glyphInfo->width = width/3;
glyphInfo->topLeftX -= 1;
glyphInfo->width += 1;
glyphInfo->width += 2;
} else if (ftglyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V) {
glyphInfo->height = glyphInfo->height/3;
}

View File

@@ -79,7 +79,6 @@ public class XBaseWindow {
private static XAtom wm_client_leader;
private long userTime;
private static long globalUserTime;
static enum InitialiseState {
@@ -669,7 +668,7 @@ public class XBaseWindow {
try {
this.visible = visible;
if (visible) {
setUserTimeFromGlobal();
setUserTimeBeforeShowing();
XlibWrapper.XMapWindow(XToolkit.getDisplay(), getWindow());
}
else {
@@ -1029,7 +1028,7 @@ public class XBaseWindow {
public void handleVisibilityEvent(XEvent xev) {
}
public void handleKeyPress(XEvent xev) {
setUserTime(xev.get_xkey().get_time());
setUserTime(xev.get_xkey().get_time(), true);
}
public void handleKeyRelease(XEvent xev) {
}
@@ -1060,7 +1059,7 @@ public class XBaseWindow {
if (!isWheel) {
switch (xev.get_type()) {
case XConstants.ButtonPress:
setUserTime(xbe.get_time());
setUserTime(xbe.get_time(), true);
if (buttonState == 0) {
XWindowPeer parent = getToplevelXWindow();
// See 6385277, 6981400.
@@ -1299,15 +1298,12 @@ public class XBaseWindow {
return x >= getAbsoluteX() && y >= getAbsoluteY() && x < (getAbsoluteX()+getWidth()) && y < (getAbsoluteY()+getHeight());
}
void setUserTimeFromGlobal() {
setUserTime(globalUserTime);
void setUserTimeBeforeShowing() {
if (globalUserTime != 0) setUserTime(globalUserTime, false);
}
private void setUserTime(long time) {
if (time == userTime) return;
userTime = time;
if ((int)time - (int)globalUserTime > 0 /* accounting for wrap-around */) {
protected void setUserTime(long time, boolean updateGlobalTime) {
if (updateGlobalTime && (int)time - (int)globalUserTime > 0 /* accounting for wrap-around */) {
globalUserTime = time;
}
XNETProtocol netProtocol = XWM.getWM().getNETProtocol();

View File

@@ -1071,20 +1071,31 @@ abstract class XDecoratedPeer extends XWindowPeer {
focusLog.fine("WM_TAKE_FOCUS on {0}", this);
}
long requestTimeStamp = cl.get_data(1);
if (requestTimeStamp == 0) {
// KDE window manager always sends 0 ('CurrentTime') as timestamp,
// even though it seems to violate ICCCM specification
// (https://bugs.kde.org/show_bug.cgi?id=347153)
requestTimeStamp = XToolkit.getCurrentServerTime();
}
// we should treat WM_TAKE_FOCUS message as user interaction, as it can originate e.g. from user clicking
// on window title bar (there will be no ButtonPress/ButtonRelease events in this case)
setUserTime(requestTimeStamp, true);
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
// JDK-8159460
Window focusedWindow = XKeyboardFocusManagerPeer.getInstance()
.getCurrentFocusedWindow();
Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
if (activeWindow != target) {
requestWindowFocus(cl.get_data(1), true);
requestWindowFocus(requestTimeStamp, true);
} else {
WindowEvent we = new WindowEvent(focusedWindow,
WindowEvent.WINDOW_GAINED_FOCUS);
sendEvent(we);
}
} else {
requestWindowFocus(cl.get_data(1), true);
requestWindowFocus(requestTimeStamp, true);
}
}

View File

@@ -110,7 +110,8 @@ final class XWM
MUTTER_WM = 15,
UNITY_COMPIZ_WM = 16,
XMONAD_WM = 17,
AWESOME_WM = 18;
AWESOME_WM = 18,
I3_WM = 19;
public String toString() {
switch (WMID) {
@@ -621,6 +622,10 @@ final class XWM
return isNetWMName("awesome");
}
static boolean isI3() {
return isNetWMName("i3");
}
static int awtWMNonReparenting = -1;
static boolean isNonReparentingWM() {
if (awtWMNonReparenting == -1) {
@@ -824,6 +829,8 @@ final class XWM
awt_wmgr = XWM.XMONAD_WM;
} else if (isAwesome()) {
awt_wmgr = XWM.AWESOME_WM;
} else if (isI3()) {
awt_wmgr = XWM.I3_WM;
}
/*
* We don't check for legacy WM when we already know that WM

View File

@@ -1216,6 +1216,12 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
return (uni > 0? sun.awt.ExtendedKeyCodes.getExtendedKeyCodeForChar(uni) : 0);
//return (uni > 0? uni + 0x01000000 : 0);
}
// java keycodes for unicode values consistent with MacOS and Windows
private static int addUnicodeOffset(int uni) {
return uni > 0 ? uni + 0x01000000 : 0;
}
void logIncomingKeyEvent(XKeyEvent ev) {
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
keyEventLog.fine("--XWindow.java:handleKeyEvent:"+ev);
@@ -1304,17 +1310,18 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
);
}
int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) :
jkc.getJavaKeycode();
int jkeyToReturn;
if (KeyEventProcessing.useNationalLayouts) {
// if jkeyToReturn is VK_UNDEFINED then look for keycode in extended key code
jkeyToReturn = jkc.getJavaKeycode();
jkeyToReturn = getNationalKeyCode(jkc, unicodeFromPrimaryKeysym);
jkeyExtended = jkeyToReturn;
} else {
jkeyToReturn = XKeysym.getLegacyJavaKeycodeOnly(ev); // someway backward compatible
}
int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) :
jkc.getJavaKeycode();
postKeyEvent( java.awt.event.KeyEvent.KEY_PRESSED,
ev.get_time(),
isDeadKey ? jkeyExtended : jkeyToReturn,
@@ -1395,16 +1402,18 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
// is undefined, we still will have a guess of what was engraved on a keytop.
int unicodeFromPrimaryKeysym = keysymToUnicode( xkeycodeToPrimaryKeysym(ev) ,0);
int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) :
jkc.getJavaKeycode();
int jkeyToReturn;
if (KeyEventProcessing.useNationalLayouts) {
// if jkeyToReturn is VK_UNDEFINED then look for keycode in extended key code
jkeyToReturn = jkc.getJavaKeycode();
jkeyToReturn = getNationalKeyCode(jkc, unicodeFromPrimaryKeysym);
jkeyExtended = jkeyToReturn;
} else {
jkeyToReturn = XKeysym.getLegacyJavaKeycodeOnly(ev); // someway backward compatible
}
int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) :
jkc.getJavaKeycode();
postKeyEvent( java.awt.event.KeyEvent.KEY_RELEASED,
ev.get_time(),
isDeadKey ? jkeyExtended : jkeyToReturn,
@@ -1417,6 +1426,14 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
}
private static int getNationalKeyCode(XKeysym.Keysym2JavaKeycode jkc, int unicodeFromPrimaryKeysym) {
// use this key code for both keyCode and extendedKeyCode
// compatible with MacOS and Windows
return jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
addUnicodeOffset(unicodeFromPrimaryKeysym) :
jkc.getJavaKeycode();
}
private boolean isDeadKey(long keysym){
return XKeySymConstants.XK_dead_grave <= keysym && keysym <= XKeySymConstants.XK_dead_semivoiced_sound;

View File

@@ -28,7 +28,6 @@ package sun.awt.X11;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.InvocationEvent;
import java.awt.event.WindowEvent;
import java.awt.peer.ComponentPeer;
import java.awt.peer.WindowPeer;
@@ -36,13 +35,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;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.ComponentAccessor;
@@ -150,10 +143,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1;
static {
/* https://userbase.kde.org/KDE_System_Administration/Environment_Variables#KDE_FULL_SESSION */
final String kdeSession = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getenv("KDE_FULL_SESSION"));
final boolean isKDE = kdeSession != null && !kdeSession.isEmpty();
final boolean isKDE = XWM.getWMID() == XWM.KDE2_WM;
X11_DISABLE_OVERRIDE_FLAG =
GetPropertyAction.privilegedGetProperty("x11.disable.override.flag", isKDE ? "true" : "false").equalsIgnoreCase("true");
X11_DISABLE_OVERRIDE_XWINDOWPEER =
@@ -1112,7 +1102,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
if (!isVisible() && vis) {
isBeforeFirstMapNotify = true;
winAttr.initialFocus = isAutoRequestFocus();
if (!winAttr.initialFocus) {
if (!winAttr.initialFocus && XWM.getWMID() != XWM.I3_WM) {
/*
* It's easier and safer to temporary suppress WM_TAKE_FOCUS
* protocol itself than to ignore WM_TAKE_FOCUS client message.
@@ -1120,6 +1110,13 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
* the message come after showing and the message come after
* activation. Also, on Metacity, for some reason, we have _two_
* WM_TAKE_FOCUS client messages when showing a frame/dialog.
*
* i3 window manager doesn't track updates to WM_TAKE_FOCUS
* property, so this approach won't work for it, breaking
* focus behaviour completely. So another way is used to
* suppress focus take over - via setting _NET_WM_USER_TIME
* to 0, as specified in EWMH spec (see
* 'setUserTimeBeforeShowing' method).
*/
suppressWmTakeFocus(true);
}
@@ -1184,6 +1181,16 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
protected void suppressWmTakeFocus(boolean doSuppress) {
}
@Override
void setUserTimeBeforeShowing() {
if (winAttr.initialFocus || XWM.getWMID() != XWM.I3_WM) {
super.setUserTimeBeforeShowing();
}
else {
setUserTime(0, false);
}
}
final boolean isSimpleWindow() {
return !(target instanceof Frame || target instanceof Dialog);
}
@@ -1425,7 +1432,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
isUnhiding |= isWMStateNetHidden();
super.handleMapNotifyEvent(xev);
if (!winAttr.initialFocus) {
if (!winAttr.initialFocus && XWM.getWMID() != XWM.I3_WM) {
suppressWmTakeFocus(false); // restore the protocol.
/*
* For some reason, on Metacity, a frame/dialog being shown
@@ -2053,7 +2060,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
this.visible = visible;
if (visible) {
applyWindowType();
setUserTimeFromGlobal();
setUserTimeBeforeShowing();
XlibWrapper.XMapRaised(XToolkit.getDisplay(), getWindow());
} else {
XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), getWindow());

View File

@@ -700,6 +700,20 @@ void AwtDesktopProperties::GetOtherParameters() {
}
free(value);
}
// Add property for light/dark theme detection
value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"),
TEXT("AppsUseLightTheme"), &valueType);
if (value != NULL) {
if (valueType == REG_DWORD) {
SetBooleanProperty(TEXT("win.lightTheme.on"), (BOOL)((int)*value == 1));
}
free(value);
}
else {
SetBooleanProperty(TEXT("win.lightTheme.on"), TRUE);
}
}
catch (std::bad_alloc&) {
if (value != NULL) {

View File

@@ -0,0 +1,94 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
import java.util.concurrent.TimeUnit;
import java.util.concurrent.CountDownLatch;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import javax.swing.JPanel;
public abstract class AccessibleComponentTest {
protected static volatile boolean testResult = true;
protected static volatile CountDownLatch countDownLatch;
protected static String INSTRUCTIONS;
protected static String exceptionString;
protected JFrame mainFrame;
protected static AccessibleComponentTest a11yTest;
public abstract CountDownLatch createCountDownLatch();
public void createUI(JPanel component, String testName) {
mainFrame = new JFrame(testName);
GridBagLayout layout = new GridBagLayout();
JPanel mainControlPanel = new JPanel(layout);
JPanel resultButtonPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
JTextArea instructionTextArea = new JTextArea();
instructionTextArea.setText(INSTRUCTIONS);
instructionTextArea.setEditable(false);
instructionTextArea.setBackground(Color.white);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(instructionTextArea, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
mainControlPanel.add(component);
JButton passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
JButton failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
testResult = false;
mainFrame.dispose();
countDownLatch.countDown();
}
});
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
mainControlPanel.add(resultButtonPanel, gbc);
mainFrame.add(mainControlPanel);
mainFrame.pack();
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
mainFrame.setVisible(true);
}
}

View File

@@ -0,0 +1,142 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* @test
* @summary manual test for JBR-2504
* @author Artem.Semenov@jetbrains.com
* @run main/manual AccessibleJListTest
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class AccessibleJListTest extends AccessibleComponentTest {
private static final String[] NAMES = {"One", "Two", "Three", "Four", "Five"};
static JWindow window;
public static void main(String[] args) throws Exception {
a11yTest = new AccessibleJListTest();
countDownLatch = a11yTest.createCountDownLatch();
SwingUtilities.invokeLater(((AccessibleJListTest) a11yTest)::createSimpleList);
countDownLatch.await();
if (!testResult) {
throw new RuntimeException(a11yTest.exceptionString);
}
countDownLatch = a11yTest.createCountDownLatch();
SwingUtilities.invokeLater(((AccessibleJListTest) a11yTest)::createCombobox);
countDownLatch.await();
if (!testResult) {
throw new RuntimeException(a11yTest.exceptionString);
}
countDownLatch = a11yTest.createCountDownLatch();
SwingUtilities.invokeLater(((AccessibleJListTest) a11yTest)::createPushButton);
countDownLatch.await();
if (!testResult) {
throw new RuntimeException(a11yTest.exceptionString);
}
}
@java.lang.Override
public CountDownLatch createCountDownLatch() {
return new CountDownLatch(1);
}
public void createSimpleList() {
INSTRUCTIONS = "INSTRUCTIONS:\n"
+ "Check a11y of JList in a simple Window.\n\n"
+ "Turn screen reader on, and Tab to the list.\n"
+ "Press the up and down arrow buttons to move through the list.\n\n"
+ "If you can hear menu items tab further and press PASS, otherwise press FAIL.\n";
JPanel frame = new JPanel();
JList<String> list = new JList<>(NAMES);
frame.setLayout(new FlowLayout());
frame.add(list);
exceptionString = "Accessible JList simple list test failed!";
super.createUI(frame, "Accessible JList test");
}
public void createCombobox() {
INSTRUCTIONS = "INSTRUCTIONS:\n"
+ "Check a11y of JList in a combobox.\n\n"
+ "Turn screen reader on, and Tab to the combobox.\n"
+ "Press the up and down arrow buttons to move through the list.\n\n"
+ "If you can hear combobox items tab further and press PASS, otherwise press FAIL.\n";
JPanel frame = new JPanel();
JComboBox<String> combo = new JComboBox<>(NAMES);
frame.setLayout(new FlowLayout());
frame.add(combo);
exceptionString = "Accessible JList combobox test failed!";
super.createUI(frame, "Accessible JList test");
}
public void createPushButton() {
INSTRUCTIONS = "INSTRUCTIONS:\n"
+ "Check a11y of JList in a popup.\n\n"
+ "Turn screen reader on, and Tab to the show button and press space.\n"
+ "Press the up and down arrow buttons to move through the list.\n\n"
+ "If you can hear popup menu items tab further and press PASS, otherwise press FAIL.\n";
JPanel frame = new JPanel();
JButton button = new JButton("show");
button.setPreferredSize(new Dimension(100, 35));
button.addActionListener(new ActionListener() {
final Runnable dispose = () -> {
window.dispose();
window = null;
button.setText("show");
};
@Override
public void actionPerformed(ActionEvent e) {
if (window == null) {
Rectangle bounds = frame.getBounds();
window = new JWindow(mainFrame);
JList<String> winList = new JList<>(NAMES);
winList.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
dispose.run();
}
}
});
window.add(winList);
window.setLocation(bounds.x + bounds.width + 20, bounds.y);
window.pack();
window.setVisible(true);
button.setText("hide (ESC)");
} else {
dispose.run();
}
}
});
frame.setLayout(new FlowLayout());
frame.add(button);
exceptionString = "Accessible JList push button test failed!";
super.createUI(frame, "Accessible JList test");
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2000-2020 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.*;
import java.awt.*;
import java.awt.event.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
/**
* @test
* @summary Regression test for JBR-2652 Window is not focused in some cases on Linux
* @key headful
*/
public class TitleBarClickTest {
private static final CompletableFuture<Boolean> f2Opened = new CompletableFuture<>();
private static final CompletableFuture<Boolean> t2Clicked = new CompletableFuture<>();
private static CompletableFuture<Boolean> t1Focused;
private static CompletableFuture<Boolean> t2Focused;
private static JFrame f1;
private static JFrame f2;
private static JTextField t1;
private static JTextField t2;
private static Robot robot;
public static void main(String[] args) throws Exception {
robot = new Robot();
try {
SwingUtilities.invokeAndWait(TitleBarClickTest::initUI);
f2Opened.get(10, TimeUnit.SECONDS);
clickAt(t2);
t2Clicked.get(10, TimeUnit.SECONDS);
SwingUtilities.invokeAndWait(() -> t1Focused = new CompletableFuture<>());
clickAtTitle(f1);
t1Focused.get(10, TimeUnit.SECONDS);
SwingUtilities.invokeAndWait(() -> t2Focused = new CompletableFuture<>());
f2.toFront();
t2Focused.get(10, TimeUnit.SECONDS);
} finally {
SwingUtilities.invokeAndWait(TitleBarClickTest::disposeUI);
}
}
private static void initUI() {
f1 = new JFrame("first");
f1.add(t1 = new JTextField());
t1.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if (t1Focused != null) t1Focused.complete(Boolean.TRUE);
}
});
f1.setBounds(100, 100, 300, 100);
f1.setVisible(true);
f2 = new JFrame("second");
f2.add(t2 = new JTextField());
t2.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if (t2Focused != null) t2Focused.complete(Boolean.TRUE);
}
});
t2.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
t2Clicked.complete(Boolean.TRUE);
}
});
f2.addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
f2Opened.complete(Boolean.TRUE);
}
});
f2.setBounds(450, 100, 300, 100);
f2.setVisible(true);
}
private static void disposeUI() {
if (f1 != null) f1.dispose();
if (f2 != null) f2.dispose();
}
private static void clickAt(int x, int y) {
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
private static void clickAt(Component component) {
Point location = component.getLocationOnScreen();
clickAt(location.x + component.getWidth() / 2, location.y + component.getHeight() / 2);
}
private static void clickAtTitle(Window window) {
int topInset = window.getInsets().top;
if (topInset <= 0) throw new RuntimeException("Window doesn't have title bar");
Point location = window.getLocationOnScreen();
clickAt(location.x + window.getWidth() / 2, location.y + topInset / 2);
}
}

View File

@@ -57,6 +57,7 @@ public class Key {
// KeyEvent.getExtendedKeyCodeForChar(ch) does not return corresponding VK_ constant for dead keys
return deadKeyCodesMap.get(ch);
} else if (isLatinUnicode(ch)) {
// Please see JBR-2672
final int UNICODE_OFFSET = 0x01000000;
return UNICODE_OFFSET + (int) ch;
} else {

View File

@@ -213,6 +213,7 @@ java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameRes
java/awt/Frame/WindowDragTest/WindowDragTest.java 8169470 generic-all
java/awt/FullScreen/8013581/bug8013581.java 8169471 macosx-all,windows-all,linux-all
java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java 8047218 generic-all
java/awt/FullScreen/BufferStrategyExceptionTest/BufferStrategyExceptionTest.java 8246558 windows-all
java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java 8169469,JBR-1897 windows-all,macosx-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,macosx-all
@@ -576,7 +577,7 @@ java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java
java/awt/Toolkit/DesktopProperties/rfe4758438.java 8193547 linux-all
java/awt/Toolkit/LockingKeyStateTest/LockingKeyStateTest.java 8208514 windows-all
java/awt/Toolkit/RealSync/Test.java 6849383 generic-all
java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java 6829250 windows-all,linux-all,macosx-all
java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java 6829250,8253398 windows-all,linux-all,macosx-all
java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java 6847163 generic-all
java/awt/TrayIcon/ActionCommand/ActionCommand.java 8197575,8150540 macosx-all,windows-all
java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 8197575,8150540 macosx-all,windows-all
@@ -595,6 +596,7 @@ java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java
java/awt/Window/8159168/SetShapeTest.java 8208507 generic-all
java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java 8142536 generic-all
java/awt/Window/Grab/GrabTest.java 8196019 macosx-all,windows-all,linux-all
java/awt/Window/GetScreenLocation/GetScreenLocationTest.java 8225787 linux-all
java/awt/Window/MultiWindowApp/ChildAlwaysOnTopTest.java 8215132,8194941 macosx-all,windows-all,linux-all
java/awt/Window/MultiWindowApp/MultiWindowAppTest.java 8159904 macosx-all,windows-all,linux-all
java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java 8225116 windows-all
@@ -635,6 +637,7 @@ java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.html
java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.html 8171510,7124379 macosx-all,linux-all
java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.html 8194947 generic-all
java/awt/event/ComponentEvent/MovedResizedTardyEventTest/MovedResizedTardyEventTest.html 6511207 generic-all
java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java 8225787 linux-all
java/awt/event/HierarchyEvent/AncestorResized/AncestorResized.java 6618538 generic-all
java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all
java/awt/event/KeyEvent/CorrectTime/CorrectTime.java 6626492 generic-all
@@ -1262,5 +1265,6 @@ javax/swing/LookAndFeel/8146276/NimbusGlueTest.java
sanity/client/SwingSet/src/GridBagLayoutDemoTest.java JBR-1977 linux-aarch64
jb/java/jcef/JCEFStartupTest.java JBR-1996 linux-i386,windows-x86
jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java nobug windows-6.1 not supported on Windows 7
jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh JBR-2585 linux-all
jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java JBR-2585 linux-all,windows-all nobug windows-6.1 not supported on Windows 7
jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh JBR-2585 linux-all
jb/java/awt/Focus/ChainOfPopupsFocusTest.java JBR-2657 windows-all,linux-all

View File

@@ -41,7 +41,6 @@ java/awt/Frame/MiscUndecorated/FrameCloseTest.java
java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java nobug linux-all,windows-all
java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java nobug macosx-all,linux-all
java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java nobug linux-all,windows-all,macosx-all
java/awt/FullScreen/BufferStrategyExceptionTest/BufferStrategyExceptionTest.java nobug macosx-all,linux-all,windows-all
java/awt/FullScreen/SetFSWindow/FSFrame.java nobug windows-all
java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java nobug windows-all
java/awt/Graphics/LineClipTest.java nobug macosx-all,windows-all