Changed the priority of the isf daemon to the same as the client 22/309922/1
authorInhong Han <inhong1.han@samsung.com>
Thu, 18 Apr 2024 06:59:12 +0000 (15:59 +0900)
committerInhong Han <inhong1.han@samsung.com>
Thu, 18 Apr 2024 07:17:56 +0000 (16:17 +0900)
Change-Id: I0169c4d03a8f42d3c6d00c585562032eb635eaae

ism/extras/efl_panel/Makefile.am
ism/extras/efl_panel/isf_cpu_boosting.cpp [new file with mode: 0644]
ism/extras/efl_panel/isf_cpu_boosting.h [new file with mode: 0644]
ism/extras/efl_panel/isf_panel_efl.cpp
ism/extras/wayland_immodule/Makefile.am
ism/extras/wayland_immodule/wayland_imcontext.c

index 368badb..efa3638 100644 (file)
@@ -20,7 +20,8 @@ AM_CPPFLAGS = -I$(top_builddir) \
 noinst_HEADERS = isf_panel_utility.h \
                  remote_input.h \
                  remote_input_keycode.h \
-                 websocketserver.h
+                 websocketserver.h \
+                 isf_cpu_boosting.h
 
 if ISF_BUILD_PANEL_EFL
 CONFIG_SCIM_PANEL_EFL  = isf
@@ -30,7 +31,8 @@ bin_PROGRAMS           = $(CONFIG_SCIM_PANEL_EFL)
 
 isf_SOURCES  = isf_panel_efl.cpp \
                isf_panel_utility.cpp \
-               ../../src/tizen_profile.cpp
+               ../../src/tizen_profile.cpp \
+               isf_cpu_boosting.cpp
 
 if ISF_BUILD_REMOTE_INPUT
 isf_SOURCES  += remote_input.cpp
diff --git a/ism/extras/efl_panel/isf_cpu_boosting.cpp b/ism/extras/efl_panel/isf_cpu_boosting.cpp
new file mode 100644 (file)
index 0000000..9ec7fbe
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * ISF(Input Service Framework)
+ *
+ * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jihoon Kim <jihoon48.kim@samsung.com>
+ *
+ * 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
+ *
+ */
+
+#define Uses_SCIM_CONFIG_PATH
+
+#include <isf_cpu_boosting.h>
+#include <unistd.h>
+#include <dlog.h>
+#include <cpu-boosting.h>
+
+#include "scim.h"
+#include "isf_debug.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "ISF_CPU_BOOSTING"
+
+using namespace scim;
+
+CpuBooster* CpuBooster::m_instance = NULL;
+static resource_pid_t resource_st = {0,};
+static String destination = String ("");
+
+CpuBooster::CpuBooster()
+{
+    m_instance = this;
+    resource_st.pid = getpid();
+    destination = scim_global_config_read (String (SCIM_GLOBAL_CONFIG_DEFAULT_PANEL_PROGRAM), String (""));
+
+    int ret = resource_register_cpu_inheritance_destination(destination.c_str(), resource_st);
+    if (ret != 0)
+        LOGE("Failed to register cpu inheritance. ret : %d", ret);
+}
+
+CpuBooster::~CpuBooster()
+{
+    if (m_instance == this) {
+        m_instance = NULL;
+    }
+
+    int ret = resource_unregister_cpu_inheritance_destination(destination.c_str());
+    if (ret != 0)
+        LOGE("Failed to unregister cpu inheritance. ret : %d", ret);
+}
+
+CpuBooster*
+CpuBooster::get_instance()
+{
+    return m_instance;
+}
+
+void
+CpuBooster::set_cpu_boosting()
+{
+    int ret = resource_set_cpu_boosting(resource_st, CPU_BOOSTING_LEVEL_STRONG, CPU_BOOSTING_RESET_ON_FORK, -1);
+    if (ret != 0)
+        LOGE("Failed to set cpu boosting");
+}
+
+void
+CpuBooster::clear_cpu_boosting()
+{
+    int ret = resource_clear_cpu_boosting(resource_st);
+    if (ret != 0)
+        LOGE("Failed to clear cpu boosting");
+}
diff --git a/ism/extras/efl_panel/isf_cpu_boosting.h b/ism/extras/efl_panel/isf_cpu_boosting.h
new file mode 100644 (file)
index 0000000..e024912
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * ISF(Input Service Framework)
+ *
+ * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jihoon Kim <jihoon48.kim@samsung.com>
+ *
+ * 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 __ISF_CPU_BOOSTING_H__
+#define __ISF_CPU_BOOSTING_H__
+
+class CpuBooster
+{
+private:
+    static CpuBooster* m_instance;
+
+public:
+    CpuBooster();
+    ~CpuBooster();
+
+    static CpuBooster* get_instance();
+
+    void set_cpu_boosting();
+    void clear_cpu_boosting();
+};
+
+#endif /* __ISF_CPU_BOOSTING_H__ */
index 75cdd10..3ca31cd 100644 (file)
@@ -44,7 +44,6 @@
 #include <glib.h>
 #include <tzplatform_config.h>
 #include <system_info.h>
-#include <cpu-boosting.h>
 
 #include "scim_private.h"
 #include "scim.h"
@@ -82,6 +81,7 @@
 #include "privilege_checker.h"
 #include "remote_input.h"
 #include "tizen_profile.h"
+#include "isf_cpu_boosting.h"
 
 using namespace scim;
 
@@ -272,8 +272,6 @@ static void       show_ime_selector_notification       (void);
 static void       set_language_and_locale              (const char *lang_str);
 static bool       app_control_launch                   (const char *app_id);
 static void       terminate_active_ise                 (const String uuid);
