diff --git a/CMakeLists.txt b/CMakeLists.txt index d62a828..3758d0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,6 @@ add_compile_definitions( pkg_check_modules(GLIB2 REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4) pkg_check_modules(LIBADWAITA REQUIRED IMPORTED_TARGET libadwaita-1) -pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11) find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED) diff --git a/INSTALL b/INSTALL index 28ee4a2..f5125b9 100644 --- a/INSTALL +++ b/INSTALL @@ -7,7 +7,6 @@ Installation Instructions gob >= 2.0.16 gtk >= 3 libchewing >= 0.5.1 - libX11 1. Remove the old build cache: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d955fe2..86a4057 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,6 @@ target_link_libraries(gui-core PUBLIC PkgConfig::GLIB2 PkgConfig::GTK4 PkgConfig::LIBADWAITA - PkgConfig::X11 PkgConfig::IBUS PkgConfig::CHEWING ) diff --git a/src/IBusChewingUtil.c b/src/IBusChewingUtil.c index 389e8ee..50ab800 100644 --- a/src/IBusChewingUtil.c +++ b/src/IBusChewingUtil.c @@ -194,29 +194,6 @@ const char *key_sym_get_name(KSym k) * Modifiers */ -#define CAPS_LOCK_MASK 2 -gboolean is_caps_led_on(Display * pDisplay) -{ - XKeyboardState retState; - - XGetKeyboardControl(pDisplay, &retState); - XFlush(pDisplay); - return (retState.led_mask & 1) ? TRUE : FALSE; -} - -void set_caps_led(gboolean on, Display * pDisplay) -{ - XKeyboardControl control; - - control.led_mode = (on) ? LedModeOn : LedModeOff; - control.led = CAPS_LOCK_MASK; - guint flags = (on) ? CAPS_LOCK_MASK : 0; - - XChangeKeyboardControl(pDisplay, KBLedMode, &control); - XkbLockModifiers(pDisplay, XkbUseCoreKbd, control.led, flags); - XFlush(pDisplay); -} - const gchar *modifier_get_string(guint modifier) { switch (modifier) { diff --git a/src/IBusChewingUtil.h b/src/IBusChewingUtil.h index fae991e..835734c 100644 --- a/src/IBusChewingUtil.h +++ b/src/IBusChewingUtil.h @@ -26,8 +26,6 @@ # include # include # include -# include -# include # define ZHUYIN_BUFFER_SIZE 12 @@ -70,10 +68,6 @@ KSym key_sym_KP_to_normal(KSym k); const char *key_sym_get_name(KSym k); -gboolean is_caps_led_on(Display * pDisplay); - -void set_caps_led(gboolean on, Display * pDisplay); - const gchar *modifier_get_string(guint modifier); const gchar *modifiers_to_string(guint modifier); diff --git a/src/ibus-chewing-engine-private.h b/src/ibus-chewing-engine-private.h index 5c253fc..93667ff 100644 --- a/src/ibus-chewing-engine-private.h +++ b/src/ibus-chewing-engine-private.h @@ -26,8 +26,6 @@ #include #define GETTEXT_PACKAGE "gtk30" #include -#include -#include #include #include "IBusChewingUtil.h" #include "IBusChewingProperties.h" @@ -71,7 +69,6 @@ struct _IBusChewingEnginePrivate { EngineFlag statusFlags; IBusCapabilite capabilite; ChewingInputStyle inputStyle; - Display * pDisplay; }; void ibus_chewing_engine_use_setting (IBusChewingEngine * self); void ibus_chewing_engine_restore_mode (IBusChewingEngine * self); diff --git a/src/ibus-chewing-engine.c b/src/ibus-chewing-engine.c index 94a8267..59b2012 100644 --- a/src/ibus-chewing-engine.c +++ b/src/ibus-chewing-engine.c @@ -27,8 +27,6 @@ #define GETTEXT_PACKAGE "gtk30" #include #include -#include -#include #include #include "IBusChewingUtil.h" #include "IBusChewingProperties.h" @@ -144,7 +142,6 @@ static IBusEngineClass *parent_class = NULL; #define is_password(self) ibus_chewing_engine_has_status_flag(self, ENGINE_FLAG_IS_PASSWORD) #define ibus_chewing_engine_is_chinese_mode(self) ibus_chewing_pre_edit_get_chi_eng_mode(self->icPreEdit) -#define is_caps_lock(self) (is_caps_led_on(((IBusChewingEnginePrivate*)ibus_chewing_engine_get_instance_private(self))->pDisplay)) #define ibus_text_is_empty(iText) ((iText == NULL) || STRING_IS_EMPTY(iText->text)) @@ -194,7 +191,6 @@ ___finalize(GObject *obj_self) if(self->AlnumSize) { g_object_unref ((gpointer) self->AlnumSize); self->AlnumSize = NULL; } if(self->setup_prop) { g_object_unref ((gpointer) self->setup_prop); self->setup_prop = NULL; } if(self->prop_list) { g_object_unref ((gpointer) self->prop_list); self->prop_list = NULL; } - if(selfp->pDisplay) { XCloseDisplay ((gpointer) selfp->pDisplay); selfp->pDisplay = NULL; } if(G_OBJECT_CLASS(parent_class)->finalize) \ (* G_OBJECT_CLASS(parent_class)->finalize)(obj_self); } @@ -253,9 +249,6 @@ ibus_chewing_engine_init (IBusChewingEngine * self G_GNUC_UNUSED) g_object_ref_sink(ibus_prop_list_new()) ; self->keymap_us = ibus_keymap_get("us") ; - selfp->pDisplay = - XOpenDisplay(NULL) - ; { /* initialize the object here */ @@ -300,11 +293,6 @@ ibus_chewing_engine_init (IBusChewingEngine * self G_GNUC_UNUSED) ibus_chewing_engine_set_status_flag(self, ENGINE_FLAG_INITIALIZED); - /* In case we cannot open X display */ - if (selfp->pDisplay == NULL) { - IBUS_CHEWING_LOG(WARN, "init() XOpenDisplay return NULL"); - } - IBUS_CHEWING_LOG(DEBUG, "init() Done"); } @@ -440,17 +428,17 @@ ibus_chewing_engine_restore_mode (IBusChewingEngine * self) { IBUS_CHEWING_LOG(DEBUG, "restore_mode() statusFlags=%x", selfp->statusFlags); - if (selfp->pDisplay != NULL) { - /* Restore Led Mode only make sense if pDisplay is available */ + GdkDisplay *display = gdk_display_get_default(); + if (display != NULL) { + GdkSeat *seat = gdk_display_get_default_seat(display); + GdkDevice *keyboard = gdk_seat_get_keyboard(seat); + /* Restore Led Mode only make sense if display is available */ if (ibus_chewing_pre_edit_has_flag(self->icPreEdit, FLAG_SYNC_FROM_IM)) { - IBUS_CHEWING_LOG(DEBUG, "restore_mode() FLAG_SYNC_FROM_IM"); - if (ibus_chewing_engine_is_chinese_mode(self) == is_caps_lock(self)) { - /* ChiEng mode does not agree each other */ - set_caps_led(!ibus_chewing_engine_is_chinese_mode(self), selfp->pDisplay); - } + IBUS_CHEWING_LOG(DEBUG, "restore_mode() FLAG_SYNC_FROM_IM (deprecated)"); } else if (ibus_chewing_pre_edit_has_flag(self->icPreEdit, FLAG_SYNC_FROM_KEYBOARD)) { IBUS_CHEWING_LOG(DEBUG, "restore_mode() FLAG_SYNC_FROM_KEYBOARD"); - chewing_set_ChiEngMode(self->icPreEdit->context, (is_caps_lock(self)) ? 0 : CHINESE_MODE); + gboolean caps_lock_on = gdk_device_get_caps_lock_state(keyboard); + chewing_set_ChiEngMode(self->icPreEdit->context, caps_lock_on ? 0 : CHINESE_MODE); } self_refresh_property(self, "InputMode"); } @@ -1220,18 +1208,8 @@ void ibus_chewing_engine_property_activate(IBusEngine * engine, /* Toggle Chinese <-> English */ ibus_chewing_pre_edit_toggle_chi_eng_mode(self->icPreEdit); IBUS_CHEWING_LOG(INFO, - "property_activate chinese=%d caps_lock=%d", - ibus_chewing_engine_is_chinese_mode(self), - is_caps_lock(self)); - - if (ibus_chewing_pre_edit_has_flag(self->icPreEdit, FLAG_SYNC_FROM_IM) - || ibus_chewing_pre_edit_has_flag(self->icPreEdit, - FLAG_SYNC_FROM_KEYBOARD)) { - if (ibus_chewing_engine_is_chinese_mode(self) == is_caps_lock(self)) { - set_caps_led(!ibus_chewing_engine_is_chinese_mode(self), - selfp->pDisplay); - } - } + "property_activate chinese=%d", + ibus_chewing_engine_is_chinese_mode(self)); ibus_chewing_engine_refresh_property(self, prop_name); } else if (STRING_EQUALS(prop_name, "AlnumSize")) { /* Toggle Full <-> Half */ diff --git a/src/ibus-chewing-engine.h b/src/ibus-chewing-engine.h index 7c85759..32afc88 100644 --- a/src/ibus-chewing-engine.h +++ b/src/ibus-chewing-engine.h @@ -27,8 +27,6 @@ #define GETTEXT_PACKAGE "gtk30" #include #include -#include -#include #include #include "IBusChewingUtil.h" #include "IBusChewingProperties.h" diff --git a/src/setup/ibus-setup-chewing-window.ui b/src/setup/ibus-setup-chewing-window.ui index dcb8881..d92073d 100644 --- a/src/setup/ibus-setup-chewing-window.ui +++ b/src/setup/ibus-setup-chewing-window.ui @@ -59,16 +59,14 @@ True Intelligent Phrasing - Enable or disable automatic candidate - selection + Enable or disable automatic candidate selection Show Systray Icon Whether to show the systray icon - This feature is currently not - implemented. + This feature is currently not implemented. False @@ -82,16 +80,14 @@ True Auto Move Cursor - Automatically move the cursor to the - next character after selection + Automatically move the cursor to the next character after selection True Add Phrase Before Cursor - Use Ctrl + Numbers (2-9) to save new - phrase before or after the cursor + Use Ctrl + Numbers (2-9) to save new phrase before or after the cursor @@ -104,15 +100,13 @@ True Easy Symbol Input - Press Shift + keys to input Chinese - punctuation symbols + Press Shift + keys to input Chinese punctuation symbols Esc Clean All Buffer - Escape key discards all uncommitted - texts + Escape key discards all uncommitted texts @@ -126,8 +120,7 @@ Maximum Chinese Characters - Until how many characters should - trigger auto-commit + Until how many characters should trigger auto-commit @@ -152,7 +145,6 @@ Disable Syncing Sync with Keyboard State - Sync with IM State @@ -171,8 +163,7 @@ Default English Letter Case - The letter case without pressing the - Shift key + The letter case without pressing the Shift key @@ -180,8 +171,7 @@ Selecting - Configure the candidate selection - behavior + Configure the candidate selection behavior @@ -205,8 +195,7 @@ True Choose Phrases Backwards - Open candidate list from the last - character of a phrase + Open candidate list from the last character of a phrase @@ -219,8 +208,7 @@ True Use Vertical Candidate Panel - Choose from vertical or horizontal - panel + Choose from vertical or horizontal panel