mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-22 01:07:11 +02:00
1.65
-Clipboard spy fix.
This commit is contained in:
parent
7b6c948b7b
commit
dab1948c5e
@ -8,10 +8,11 @@ import static java.lang.Thread.sleep;
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
|
|
||||||
public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotifiable, ClipboardChangeObservable {
|
public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotifiable, ClipboardChangeObservable {
|
||||||
|
|
||||||
private static final int SLEEP = 50;
|
private static final int SLEEP = 250;
|
||||||
|
|
||||||
private final Clipboard _sysClip;
|
private final Clipboard _sysClip;
|
||||||
|
|
||||||
@ -23,10 +24,13 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
|
|
||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
|
|
||||||
|
private volatile boolean _gaining_ownership;
|
||||||
|
|
||||||
public ClipboardSpy() {
|
public ClipboardSpy() {
|
||||||
_sysClip = getDefaultToolkit().getSystemClipboard();
|
_sysClip = getDefaultToolkit().getSystemClipboard();
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_contents = null;
|
_contents = null;
|
||||||
|
_gaining_ownership = false;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_observers = new ConcurrentLinkedQueue<>();
|
_observers = new ConcurrentLinkedQueue<>();
|
||||||
}
|
}
|
||||||
@ -36,6 +40,10 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
return _contents;
|
return _contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Clipboard getSysClip() {
|
||||||
|
return _sysClip;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify() {
|
public void secureNotify() {
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
@ -89,15 +97,33 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
@Override
|
@Override
|
||||||
public void lostOwnership(Clipboard c, Transferable t) {
|
public void lostOwnership(Clipboard c, Transferable t) {
|
||||||
|
|
||||||
_contents = getClipboardContents();
|
if(!_gaining_ownership)
|
||||||
|
{
|
||||||
|
_gaining_ownership = true;
|
||||||
|
|
||||||
notifyChangeToMyObservers();
|
THREAD_POOL.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
gainOwnership(_contents);
|
_contents = getClipboardContents();
|
||||||
|
|
||||||
|
notifyChangeToMyObservers();
|
||||||
|
|
||||||
|
gainOwnership(_contents);
|
||||||
|
|
||||||
|
_gaining_ownership = false;
|
||||||
|
}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Transferable getClipboardContents() {
|
private Transferable getClipboardContents() {
|
||||||
|
|
||||||
|
try{
|
||||||
|
sleep(SLEEP);
|
||||||
|
} catch (InterruptedException ex1) {
|
||||||
|
getLogger(ClipboardSpy.class.getName()).log(SEVERE, null, ex1);
|
||||||
|
}
|
||||||
|
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
Transferable c = null;
|
Transferable c = null;
|
||||||
@ -127,6 +153,12 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
|
|
||||||
private void gainOwnership(Transferable t) {
|
private void gainOwnership(Transferable t) {
|
||||||
|
|
||||||
|
try{
|
||||||
|
sleep(SLEEP);
|
||||||
|
} catch (InterruptedException ex1) {
|
||||||
|
getLogger(ClipboardSpy.class.getName()).log(SEVERE, null, ex1);
|
||||||
|
}
|
||||||
|
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -61,7 +61,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "1.64";
|
public static final String VERSION = "1.65";
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
public static final int WATCHDOG_PORT = 1338;
|
public static final int WATCHDOG_PORT = 1338;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user