-static void       set_cpu_boosting                     (void);
-static void       clear_cpu_boosting                   (void);
 
 /////////////////////////////////////////////////////////////////////////////
 // Declaration of internal variables.
@@ -6348,24 +6346,6 @@ static void terminate_active_ise (const String uuid)
     }
 }
 
-static void set_cpu_boosting ()
-{
-    resource_pid_t resource_st = {0,};
-    resource_st.pid = getpid();
-    int ret = resource_set_cpu_boosting(resource_st, CPU_BOOSTING_LEVEL_STRONG, CPU_BOOSTING_RESET_ON_FORK, -1);
-    if (ret != 0)
-        LOGE("Failed to set cpu boosting");
-}
-
-static void clear_cpu_boosting ()
-{
-    resource_pid_t resource_st = {0,};
-    resource_st.pid = getpid();
-    int ret = resource_clear_cpu_boosting(resource_st);
-    if (ret != 0)
-        LOGE("Failed to clear cpu boosting");
-}
-
 static void slot_run_helper (const String &uuid, const String &config, const String &display)
 {
     ISF_SAVE_LOG ("time:%ld  pid:%d  %s  %s  uuid(%s)",
@@ -7385,6 +7365,8 @@ int main (int argc, char *argv [])
     bool          user_data_path_exists = false;
     bool          user_data_path_is_dir = false;
 
+    CpuBooster    *booster        = NULL;
+
 #ifdef HAVE_ECOREX
     Ecore_Event_Handler *xclient_message_handler  = NULL;
     Ecore_Event_Handler *xwindow_property_handler = NULL;
@@ -7560,7 +7542,9 @@ int main (int argc, char *argv [])
     ConfigBase::set (_config);
     check_time ("create config instance");
 
-    set_cpu_boosting();
+    booster = new CpuBooster();
+    if (booster)
+        booster->set_cpu_boosting();
 
     try {
         if (!initialize_panel_agent (_config, display_name, should_resident)) {
@@ -7728,7 +7712,8 @@ int main (int argc, char *argv [])
     if (!isf_cynara_initialize())
         LOGW ("Failed to initialize cynara");
 
-    clear_cpu_boosting();
+    if (booster)
+        booster->clear_cpu_boosting();
 
 #if ISF_BUILD_CANDIDATE_UI
     elm_run ();
@@ -7786,6 +7771,9 @@ cleanup:
 #endif
     delete_ise_check_pid_alive_timer();
 
+    if (booster)
+        delete booster;
+
     if (_info_manager) {
         try {
             _info_manager->stop ();
index 9f06705..ad26e7b 100644 (file)
@@ -30,7 +30,8 @@ module_la_CFLAGS = @ECORE_CFLAGS@ \
                    @DLOG_CFLAGS@ \
                    @VCONF_CFLAGS@ \
                    @APP_COMMON_CFLAGS@ \
-                   @APP_PREFERENCE_CFLAGS@
+                   @APP_PREFERENCE_CFLAGS@ \
+                   @SYSTEM_RESOURCE_CFLAGS@
 
 module_la_LDFLAGS  = -rpath $(moduledir) \
                      -avoid-version \
@@ -46,4 +47,5 @@ module_la_LIBADD   = $(LD_VERSION_SCRIPT_OPTION) \
                      @VCONF_LIBS@ \
                      @APP_COMMON_LIBS@ \
                      @APP_PREFERENCE_LIBS@ \
+                     @SYSTEM_RESOURCE_LIBS@ \
                      $(top_builddir)/ism/src/libprofile.la
index 94bef64..2e99d8b 100644 (file)
@@ -45,6 +45,7 @@
 #include <xkbcommon/xkbcommon.h>
 #include <ctype.h>
 #include <app_preference.h>
+#include <cpu-boosting.h>
 
 #include "isf_debug.h"
 #include "wayland_imcontext.h"
@@ -77,6 +78,7 @@
 #define PREFERENCE_APP_GRAB_BACK_KEY    "app/grab/back_key"
 
 #define SOCK_PATH "/run/.isf/scim-panel-socket"
+#define DEFAULT_PANEL_NAME "isf"
 
 typedef enum {
     INPUT_LANG_URDU,
@@ -3282,9 +3284,27 @@ _prediction_hint_data_foreach_cb(const Eina_Hash *hash, const void *key,
     return EINA_TRUE;
 }
 
+static void
+_set_cpu_inheritance()
+{
+    int ret = resource_set_cpu_inheritance(gettid(), DEFAULT_PANEL_NAME, -1);
+    if (ret != 0)
+        LOGE("Failed to set cpu inheritance. ret : %d", ret);
+}
+
+static void
+_clear_cpu_inheritance()
+{
+    int ret = resource_clear_cpu_inheritance(gettid(), DEFAULT_PANEL_NAME);
+    if (ret != 0)
+        LOGE("Failed to clear cpu inheritance. ret : %d", ret);
+}
+
 void
 wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
 {
+    _set_cpu_inheritance();
+
     LOGD ("ctx : %p. enable : %d, on demand : %d", ctx,
           ecore_imf_context_input_panel_enabled_get(ctx),
           ecore_imf_context_input_panel_show_on_demand_get (ctx));
@@ -3312,6 +3332,7 @@ wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
             }
         }
         LOGW("ctx : %p. Fail to set focus!", ctx);
+        _clear_cpu_inheritance();
         return;
     }
 
@@ -3379,6 +3400,7 @@ wayland_im_context_focus_out(Ecore_IMF_Context *ctx)
     }
 
     set_focus_out(ctx);
+    _clear_cpu_inheritance();
 }
 
 void