diagnostics for IDEA-143603 (unable to paste text copied from other applications)

This commit is contained in:
Dmitry Batrak
2015-08-31 13:12:05 +03:00
parent 2930311adc
commit a9209297df
2 changed files with 41 additions and 1 deletions
@@ -521,6 +521,8 @@ public class IdeEventQueue extends EventQueue {
}
myEventCount++;
traceClipboardEvents(e);
if (e instanceof WindowEvent) {
processAppActivationEvents((WindowEvent)e);
@@ -648,6 +650,40 @@ public class IdeEventQueue extends EventQueue {
}
}
private static final Field ourInvocationEventRunnableAccessor;
static {
Field field = null;
if (Registry.is("trace.clipboard.events") && SystemInfo.isJavaVersionAtLeast("1.8.0_60")) {
try {
field = InvocationEvent.class.getDeclaredField("runnable");
field.setAccessible(true);
}
catch (Exception e) {
LOG.warn("Error creating accessor for java.awt.event.InvocationEvent.runnable field", e);
}
}
ourInvocationEventRunnableAccessor = field;
}
private static void traceClipboardEvents(AWTEvent e) {
if (ourInvocationEventRunnableAccessor != null && e instanceof InvocationEvent && e.getClass().getName().equals("sun.awt.PeerEvent")) {
try {
Object r = ourInvocationEventRunnableAccessor.get(e);
if (r != null) {
String className = r.getClass().getName();
// This check for event constructed in SunClipboard.lostOwnershipLater() (known to work with JDK 8u60)
if (className.contains("sun.awt.datatransfer.SunClipboard") && className.contains("Lambda")) {
LOG.info("Clipboard has been set by other application");
}
}
}
catch (Exception ex) {
LOG.warn("Error accessing java.awt.event.InvocationEvent.runnable field");
}
}
}
private MouseEvent lastClickEvent = null;
private long lastClickTime = 0L;
@@ -653,4 +653,8 @@ ruby.remote.debugger.supports.catchpoint.removal=true
use.read.action.to.init.service=true
ide.mac.new.color.picker=false
ide.mac.new.color.picker=false
trace.clipboard.events=false
trace.clipboard.events.description=Enable detection and logging of OS notifications about external clipboard changes
trace.clipboard.events.restartRequired=true