#include <libds/log.h>
#include <libds/single_pixel_buffer_v1.h>
-#include <cpu-boosting.h>
-
/* handle include for printing uint64_t */
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
static Eina_Bool need_send_released = EINA_FALSE;
static Eina_Bool need_send_motion = EINA_TRUE;
-static GMutex flush_mutex;
+static GMutex connection_mutex;
static int _e_comp_wl_hooks_delete = 0;
static int _e_comp_wl_hooks_walking = 0;
ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
}
- g_mutex_lock(&flush_mutex);
+ g_mutex_lock(&connection_mutex);
wl_display_flush_clients(e_comp_wl->wl.disp);
- g_mutex_unlock(&flush_mutex);
+ g_mutex_unlock(&connection_mutex);
if (e_config->key_input_ttrace_enable)
{
}
}
-void
-_e_comp_wl_main_thread_set_boosting()
+EINTERN void
+e_comp_wl_connection_lock()
{
- pid_t main_thread_id = e_input_main_thread_id_get();
- if (main_thread_id <= 0)
- {
- ERR("Failed to get main thread id");
- return;
- }
-
- TRACE_INPUT_BEGIN("_e_comp_wl_main_thread_set_boosting");
- resource_pid_t resource;
- resource.pid = 0;
- resource.tid = &main_thread_id;
- resource.tid_count = 1;
-
- int ret = resource_set_cpu_boosting(resource, CPU_BOOSTING_LEVEL_STRONG, CPU_BOOSTING_RESET_ON_FORK, -1);
- TRACE_INPUT_END();
-
- if (ret != 0)
- ERR("set_cpu_boosting failed. error %d", ret);
+ e_input_boost_lock(&connection_mutex);
}
-void
-_e_comp_wl_main_thread_clear_boosting()
+EINTERN void
+e_comp_wl_connection_unlock()
{
- pid_t main_thread_id = e_input_main_thread_id_get();
- if (main_thread_id <= 0)
- {
- ERR("Failed to get main thread id");
- return;
- }
-
- TRACE_INPUT_BEGIN("_e_comp_wl_main_thread_clear_boosting");
- resource_pid_t resource;
- resource.pid = 0;
- resource.tid = &main_thread_id;
- resource.tid_count = 1;
-
- int ret = resource_clear_cpu_boosting(resource);
- TRACE_INPUT_END();
-
- if (ret != 0)
- ERR("clear_cpu_boosting failed. error %d", ret);
-
+ e_input_boost_unlock(&connection_mutex);
}
void
E_Client *focused_ec;
if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
- if (!g_mutex_trylock(&flush_mutex))
- {
- TRACE_INPUT_BEGIN("flush_mutex lock");
- _e_comp_wl_main_thread_set_boosting();
- g_mutex_lock(&flush_mutex);
- _e_comp_wl_main_thread_clear_boosting();
- TRACE_INPUT_END();
- }
+ e_input_boost_lock(&connection_mutex);
focused_ec = e_client_focused_get();
if (focused_ec)
struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
if (!surface)
{
- g_mutex_unlock(&flush_mutex);
+ e_input_boost_unlock(&connection_mutex);
return;
}
wl_client_flush(wc);
}
- g_mutex_unlock(&flush_mutex);
+ e_input_boost_unlock(&connection_mutex);
}
static void
/* set compositor wayland data */
e_comp_wl = e_comp->wl_comp_data = wl_cdata;
- g_mutex_init(&flush_mutex);
+ g_mutex_init(&connection_mutex);
/* try to create a wayland display */
if (!(wl_cdata->wl.disp = wl_display_create()))
sock_err:
wl_display_destroy(wl_cdata->wl.disp);
disp_err:
- g_mutex_clear(&flush_mutex);
+ g_mutex_clear(&connection_mutex);
free(comp);
return EINA_FALSE;
}
EINTERN void e_comp_wl_display_flush();
EINTERN void e_comp_wl_focused_client_flush();
+EINTERN void e_comp_wl_connection_lock();
+EINTERN void e_comp_wl_connection_unlock();
+
EINTERN E_Client *e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource);
# endif
#include "e_input_private.h"
#include <Ecore_Input_Evas.h>
+#include <cpu-boosting.h>
+#include <pthread.h>
+
static int _e_input_hooks_delete = 0;
static int _e_input_hooks_walking = 0;
static pid_t _e_input_thread_id = 0;
static pid_t _e_input_main_thread_id = 0;
+static pthread_key_t thread_id_key = 0;
+static pthread_once_t once_init = PTHREAD_ONCE_INIT;
+static int _e_input_thread_error = 0;
static Eina_Inlist *_e_input_hooks[] =
{
return _e_input_thread_id;
}
+void
+e_input_init_thread()
+{
+ int ret = pthread_key_create(&thread_id_key, NULL);
+ if (ret < 0)
+ {
+ ERR("failed to create pthread_key");
+ }
+
+ _e_input_thread_error = ret;
+}
+
EINTERN void e_input_thread_id_set(pid_t tid)
{
_e_input_thread_id = tid;
+
+ pthread_once(&once_init, e_input_init_thread);
+ int ret = pthread_setspecific(thread_id_key, &_e_input_thread_id);
+ if (ret < 0)
+ {
+ ERR("failed to set thread specific");
+ }
+
+ _e_input_thread_error = ret;
}
E_API pid_t e_input_main_thread_id_get()
{
_e_input_main_thread_id = tid;
}
+
+void
+_e_input_main_thread_set_boosting()
+{
+ if (!pthread_getspecific(thread_id_key))
+ return;
+
+ pid_t main_thread_id = e_input_main_thread_id_get();
+ if (main_thread_id <= 0)
+ {
+ ERR("Failed to get main thread id");
+ return;
+ }
+
+ TRACE_INPUT_BEGIN(_e_input_main_thread_set_boosting);
+ resource_pid_t resource;
+ resource.pid = 0;
+ resource.tid = &main_thread_id;
+ resource.tid_count = 1;
+
+ int ret = resource_set_cpu_boosting(resource, CPU_BOOSTING_LEVEL_STRONG, CPU_BOOSTING_RESET_ON_FORK, -1);
+ TRACE_INPUT_END();
+
+ if (ret != 0)
+ ERR("set_cpu_boosting failed. error %d", ret);
+}
+
+void
+_e_input_main_thread_clear_boosting()
+{
+ if (!pthread_getspecific(thread_id_key))
+ return;
+
+ pid_t main_thread_id = e_input_main_thread_id_get();
+ if (main_thread_id <= 0)
+ {
+ ERR("Failed to get main thread id");
+ return;
+ }
+
+ TRACE_INPUT_BEGIN(_e_input_main_thread_clear_boosting);
+ resource_pid_t resource;
+ resource.pid = 0;
+ resource.tid = &main_thread_id;
+ resource.tid_count = 1;
+
+ int ret = resource_clear_cpu_boosting(resource);
+ TRACE_INPUT_END();
+
+ if (ret != 0)
+ ERR("clear_cpu_boosting failed. error %d", ret);
+
+}
+
+EINTERN void e_input_boost_lock(GMutex *mutex)
+{
+ if (!g_mutex_trylock(mutex))
+ {
+ _e_input_main_thread_set_boosting();
+ g_mutex_lock(mutex);
+ _e_input_main_thread_clear_boosting();
+ }
+}
+
+EINTERN void e_input_boost_unlock(GMutex *mutex)
+{
+ g_mutex_unlock(mutex);
+}
#define E_INPUT_REQUEST_SERVER ((void *)0x1)
#include <xkbcommon/xkbcommon.h>
+#include <glib.h>
+
#include "e_device.h"
#include "e_input_event.h"
E_API pid_t e_input_main_thread_id_get();
EINTERN void e_input_main_thread_id_set(pid_t tid);
+EINTERN void e_input_boost_lock(GMutex *mutex);
+EINTERN void e_input_boost_unlock(GMutex *mutex);
+
EINTERN void e_input_thread_run(E_Input_Backend *input);
EINTERN Eina_Bool e_input_libinput_context_create(E_Input_Backend *input);