mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 19:21:38 +02:00
Connect to IBUS
This commit is contained in:
17
glfw/dbus_glfw.c
vendored
17
glfw/dbus_glfw.c
vendored
@@ -50,6 +50,17 @@ glfw_dbus_init(_GLFWDBUSData *dbus) {
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBusConnection*
|
||||||
|
glfw_dbus_connect_to(const char *path, const char* err_msg) {
|
||||||
|
DBusError err;
|
||||||
|
dbus_error_init(&err);
|
||||||
|
DBusConnection *ans = dbus_connection_open_private(path, &err);
|
||||||
|
if (!ans) {
|
||||||
|
report_error(&err, err_msg);
|
||||||
|
}
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glfw_dbus_terminate(_GLFWDBUSData *dbus) {
|
glfw_dbus_terminate(_GLFWDBUSData *dbus) {
|
||||||
if (dbus->session_conn) {
|
if (dbus->session_conn) {
|
||||||
@@ -58,3 +69,9 @@ glfw_dbus_terminate(_GLFWDBUSData *dbus) {
|
|||||||
dbus->session_conn = NULL;
|
dbus->session_conn = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
glfw_dbus_close_connection(DBusConnection *conn) {
|
||||||
|
dbus_connection_close(conn);
|
||||||
|
dbus_connection_unref(conn);
|
||||||
|
}
|
||||||
|
|||||||
2
glfw/dbus_glfw.h
vendored
2
glfw/dbus_glfw.h
vendored
@@ -36,3 +36,5 @@ typedef struct {
|
|||||||
|
|
||||||
GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus);
|
GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus);
|
||||||
void glfw_dbus_terminate(_GLFWDBUSData *dbus);
|
void glfw_dbus_terminate(_GLFWDBUSData *dbus);
|
||||||
|
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg);
|
||||||
|
void glfw_dbus_close_connection(DBusConnection *conn);
|
||||||
|
|||||||
15
glfw/ibus_glfw.c
vendored
15
glfw/ibus_glfw.c
vendored
@@ -31,6 +31,8 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "ibus_glfw.h"
|
#include "ibus_glfw.h"
|
||||||
|
|
||||||
|
#define debug(...) if (_glfw.hints.init.debugKeyboard) printf(__VA_ARGS__);
|
||||||
|
|
||||||
static inline GLFWbool
|
static inline GLFWbool
|
||||||
has_env_var(const char *name, const char *val) {
|
has_env_var(const char *name, const char *val) {
|
||||||
const char *q = getenv(name);
|
const char *q = getenv(name);
|
||||||
@@ -128,4 +130,17 @@ glfw_connect_to_ibus(_GLFWIBUSData *ibus, _GLFWDBUSData *dbus) {
|
|||||||
if (!address_file_name) return;
|
if (!address_file_name) return;
|
||||||
const char *address = read_ibus_address(address_file_name);
|
const char *address = read_ibus_address(address_file_name);
|
||||||
if (!address) return;
|
if (!address) return;
|
||||||
|
ibus->conn = glfw_dbus_connect_to(address, "Failed to connect to the IBUS daemon, with error");
|
||||||
|
if (!ibus->conn) return;
|
||||||
|
ibus->ok = GLFW_TRUE;
|
||||||
|
debug("Connected to IBUS daemon for IME input management\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
glfw_ibus_terminate(_GLFWIBUSData *ibus) {
|
||||||
|
if (ibus->conn) {
|
||||||
|
glfw_dbus_close_connection(ibus->conn);
|
||||||
|
ibus->conn = NULL;
|
||||||
|
}
|
||||||
|
ibus->ok = GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
2
glfw/ibus_glfw.h
vendored
2
glfw/ibus_glfw.h
vendored
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GLFWbool ok;
|
GLFWbool ok;
|
||||||
|
DBusConnection *conn;
|
||||||
} _GLFWIBUSData;
|
} _GLFWIBUSData;
|
||||||
|
|
||||||
void glfw_connect_to_ibus(_GLFWIBUSData *ibus, _GLFWDBUSData *dbus);
|
void glfw_connect_to_ibus(_GLFWIBUSData *ibus, _GLFWDBUSData *dbus);
|
||||||
|
void glfw_ibus_terminate(_GLFWIBUSData *ibus);
|
||||||
|
|||||||
1
glfw/xkb_glfw.c
vendored
1
glfw/xkb_glfw.c
vendored
@@ -200,6 +200,7 @@ glfw_xkb_release(_GLFWXKBData *xkb) {
|
|||||||
xkb_context_unref(xkb->context);
|
xkb_context_unref(xkb->context);
|
||||||
xkb->context = NULL;
|
xkb->context = NULL;
|
||||||
}
|
}
|
||||||
|
glfw_ibus_terminate(&xkb->ibus);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool
|
GLFWbool
|
||||||
|
|||||||
Reference in New Issue
Block a user