Skip to content

Instantly share code, notes, and snippets.

@lo48576
Last active March 4, 2022 17:20
Show Gist options
  • Save lo48576/082a1f3b8ba23c6b73d8e260968c7f9b to your computer and use it in GitHub Desktop.
Save lo48576/082a1f3b8ba23c6b73d8e260968c7f9b to your computer and use it in GitHub Desktop.
fcitk4 & fcitx-skk & libskk セット
From 1f4c3a96cb2d1308581864676dd86ea6aa393ccb Mon Sep 17 00:00:00 2001
From: Weng Xuetian <[email protected]>
Date: Sat, 2 Nov 2019 22:02:54 -0700
Subject: [PATCH] [ipcportal] use /org/freedesktop/portal as dbus path for
portal.
---
src/frontend/ipcportal/ipcportal.c | 8 ++++----
src/frontend/ipcportal/ipcportal.h | 9 +++++----
src/frontend/qt/fcitxinputcontextproxy.cpp | 2 +-
src/lib/fcitx-gclient/fcitxclient.c | 2 +-
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/frontend/ipcportal/ipcportal.c b/src/frontend/ipcportal/ipcportal.c
index bed18299..14cd617c 100644
--- a/src/frontend/ipcportal/ipcportal.c
+++ b/src/frontend/ipcportal/ipcportal.c
@@ -49,7 +49,7 @@ typedef struct _FcitxLastSentIMInfo
typedef struct _FcitxPortalIC {
int id;
char* sender;
- char path[32];
+ char path[64];
uuid_t uuid;
int width;
int height;
@@ -234,7 +234,7 @@ void* PortalCreate(FcitxInstance* instance, int frontendid)
}
DBusObjectPathVTable fcitxPortalVTable = {NULL, &PortalDBusEventHandler, NULL, NULL, NULL, NULL };
- dbus_connection_register_object_path(ipc->_conn, FCITX_IM_DBUS_PATH, &fcitxPortalVTable, ipc);
+ dbus_connection_register_object_path(ipc->_conn, FCITX_IM_DBUS_PORTAL_PATH, &fcitxPortalVTable, ipc);
dbus_connection_flush(ipc->_conn);
FcitxIMEventHook hook;
@@ -266,7 +266,7 @@ void PortalCreateIC(void* arg, FcitxInputContext* context, void* priv)
ipcic->sender = strdup(dbus_message_get_sender(message));
ipc->maxid ++;
ipcic->lastPreeditIsEmpty = false;
- sprintf(ipcic->path, "/inputcontext/%d", ipcic->id);
+ sprintf(ipcic->path, FCITX_IC_DBUS_PORTAL_PATH, ipcic->id);
uuid_generate(ipcic->uuid);
int icpid = 0;
@@ -420,7 +420,7 @@ static DBusHandlerResult PortalICDBusEventHandler(DBusConnection *connection, DB
{
FcitxPortalFrontend* ipc = (FcitxPortalFrontend*) user_data;
int id = -1;
- sscanf(dbus_message_get_path(msg), "/inputcontext/%d", &id);
+ sscanf(dbus_message_get_path(msg), FCITX_IC_DBUS_PORTAL_PATH, &id);
FcitxInputContext* ic = FcitxInstanceFindIC(ipc->owner, ipc->frontendid, &id);
DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
DBusMessage *reply = NULL;
diff --git a/src/frontend/ipcportal/ipcportal.h b/src/frontend/ipcportal/ipcportal.h
index 17e24138..07d1f6c4 100644
--- a/src/frontend/ipcportal/ipcportal.h
+++ b/src/frontend/ipcportal/ipcportal.h
@@ -17,14 +17,15 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef FCITX_IPC_H
-#define FCITX_IPC_H
+#ifndef FCITX_IPC_PORTAL_H
+#define FCITX_IPC_PORTAL_H
#ifdef __cplusplus
extern "C" {
#endif
-#define FCITX_IM_DBUS_PATH "/inputmethod"
+#define FCITX_IM_DBUS_PORTAL_PATH "/org/freedesktop/portal/inputmethod"
+#define FCITX_IC_DBUS_PORTAL_PATH "/org/freedesktop/portal/inputcontext/%d"
#define FCITX_PORTAL_SERVICE "org.freedesktop.portal.Fcitx"
#define FCITX_IM_DBUS_INTERFACE "org.fcitx.Fcitx.InputMethod1"
@@ -34,5 +35,5 @@ extern "C" {
}
#endif
-#endif // FCITX_IPC_H
+#endif // FCITX_IPC_PORTAL_H
// kate: indent-mode cstyle; space-indent on; indent-width 0;
diff --git a/src/frontend/qt/fcitxinputcontextproxy.cpp b/src/frontend/qt/fcitxinputcontextproxy.cpp
index 0f7c5dfd..a418e81d 100644
--- a/src/frontend/qt/fcitxinputcontextproxy.cpp
+++ b/src/frontend/qt/fcitxinputcontextproxy.cpp
@@ -116,7 +116,7 @@ void FcitxInputContextProxy::createInputContext() {
QFileInfo info(QCoreApplication::applicationFilePath());
if (service == "org.freedesktop.portal.Fcitx") {
m_portal = true;
- m_im1proxy = new org::fcitx::Fcitx::InputMethod1(owner, "/inputmethod",
+ m_im1proxy = new org::fcitx::Fcitx::InputMethod1(owner, "/org/freedesktop/portal/inputmethod",
connection, this);
FcitxInputContextArgumentList list;
FcitxInputContextArgument arg;
diff --git a/src/lib/fcitx-gclient/fcitxclient.c b/src/lib/fcitx-gclient/fcitxclient.c
index 65916d3d..e7f89a63 100644
--- a/src/lib/fcitx-gclient/fcitxclient.c
+++ b/src/lib/fcitx-gclient/fcitxclient.c
@@ -669,7 +669,7 @@ static void _fcitx_client_create_ic_portal(FcitxClient *self) {
fcitx_connection_get_g_dbus_connection(self->priv->connection),
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
_fcitx_client_get_portal_interface_info(),
- "org.freedesktop.portal.Fcitx", "/inputmethod",
+ "org.freedesktop.portal.Fcitx", "/org/freedesktop/portal/inputmethod",
"org.fcitx.Fcitx.InputMethod1", self->priv->cancellable,
_fcitx_client_create_ic_portal_phase1_finished, self);
}
--
2.24.1
diff -Naur fcitx-skk-0.1.4.orig/src/skk.c fcitx-skk-0.1.4/src/skk.c
--- fcitx-skk-0.1.4.orig/src/skk.c 2017-10-20 16:03:38.000000000 +0900
+++ fcitx-skk-0.1.4/src/skk.c 2022-02-15 17:31:34.238294721 +0900
@@ -433,7 +433,7 @@
return NULL;
}
skk_context_set_period_style(skk->context, SKK_PERIOD_STYLE_JA_JA);
- skk_context_set_input_mode(skk->context, SKK_INPUT_MODE_HIRAGANA);
+ skk_context_set_input_mode(skk->context, skk->config.initialInputMode);
FcitxSkkApplyConfig(skk);
@@ -521,6 +521,7 @@
FcitxInstanceSetContext(skk->owner, CONTEXT_DISABLE_QUICKPHRASE, &flag);
FcitxInstanceSetContext(skk->owner, CONTEXT_DISABLE_FULLWIDTH, &flag);
FcitxInstanceSetContext(skk->owner, CONTEXT_DISABLE_AUTO_FIRST_CANDIDATE_HIGHTLIGHT, &flag);
+ skk_context_set_input_mode(skk->context, skk->config.initialInputMode);
return true;
}
diff -Naurp fcitx-skk-0.1.4.orig/src/skk.c fcitx-skk-0.1.4/src/skk.c
--- fcitx-skk-0.1.4.orig/src/skk.c 2018-01-22 00:23:23.519925982 +0900
+++ fcitx-skk-0.1.4/src/skk.c 2018-01-22 00:34:03.206759062 +0900
@@ -263,35 +263,35 @@ boolean FcitxSkkLoadDictionary(FcitxSkk*
if (path == NULL || mode == 0) {
break;
}
+ char* needfree = NULL;
+ char* realpath = NULL;
+ if (strncmp(path, "$FCITX_CONFIG_DIR/", strlen("$FCITX_CONFIG_DIR/")) == 0) {
+ FcitxXDGGetFileUserWithPrefix("", path + strlen("$FCITX_CONFIG_DIR/"), NULL, &needfree);
+ realpath = needfree;
+ } else {
+ realpath = path;
+ }
if (mode == 1) {
- if(strlen(path) > 4 && !strcmp(path + strlen(path) - 4, ".cdb")) {
- SkkCdbDict* dict = skk_cdb_dict_new(path, encoding, NULL);
+ if(strlen(realpath) > 4 && !strcmp(realpath + strlen(realpath) - 4, ".cdb")) {
+ SkkCdbDict* dict = skk_cdb_dict_new(realpath, encoding, NULL);
if (dict) {
utarray_push_back(&dictionaries, &dict);
}
} else {
- SkkFileDict* dict = skk_file_dict_new(path, encoding, NULL);
+ SkkFileDict* dict = skk_file_dict_new(realpath, encoding, NULL);
if (dict) {
utarray_push_back(&dictionaries, &dict);
}
}
} else {
- char* needfree = NULL;
- char* realpath = NULL;
- if (strncmp(path, "$FCITX_CONFIG_DIR/", strlen("$FCITX_CONFIG_DIR/")) == 0) {
- FcitxXDGGetFileUserWithPrefix("", path + strlen("$FCITX_CONFIG_DIR/"), NULL, &needfree);
- realpath = needfree;
- } else {
- realpath = path;
- }
SkkUserDict* userdict = skk_user_dict_new(realpath, encoding, NULL);
- if (needfree) {
- free(needfree);
- }
if (userdict) {
utarray_push_back(&dictionaries, &userdict);
}
}
+ if (needfree) {
+ free(needfree);
+ }
} else if (type == FSTD_Server) {
host = host ? host : "localhost";
port = port ? port : "1178";
From 663e5cf06b69ad25fcfac00f380eee8fa00c7ad8 Mon Sep 17 00:00:00 2001
From: YOSHIOKA Takuma <[email protected]>
Date: Sun, 23 Sep 2018 22:27:38 +0900
Subject: [PATCH] Let lonely modifiers pass through if no command assigned
This change prevents modifiers, "Control_L" without normal key for
example, from being eaten by libskk.
---
libskk/state.vala | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libskk/state.vala b/libskk/state.vala
index 1788951..6500769 100644
--- a/libskk/state.vala
+++ b/libskk/state.vala
@@ -423,6 +423,11 @@ namespace Skk {
ref KeyEvent key)
{
var command = state.lookup_key (key);
+
+ // if no command nor code is assigned to key, we can't proceed
+ if (command == null && key.code == 0)
+ return false;
+
// check abort and commit event
if (command == "abort" ||
command == "abort-to-latin" ||
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment