[mac] use another key for async clipboard fetching

This commit is contained in:
Alexey Pegov
2011-12-12 14:18:26 +04:00
parent 65e4cec0a4
commit 80d2c2f516
2 changed files with 12 additions and 6 deletions
@@ -184,6 +184,7 @@ public class ClipboardSynchronizer implements ApplicationComponent {
private static class MacClipboardHandler extends ClipboardHandler {
private static final String CLIPBOARD_CONTENTS = "CLIPBOARD_CONTENTS";
private static final String MAC_CLIPBOARD_SYNC_ACTIVE = "Mac.Clipboard.Sync.Active";
private Pair<String,Transferable> myFullTransferable;
private static Callback myClipboardQueryCallback = new Callback() {
@@ -195,7 +196,7 @@ public class ClipboardSynchronizer implements ApplicationComponent {
pane.putClientProperty(CLIPBOARD_CONTENTS, transferable);
}
pane.putClientProperty(MacUtil.MAC_NATIVE_WINDOW_SHOWING, null);
pane.putClientProperty(MAC_CLIPBOARD_SYNC_ACTIVE, null);
}
}
};
@@ -298,8 +299,8 @@ public class ClipboardSynchronizer implements ApplicationComponent {
.invoke(synchronizer, "performSelectorOnMainThread:withObject:waitUntilDone:", Foundation.createSelector("run:"), null,
false);
pane.putClientProperty(MacUtil.MAC_NATIVE_WINDOW_SHOWING, Boolean.TRUE);
MacUtil.startModal(pane);
pane.putClientProperty(MAC_CLIPBOARD_SYNC_ACTIVE, Boolean.TRUE);
MacUtil.startModal(pane, MAC_CLIPBOARD_SYNC_ACTIVE);
Foundation.cfRelease(synchronizer);
@@ -18,6 +18,7 @@ package com.intellij.ui.mac.foundation;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import static com.intellij.ui.mac.foundation.Foundation.invoke;
@@ -67,12 +68,12 @@ public class MacUtil {
return focusedWindow;
}
public static synchronized void startModal(JComponent component) {
public static synchronized void startModal(JComponent component, String key) {
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = component.getToolkit().getSystemEventQueue();
while (component.getClientProperty(MAC_NATIVE_WINDOW_SHOWING) == Boolean.TRUE) {
while (component.getClientProperty(key) == Boolean.TRUE) {
AWTEvent event = theQueue.getNextEvent();
Object source = event.getSource();
if (event instanceof ActiveEvent) {
@@ -91,7 +92,7 @@ public class MacUtil {
}
else {
assert false: "Should be called from Event-Dispatch Thread only!";
while (component.getClientProperty(MAC_NATIVE_WINDOW_SHOWING) == Boolean.TRUE) {
while (component.getClientProperty(key) == Boolean.TRUE) {
// TODO:
//wait();
}
@@ -101,5 +102,9 @@ public class MacUtil {
}
}
public static synchronized void startModal(JComponent component) {
startModal(component, MAC_NATIVE_WINDOW_SHOWING);
}
}