From 3d9d46cef1e4044344d70226cdab665962bcd706 Mon Sep 17 00:00:00 2001 From: Inhong Han Date: Thu, 4 Jan 2024 19:13:00 +0900 Subject: [PATCH] Add back key no grab mode using the Preference Change-Id: I0e9e1715169801473ff6a51a86760afd3339db13 --- configure.ac | 3 +++ ism/extras/wayland_immodule/Makefile.am | 4 +++- ism/extras/wayland_immodule/wayland_imcontext.c | 28 +++++++++++++++++++++++++ packaging/isf.spec | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7d92397..05be764 100644 --- a/configure.ac +++ b/configure.ac @@ -358,6 +358,9 @@ PKG_CHECK_MODULES(GMOCK, [gmock]) # Check system resource library PKG_CHECK_MODULES(SYSTEM_RESOURCE, [capi-system-resource]) +# Check App Preference +PKG_CHECK_MODULES(APP_PREFERENCE, [capi-appfw-preference]) + if test "$ISF_HAS_VCONF" = "yes"; then AC_DEFINE(HAVE_VCONF,1,[Have VConf functions.]) fi diff --git a/ism/extras/wayland_immodule/Makefile.am b/ism/extras/wayland_immodule/Makefile.am index 9e8de8b..9f06705 100644 --- a/ism/extras/wayland_immodule/Makefile.am +++ b/ism/extras/wayland_immodule/Makefile.am @@ -29,7 +29,8 @@ module_la_CFLAGS = @ECORE_CFLAGS@ \ @WL_TEXT_INPUT_CFLAGS@ \ @DLOG_CFLAGS@ \ @VCONF_CFLAGS@ \ - @APP_COMMON_CFLAGS@ + @APP_COMMON_CFLAGS@ \ + @APP_PREFERENCE_CFLAGS@ module_la_LDFLAGS = -rpath $(moduledir) \ -avoid-version \ @@ -44,4 +45,5 @@ module_la_LIBADD = $(LD_VERSION_SCRIPT_OPTION) \ @DLOG_LIBS@ \ @VCONF_LIBS@ \ @APP_COMMON_LIBS@ \ + @APP_PREFERENCE_LIBS@ \ $(top_builddir)/ism/src/libprofile.la diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index 162db26..963e741 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -36,6 +36,7 @@ #endif #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include "isf_debug.h" #include "wayland_imcontext.h" @@ -72,6 +74,7 @@ #define VCONFKEY_AUTOPERIOD_ALLOW_BOOL "file/private/isf/autoperiod_allow" #define VCONFKEY_AUTOCAPITAL_ALLOW_BOOL "file/private/isf/autocapital_allow" #define VCONFKEY_MULTIVIEW_MODE "memory/multiscreen/info" +#define PREFERENCE_APP_GRAB_BACK_KEY "app/grab/back_key" #define SOCK_PATH "/run/.isf/scim-panel-socket" @@ -164,6 +167,7 @@ static Eina_Bool g_focused = EINA_FALSE; static double g_original_key_rate = 0.0, g_original_key_delay = 0.0, g_desired_key_rate = 0.0; static double g_filter_event_elapsed_time = 0.0; static int g_last_key_event_serial = 0; +static bool g_app_grab_back_key = false; // typedef struct __LanguageInfo { @@ -464,6 +468,12 @@ static void multiview_mode_changed_cb (keynode_t *key, void* data) } } +static void app_grab_back_key_changed_cb(const char *key, void *user_data) +{ + if (preference_get_boolean(PREFERENCE_APP_GRAB_BACK_KEY, &g_app_grab_back_key) != PREFERENCE_ERROR_NONE) + LOGW("Failed to get preference value"); +} + static Eina_Bool check_symbol (Eina_Unicode ucode, Eina_Unicode symbols[], int symbol_num) { @@ -841,6 +851,9 @@ _ecore_event_to_ecore_imf_key_up_event(Ecore_Event_Key *ecore_event, Ecore_IMF_E static Eina_Bool check_nograb_backkey() { + if (g_app_grab_back_key) + return EINA_TRUE; /* the event is kept */ + char *nograb_backkey = getenv ("ISF_KEY_NOGRAB_BACKKEY"); if (nograb_backkey) { if (atoi (nograb_backkey) != 0) @@ -3029,6 +3042,18 @@ void wayland_im_initialize () LOGW ("Failed to register callback function for multiview mode."); #endif + bool exist = false; + if (preference_is_existing(PREFERENCE_APP_GRAB_BACK_KEY, &exist) != PREFERENCE_ERROR_NONE) + LOGW("Failed to get preference information"); + + if (exist) { + if (preference_get_boolean(PREFERENCE_APP_GRAB_BACK_KEY, &g_app_grab_back_key) != PREFERENCE_ERROR_NONE) + LOGW("Failed to get preference value"); + } + + if (preference_set_changed_cb(PREFERENCE_APP_GRAB_BACK_KEY, app_grab_back_key_changed_cb, NULL) != PREFERENCE_ERROR_NONE) + LOGW("Failed to set app_grab_back_key_changed_cb()"); + _ime_device = ecore_device_add(); if (_ime_device) { ecore_device_name_set (_ime_device, IME_DEVICE_NAME); @@ -3057,6 +3082,9 @@ void wayland_im_uninitialize () vconf_ignore_key_changed (VCONFKEY_MULTIVIEW_MODE, multiview_mode_changed_cb); #endif + if (preference_unset_changed_cb(PREFERENCE_APP_GRAB_BACK_KEY) != PREFERENCE_ERROR_NONE) + LOGW("Failed to unset app_grab_back_key_changed_cb()"); + if (_ime_device) { ecore_device_del (_ime_device); _ime_device = NULL; diff --git a/packaging/isf.spec b/packaging/isf.spec index 10ab905..27be5de 100644 --- a/packaging/isf.spec +++ b/packaging/isf.spec @@ -42,6 +42,7 @@ BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(capi-system-resource) +BuildRequires: pkgconfig(capi-appfw-preference) Requires(postun): /sbin/ldconfig Requires: org.tizen.isf-kbd-mode-changer -- 2.7.4