Skip to content

Commit

Permalink
Fixed bug 5103 - Port fcitx support to both fcitx 4 & 5
Browse files Browse the repository at this point in the history
wengxt

Due to the new major fcitx version is coming close, the existing code need to be ported to use new Fcitx dbus interface.

The new dbus interface is supported by both fcitx 4 and 5, and has a good side effect, which is that it will work with flatpak for free. Also the patch remove the dependency on fcitx header. Instead, it just hardcodes a few enum value in the code so need to handle the different header for fcitx4 or 5.
  • Loading branch information
slouken committed May 11, 2020
1 parent 33642b4 commit eadc869
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 112 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Expand Up @@ -1213,13 +1213,18 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS)
set(HAVE_DBUS_DBUS_H TRUE)
include_directories(${DBUS_INCLUDE_DIRS})
list(APPEND EXTRA_LIBS ${DBUS_LIBRARIES})
# Fcitx need only dbus.
set(HAVE_FCITX TRUE)
endif()

pkg_search_module(IBUS ibus-1.0 ibus)
if(IBUS_FOUND)
set(HAVE_IBUS_IBUS_H TRUE)
include_directories(${IBUS_INCLUDE_DIRS})
list(APPEND EXTRA_LIBS ${IBUS_LIBRARIES})
endif()

if (HAVE_IBUS_IBUS_H OR HAVE_FCITX)
add_definitions(-DSDL_USE_IME)
endif()
if(HAVE_LIBUNWIND_H)
Expand All @@ -1229,8 +1234,6 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS)
list(APPEND EXTRA_LIBS ${UNWIND_LIBRARIES} ${UNWIND_GENERIC_LIBRARIES})
endif()
endif()

check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
endif()

if(INPUT_TSLIB)
Expand Down
27 changes: 8 additions & 19 deletions configure.ac
Expand Up @@ -2731,24 +2731,13 @@ CheckFcitx()
AS_HELP_STRING([--enable-fcitx], [enable fcitx support [[default=yes]]]),
, enable_fcitx=yes)
if test x$enable_fcitx = xyes; then
PKG_CHECK_MODULES([FCITX], [fcitx], have_fcitx=yes, have_fcitx=no)
CFLAGS="$CFLAGS $FCITX_CFLAGS"
AC_CHECK_HEADER(fcitx/frontend.h,
have_fcitx_frontend_h_hdr=yes,
have_fcitx_frontend_h_hdr=no)
CFLAGS="$save_CFLAGS"
if test x$have_fcitx_frontend_h_hdr = xyes; then
if test x$enable_ime != xyes; then
AC_MSG_WARN([IME support is required for fcitx.])
have_fcitx_frontend_h_hdr=no
elif test x$enable_dbus != xyes; then
AC_MSG_WARN([DBus support is required for fcitx.])
have_fcitx_frontend_h_hdr=no
else
AC_DEFINE(HAVE_FCITX_FRONTEND_H, 1, [ ])
EXTRA_CFLAGS="$EXTRA_CFLAGS $FCITX_CFLAGS"
SOURCES="$SOURCES $srcdir/src/core/linux/SDL_fcitx.c"
fi
if test x$enable_ime != xyes; then
AC_MSG_WARN([IME support is required for fcitx.])
elif test x$enable_dbus != xyes; then
AC_MSG_WARN([DBus support is required for fcitx.])
else
AC_DEFINE(HAVE_FCITX, 1, [ ])
SOURCES="$SOURCES $srcdir/src/core/linux/SDL_fcitx.c"
fi
fi
}
Expand Down Expand Up @@ -4408,7 +4397,7 @@ if test x$have_ibus_ibus_h_hdr = xyes; then
else
SUMMARY="${SUMMARY}Using ibus : NO\n"
fi
if test x$have_fcitx_frontend_h_hdr = xyes; then
if test x$enable_fcitx = xyes; then
SUMMARY="${SUMMARY}Using fcitx : YES\n"
else
SUMMARY="${SUMMARY}Using fcitx : NO\n"
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_config.h.cmake
Expand Up @@ -203,7 +203,7 @@

#cmakedefine HAVE_ALTIVEC_H 1
#cmakedefine HAVE_DBUS_DBUS_H 1
#cmakedefine HAVE_FCITX_FRONTEND_H 1
#cmakedefine HAVE_FCITX 1
#cmakedefine HAVE_IBUS_IBUS_H 1
#cmakedefine HAVE_IMMINTRIN_H 1
#cmakedefine HAVE_LIBSAMPLERATE_H 1
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_config.h.in
Expand Up @@ -204,7 +204,7 @@

#undef HAVE_ALTIVEC_H
#undef HAVE_DBUS_DBUS_H
#undef HAVE_FCITX_FRONTEND_H
#undef HAVE_FCITX
#undef HAVE_IBUS_IBUS_H
#undef HAVE_IMMINTRIN_H
#undef HAVE_LIBSAMPLERATE_H
Expand Down
4 changes: 4 additions & 0 deletions src/core/linux/SDL_dbus.c
Expand Up @@ -57,6 +57,10 @@ LoadDBUSSyms(void)
SDL_DBUS_SYM(message_new_method_call);
SDL_DBUS_SYM(message_append_args);
SDL_DBUS_SYM(message_append_args_valist);
SDL_DBUS_SYM(message_iter_init_append);
SDL_DBUS_SYM(message_iter_open_container);
SDL_DBUS_SYM(message_iter_append_basic);
SDL_DBUS_SYM(message_iter_close_container);
SDL_DBUS_SYM(message_get_args);
SDL_DBUS_SYM(message_get_args_valist);
SDL_DBUS_SYM(message_iter_init);
Expand Down
4 changes: 4 additions & 0 deletions src/core/linux/SDL_dbus.h
Expand Up @@ -54,6 +54,10 @@ typedef struct SDL_DBusContext {
DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *);
dbus_bool_t (*message_append_args)(DBusMessage *, int, ...);
dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list);
void (*message_iter_init_append)(DBusMessage *, DBusMessageIter *);
dbus_bool_t (*message_iter_open_container)(DBusMessageIter *, int, const char *, DBusMessageIter *);
dbus_bool_t (*message_iter_append_basic)(DBusMessageIter *, int, const void *);
dbus_bool_t (*message_iter_close_container)(DBusMessageIter *, DBusMessageIter *);
dbus_bool_t (*message_get_args)(DBusMessage *, DBusError *, int, ...);
dbus_bool_t (*message_get_args_valist)(DBusMessage *, DBusError *, int, va_list);
dbus_bool_t (*message_iter_init)(DBusMessage *, DBusMessageIter *);
Expand Down

0 comments on commit eadc869

Please sign in to comment.