Don't link hime-im-client, use it with dlopen instead
This commit is contained in:
parent
6001968f85
commit
d3e1827ff0
5 changed files with 228 additions and 69 deletions
2
external/CMakeLists.txt
vendored
2
external/CMakeLists.txt
vendored
|
|
@ -30,7 +30,7 @@ if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
|
||||||
add_checked_subdirectory(glibmm)
|
add_checked_subdirectory(glibmm)
|
||||||
endif()
|
endif()
|
||||||
add_checked_subdirectory(gsl)
|
add_checked_subdirectory(gsl)
|
||||||
if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
|
if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
|
||||||
add_checked_subdirectory(hime_qt)
|
add_checked_subdirectory(hime_qt)
|
||||||
endif()
|
endif()
|
||||||
if (add_hunspell_library)
|
if (add_hunspell_library)
|
||||||
|
|
|
||||||
75
external/hime_qt/hime_im_client/CMakeLists.txt
vendored
75
external/hime_qt/hime_im_client/CMakeLists.txt
vendored
|
|
@ -13,85 +13,28 @@ else()
|
||||||
init_target(external_hime_im_client "(external)")
|
init_target(external_hime_im_client "(external)")
|
||||||
|
|
||||||
set(hime_loc ${third_party_loc}/hime)
|
set(hime_loc ${third_party_loc}/hime)
|
||||||
set(hime_src ${hime_loc}/src)
|
set(hime_im_client_src ${hime_loc}/src/im-client)
|
||||||
set(hime_im_client_src ${hime_src}/im-client)
|
|
||||||
|
|
||||||
nice_target_sources(external_hime_im_client ${hime_im_client_src}
|
nice_target_sources(external_hime_im_client ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
hime-im-client-attr.h
|
hime_im_client_helper.cpp
|
||||||
hime-im-client.c
|
|
||||||
hime-im-client.h
|
|
||||||
hime-protocol.h
|
|
||||||
hime-send.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
nice_target_sources(external_hime_im_client ${hime_src}
|
|
||||||
PRIVATE
|
|
||||||
hime-conf.c
|
|
||||||
util.c
|
|
||||||
im-addr.c
|
|
||||||
hime-crypt.c
|
|
||||||
)
|
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
pkg_check_modules(GTK REQUIRED gtk+-3.0)
|
|
||||||
|
|
||||||
target_include_directories(external_hime_im_client
|
target_include_directories(external_hime_im_client
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${hime_im_client_src}
|
${hime_im_client_src}
|
||||||
PRIVATE
|
|
||||||
${hime_src}
|
|
||||||
${hime_src}/IMdkit/include
|
|
||||||
${GTK_INCLUDE_DIRS}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(external_hime_im_client
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(X11 REQUIRED x11)
|
||||||
|
|
||||||
|
target_include_directories(external_hime_im_client SYSTEM
|
||||||
PRIVATE
|
PRIVATE
|
||||||
HIME_BIN_DIR="/usr/bin"
|
${X11_INCLUDE_DIRS}
|
||||||
HIME_TABLE_DIR="/usr/share/hime/table"
|
|
||||||
UNIX=1
|
|
||||||
FREEBSD=0
|
|
||||||
CLIENT_LIB=1
|
|
||||||
GTK_DISABLE_DEPRECATED
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
add_library(external_hime_im_client_options INTERFACE)
|
|
||||||
|
|
||||||
target_compile_options(external_hime_im_client_options
|
|
||||||
INTERFACE
|
|
||||||
-Wno-sometimes-uninitialized
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(external_hime_im_client
|
|
||||||
PRIVATE
|
|
||||||
external_hime_im_client_options
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(external_hime_im_client
|
target_link_libraries(external_hime_im_client
|
||||||
PRIVATE
|
PRIVATE
|
||||||
desktop-app::external_glib
|
${CMAKE_DL_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (DESKTOP_APP_USE_PACKAGED)
|
|
||||||
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
|
|
||||||
|
|
||||||
target_link_libraries(external_hime_im_client
|
|
||||||
PRIVATE
|
|
||||||
PkgConfig::X11
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
pkg_check_modules(X11 REQUIRED x11)
|
|
||||||
|
|
||||||
target_include_directories(external_hime_im_client SYSTEM
|
|
||||||
PRIVATE
|
|
||||||
${X11_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(external_hime_im_client
|
|
||||||
PRIVATE
|
|
||||||
X11
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
208
external/hime_qt/hime_im_client/hime_im_client_helper.cpp
vendored
Normal file
208
external/hime_qt/hime_im_client/hime_im_client_helper.cpp
vendored
Normal file
|
|
@ -0,0 +1,208 @@
|
||||||
|
// This file is part of Desktop App Toolkit,
|
||||||
|
// a set of libraries for developing nice desktop applications.
|
||||||
|
//
|
||||||
|
// For license and copyright information please follow this link:
|
||||||
|
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
//
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <hime-im-client.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func)
|
||||||
|
|
||||||
|
namespace HimeHelper {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void (*hime_im_client_close)(HIME_client_handle *handle);
|
||||||
|
void (*hime_im_client_focus_in)(HIME_client_handle *handle);
|
||||||
|
void (*hime_im_client_focus_out)(HIME_client_handle *handle);
|
||||||
|
void (*hime_im_client_focus_out2)(HIME_client_handle *handle, char **rstr);
|
||||||
|
int (*hime_im_client_forward_key_press)(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const KeySym key,
|
||||||
|
const uint32_t state,
|
||||||
|
char **rstr);
|
||||||
|
int (*hime_im_client_forward_key_release)(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const KeySym key,
|
||||||
|
const uint32_t state,
|
||||||
|
char **rstr);
|
||||||
|
int (*hime_im_client_get_preedit)(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
char **str,
|
||||||
|
HIME_PREEDIT_ATTR att[],
|
||||||
|
int *cursor,
|
||||||
|
int *sub_comp_len);
|
||||||
|
HIME_client_handle *(*hime_im_client_open)(Display *display);
|
||||||
|
void (*hime_im_client_reset)(HIME_client_handle *handle);
|
||||||
|
void (*hime_im_client_set_cursor_location)(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const int x,
|
||||||
|
const int y);
|
||||||
|
void (*hime_im_client_set_flags)(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const int flags,
|
||||||
|
int *ret_flags);
|
||||||
|
void (*hime_im_client_set_client_window)(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const Window win);
|
||||||
|
void (*hime_im_client_set_window)(HIME_client_handle *handle, Window win);
|
||||||
|
|
||||||
|
struct HandleDeleter {
|
||||||
|
void operator()(void *handle) {
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using Handle = std::unique_ptr<void, HandleDeleter>;
|
||||||
|
|
||||||
|
bool LoadLibrary(Handle &handle, const char *name) {
|
||||||
|
handle = Handle(dlopen(name, RTLD_LAZY | RTLD_NODELETE));
|
||||||
|
if (handle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
std::cerr << dlerror() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Function>
|
||||||
|
inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) {
|
||||||
|
func = handle
|
||||||
|
? reinterpret_cast<Function>(dlsym(handle.get(), name))
|
||||||
|
: nullptr;
|
||||||
|
if (const auto error = dlerror()) {
|
||||||
|
std::cerr << error << std::endl;
|
||||||
|
}
|
||||||
|
return (func != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Resolve() {
|
||||||
|
static const auto loaded = [&] {
|
||||||
|
auto lib = Handle();
|
||||||
|
return LoadLibrary(lib, "libhime-im-client.so.1")
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_close)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_focus_in)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_focus_out)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_focus_out2)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_forward_key_press)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_forward_key_release)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_get_preedit)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_open)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_reset)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_set_cursor_location)
|
||||||
|
&& LOAD_SYMBOL(lib, hime_im_client_set_flags)
|
||||||
|
&& (LOAD_SYMBOL(lib, hime_im_client_set_client_window)
|
||||||
|
|| LOAD_SYMBOL(lib, hime_im_client_set_window));
|
||||||
|
}();
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace HimeHelper
|
||||||
|
|
||||||
|
void hime_im_client_close(HIME_client_handle *handle) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_close(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_focus_in(HIME_client_handle *handle) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_focus_in(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_focus_out(HIME_client_handle *handle) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_focus_out(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_focus_out2(HIME_client_handle *handle, char **rstr) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_focus_out2(handle, rstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hime_im_client_forward_key_press(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const KeySym key,
|
||||||
|
const uint32_t state,
|
||||||
|
char **rstr) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
return HimeHelper::hime_im_client_forward_key_press(
|
||||||
|
handle,
|
||||||
|
key,
|
||||||
|
state,
|
||||||
|
rstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hime_im_client_forward_key_release(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const KeySym key,
|
||||||
|
const uint32_t state,
|
||||||
|
char **rstr) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
return HimeHelper::hime_im_client_forward_key_release(
|
||||||
|
handle,
|
||||||
|
key,
|
||||||
|
state,
|
||||||
|
rstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hime_im_client_get_preedit(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
char **str,
|
||||||
|
HIME_PREEDIT_ATTR att[],
|
||||||
|
int *cursor,
|
||||||
|
int *sub_comp_len) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
return HimeHelper::hime_im_client_get_preedit(
|
||||||
|
handle,
|
||||||
|
str,
|
||||||
|
att,
|
||||||
|
cursor,
|
||||||
|
sub_comp_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
HIME_client_handle *hime_im_client_open(Display *display) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
return HimeHelper::hime_im_client_open(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_reset(HIME_client_handle *handle) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_reset(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_set_cursor_location(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const int x,
|
||||||
|
const int y) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_set_cursor_location(
|
||||||
|
handle,
|
||||||
|
x,
|
||||||
|
y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_set_flags(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const int flags,
|
||||||
|
int *ret_flags) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_set_flags(
|
||||||
|
handle,
|
||||||
|
flags,
|
||||||
|
ret_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_set_client_window(
|
||||||
|
HIME_client_handle *handle,
|
||||||
|
const Window win) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_set_client_window(handle, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hime_im_client_set_window(HIME_client_handle *handle, Window win) {
|
||||||
|
HimeHelper::Resolve();
|
||||||
|
HimeHelper::hime_im_client_set_window(handle, win);
|
||||||
|
}
|
||||||
8
external/qt/qt_static_plugins/CMakeLists.txt
vendored
8
external/qt/qt_static_plugins/CMakeLists.txt
vendored
|
|
@ -28,7 +28,6 @@ if (LINUX)
|
||||||
target_link_libraries(external_qt_static_plugins
|
target_link_libraries(external_qt_static_plugins
|
||||||
PUBLIC
|
PUBLIC
|
||||||
desktop-app::external_fcitx_qt5
|
desktop-app::external_fcitx_qt5
|
||||||
desktop-app::external_hime_qt
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
|
if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
|
||||||
|
|
@ -38,4 +37,11 @@ if (LINUX)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
|
||||||
|
target_link_libraries(external_qt_static_plugins
|
||||||
|
PUBLIC
|
||||||
|
desktop-app::external_hime_qt
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin)
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin)
|
Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin)
|
||||||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin)
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin)
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
#endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY
|
#endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY
|
||||||
#endif // Q_OS_UNIX && !Q_OS_MAC
|
#endif // Q_OS_UNIX && !Q_OS_MAC
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue