linux-menubar: run glib-loop when javafx can't be started

This commit is contained in:
Artem Bochkarev
2018-10-24 18:26:29 +07:00
parent 104db14a74
commit cef5f29227
4 changed files with 21 additions and 3 deletions
Binary file not shown.
+6
View File
@@ -93,6 +93,12 @@ void stopWatchDbus() {
// _info("glib main loop is stopped");
}
// used when javaFX can't be started
void runMainLoop(jlogger jlogger, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished) {
startWatchDbus(jlogger, onAppmenuServiceAppeared, onAppmenuServiceVanished);
g_main_loop_run(g_main_loop_new(NULL/*will be used g_main_context_default()*/, FALSE));
}
static void _onDbusOwnerChange(GObject *gobject, GParamSpec *pspec, gpointer user_data) {
GDBusProxy *proxy = G_DBUS_PROXY(gobject);
+3
View File
@@ -39,6 +39,9 @@ extern "C"{
// must be called from java thread (to avoid detach, so jna-callbacks will be invoked from same thread)
void startWatchDbus(jlogger jlogger, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished);
void stopWatchDbus();
void runMainLoop(jlogger jlogger, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished);
void execOnMainLoop(jrunnable run);
WndInfo* registerWindow(long windowXid, jeventcallback handler); // creates menu-server and binds to xid
@@ -40,6 +40,9 @@ import com.sun.javafx.application.PlatformImpl;
interface GlobalMenuLib extends Library {
void startWatchDbus(JLogger jlogger, JRunnable onAppmenuServiceAppeared, JRunnable onAppmenuServiceVanished);
void stopWatchDbus();
void runMainLoop(JLogger jlogger, JRunnable onAppmenuServiceAppeared, JRunnable onAppmenuServiceVanished);
void execOnMainLoop(JRunnable run);
Pointer registerWindow(long windowXid, EventHandler handler);
@@ -164,9 +167,15 @@ public class GlobalMenuLinux implements GlobalMenuLib.EventHandler, Disposable {
};
// NOTE: linux implementation of javaFX starts native main loop with GtkApplication._runLoop()
PlatformImpl.startup(()-> {
ourLib.startWatchDbus(ourGLogger, ourOnAppmenuServiceAppeared, ourOnAppmenuServiceVanished);
});
try {
PlatformImpl.startup(() -> {
ourLib.startWatchDbus(ourGLogger, ourOnAppmenuServiceAppeared, ourOnAppmenuServiceVanished);
});
} catch (Throwable e) {
LOG.info("can't start main loop via javaFX (will run it manualy): " + e.getMessage());
final Thread glibMain = new Thread(()->ourLib.runMainLoop(ourGLogger, ourOnAppmenuServiceAppeared, ourOnAppmenuServiceVanished));
glibMain.start();
}
} else {
ourGLogger = null;
ourProcessQueue = null;