Skip to content

Commit

Permalink
Do not hand on startup if the ibus daemon is hung
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jul 12, 2018
1 parent 3c772c3 commit 98ede45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions glfw/dbus_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ toggle_dbus_timeout(DBusTimeout *timeout, void *data) {


DBusConnection*
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name) {
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name, GLFWbool register_on_bus) {
DBusError err;
dbus_error_init(&err);
DBusConnection *ans = dbus_connection_open_private(path, &err);
Expand All @@ -139,13 +139,13 @@ glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name) {
return NULL;
}
dbus_connection_set_exit_on_disconnect(ans, FALSE);
dbus_connection_flush(ans);
dbus_error_free(&err);
if (!dbus_bus_register(ans, &err)) {
report_error(&err, err_msg);
return NULL;
if (register_on_bus) {
if (!dbus_bus_register(ans, &err)) {
report_error(&err, err_msg);
return NULL;
}
}
dbus_connection_flush(ans);
if (!dbus_connection_set_watch_functions(ans, add_dbus_watch, remove_dbus_watch, toggle_dbus_watch, (void*)name, NULL)) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to set DBUS watches on connection to: %s", path);
dbus_connection_close(ans);
Expand Down
2 changes: 1 addition & 1 deletion glfw/dbus_glfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct {

GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld);
void glfw_dbus_terminate(_GLFWDBUSData *dbus);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name, GLFWbool register_on_bus);
void glfw_dbus_close_connection(DBusConnection *conn);
GLFWbool
glfw_dbus_call_method_no_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
Expand Down
3 changes: 1 addition & 2 deletions glfw/ibus_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,14 @@ setup_connection(_GLFWIBUSData *ibus) {
ibus->conn = NULL;
}
debug("Connecting to IBUS daemon @ %s for IME input management\n", ibus->address);
ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus");
ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus", GLFW_FALSE);
if (!ibus->conn) return GLFW_FALSE;
free((void*)ibus->input_ctx_path); ibus->input_ctx_path = NULL;
if (!glfw_dbus_call_method_with_reply(
ibus->conn, IBUS_SERVICE, IBUS_PATH, IBUS_INTERFACE, "CreateInputContext", input_context_created, ibus,
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID)) {
return GLFW_FALSE;
}
dbus_connection_flush(ibus->conn);
return GLFW_TRUE;
}

Expand Down

0 comments on commit 98ede45

Please sign in to comment.