From ce748e3c519e6d4985cf12592fac59523c91dca2 Mon Sep 17 00:00:00 2001 From: Wonkeun Oh Date: Tue, 7 Apr 2015 11:23:36 +0900 Subject: [PATCH] Added kbd-mode-changer package Change-Id: If2541b87364c0d770da9370f771f3fe925840f55 --- Makefile.am | 4 + configure.ac | 8 ++ ism/extras/Makefile.am | 2 +- ism/extras/kbd_mode_changer/Makefile.am | 41 ++++++++ ism/extras/kbd_mode_changer/include/main.h | 45 +++++++++ ism/extras/kbd_mode_changer/main.cpp | 108 +++++++++++++++++++++ org.tizen.isf-kbd-mode-changer.manifest | 5 + org.tizen.isf-kbd-mode-changer.xml | 9 ++ packaging/isf.spec | 22 +++++ 9 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 ism/extras/kbd_mode_changer/Makefile.am create mode 100644 ism/extras/kbd_mode_changer/include/main.h create mode 100644 ism/extras/kbd_mode_changer/main.cpp create mode 100644 org.tizen.isf-kbd-mode-changer.manifest create mode 100644 org.tizen.isf-kbd-mode-changer.xml diff --git a/Makefile.am b/Makefile.am index acd76e4f..4b74b8eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,10 @@ endif pkgconfig_DATA = isf.pc scim.pc \ $(GTK_UTILS_PKGCONFIG) +if ISF_BUILD_KBD_MODE_CHANGER +kbdmodechangerxmldir = /usr/share/packages/ +kbdmodechangerxml_DATA = org.tizen.isf-kbd-mode-changer.xml +endif if ISF_INSTALL_SYSTEMD_SCRIPT SYSTEMD_SCRIPT = scim.service diff --git a/configure.ac b/configure.ac index 2ad79433..37f69dc9 100644 --- a/configure.ac +++ b/configure.ac @@ -309,6 +309,9 @@ PKG_CHECK_MODULES(PACKAGE_MANAGER, [capi-appfw-package-manager]) # Check App Control PKG_CHECK_MODULES(APP_CONTROL, [capi-appfw-app-control]) +# Check appfw library +PKG_CHECK_MODULES(APPFW, [capi-appfw-application]) + # Check core package manager PKG_CHECK_MODULES(PKGMGR_INFO, [pkgmgr-info], [ISF_HAS_PKGMGR_INFO=yes], @@ -711,6 +714,9 @@ AM_CONDITIONAL(ISF_BUILD_DB_UTIL, AM_CONDITIONAL(ISF_INSTALL_SYSTEMD_SCRIPT, [test "$enable_lazy_launch" = "no"]) +AM_CONDITIONAL(ISF_BUILD_KBD_MODE_CHANGER, + [test "$ISF_HAS_ECOREX" = "yes"]) + AC_SUBST(SCIM_BUILD_TESTS) AC_SUBST(SCIM_BUILD_CONFIG_SIMPLE) AC_SUBST(SCIM_BUILD_CONFIG_SOCKET) @@ -729,6 +735,7 @@ AC_SUBST(ISF_BUILD_PANEL_EFL) AC_SUBST(ISF_BUILD_WITH_GCONF) AC_SUBST(ISF_BUILD_DB_UTIL) AC_SUBST(ISF_INSTALL_SYSTEMD_SCRIPT) +AC_SUBST(ISF_BUILD_KBD_MODE_CHANGER) ISF_BUILDING_DLL="-DISF_BUILDING_DLL" AC_SUBST(ISF_BUILDING_DLL) @@ -775,6 +782,7 @@ AC_CONFIG_FILES([Makefile ism/extras/gtk2_immodule/Makefile ism/extras/efl_immodule/Makefile ism/extras/efl_panel/Makefile + ism/extras/kbd_mode_changer/Makefile ism/extras/efl_wsm/Makefile ism/extras/efl_wsc/Makefile ism/demos/Makefile diff --git a/ism/extras/Makefile.am b/ism/extras/Makefile.am index 73c28a64..2246890a 100644 --- a/ism/extras/Makefile.am +++ b/ism/extras/Makefile.am @@ -18,4 +18,4 @@ MAINTAINERCLEANFILES = Makefile.in CLEANFILES = *.bak -SUBDIRS = gtk2_immodule efl_panel efl_immodule efl_wsm efl_wsc +SUBDIRS = gtk2_immodule efl_panel efl_immodule kbd_mode_changer efl_wsm efl_wsc diff --git a/ism/extras/kbd_mode_changer/Makefile.am b/ism/extras/kbd_mode_changer/Makefile.am new file mode 100644 index 00000000..83c94530 --- /dev/null +++ b/ism/extras/kbd_mode_changer/Makefile.am @@ -0,0 +1,41 @@ +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *.bak + +INCLUDES = -I$(top_builddir) \ + -I$(top_builddir)/ism/src \ + -I$(top_srcdir) \ + -I$(top_srcdir)/ism/src \ + -I$(top_srcdir)/ism/intl \ + -I$(top_srcdir)/ism/data \ + -I$(top_srcdir)/ism/utils \ + -I$(top_srcdir)/ism/extras/kbd_mode_changer/include \ + -I$(includedir) \ + -DSCIM_DATADIR=\"@SCIM_DATADIR@\" \ + -DSCIM_LOCALEDIR=\"@SCIM_LOCALEDIR@\" \ + -DSCIM_SYSCONFDIR=\"@SCIM_SYSCONFDIR@\" \ + -DSCIM_LIBEXECDIR=\"@SCIM_LIBEXECDIR@\" \ + -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" \ + -DSCIM_MODULE_PATH=\"@SCIM_MODULE_PATH@\" \ + -DSCIM_TEMPDIR=\"@SCIM_TEMPDIR@\" + + +noinst_HEADERS = + +if ISF_BUILD_KBD_MODE_CHANGER +ISF_KBD_MODE_CHANGER = isf-kbd-mode-changer +endif + +appexecdir = /usr/apps/org.tizen.isf-kbd-mode-changer/bin/ +appexec_PROGRAMS = $(ISF_KBD_MODE_CHANGER) + +isf_kbd_mode_changer_SOURCES = main.cpp + +isf_kbd_mode_changer_CXXFLAGS = @EFL_CFLAGS@ \ + @DLOG_CFLAGS@ \ + @APPFW_CFLAGS@ + +isf_kbd_mode_changer_LDFLAGS = @EFL_LIBS@ -rpath $(libdir)\ + @DLOG_LIBS@ \ + @APPFW_LIBS@ + +isf_kbd_mode_changer_LDADD = $(top_builddir)/ism/src/libscim@SCIM_EPOCH@.la diff --git a/ism/extras/kbd_mode_changer/include/main.h b/ism/extras/kbd_mode_changer/include/main.h new file mode 100644 index 00000000..3dfb456d --- /dev/null +++ b/ism/extras/kbd_mode_changer/include/main.h @@ -0,0 +1,45 @@ +/* + * ISF(Input Service Framework) + * + * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. + * Copyright (c) 2012-2014 Samsung Electronics Co., Ltd. + * + * Contact: Wonkeun Oh , Jihoon Kim + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#include +#include +#include + +#if !defined(PACKAGE) +# define PACKAGE "isf-kbd-mode-changer" +#endif + +#if !defined(PKGNAME) +# define PKGNAME "org.tizen.isf-kbd-mode-changer" +#endif + +#ifdef LOG_TAG +# undef LOG_TAG +#endif +#define LOG_TAG "ISF_KBD_MODE_CHANGER" + +#endif /* __MAIN_H__ */ diff --git a/ism/extras/kbd_mode_changer/main.cpp b/ism/extras/kbd_mode_changer/main.cpp new file mode 100644 index 00000000..304466fc --- /dev/null +++ b/ism/extras/kbd_mode_changer/main.cpp @@ -0,0 +1,108 @@ +/* + * ISF(Input Service Framework) + * + * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. + * Copyright (c) 2012-2014 Samsung Electronics Co., Ltd. + * + * Contact: Wonkeun Oh , Jihoon Kim + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include "main.h" + +typedef enum +{ + TOOLBAR_KEYBOARD_MODE = 0, /* Hardware keyboard ISE */ + TOOLBAR_HELPER_MODE /* Software keyboard ISE */ +} TOOLBAR_MODE_T; + + +#define E_PROP_DEVICEMGR_INPUTWIN "DeviceMgr Input Window" +#define E_PROP_DEVICEMGR_CONTROLWIN "_ISF_CONTROL_WINDOW" +#define PROP_X_EXT_KEYBOARD_INPUT_DETECTED "HW Keyboard Input Started" +#define PROP_X_EXT_KEYBOARD_EXIST "X External Keyboard Exist" + + +bool app_create (void *user_data) +{ + LOGD ("app create"); + return true; +} + +void app_control (app_control_h app_control, void *user_data) +{ + LOGD ("%s", __func__); + + Ecore_X_Atom prop_x_keyboard_input_detected = 0; + TOOLBAR_MODE_T kbd_mode = TOOLBAR_HELPER_MODE; + Ecore_X_Window _control_win = 0; + Ecore_X_Window _input_win = 0; + int ret = 0; + unsigned int val = 0; + + LOGD ("isf_extra_hwkbd_module start"); + + Ecore_X_Atom atom = ecore_x_atom_get (E_PROP_DEVICEMGR_CONTROLWIN); + ecore_x_window_prop_xid_get (ecore_x_window_root_first_get (), atom, ECORE_X_ATOM_WINDOW, &_control_win, 1); + + if (!prop_x_keyboard_input_detected) + prop_x_keyboard_input_detected = ecore_x_atom_get (PROP_X_EXT_KEYBOARD_INPUT_DETECTED); + + if (ecore_x_window_prop_card32_get (_control_win, prop_x_keyboard_input_detected, &val, 1) > 0) { + if (val == 1) { + kbd_mode = TOOLBAR_KEYBOARD_MODE; + } else { + kbd_mode = TOOLBAR_HELPER_MODE; + } + } else { + kbd_mode = TOOLBAR_HELPER_MODE; + } + + // get the input window + atom = ecore_x_atom_get (E_PROP_DEVICEMGR_INPUTWIN); + ret = ecore_x_window_prop_xid_get (ecore_x_window_root_first_get (), atom, ECORE_X_ATOM_WINDOW, &_input_win, 1); + + //Set the window property value; + if (kbd_mode == TOOLBAR_KEYBOARD_MODE) { + val = 0; + ecore_x_window_prop_card32_set (_input_win, ecore_x_atom_get (PROP_X_EXT_KEYBOARD_EXIST), &val, 1); + LOGD ("keyboard mode is changed HW -> SW by isf-kbd-mode-changer"); + } + ui_app_exit (); +} + +void app_terminate (void *user_data) +{ + LOGD ("app terminated"); +} + +int main (int argc, char *argv []) +{ + + ui_app_lifecycle_callback_s event_callback = {0,}; + + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.app_control = app_control; + + LOGD ("start org.tizen.isf-kbd-mode-changer"); + + return ui_app_main (argc, argv, &event_callback, NULL); + +} diff --git a/org.tizen.isf-kbd-mode-changer.manifest b/org.tizen.isf-kbd-mode-changer.manifest new file mode 100644 index 00000000..017d22d3 --- /dev/null +++ b/org.tizen.isf-kbd-mode-changer.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/org.tizen.isf-kbd-mode-changer.xml b/org.tizen.isf-kbd-mode-changer.xml new file mode 100644 index 00000000..556cb818 --- /dev/null +++ b/org.tizen.isf-kbd-mode-changer.xml @@ -0,0 +1,9 @@ + + + + Jihoon Kim + isf-kbd-mode-changer + + + + diff --git a/packaging/isf.spec b/packaging/isf.spec index e3106f31..d0ce014c 100644 --- a/packaging/isf.spec +++ b/packaging/isf.spec @@ -33,11 +33,13 @@ BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(capi-appfw-app-control) +BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: capi-appfw-package-manager-devel Requires(post): /sbin/ldconfig /usr/bin/vconftool Requires(postun): /sbin/ldconfig %define _optexecdir /opt/usr/devel/usr/bin/ +%define APP_PREFIX %{_prefix}/apps/org.tizen.isf-kbd-mode-changer/bin/ %description Input Service Framewok (ISF) is an input method (IM) platform, and it has been derived from SCIM. @@ -50,6 +52,16 @@ Requires: %{name} = %{version}-%{release} %description devel This package contains ISF header files for ISE development. +%if %{without wayland} +%package -n org.tizen.isf-kbd-mode-changer +Summary: isf-kbd-mode-changer +Group: Application +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.isf-kbd-mode-changer +isf-kbd-mode-changer +%endif + %prep %setup -q cp %{SOURCE1001} . @@ -177,3 +189,13 @@ cat scim.lang > isf.lang %{_libdir}/libscim-*.so %{_libdir}/pkgconfig/isf.pc %{_libdir}/pkgconfig/scim.pc + +%if %{without wayland} +%post -n org.tizen.isf-kbd-mode-changer +mkdir -p /usr/apps/org.tizen.isf-kbd-mode-changer + +%files -n org.tizen.isf-kbd-mode-changer +%manifest org.tizen.isf-kbd-mode-changer.manifest +/usr/share/packages/org.tizen.isf-kbd-mode-changer.xml +%{APP_PREFIX}/* +%endif -- 2.34.1