Fixed issues with GTK event loop start/stop.
This commit is contained in:
parent
4f0f8bae64
commit
893e6ac82e
|
@ -54,7 +54,8 @@ public interface Gtk extends Library {
|
||||||
*/
|
*/
|
||||||
public void gtk_main();
|
public void gtk_main();
|
||||||
/**
|
/**
|
||||||
* Makes the innermost invocation of the main loop return when it regains control.
|
* Makes the innermost invocation of the main loop return when it regains control. ONLY CALL FROM THE GtkSupport class, UNLESS
|
||||||
|
* you know what you're doing!
|
||||||
*/
|
*/
|
||||||
public void gtk_main_quit();
|
public void gtk_main_quit();
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
public class GtkSupport {
|
public class GtkSupport {
|
||||||
public static final boolean isSupported;
|
public static final boolean isSupported;
|
||||||
|
private static boolean hasSwt = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (Gtk.INSTANCE != null && AppIndicator.INSTANCE != null && Gobject.INSTANCE != null && GThread.INSTANCE != null) {
|
if (Gtk.INSTANCE != null && AppIndicator.INSTANCE != null && Gobject.INSTANCE != null && GThread.INSTANCE != null) {
|
||||||
isSupported = true;
|
isSupported = true;
|
||||||
|
|
||||||
boolean hasSwt = false;
|
|
||||||
try {
|
try {
|
||||||
Class<?> swtClass = Class.forName("org.eclipse.swt.widgets.Display");
|
Class<?> swtClass = Class.forName("org.eclipse.swt.widgets.Display");
|
||||||
if (swtClass != null) {
|
if (swtClass != null) {
|
||||||
|
@ -18,7 +18,8 @@ public class GtkSupport {
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
|
|
||||||
// swt already init's gtk. If we are using GTK, we need to make sure the event loop is runnign
|
// If we are using GTK, we need to make sure the event loop is running. There can be multiple/nested loops.
|
||||||
|
// since SWT uses one already, it's not necessary to have two.
|
||||||
if (!hasSwt) {
|
if (!hasSwt) {
|
||||||
Gtk instance = Gtk.INSTANCE;
|
Gtk instance = Gtk.INSTANCE;
|
||||||
instance.gtk_init(0, null);
|
instance.gtk_init(0, null);
|
||||||
|
@ -58,4 +59,10 @@ public class GtkSupport {
|
||||||
public static void init() {
|
public static void init() {
|
||||||
// placeholder to init GTK
|
// placeholder to init GTK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void shutdownGTK() {
|
||||||
|
if (!hasSwt) {
|
||||||
|
Gtk.INSTANCE.gtk_main_quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user