JBR-2696 Log focus API invocations with stack traces

(cherry picked from commits 0f038754e5, a507cab6d3)
This commit is contained in:
Dmitry Batrak
2020-09-07 14:19:43 +03:00
committed by alexey.ushakov@jetbrains.com
parent d70ca91111
commit 3fb5212b10
3 changed files with 20 additions and 3 deletions

View File

@@ -54,6 +54,7 @@ import javax.swing.JMenuBar;
import sun.awt.AWTAccessor;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CPlatformWindow;
import sun.util.logging.PlatformLogger;
/**
* The {@code Application} class allows you to integrate your Java application with the native Mac OS X environment.
@@ -74,6 +75,8 @@ import sun.lwawt.macosx.CPlatformWindow;
* @since 1.4
*/
public class Application {
private static final PlatformLogger focusRequestLog = PlatformLogger.getLogger("jb.focus.requests");
private static native void nativeInitializeApplicationDelegate();
static Application sApplication = null;
@@ -296,6 +299,9 @@ public class Application {
* @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
*/
public void requestForeground(final boolean allWindows) {
if (focusRequestLog.isLoggable(PlatformLogger.Level.FINE)) {
focusRequestLog.fine("requestForeground(" + (allWindows ? "allWindows" : "") + ")", new Throwable());
}
_AppMiscHandlers.requestActivation(allWindows);
}

View File

@@ -96,8 +96,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;
@@ -113,7 +111,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;
@@ -227,6 +224,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
@@ -7935,6 +7933,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

@@ -395,6 +395,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;
@@ -1310,6 +1311,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) {
@@ -1353,6 +1357,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);