use latest version of JNativeHook. remove jar file, just use maven dep
This commit is contained in:
parent
5aebf5eefd
commit
8f8e407e68
|
@ -9,5 +9,6 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'lib', include: ['*.jar'])
|
compile fileTree(dir: 'lib', include: ['*.jar'])
|
||||||
|
compile 'com.1stleg:jnativehook:2.0.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -23,6 +23,8 @@ import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main frame executing Llanfair.
|
* Main frame executing Llanfair.
|
||||||
|
@ -93,6 +95,11 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
* @param args array of command line parameters supplied at launch
|
* @param args array of command line parameters supplied at launch
|
||||||
*/
|
*/
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
|
// latest version of JNativeHook is a bit noisy logging-wise by default
|
||||||
|
Logger jnativehookLogger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
|
||||||
|
jnativehookLogger.setLevel(Level.WARNING);
|
||||||
|
jnativehookLogger.setUseParentHandlers(false);
|
||||||
|
|
||||||
if ( args.length > 0 ) {
|
if ( args.length > 0 ) {
|
||||||
String locale = args[0];
|
String locale = args[0];
|
||||||
LocaleDelegate.setDefault( new Locale( locale ) );
|
LocaleDelegate.setDefault( new Locale( locale ) );
|
||||||
|
@ -388,7 +395,11 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
*/
|
*/
|
||||||
@Override public void windowClosed( WindowEvent event ) {
|
@Override public void windowClosed( WindowEvent event ) {
|
||||||
Settings.save();
|
Settings.save();
|
||||||
GlobalScreen.unregisterNativeHook();
|
try {
|
||||||
|
GlobalScreen.unregisterNativeHook();
|
||||||
|
} catch (NativeHookException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void windowClosing(WindowEvent event) {}
|
@Override public void windowClosing(WindowEvent event) {}
|
||||||
|
@ -436,13 +447,17 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
try {
|
try {
|
||||||
GlobalScreen.registerNativeHook();
|
GlobalScreen.registerNativeHook();
|
||||||
} catch (NativeHookException e) {
|
} catch (NativeHookException e) {
|
||||||
throw new IllegalStateException("cannot register native hook");
|
// NOTE: commenting this out as the latest version of JNativeHook has at least some ability to
|
||||||
|
// pop up an OS-specific dialog asking about accessibility permissions (at least on OS X)
|
||||||
|
// and afterwards the application recovered fine from the user's perspective. throwing an
|
||||||
|
// exception here causes Llanfair to just close immediately after the dialog has opened.
|
||||||
|
//throw new IllegalStateException("cannot register native hook");
|
||||||
}
|
}
|
||||||
setAlwaysOnTop(Settings.GNR_ATOP.get());
|
setAlwaysOnTop(Settings.GNR_ATOP.get());
|
||||||
addWindowListener(this);
|
addWindowListener(this);
|
||||||
addMouseWheelListener(this);
|
addMouseWheelListener(this);
|
||||||
Settings.addPropertyChangeListener(this);
|
Settings.addPropertyChangeListener(this);
|
||||||
GlobalScreen.getInstance().addNativeKeyListener(this);
|
GlobalScreen.addNativeKeyListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -156,7 +156,7 @@ class TabHotkeys extends SettingsTab {
|
||||||
public void mouseClicked(MouseEvent event) {
|
public void mouseClicked(MouseEvent event) {
|
||||||
if (!isEditing) {
|
if (!isEditing) {
|
||||||
setBackground(Color.YELLOW);
|
setBackground(Color.YELLOW);
|
||||||
GlobalScreen.getInstance().addNativeKeyListener(this);
|
GlobalScreen.addNativeKeyListener(this);
|
||||||
isEditing = true;
|
isEditing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ class TabHotkeys extends SettingsTab {
|
||||||
int code = event.getKeyCode();
|
int code = event.getKeyCode();
|
||||||
String text = null;
|
String text = null;
|
||||||
|
|
||||||
if (code == NativeKeyEvent.VK_ESCAPE) {
|
if (code == NativeKeyEvent.VC_ESCAPE) {
|
||||||
code = -1;
|
code = -1;
|
||||||
text = "" + Language.DISABLED;
|
text = "" + Language.DISABLED;
|
||||||
} else {
|
} else {
|
||||||
|
@ -193,7 +193,7 @@ class TabHotkeys extends SettingsTab {
|
||||||
setting.set(code);
|
setting.set(code);
|
||||||
|
|
||||||
setBackground(Color.GREEN);
|
setBackground(Color.GREEN);
|
||||||
GlobalScreen.getInstance().removeNativeKeyListener(this);
|
GlobalScreen.removeNativeKeyListener(this);
|
||||||
isEditing = false;
|
isEditing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue