SET(INC_DIR include)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(requires "dlog capi-base-common ecore ecore-input evas")
-IF (WITH_WAYLAND)
- ADD_DEFINITIONS("-DWAYLAND")
- SET(requires "${requires} ecore-wayland")
-ENDIF (WITH_WAYLAND)
-IF (WITH_X11)
- ADD_DEFINITIONS("-DX11")
- SET(requires "${requires} ecore-x utilX")
-ENDIF (WITH_X11)
-
+SET(requires "dlog capi-base-common ecore ecore-input evas ecore-wayland")
SET(pc_requires "capi-base-common")
INCLUDE(FindPkgConfig)
-%bcond_with x
-%bcond_with wayland
-
Name: capi-system-media-key
Summary: A System Information library in SLP C API
Version: 0.1.0
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(ecore-input)
BuildRequires: pkgconfig(evas)
-
-%if %{with x}
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(utilX)
-%endif
-%if %{with wayland}
BuildRequires: pkgconfig(ecore-wayland)
-%endif
%description
%{summary}.
-
%package devel
Summary: A Media Key library in SLP C API (Development)
Group: System/API
%build
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-%if %{with wayland}
--DWITH_WAYLAND=TRUE
-%endif
-%if %{with x}
--DWITH_X11=TRUE
-%endif
+%cmake -DFULLVER=%{version} \
+ -DMAJORVER=${MAJORVER} \
+ .
make %{?jobs:-j%jobs}
%files
%manifest %{name}.manifest
-%license LICENSE
+%license LICENSE
%{_libdir}/libcapi-system-media-key.so.*
%manifest capi-system-media-key.manifest
%{_includedir}/system/media_key.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-system-media-key.so
-
-
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Input.h>
-#if defined(X11)
-#include <Ecore_X.h>
-#include <utilX.h>
-#elif defined(WAYLAND)
#include <Ecore_Wayland.h>
-#endif
#include <dlog.h>
static Ecore_Event_Handler *media_key_up;
static Ecore_Event_Handler *media_key_down;
-#if defined(X11)
-static Ecore_X_Window win;
-#endif
-
static int _media_key_init(void)
{
if (_media_key_initialized)
return 0;
-#if defined(X11)
- ecore_x_init(NULL);
-
- win = ecore_x_window_input_new(ecore_x_window_root_first_get(), 0, 0, 1, 1);
- if (!win) {
- LOGE("failed to create input window");
- return -1;
- }
- ecore_x_icccm_title_set(win, "media key receiver");
- ecore_x_netwm_name_set(win, "media key receiver");
- ecore_x_netwm_pid_set(win, getpid());
-#elif defined(WAYLAND)
ecore_wl_init(NULL);
-#endif
_media_key_initialized = 1;
return 0;
static void _media_key_fini(void)
{
-#if defined(X11)
- ecore_x_window_free(win);
- ecore_x_shutdown();
-#elif defined(WAYLAND)
ecore_wl_shutdown();
-#endif
_media_key_initialized = 0;
}
static int _grab_media_key(void)
{
int i;
-#if defined(X11)
- int ret;
-#elif defined(WAYLAND)
Eina_Bool ret;
-#endif
-
for (i = 0; media_keys[i].key_str; i++) {
-#if defined(X11)
- ret = utilx_grab_key(ecore_x_display_get(), win,
- media_keys[i].key_str, OR_EXCLUSIVE_GRAB);
- if (ret < 0) {
- LOGE("failed to grab key: %s", media_keys[i].key_str);
- for (i = i - 1; i >= 0; i--)
- utilx_ungrab_key(ecore_x_display_get(), win,
- media_keys[i].key_str);
-
- return ret;
- }
-#elif defined(WAYLAND)
ret = ecore_wl_window_keygrab_set(NULL, media_keys[i].key_str,
0, 0, 0, ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE);
if (ret != EINA_TRUE) {
return -1;
}
-#endif
}
return 0;
static int _ungrab_media_key(void)
{
int i;
-#if defined(X11)
- int ret;
-#elif defined(WAYLAND)
Eina_Bool ret;
-#endif
for (i = 0; media_keys[i].key_str; i++) {
-#if defined(X11)
- ret = utilx_ungrab_key(ecore_x_display_get(), win,
- media_keys[i].key_str);
- if (ret)
- LOGE("failed to ungrab key: %s", media_keys[i].key_str);
-#elif defined(WAYLAND)
ret = ecore_wl_window_keygrab_unset(NULL, media_keys[i].key_str, 0, 0);
if (ret != EINA_TRUE)
LOGE("failed to ungrab key: %s", media_keys[i].key_str);
-#endif
}
return 0;