From: Kibum Kim Date: Fri, 6 Jan 2012 15:48:46 +0000 (+0900) Subject: Git init X-Git-Tag: accepted/2.0alpha-wayland/20130117.213713~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d840ba7ad156c95c8caac7c334ae2354a2d9f6bc;hp=53096f6974850e1ac26414ff4bbfe5d632ab0c07;p=profile%2Fivi%2Flibslp-utilx.git Git init --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..5a3e1bb --- /dev/null +++ b/AUTHORS @@ -0,0 +1,3 @@ +Doyoun Kang +Sung-Jin Park +Gwangyeong Mun diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4574814 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,47 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(utilX C) + +SET(SRCS x11.c) +SET(HEADERS utilX.h) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "\${prefix}") +SET(LIBDIR "\${prefix}/lib") +SET(INCLUDEDIR "\${prefix}/include") +SET(VERSION_MAJOR 1) +SET(VERSION "${VERSION_MAJOR}.1.0") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED x11) +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g") +#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DFACTORYFS=\"${PREFIX}\"") +#ADD_DEFINITIONS("-DDEBUG") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) + +FOREACH(hfile ${HEADERS}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include) +ENDFOREACH(hfile) + +#ADD_SUBDIRECTORY(test) + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..4ec25ed --- /dev/null +++ b/COPYING @@ -0,0 +1,14 @@ +Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..0739dfa --- /dev/null +++ b/debian/README @@ -0,0 +1,6 @@ +The Debian Package libslp-utilx +---------------------------- + +Comments regarding the Package + + -- unknown Fri, 13 Nov 2009 20:11:57 +0900 diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..bb4944e --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,6 @@ +libslp-utilx for Debian +---------------------- + + + + -- unknown Fri, 13 Nov 2009 20:11:57 +0900 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..0098e07 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,456 @@ +libslp-utilx (0.1.7-0) unstable; urgency=low + + * Add an API - utilx_show_capture_effect. + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.7-0 + + -- Gwangyeong Mun Wed, 23 Nov 2011 18:36:43 +0900 + +libslp-utilx (0.1.6-0) unstable; urgency=low + + * Add an API - utilx_get_indicator_state. + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.6-0 + + -- Doyoun Kang Wed, 09 Nov 2011 14:06:14 +0900 + +libslp-utilx (0.1.5-4) unstable; urgency=low + + * Add utilx_s[g]et_window_cardinal_property. + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.5-4 + + -- Boram Park Fri, 21 Oct 2011 16:49:40 +0900 + +libslp-utilx (0.1.5-3) unstable; urgency=low + + * FIX : screen_capture should work even if root_window doesn't have _CB_SCREEN_CAPTURE_DISABLE. + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.5-3 + + -- Boram Park Thu, 20 Oct 2011 16:30:06 +0900 + +libslp-utilx (0.1.5-2) unstable; urgency=low + + * Add utilx_s[g]et_screen_capture. + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.5-2 + + -- Boram Park Thu, 20 Oct 2011 16:05:36 +0900 + +libslp-utilx (0.1.5-1) unstable; urgency=low + + * Changed the boilerplate of sources + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.5-1 + + -- Doyoun Kang Thu, 20 Oct 2011 15:36:18 +0900 + +libslp-utilx (0.1.5-0) unstable; urgency=low + + * Bug fix in utilx_grab_key() for OR_EXCLUSIVE_GRAB mode + * Add an API:utilx_get_key_status() + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.5-0 + + -- Sung-Jin Park Thu, 13 Oct 2011 16:01:50 +0900 + +libslp-utilx (0.1.4-1) unstable; urgency=low + + * Add key symbol strings for Earjack/BT Headset/Multimedia keys + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.4-1 + + -- Sung-Jin Park Tue, 11 Oct 2011 09:53:48 +0900 + +libslp-utilx (0.1.4-0) unstable; urgency=low + + * Add a API - utilx_get_system_notification_level + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.4-0 + + -- Doyoun Kang Tue, 04 Oct 2011 12:37:05 +0900 + +libslp-utilx (0.1.3-1) unstable; urgency=low + + * Add overrridable EXCLUSIVE_GRAB mode (OR_EXCLUSIVE_GRAB) in utilx_grab_key()/utilx_ungrab_key() + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.3-1 + + -- Sung-Jin Park Wed, 21 Sep 2011 15:26:16 +0900 + +libslp-utilx (0.1.3-0) unstable; urgency=low + + * Add a API - utilx_set_window_opaque_state + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.3-0 + + -- Doyoun Kang Tue, 20 Sep 2011 11:21:57 +0900 + +libslp-utilx (0.1.2-0) unstable; urgency=low + + * Restore a API (utilx_enable_indicator) + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.2-0 + + -- Doyoun Kang Tue, 26 Jul 2011 01:01:25 +0900 + +libslp-utilx (0.1.1-23) unstable; urgency=low + + * Removed unused APIs + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-23 + + -- Doyoun Kang Mon, 25 Jul 2011 11:21:07 +0900 + +libslp-utilx (0.1.1-22) unstable; urgency=low + + * Fixes build warning (by Hyunsuk Oh) + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-22 + + -- Doyoun Kang Tue, 29 Mar 2011 10:45:00 +0900 + +libslp-utilx (0.1.1-21) unstable; urgency=low + + * [COMP] Disable Demo Feature : Live Magazine & Menu-Screen Demo Animation + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-21 + + -- Gwangyeong Mun Mon, 14 Feb 2011 14:59:00 +0900 + +libslp-utilx (0.1.1-20) unstable; urgency=low + + * [COMP] Add Demo Feature : Live Magazine & Menu-Screen Demo Animation + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-20 + + -- Gwangyeong Mun Tue, 08 Feb 2011 14:34:06 +0900 + +libslp-utilx (0.1.1-19) unstable; urgency=low + + * Add UTILX_SS_SLOT_ID_NONE enumeration. + * Remove Warning messages + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-19 + + -- Gwangyeong Mun Sun, 16 Jan 2011 19:02:12 +0900 + +libslp-utilx (0.1.1-18) unstable; urgency=low + + * [COMP] change effect type, effect style's enum string more clearly. + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-18 + + -- Gwangyeong Mun Mon, 27 Dec 2010 17:21:23 +0900 + +libslp-utilx (0.1.1-17) unstable; urgency=low + + * [COMP] add custom effect related api + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-17 + + -- Gwangyeong Mun Wed, 22 Dec 2010 18:25:17 +0900 + +libslp-utilx (0.1.1-16) unstable; urgency=low + + * Disable debug mode + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-16 + + -- Doyoun Kang Wed, 22 Dec 2010 10:34:51 +0900 + +libslp-utilx (0.1.1-15) unstable; urgency=low + + * Modify not to call retvm_if() and DBG + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-15 + + -- Sung-Jin Park Wed, 15 Dec 2010 16:08:50 +0900 + +libslp-utilx (0.1.1-14) unstable; urgency=low + + * Remove a dependency on libslp-applog-dev + * Git: 165.213.180.234:slp/pkgs/l/libslp-utilx + * Tag: libslp-utilx_0.1.1-14 + + -- Sung-Jin Park Wed, 15 Dec 2010 14:39:37 +0900 + +libslp-utilx (0.1.1-13) unstable; urgency=low + + * Add KEY_CANCEL into utilX.h + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-13 + + -- Sung-Jin Park Fri, 03 Dec 2010 16:19:58 +0900 + +libslp-utilx (0.1.1-12) unstable; urgency=low + + * Update Documentation + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-12 + + -- Doyoun Kang Thu, 11 Nov 2010 09:57:39 +0900 + +libslp-utilx (0.1.1-11) unstable; urgency=low + + * Add APIs for activating with group + * Modify utilx_set_window_rotation_angle function to set old and new angle values + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-11 + + -- Doyoun Kang Mon, 08 Nov 2010 11:37:59 +0900 + +libslp-utilx (0.1.1-10) unstable; urgency=low + + * Add macros related the length of string corresponds to each hard key + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-10 + + -- Sung-Jin Park Fri, 29 Oct 2010 17:20:31 +0900 + +libslp-utilx (0.1.1-9) unstable; urgency=low + + * [COMP] change window effect related name + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-9 + + -- Gwangyeong Mun Sun, 24 Oct 2010 15:25:03 +0900 + +libslp-utilx (0.1.1-8) unstable; urgency=low + + * 1. Update documentation + 2. Add boilerplate in source files + 3. Add COPYING,AUTHORS files + 4. Remedy debian/copyright file + 5. Remove test directory + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-8 + + -- Doyoun Kang Fri, 22 Oct 2010 14:25:35 +0900 + +libslp-utilx (0.1.1-7) unstable; urgency=low + + * Update documentation about Window Effect for doxygen + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-7 + + -- Gwangyeong Mun Fri, 01 Oct 2010 17:19:22 +0900 + +libslp-utilx (0.1.1-6) unstable; urgency=low + + * [COMP] add XSync when effect property is changed. + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-6 + + -- Gwangyeong Mun Mon, 20 Sep 2010 21:25:09 +0900 + +libslp-utilx (0.1.1-5) unstable; urgency=low + + * Change documentation about key grab/ungrab for doxygen + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-5 + + -- Sung-Jin Park Tue, 07 Sep 2010 18:50:26 +0900 + +libslp-utilx (0.1.1-4) unstable; urgency=low + + * [COMP] Add Feature : set/get window effect state and set fake launch effect + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-4 + + -- Gwangyeong Mun Tue, 07 Sep 2010 16:49:12 +0900 + +libslp-utilx (0.1.1-3) unstable; urgency=low + + * Disable debugging log. + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-3 + + -- Doyoun Kang Tue, 31 Aug 2010 16:31:35 +0900 + +libslp-utilx (0.1.1-2) unstable; urgency=low + + * Remove deprecated APIs and remove dependency with sysman and heynoti libraries. + * Git: 165.213.180.234:/git/slp/pkgs/libslp-utilx + * Tag: libslp-utilx_0.1.1-2 + + -- Doyoun Kang Mon, 19 Jul 2010 15:34:50 +0900 + +libslp-utilx (0.1.1-1) unstable; urgency=low + + * Change doxygen documentation. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.1-1 + + -- Doyoun Kang Tue, 13 Jul 2010 15:48:51 +0900 + +libslp-utilx (0.1.1-0) unstable; urgency=low + + * Change/Add APIs. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.1-0 + + -- Doyoun Kang Thu, 24 Jun 2010 11:20:53 +0900 + +libslp-utilx (0.1.0-24) unstable; urgency=low + + * Remove postinst file for DAC. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-24 + + -- Doyoun Kang Thu, 03 Jun 2010 13:30:31 +0900 + +libslp-utilx (0.1.0-23) unstable; urgency=low + + * Change code according to changing of heynoti APIs. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-23 + + -- Doyoun Kang Tue, 01 Jun 2010 11:26:52 +0900 + +libslp-utilx (0.1.0-22) unstable; urgency=low + + * Remove libslp-util dependency. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-22 + + -- Doyoun Kang Sun, 30 May 2010 13:51:09 +0900 + +libslp-utilx (0.1.0-21) unstable; urgency=low + + * Modify utilX.pc file to link sysman and heynoti library. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-21 + + -- Doyoun Kang Fri, 28 May 2010 09:58:17 +0900 + +libslp-utilx (0.1.0-20) unstable; urgency=low + + * Replace deprecated core_util_xxx APIs to another APIs. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-20 + + -- Doyoun Kang Thu, 27 May 2010 16:07:30 +0900 + +libslp-utilx (0.1.0-19) unstable; urgency=low + + * Change debian control file to include libslp-utilx-dev from the SDK. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-19 + + -- Doyoun Kang Tue, 25 May 2010 22:30:42 +0900 + +libslp-utilx (0.1.0-18) unstable; urgency=low + + * Change debian control file to exclude from the SDK. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-18 + + -- Doyoun Kang Mon, 03 May 2010 12:01:16 +0900 + +libslp-utilx (0.1.0-17) unstable; urgency=low + + * Add postinst file. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-utilx-0 + * Tag: libslp-utilx_0.1.0-17 + + -- Doyoun Kang Wed, 21 Apr 2010 13:39:01 +0900 + +libslp-utilx (0.1.0-16) unstable; urgency=low + + * Repackaging (Modify x11.c not to change focus window if lower window is not current focus window.) + + -- Doyoun Kang Wed, 31 Mar 2010 15:53:46 +0900 + +libslp-utilx (0.1.0-15) unstable; urgency=low + + * Modify x11.c not to change focus window if lower window is not current focus window. + + -- Doyoun Kang Wed, 31 Mar 2010 14:27:35 +0900 + +libslp-utilx (0.1.0-14) unstable; urgency=low + + * Update revision for ToolChain upgrage + + -- Sung-Jin Park Fri, 26 Mar 2010 13:37:37 +0900 + +libslp-utilx (0.1.0-13) unstable; urgency=low + + * Add code for sending "_NET_ACTIVE_WINDOW" client message to raised window. + + -- Doyoun Kang Mon, 01 Mar 2010 17:06:23 +0900 + +libslp-utilx (0.1.0-12) unstable; urgency=low + + * Remove applog.h from package + Modify debian/control to add a dependency with libslp-applog-dev package + + -- Sung-Jin Park Thu, 25 Feb 2010 15:56:59 +0900 + +libslp-utilx (0.1.0-11) unstable; urgency=low + + * Add exception routines + + -- Sung-Jin Park Tue, 23 Feb 2010 23:43:40 +0900 + +libslp-utilx (0.1.0-10) unstable; urgency=low + + * Fix x11.c not to process events when error occurs + + -- Sung-Jin Park Tue, 23 Feb 2010 19:42:07 +0900 + +libslp-utilx (0.1.0-9) unstable; urgency=low + + * Remove __FILENAME__ macro + + -- Sung-Jin Park Thu, 18 Feb 2010 21:04:16 +0900 + +libslp-utilx (0.1.0-8) unstable; urgency=low + + * Fix Exclusive mode error + + -- Sung-Jin Park Fri, 12 Feb 2010 19:13:43 +0900 + +libslp-utilx (0.1.0-7) unstable; urgency=low + + * Fix exclusive mode grab functions + + -- Sung-Jin Park Thu, 11 Feb 2010 22:21:50 +0900 + +libslp-utilx (0.1.0-6) unstable; urgency=low + + * Fix function names with changed external function names + + -- Sung-Jin Park Wed, 27 Jan 2010 10:06:14 +0900 + +libslp-utilx (0.1.0-5) unstable; urgency=low + + * Change all things start with SLP_, SLP- and SLP + + -- Sung-Jin Park Tue, 26 Jan 2010 18:40:28 +0900 + +libslp-utilx (0.1.0-4) unstable; urgency=low + + * Modify utilX.h file (add #include ) + + -- Sung-Jin Park Fri, 22 Jan 2010 22:18:11 +0900 + +libslp-utilx (0.1.0-3) unstable; urgency=low + + * Change APIs related to key grab + 2 newly-added APIs, 3 deprecated APIs and 2 removed APIs + + -- Sung-Jin Park Fri, 22 Jan 2010 19:07:59 +0900 + +libslp-utilx (0.1.0-2) unstable; urgency=low + + * Add to the isntall list + + -- wonguk.jeong Mon, 30 Nov 2009 09:32:01 +0000 + +libslp-utilx (0.1.0-1) unstable; urgency=low + + * Initial Release. + + -- wonguk.jeong Fri, 13 Nov 2009 20:11:57 +0900 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..679cd19 --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: libslp-utilx +Section: libs +Priority: extra +Maintainer: Doyoun Kang , Sung-Jin Park , Gwangyeong Mun +Build-Depends: debhelper (>= 5), autotools-dev, libx11-dev +Standards-Version: 3.7.2 + +Package: libslp-utilx-dev +Section: libs +Architecture: any +Depends: libslp-utilx-0 (= ${Source-Version}), libx11-dev +Description: Utilities of Xwindow (development files) + Utility functions for the XWindow + +Package: libslp-utilx-0 +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libx11-6 +Description: Utilities of Xwindow (shared object files) + Utility functions for the XWindow diff --git a/debian/copyright b/debian/copyright new file mode 100755 index 0000000..c3dc47f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,7 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License version 2.1. + +The full text of the LGPL 2.1 can be found in +/usr/share/common-licenses diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..ca882bb --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..a0f0008 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +CMakeLists.txt diff --git a/debian/libsl-utilx-0.install.in b/debian/libsl-utilx-0.install.in new file mode 100644 index 0000000..bf766f0 --- /dev/null +++ b/debian/libsl-utilx-0.install.in @@ -0,0 +1 @@ +@PREFIX@/lib/*.so* diff --git a/debian/libsl-utilx-dev.install.in b/debian/libsl-utilx-dev.install.in new file mode 100644 index 0000000..0f2a4da --- /dev/null +++ b/debian/libsl-utilx-dev.install.in @@ -0,0 +1,2 @@ +@PREFIX@/include/* +@PREFIX@/lib/pkgconfig/*.pc diff --git a/debian/libslp-utilx-0.install.in b/debian/libslp-utilx-0.install.in new file mode 100644 index 0000000..bf766f0 --- /dev/null +++ b/debian/libslp-utilx-0.install.in @@ -0,0 +1 @@ +@PREFIX@/lib/*.so* diff --git a/debian/libslp-utilx-dev.install.in b/debian/libslp-utilx-dev.install.in new file mode 100644 index 0000000..0f2a4da --- /dev/null +++ b/debian/libslp-utilx-dev.install.in @@ -0,0 +1,2 @@ +@PREFIX@/include/* +@PREFIX@/lib/pkgconfig/*.pc diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8cb0a15 --- /dev/null +++ b/debian/rules @@ -0,0 +1,117 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +CFLAGS ?= -Wall -g +LDFLAGS ?= +PREFIX ?= /usr +DATADIR ?= /opt + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX) + + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/wavplayer.sgml > wavplayer.1 + + for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ + cat $$f > $${f%.in}; \ + sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \ + sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \ + done + + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + rm -rf CMakeCache.txt + rm -rf CMakeFiles + rm -rf cmake_install.cmake + rm -rf Makefile + rm -rf install_manifest.txt + rm -rf *.so + + for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ + rm -f $${f%.in}; \ + done + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/wavplayer. + $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs -plibslp-utilx-0 + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/packaging/libslp-utilx.spec b/packaging/libslp-utilx.spec new file mode 100644 index 0000000..98828e3 --- /dev/null +++ b/packaging/libslp-utilx.spec @@ -0,0 +1,59 @@ +Name: libslp-utilx +Summary: utilX +Version: 0.1.4 +Release: 0 +Group: System/Libraries +License: SAMSUNG +Source0: %{name}-%{version}.tar.gz +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +BuildRequires: cmake +BuildRequires: pkgconfig(x11) + +%description +Utility functions for the XWindow + + +%package devel +Summary: utilX +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Utility functions for the XWindow (developement files) + +%prep +%setup -q + + +%build +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%defattr(-,root,root,-) +/usr/lib/libutilX.so.* + + +%files devel +%defattr(-,root,root,-) +/usr/include/utilX.h +/usr/lib/libutilX.so +/usr/lib/pkgconfig/utilX.pc + + + + diff --git a/utilX.h b/utilX.h new file mode 100644 index 0000000..1644b22 --- /dev/null +++ b/utilX.h @@ -0,0 +1,1336 @@ +/* + * libslp-utilx + * + Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + * + */ + +#ifndef __SAMSUNG_LINUX_UTIL_X11_H__ +#define __SAMSUNG_LINUX_UTIL_X11_H__ + +#ifdef __GNUC__ +#define DEPRECATED __attribute__((deprecated)) +#else +#define DEPRECATED +#endif + +/** + * @defgroup utilX X11 utilities + * @ingroup lib + * @brief Samsung Linux platform X11 utilties + * + * Common X11 utilities + * You can use this API with #include + */ + +/** + * @addtogroup utilX + * @{ + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#define KEY_VOLUMEUP "XF86AudioRaiseVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Up' key */ +#define KEY_VOLUMEDOWN "XF86AudioLowerVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Down' key */ + +#define KEY_CAMERA "XF86WebCam" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Half-Press of Camera' key */ +#define KEY_CONFIG "XF86Pictures" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Full-Press of Camera' key */ + +#define KEY_POWER "XF86PowerOff" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Power' key */ +#define KEY_PAUSE "XF86Standby" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause' key */ +#define KEY_CANCEL "Cancel" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Cancel' key */ + +// Earjack/BT Headset/Multimedia keys +#define KEY_PLAYCD "XF86AudioPlay" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Play Audio' key */ +#define KEY_STOPCD "XF86AudioStop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Stop Audio' key */ +#define KEY_PAUSECD "XF86AudioPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause Audio' key */ +#define KEY_NEXTSONG "XF86AudioNext" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Next Song' key */ +#define KEY_PREVIOUSSONG "XF86AudioPrev" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Previous Song' key */ +#define KEY_REWIND "XF86AudioRewind" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Rewind Song' key */ +#define KEY_FASTFORWARD "XF86AudioForward" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Forward Song' key */ + +// 3-Touch key +#define KEY_SEND "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */ +#define KEY_SELECT "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */ +#define KEY_END "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */ + +// Renamed 3-Touch key +#define KEY_MENU "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */ +#define KEY_HOME "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */ +#define KEY_BACK "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */ + +#define LEN_KEY_VOLUMEUP 20 /**< this macro is the length of string corresponds to 'Volume Up' key */ +#define LEN_KEY_VOLUMEDOWN 20 /**< this macro is the length of string corresponds to 'Volume Down' key */ + +#define LEN_KEY_CAMERA 10 /**< this macro is the length of string corresponds to 'Half-Press of Camera' key */ +#define LEN_KEY_CONFIG 12 /**< this macro is the length of string corresponds to 'Full-Press of Camera' key */ + +#define LEN_KEY_POWER 12 /**< this macro is the length of string corresponds to 'Power' key */ +#define LEN_KEY_PAUSE 11 /**< this macro is the length of string corresponds to 'Pause' key */ + +// Earjack/BT Headset/Multimedia keys +#define LEN_KEY_PLAYCD 13/**< this macro is the length of string corresponds to 'Play Audio' key */ +#define LEN_KEY_STOPCD 13/**< this macro is the length of string corresponds to 'Stop Audio' key */ +#define LEN_KEY_PAUSECD 14/**< this macro is the length of string corresponds to 'Pause Audio' key */ +#define LEN_KEY_NEXTSONG 13/**< this macro is the length of string corresponds to 'Next Song' key */ +#define LEN_KEY_PREVIOUSSONG 13/**< this macro is the length of string corresponds to 'Previous Song' key */ +#define LEN_KEY_REWIND 15/**< this macro is the length of string corresponds to 'Rewind Song' key */ +#define LEN_KEY_FASTFORWARD 16/**< this macro is the length of string corresponds to 'Forwand Song' key */ + +// 3-Touch key +#define LEN_KEY_SEND 8 /**< this macro is the length of string corresponds to 'Send' key */ +#define LEN_KEY_SELECT 9 /**< this macro is the length of string corresponds to 'Home' key */ +#define LEN_KEY_END 8 /**< this macro is the length of string corresponds to 'End' key */ + +// Renamed 3-Touch key +#define LEN_KEY_MENU 8 /**< this macro is the length of string corresponds to 'Send' key */ +#define LEN_KEY_HOME 9 /**< this macro is the length of string corresponds to 'Home' key */ +#define LEN_KEY_BACK 8 /**< this macro is the length of string corresponds to 'End' key */ + +#define OR_EXCLUSIVE_GRAB 0xf00000 /**< this means that the client window will always get the grabbed-key exclusively regardless of the position on the window stack but the grab is overridable by the other client window */ +#define EXCLUSIVE_GRAB 0x0f0000 /**< this means that the client window will always get the grabbed-key exclusively regardless of the position on the window stack */ +#define TOP_POSITION_GRAB 0x00f000 /**< this means that the client window will get the grabbed-key only when on the top of the grabbing-window stack */ +#define SHARED_GRAB 0x000f00 /**< this means that the client window will get the grabbed-key together with the other client window(s) */ +#define GRAB_MODE_MASK 0xffff00 /**< this mask will be used for getting the key-grab mode of a client window */ + +#define EXCLUSIVE_GRABBED_ALREADY 1 /**< this means that the client window is grabbing the key already in EXCLUSIVE mode */ + +#define STR_ATOM_GRAB_KEY "_GRAB_KEY" /**< this is an XATOM for getting/setting the property for grabbing a key for a window */ +#define STR_ATOM_GRAB_EXCL_WIN "_GRAB_EXCL_WIN_KEYCODE" /**< this means that the key was grabbed by a client window in EXCLUSIVE mod */ +#define STR_ATOM_GRAB_OR_EXCL_WIN "_GRAB_OR_EXCL_WIN_KEYCODE" /**< this means that the key was grabbed by a client window in OR_EXCLUSIVE mod */ + +/** + * @brief Enumeration of key status + */ +typedef enum _Utilx_Key_Status +{ + UTILX_KEY_STATUS_PRESSED, /**< key status is pressed */ + UTILX_KEY_STATUS_RELEASED, /**< key status is released */ + UTILX_KEY_STATUS_UNKNOWN /** < key status is unknown or error happened */ +} Utilx_Key_Status; + +/** + * @brief Enumeration of notification window's priority level + */ +typedef enum _Utilx_Notification_Level +{ + UTILX_NOTIFICATION_LEVEL_LOW, /**< low level notification */ + UTILX_NOTIFICATION_LEVEL_NORMAL, /**< normal level notification*/ + UTILX_NOTIFICATION_LEVEL_HIGH /**< high level notification */ +} Utilx_Notification_Level; + +/** + * @brief Enumeration of Compositing Window Manager's Effect Type + */ +typedef enum _Utilx_Effect_Type +{ + UTILX_EFFECT_TYPE_MAP, /**< Effect for Window's Map Notify Event */ + UTILX_EFFECT_TYPE_UNMAP, /**< Effect for Window's UnMap Notify Event */ + UTILX_EFFECT_TYPE_RAISEABOVE, /**< Effect for Window's Configure Notify ( RaiseAbove case ) Event */ + UTILX_EFFECT_TYPE_ROTATION, /**< Effect for Window's Rotation Property Change Notify Event ( X Property: ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE ) */ + UTILX_EFFECT_TYPE_FOCUSIN, /**< Effect for Window's FocusIn Event ( E17's Event: E_EVENT_BORDER_FOCUS_IN ) */ + UTILX_EFFECT_TYPE_FOCUSOUT /**< Effect for Window's FocusOut Event ( E17's Event : E_EVENT_BORDER_FOCUS_OUT ) */ +} Utilx_Effect_Type; + +/** + * @brief Enumeration of Compositing Window Manager's Effect Style + */ +typedef enum _Utilx_Effect_Style +{ + UTILX_EFFECT_STYLE_DEFAULT, /**< Default Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_NONE, /**< None of Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM0, /**< Custom0 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM1, /**< Custom1 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM2, /**< Custom2 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM3, /**< Custom3 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM4, /**< Custom4 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM5, /**< Custom5 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM6, /**< Custom6 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM7, /**< Custom7 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM8, /**< Custom8 Effect Style for Effect Type */ + UTILX_EFFECT_STYLE_CUSTOM9 /**< Custom9 Effect Style for Effect Type */ +} Utilx_Effect_Style; + +/** + * @brief Enumeration of opaque state + */ +typedef enum _Utilx_Opaque_State +{ + UTILX_OPAQUE_STATE_OFF = 0, /**< Transparent state */ + UTILX_OPAQUE_STATE_ON = 1, /**< Opaque state */ +} Utilx_Opaque_State; + + +/** + * @fn void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level) + * @brief Sets the priority level for the specified notification window + * + * This function sets the priority level of the notification windows.\n + * Every notification window has a base priority level by the notification window's priority value. (Default priority is UTILX_NOTIFICATION_LEVEL_LOW) + * + * The priority is used for ordering of notification windows.\n + * The notification window which is set UTILX_NOTIFICATION_LEVEL_HIGH priority will be placed to the top of notification windows.\n + * If there are notification windows that have same priorities, the latest created notification window is placed on the other window. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window to be set + * @param[in] level Specifies the level (UTILX_NOTIFICATION_LEVEL_LOW, UTILX_NOTIFICATION_LEVEL_NORMAL, UTILX_NOTIFICATION_LEVEL_HIGH) + * @remark This is used only notification window. + * @pre The win should be notification type window + * @post None + * @see utilx_get_system_notification_level + * @par Example + @code + #include + + ... + + Evas_Object *win; + Ecore_X_Window xwin; + + win = create_mwnd(); + xwin = elm_win_xwindow_get(win); + + // Set Notification type + ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION); + + // Set Notification's priority + utilx_set_system_notification_level (ecore_x_display_get(), xwin, UTILX_NOTIFICATION_LEVEL_HIGH); + + ... + @endcode + */ +void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level); + +/** + * @fn Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win) + * @brief Gets the priority level for the specified notification window + * + * This function returns the priority level of the notification windows.\n + * If a user didn't set the notification's priority level, this function returns default value (UTILX_NOTIFICATION_LEVEL_LOW). + * + * This function is a synchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window to be get + * @return current notication level (UTILX_NOTIFICATION_LEVEL_LOW, UTILX_NOTIFICATION_LEVEL_NORMAL, UTILX_NOTIFICATION_LEVEL_HIGH) + * @remark This is used only notification window. + * @pre The win should be notification type window + * @post None + * @see utilx_set_system_notification_level + * @par Example + @code + #include + + ... + + Evas_Object *win; + Ecore_X_Window xwin; + Utilx_Notification_Level level; + + win = elm_win_add (NULL, "test", ELM_WIN_NOTIFICATION); + xwin = elm_win_xwindow_get(win); + + level = utilx_get_system_notification_level (ecore_x_display_get(), xwin); + + ... + @endcode + */ +Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win); + +/** + * @fn void utilx_enable_indicator (Display* dpy, Window win, int enable) + * @brief Sets the window to show/hide the indicator + * + * This function enables or disables the indicator. + * + * If an application wants to show the window with the indicator, the application must call this function with 1 as the enable parameter.\n + * Otherwise, the application must call this function with 0 as the enable parameter. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window to use indicator + * @param[in] enable Specifies whether the window use indicator or not + * @remark None + * @pre None + * @post If the enable is 1, then the indicator window should be shown on the screen. Otherwise, the indicator window should be hidden from the screen. + * @see elm_win_indicator_state_set, utilx_get_indicator_state + * @par Example + @code + #include + #include + + ... + + Display* dpy; + Window root, win; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0)); + XMapWindow (dpy, win); + + // If the win want to show indicator, enables indicator. + utilx_enable_indicator (dpy, win, 1); + XFlush (d); + + // If the win want to hide indicator, disables indicator. + utilx_enable_indicator (dpy, win, 0); + XFlush (d); + + ... + @endcode + */ +void utilx_enable_indicator (Display* dpy, Window win, int enable); + +/** + * @fn int utilx_get_indicator_state (Display* dpy, Window win) + * @brief Gets the indicator's state of the specified window + * + * This function gets the indicator's state of the specified window. + * + * An application can set the indicator's state using utilx_enable_indicator or elm_win_indicator_state_set. + * If an application sets enables the indicator, this returns 1.\n + * If an application disables the indicator, this returns 0.\n + * If an application doesn't set the indicator's state, in other words, + * an application doesn't call utilx_enable_indicator or elm_win_indicator_state_set, + * this returns -1. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window to get the indicator's state + * @return 1 if the indicator is enabled, 0 if the indicator is disabled, otherwise -1 + * @remark None + * @pre None + * @post None + * @see elm_win_indicator_state_set, utilx_enable_indicator + * @par Example + @code + #include + #include + + ... + + Display* dpy; + Window root, win; + int state; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0)); + XMapWindow (dpy, win); + + state = utilx_get_indicator_state (dpy, win) + // state is -1 (unknown) + + // If the win want to show indicator, enables indicator. + utilx_enable_indicator (dpy, win, 1); + XFlush (d); + + state = utilx_get_indicator_state (dpy, win) + // state is 1 (enabled) + + // If the win want to hide indicator, disables indicator. + utilx_enable_indicator (dpy, win, 0); + XFlush (d); + + state = utilx_get_indicator_state (dpy, win) + // state is 0 (disabled) + + ... + @endcode + */ +int utilx_get_indicator_state (Display* dpy, Window win); + + +/** + * @fn int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mode) + * @brief Grabs a key specfied by key_name for win in grab_mode + * + * This function establishs a grab of the specified key for the specified window.\n + * Once a key was grabbed, all events originated from the key will only be reported to the specfied window.\n + * The grab of the key will be released by calling utilx_ungrab_key. + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window to grab a key + * @param[in] key_name Name of a key in string (ex> KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SEND and so on) + * @param[in] grab_mode Grab mode (such as EXCLUSIVE_GRAB, TOP_POSITION_GRAB and SHARED_GRAB) + * @return 0 on Success, otherwise Fail + * @remark If utilx_grab_key() returns 0, the specified window will get the events of the specified key.\n + However, delivery of a key can always be changed by other applications grabbing the key with higher priority.\n + It can also be changed by the changes of window stacks.\n + Trial for choosing a proper grab mode will be needed. + * @pre This API must be called after the window 'win' has been mapped + * @post This API adds/changes the window property related to grabbed key + * @see utilx_ungrab_key + * @par Example (using X11 APIs) + @code + + // EXCLUSIVE_GRAB // + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + XEvent e; + int grab_result; + Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0)); + XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask); + XMapWindow(disp, w); + + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + grab_result = utilx_grab_key(disp, w, KEY_POWER, EXCLUSIVE_GRAB); + if( EXCLUSIVE_GRABBED_ALREADY == grab_result ) + return -1; + break; + } + ... + } + ... + + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + // TOP_POSITION_GRAB // + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + XEvent e; + Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0)); + XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask); + XMapWindow(disp, w); + + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB); + break; + } + ... + } + ... + + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + // SHARED_GRAB // + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + XEvent e; + Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0)); + XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask); + XMapWindow(disp, w); + + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB); + break; + } + ... + } + ... + + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + @endcode + * @par Example (using EFL APIs) + @code + + // EXCLUSIVE_GRAB // + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + + int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB); + if( EXCLUSIVE_GRABBED_ALREADY == grab_result ) + return -1; + + ... + + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ + return 0; + } + + // TOP_POSITION_GRAB // + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + + utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB); + + ... + + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ + return 0; + } + + // SHARED_GRAB // + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + + utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB); + + ... + + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ + return 0; + } + @endcode + */ +int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mode); + +/** + * @fn int utilx_ungrab_key (Display* dpy, Window win, const char* key_name) + * @brief Ungrabs a key specfied by key_name for win + * + * This function releases the already established grab of the specfied key for the specified window.\n + * Once the grab of the key was released, delivery of the key events for the specfied window is going to be stopped. + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window to grab a key + * @param[in] key_name Name of a key in string (ex> KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SEND and so on) + * @return 0 on Success, otherwise Fail + * @remark No additional information + * @pre This API must be called after the window 'win' has been mapped + * @post This API changes/removes the window property related to grabbed key + * @see utilx_grab_key + * @par Example (using X11 APIs) + @code + + // EXCLUSIVE_GRAB // + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + XEvent e; + int grab_result; + Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0)); + XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask); + XMapWindow(disp, w); + + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + grab_result = utilx_grab_key(disp, w, KEY_POWER, EXCLUSIVE_GRAB); + if( EXCLUSIVE_GRABBED_ALREADY == grab_result ) + return -1; + break; + } + ... + } + ... + + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + // TOP_POSITION_GRAB // + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + XEvent e; + Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0)); + XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask); + XMapWindow(disp, w); + + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB); + break; + } + ... + } + ... + + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + // SHARED_GRAB // + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + XEvent e; + Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0)); + XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask); + XMapWindow(disp, w); + + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB); + break; + } + ... + } + ... + + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + @endcode + * @par Example (using EFL APIs) + @code + + // EXCLUSIVE_GRAB // + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + + int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB); + if( EXCLUSIVE_GRABBED_ALREADY == grab_result ) + return -1; + ... + + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ + return 0; + } + + // TOP_POSITION_GRAB // + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + + utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB); + + ... + + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ + + return 0; + } + + // SHARED_GRAB // + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + + utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB); + + ... + + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ + return 0; + } + @endcode + */ +int utilx_ungrab_key (Display* dpy, Window win, const char* key_name); + +/** + * @fn int utilx_get_key_status(Display* dpy, char *key_name) + * @brief Gets a status of a key specified by key_name + * + * This function gets a status of a key.\n + * ex>UTILX_KEY_STATUS_PRESSED, UTILX_KEY_STATUS_RELEASED and UTILX_KEY_STATUS_UNKNOWN + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] key_name Name of a key in string (ex> KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SEND and so on) + * @return 0 on Success, otherwise Fail + * @remark No additional information + * @pre This API must be called for H/W keys specified in this header file(utilX.h). + * @par Example (using X11 APIs) + @code + + #include + #include + + int main() + { + Display *disp = XOpenDisplay(NULL); + Utilx_Key_Status status; + + status = utilx_get_key_status(disp, KEY_PLAYCD); + + switch( status ) + { + case UTILX_KEY_STATUS_PRESSED: + //The key is pressed. + break; + + case UTILX_KEY_STATUS_RELEASED: + //The key is released. + break; + + case UTILX_KEY_STATUS_UNKNOWN: + default: + //The key status is unknown; + break; + } + + return 0; + } + + @endcode + * @par Example (using EFL APIs) + @code + + #include + #include + #include + + int main() + { + ... + + Ecore_X_Display* disp = ecore_x_display_get(); + Utilx_Key_Status status; + + status = utilx_get_key_status(disp, KEY_PLAYCD); + + switch( status ) + { + case UTILX_KEY_STATUS_PRESSED: + //The key is pressed. + break; + + case UTILX_KEY_STATUS_RELEASED: + //The key is released. + break; + + case UTILX_KEY_STATUS_UNKNOWN: + default: + //The key status is unknown; + break; + } + return 0; + } + @endcode + */ +Utilx_Key_Status utilx_get_key_status(Display* dpy, char *key_name); + +/* Window Effect APIs */ +/** + * @fn void utilx_set_window_effect_state(Display* dpy, Window win, int state) + * @brief Sets a window's effect state ( enable or disable ) + * + * This function sets window's effect state. if effect is not enabled by composite manager, \n + * window's effect could not be enabled. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window handle + * @param[in] state Enables/disables the window effect + * @remark This is used only client window. ( not root window ) + * @pre This api must be called before fist show ( XMapWindow Event ). + * @post This changes Client Window's Effect related property. + * @see utilx_get_window_effect_state + * @par Example + @code + #include + #include + ... + + Display* dpy; + Window root, win; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0)); + + // Sets a window's effect state to enable ( enable : 1, disable 0 ) + utilx_set_window_effect_state(dpy, win, 1); + + XMapWindow (dpy, win); + ... + @endcode + */ +void utilx_set_window_effect_state(Display* dpy, Window win, int state); + +/** +* @fn int utilx_get_window_effect_state(Display* dpy, Window win) +* @brief Gets a window's effect state ( enable or disable ) +* +* This function returns windows's effect state.\n +* If effect is not enabled by composite manager, then this return value is unusable or meanless. +* +* This function is a asynchronous call. +* +* @param[in] dpy Specifies the connection to the X server +* @param[in] win Specifies the window handle +* @return Current window effect state +* @remark This is used only client window. ( not root window ) +* @pre This api does not require any pre-condition. +* @post This api does not change any condition. +* @see utilx_set_window_effect_state +* @par Example + @code + #include + #include + ... + + Display* dpy; + Window root, win; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0)); + + XMapWindow (dpy, win); + + // Gets a window's effect state ( enable : 1, disable 0 ) + printf( "current window's effect state = %d\n", utilx_get_window_effect_state(dpy, win) ) ; + ... + @endcode +*/ +int utilx_get_window_effect_state(Display* dpy, Window win); + +/** + * @fn void utilx_show_fake_effect(Display* dpy, Window win, char *fake_image_file) + * @brief Shows a window's "fake show effect" animation + * + * This function show's application fake show image.\n + * This function is only used by application launching program. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the root window handle + * @param[in] fake_image_file Specifies the fake window image and file format is png type. + * @remark This is used only menu-screen window. + * @pre This api must be called before client's fist show ( XMapWindow Event ). you must call this api then run application. + * @post This changes root window's fake effect related property. + * @see utilx_hide_fake_effect + * @par Example + @code + #include + #include + ... + + Display* dpy; + Window root; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + // Shows a window's "fake show effect" animation, and if you want to see animation, /root/fake_window_image.png file must be exited. + utilx_show_fake_effect( dpy, root, "/root/fake_window_image.png"); + ... + @endcode + */ +void utilx_show_fake_effect(Display *dpy, Window win, char *fake_image_file); + +/** + * @fn void utilx_hide_fake_effect(Display* dpy, Window win) + * @brief Shows a window's "fake hide effect" animation, and this animation uses "fake show effect" 's window image. + * + * This function shoes a window's fake hide effect.\n + * This function is only used by application launching program.\n + * When application was not executed by any error. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the root window handle + * @remark This is used only menu-screen window. + * @pre This api must be called after "utilx_show_fake_effect()". + * @post This changes root window's fake effect related property. + * @see utilx_show_fake_effect + * @par Example + @code + #include + #include + ... + + Display* dpy; + Window root; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + // Shows a window's "fake hide effect" animation. and if you wnat to see animation, utilx_show_fake_effect() function must be excuted before utilx_show_fake_effect() + // and if real window is showed , then fake hide effect could not be showed. + utilx_hide_fake_effect( dpy, root ); + ... + @endcode + */ +void utilx_hide_fake_effect(Display *dpy, Window win); + +/** + * @fn void utilx_set_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type, Utilx_Effect_Style style) + * @brief Sets a window's effect style with effect type. + * + * This function sets a window's effect style with effect type.\n + * Default Window Effect is setted by Window Type and Window Class.\n + * And then, you could change custom effecct.\n + * Custom Effect is available max 10. ( CUSTOM0 ~ CUSTOM9 )\n + * If you didn't set custom effect, then compositing window manger provides Default Window Effect.\n + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window handle + * @param[in] type Specifies the window's effect type ( ex. UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_TYPE_UNMAP, etc ) + * @param[in] style Specifies the window's effect style ( ex. UTILX_EFFECT_STYLE_DEFAULT, UTILX_EFFECT_STYLE_NONE, UTILX_EFFECT_STYLE_CUSTOM0, etc ) + * @remark This is used only client window. ( not root window ) + * @pre This api does not require any pre-condition. + * @post This changes window's effect type related property ( _NET_CM_WINDOW_EFFECT_TYPE ). + * @see utilx_get_window_effect_style + * @par Example + @code + #include + #include + #include + ... + + Display *dpy ; + Window win, root ; + unsigned long black, white; + + dpy = XOpenDisplay(NULL) ; + + black = BlackPixel(dpy, 0); + white = WhitePixel(dpy, 0); + + root = XDefaultRootWindow (dpy); + win = XCreateSimpleWindow ( dpy, root, 0, 0, 100, 100, 2, BlackPixel (d,0), WhitePixel(d,0) ); + + utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_CUSTOM0); // window's show effet type change to UTILX_EFFECT_STYLE_CUSTOM0 + + XMapWindow(dpy, win); + + ... + + utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP, UTILX_EFFECT_STYLE_CUSTOM0); // window's hide effet type change to UTILX_EFFECT_STYLE_CUSTOM0 + + XUnmapWindow (dpy, win); + + utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_DEFAULT); // window's show effet type change to UTILX_EFFECT_STYLE_DEFAULT + XMapWindow (dpy, win); + + ... + + utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP, UTILX_EFFECT_STYLE_DEFAULT); // window's hide effet type change to UTILX_EFFECT_STYLE_DEFAULT + XUnmapWindow (dpy, win); + + ... + + utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_NONE); // window's show effet type change to UTILX_EFFECT_STYLE_NONE + XMapWindow (dpy, win); + + ... + + utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP, UTILX_EFFECT_STYLE_NONE); // window's hide effet type change to UTILX_EFFECT_STYLE_NONE + XUnmapWindow (dpy, win); + + ... + @endcode + */ +void utilx_set_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type, Utilx_Effect_Style style); + +/** + * @fn Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type) + * @brief Gets a window's effect style with effect type. + * + * This function gets a window's effect style with effect type.\n + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window handle + * @param[in] type Specifies the window's effect type ( ex. UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_TYPE_UNMAP, etc ) + * @return Current window's effect style ( ex. UTILX_EFFECT_STYLE_DEFAULT, UTILX_EFFECT_STYLE_NONE, UTILX_EFFECT_STYLE_CUSTOM0, etc ) + * @remark This is used only client window. ( not root window ) + * @pre This api does not require any pre-condition. + * @post This api does not change any condition. + * @see utilx_set_window_effect_style + * @par Example + @code + #include + #include + #include + ... + + Display *dpy ; + Window win, root ; + unsigned long black, white; + Utilx_Effect_Style style; + + dpy = XOpenDisplay(NULL) ; + + black = BlackPixel(dpy, 0); + white = WhitePixel(dpy, 0); + + root = XDefaultRootWindow (dpy); + win = XCreateSimpleWindow ( dpy, root, 0, 0, 100, 100, 2, BlackPixel (d,0), WhitePixel(d,0) ); + + style = utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP); // get effect style with window's show effet type + + ... + + style = utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP); // get effect style with window's show effet type + + ... + @endcode + */ +Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type); + +/** + * @fn void utilx_set_window_opaque_state (Display* dpy, Window win, int opaque) + * @brief Sets the window's opaque state + * + * This function sets window's visibility to opaque even if the window is an alpha window. + * This function is available only alpha window. + * An alpha window's default opaque state is UTILX_OPAQUE_STATE_OFF. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window handle + * @param[in] state Specifies whether the window set a visible state to opaque(UTILX_OPAQUE_STATE_ON) or not(UTILX_OPAQUE_STATE_OFF) + * @return 1 on Success, otherwise Fail + * @remark This is used only alpha window. + * @pre None + * @post + * @see + * @par Example + @code + #include + #include + + ... + + Display* dpy; + Window root, win; + int ret; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0)); + XMapWindow (dpy, win); + + ret = utilx_set_window_opaque_state (dpy, win, UTILX_OPAQUE_STATE_ON); + if (!ret) + { + printf ("Error! Failed to set opaque state.\n"); + } + + XFlush (dpy); + + ... + @endcode + */ +int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state); + +/** + * @fn int utilx_set_screen_capture(Display* dpy, int enable) + * @brief Specifies whether the screen capture functionality is enable or not. + * + * This function makes the screen capture functionality of CBHM enable or disable. + * CBHM = Clipboard History Manager. + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] enable Specifies the window handle. (1:Enable, 0:Disable) + * @pre This api does not require any pre-condition. + * @post This api does not change any condition. + * @see utilx_get_screen_capture + * @par Example + @code + #include + #include + #include + ... + + Display *dpy ; + + dpy = XOpenDisplay(NULL) ; + + utilx_set_screen_capture (dpy, 1); + + ... + @endcode + */ +int utilx_set_screen_capture(Display* dpy, int enable); + +/** + * @fn int utilx_get_screen_capture(Display* dpy, int enable) + * @brief Gets whether the screen capture functionality is enable or not. + * + * This function gets whether the screen capture functionality of CBHM is enable or not. + * CBHM = Clipboard History Manager. + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @pre This api does not require any pre-condition. + * @post This api does not change any condition. + * @see utilx_set_screen_capture + * @par Example + @code + #include + #include + #include + ... + + Display *dpy ; + int enable; + + dpy = XOpenDisplay(NULL) ; + + enable = utilx_set_screen_capture (dpy); + + ... + @endcode + */ +int utilx_get_screen_capture(Display* dpy); + +/** + * @fn void utilx_set_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value) + * @brief Sets the cardinal property to Window + * + * This function Sets the cardinal property to Window. + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window handle + * @param[in] atom Specifies the atom of cardinal property + * @param[in] value the value of cardinal property to set. + * @pre This api does not require any pre-condition. + * @post This api does not change any condition. + * @see utilx_get_window_cardinal_property + * @par Example + @code + #include + #include + #include + ... + + Display *dpy ; + Window root; + Atom atom = None; + int value = 1; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + atom = XInternAtom(dpy, "TEST_ATOM", False); + + utilx_set_window_cardinal_property (dpy, root, atom, (unsigned int*)&value); + + ... + @endcode + */ +void utilx_set_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value); + +/** + * @fn int utilx_get_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value) + * @brief Gets the value of cardinal property. + * + * This function gets the value of cardinal property. + * + * This function is synchronous. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the window handle + * @param[in] atom Specifies the atom of cardinal property + * @param[out] value the value of cardinal property to get. + * @pre This api does not require any pre-condition. + * @post This api does not change any condition. + * @see utilx_set_window_cardinal_property + * @par Example + @code + #include + #include + #include + ... + + Display *dpy ; + Window root; + Atom atom = None; + int value; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + atom = XInternAtom(dpy, "TEST_ATOM", False); + + if (utilx_set_window_cardinal_property (dpy, root, atom, (unsigned int*)&value) > 0) + { + success; + } + + ... + @endcode + */ +int utilx_get_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value); + +/** + * @fn void utilx_show_capture_effect(Display *dpy, Window win ) + * @brief Shows a capture effect animation + * + * This function show capture effect animation.\n + * This function is only used by Screen Capture Application. + * + * This function is a asynchronous call. + * + * @param[in] dpy Specifies the connection to the X server + * @param[in] win Specifies the root window handle + * @remark This is used only screen capture application. + * @pre This api does not require any pre-condition. + * @post This api does not change any condition. + * @see utilx_set_screen_capture + * @par Example + @code + #include + #include + ... + + Display* dpy; + Window root; + + dpy = XOpenDisplay (NULL); + root = XDefaultRootWindow (dpy); + + // Shows a Shows a capture effect animation + utilx_show_capture_effect( dpy, root); + ... + @endcode + */ +void utilx_show_capture_effect(Display *dpy, Window win ); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + +#endif /* __SAMSUNG_LINUX_UTIL_X11_H__ */ + diff --git a/utilX.pc b/utilX.pc new file mode 100644 index 0000000..f0fd703 --- /dev/null +++ b/utilX.pc @@ -0,0 +1,12 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: libSLP-utilX +Description: SAMSUNG Linux platform X11 utilities library +Version: 1.1.0 +Libs: -L${libdir} -lutilX +Cflags: -I${includedir} diff --git a/utilX.pc.in b/utilX.pc.in new file mode 100644 index 0000000..5079edf --- /dev/null +++ b/utilX.pc.in @@ -0,0 +1,12 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: libSLP-utilX +Description: SAMSUNG Linux platform X11 utilities library +Version: @VERSION@ +Libs: -L${libdir} -lutilX +Cflags: -I${includedir} diff --git a/util_x11.h b/util_x11.h new file mode 100644 index 0000000..1e24bcb --- /dev/null +++ b/util_x11.h @@ -0,0 +1,27 @@ +/* + * libslp-utilx + * + Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + * + */ + +#ifndef __SAMSUNG_LINUX_UTIL_X11_I_H__ +#define __SAMSUNG_LINUX_UTIL_X11_I_H__ + +#ifndef API +#define API __attribute__ ((visibility("default"))) +#endif + +#endif /* __SAMSUNG_LINUX_APP_UTIL_X11_IH__ */ diff --git a/x11.c b/x11.c new file mode 100644 index 0000000..1d669a3 --- /dev/null +++ b/x11.c @@ -0,0 +1,1191 @@ +/* + * libslp-utilx + * + Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + * + */ + +#include +#include +#include +#include + +#include +#include + +#include "utilX.h" +#include "util_x11.h" + + +#define UTILX_DEBUG 0 +#if UTILX_DEBUG +#define UTILX_TRACE printf +#else +#define UTILX_TRACE(...) +#endif + +static Atom _atom_grab_key = None; +static Atom _atom_grab_excl_win = None; +static Atom _atom_grab_or_excl_win = None; + +static Atom _atom_notification_level = None; +static Atom _atom_indicator_visible_state = None; + +static Atom _atom_comp_effect_state = None; +static Atom _atom_comp_fake_launch = None; +static Atom _atom_comp_fake_launch_image = None; + +static Atom _atom_comp_window_effect_type = None; +static Atom _atom_comp_effect_default = None; +static Atom _atom_comp_effect_none = None; +static Atom _atom_comp_effect_custom0 = None; +static Atom _atom_comp_effect_custom1 = None; +static Atom _atom_comp_effect_custom2 = None; +static Atom _atom_comp_effect_custom3 = None; +static Atom _atom_comp_effect_custom4 = None; +static Atom _atom_comp_effect_custom5 = None; +static Atom _atom_comp_effect_custom6 = None; +static Atom _atom_comp_effect_custom7 = None; +static Atom _atom_comp_effect_custom8 = None; +static Atom _atom_comp_effect_custom9 = None; + +static Atom _atom_window_opaque = None; + +static Atom _atom_screen_capture_disable = None; + +static Atom _atom_comp_capture_effect = None; + +const unsigned long maxlen = 1024l; + +static void _utilx_set_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num); +static int _utilx_get_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int len); + +static void _utilx_effect_atom_check( Display* dpy ); +static Atom _utilx_convert_style_to_atom( Display* dpy, Utilx_Effect_Style style ); +static Utilx_Effect_Style _utilx_convert_atom_to_style( Display* dpy, Atom style ); + +API void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level) +{ + UTILX_TRACE ("[UTILX] utilx_set_system_notification_level... win = %x, level = %d\n", win, level); + + int noti_level; + + if (dpy == NULL) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return; + } + + switch (level) + { + case UTILX_NOTIFICATION_LEVEL_LOW: + noti_level = 50; + break; + + case UTILX_NOTIFICATION_LEVEL_NORMAL: + noti_level = 100; + break; + + case UTILX_NOTIFICATION_LEVEL_HIGH: + noti_level = 150; + break; + + default: + noti_level = 50; + break; + } + + if (!_atom_notification_level) + { + _atom_notification_level = XInternAtom (dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False); + if (!_atom_notification_level) + { + fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__); + return; + } + } + + _utilx_set_window_property (dpy, win, _atom_notification_level, XA_CARDINAL, + (unsigned int *)¬i_level, 1); +} + + +API Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win) +{ + UTILX_TRACE ("[UTILX] utilx_get_system_notification_level... win = %x\n", win); + + Utilx_Notification_Level noti_level; + unsigned int level; + int ret; + + noti_level = UTILX_NOTIFICATION_LEVEL_LOW; + + if (dpy == NULL) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + goto error; + } + + if (!_atom_notification_level) + { + _atom_notification_level = XInternAtom (dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False); + if (!_atom_notification_level) + { + fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__); + goto error; + } + } + + ret = _utilx_get_window_property (dpy, win, _atom_notification_level, XA_CARDINAL, + (unsigned int *)&level, 1); + + if (ret > 0) + { + switch (level) + { + case 50: + noti_level = UTILX_NOTIFICATION_LEVEL_LOW; + break; + + case 100: + noti_level = UTILX_NOTIFICATION_LEVEL_NORMAL; + break; + + case 150: + noti_level = UTILX_NOTIFICATION_LEVEL_HIGH; + break; + + default: + noti_level = UTILX_NOTIFICATION_LEVEL_LOW; + break; + } + } + else + { + noti_level = UTILX_NOTIFICATION_LEVEL_LOW; + } + +error: + return noti_level; +} + + +API void utilx_enable_indicator (Display* dpy, Window win, int enable) +{ + UTILX_TRACE ("[UTILX] utilx_indicator_set_visible_state... win = %x, show_state = %d\n", win, enable); + + if (dpy == NULL) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return; + } + + if (!_atom_indicator_visible_state) + { + _atom_indicator_visible_state = XInternAtom (dpy, "_E_ILLUME_INDICATOR_STATE", False); + if (!_atom_indicator_visible_state) + { + fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_INDICATOR_STATE atom.. %s (%d)\n", __func__, __LINE__); + return; + } + } + + _utilx_set_window_property (dpy, win, _atom_indicator_visible_state, XA_CARDINAL, + (unsigned int *)&enable, 1); +} + + +API int utilx_get_indicator_state (Display* dpy, Window win) +{ + UTILX_TRACE ("[UTILX] utilx_indicator_set_visible_state... win = %x, show_state = %d\n", win, enable); + + int ret; + int state; + + if (dpy == NULL) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return -1; + } + + if (!_atom_indicator_visible_state) + { + _atom_indicator_visible_state = XInternAtom (dpy, "_E_ILLUME_INDICATOR_STATE", False); + if (!_atom_indicator_visible_state) + { + fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_INDICATOR_STATE atom.. %s (%d)\n", __func__, __LINE__); + return -1; + } + } + + ret = _utilx_get_window_property (dpy, win, _atom_indicator_visible_state, XA_CARDINAL, + (unsigned int *)&state, 1); + + if (ret > 0) + return state; + else + return -1; +} + +static void +_utilx_set_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num) +{ + XChangeProperty (dpy, win, atom, type, 32, PropModeReplace, (unsigned char *)val, num); + XSync(dpy, 0 ); +} + + +static int +_utilx_get_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int len) +{ + unsigned char* prop_ret; + Atom type_ret; + unsigned long bytes_after, num_ret; + int format_ret; + unsigned int i; + int num; + + prop_ret = NULL; + if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False, + type, &type_ret, &format_ret, &num_ret, + &bytes_after, &prop_ret) != Success) + { + return -1; + } + + if (type_ret != type || format_ret != 32) + { + num = -1; + } + else if (num_ret == 0 || !prop_ret) + { + num = 0; + } + else + { + if (num_ret < len) + len = num_ret; + for (i = 0; i < len; i++) + { + val[i] = ((unsigned long *)prop_ret)[i]; + } + num = len; + } + + if (prop_ret) + XFree(prop_ret); + + return num; + +} + + +static unsigned long _get_list_of_grabbed_key (Display *disp, Window win, int **key_list) +{ + Atom ret_type; + int ret_format; + unsigned long nr_item; + unsigned long sz_remains_data; + + if (XGetWindowProperty(disp, win, + _atom_grab_key, 0, 0x7fffffff, False, XA_CARDINAL, + &ret_type, &ret_format, &nr_item, + &sz_remains_data, (unsigned char**)key_list) != Success) + { + nr_item = 0; + } + +// fprintf(stderr, "%d - %lu\n", ret_format, nr_item); + + return nr_item; +} + + +static void _free_list_of_grabbed_key (int *key_list) +{ + if (key_list) { + XFree(key_list); + } +} + + +static void _free_new_list_of_grabbed_key (int *new_key_list) +{ + if (new_key_list) { + free(new_key_list); + } +} + + +static int _search_grabbed_key (int *key_list, int key, unsigned long cnt) +{ + register int i; + + for (i = cnt - 1; i >= 0; i --) { + if (key_list[i] == key) break; + } + + return i; +} + + +static int *_del_grabbed_key (int *key_list, int i, unsigned long *cnt) +{ + int *new_key_list = NULL; + + // Only one element is exists in the list of grabbed key + (*cnt) --; + + if (*cnt == 0) return NULL; + + // Shrink the buffer + new_key_list = malloc((*cnt) * sizeof(int)); + if (new_key_list == NULL) { + perror(__func__); + return NULL; + } + + // copy head + if (i > 0) { + memcpy(new_key_list, key_list, sizeof(int) * i); + } + + // copy tail + if ((*cnt) - i > 0) { + memcpy(new_key_list + i, + key_list + i + 1, + sizeof(int) * ((*cnt) - i) + ); + } + return new_key_list; +} + + +static void _set_exclusive_grab_info_to_root (Display *disp, int keycode, Window win, int grab_mode) +{ + int *key_list = NULL; + + Atom ret_type; + int ret_format; + unsigned long nr_item; + unsigned long sz_remains_data; + Window ex_grabwin; + + if( grab_mode == EXCLUSIVE_GRAB ) + { + if( _atom_grab_excl_win == None ) + _atom_grab_excl_win = XInternAtom(disp, STR_ATOM_GRAB_EXCL_WIN, False); + ex_grabwin = _atom_grab_excl_win; + } + else if( grab_mode == OR_EXCLUSIVE_GRAB ) + { + if( _atom_grab_or_excl_win == None ) + _atom_grab_or_excl_win = XInternAtom(disp, STR_ATOM_GRAB_OR_EXCL_WIN, False); + ex_grabwin = _atom_grab_or_excl_win; + } + else + return; + + if (XGetWindowProperty(disp, DefaultRootWindow(disp), + ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL, + &ret_type, &ret_format, &nr_item, + &sz_remains_data, (unsigned char**)&key_list) != Success) + { + fprintf(stderr, "[utilX][%s] Fail to get root window property !\n", __FUNCTION__); + goto out; + } + +#if 1//def __DEBUG__ + printf("[%s] keycode = %d\n", __FUNCTION__, keycode); +#endif + + XChangeProperty(disp, DefaultRootWindow(disp), ex_grabwin, XA_CARDINAL, 32, + nr_item ? PropModeAppend : PropModeReplace, (unsigned char *)&keycode, 1); + XSync(disp, False); + +out: + return; +} + + +static void _unset_exclusive_grab_info_to_root (Display *disp, int keycode, int grab_mode) +{ + int i; + unsigned long cnt = 0; + int *key_list = NULL; + int *new_key_list = NULL; + + Atom ret_type; + int ret_format; + unsigned long nr_item; + unsigned long sz_remains_data; + Window ex_grabwin; + + if( grab_mode == EXCLUSIVE_GRAB ) + { + if( _atom_grab_excl_win == None ) + _atom_grab_excl_win = XInternAtom(disp, STR_ATOM_GRAB_EXCL_WIN, False); + ex_grabwin = _atom_grab_excl_win; + } + else if( grab_mode == OR_EXCLUSIVE_GRAB ) + { + if( _atom_grab_or_excl_win == None ) + _atom_grab_or_excl_win = XInternAtom(disp, STR_ATOM_GRAB_OR_EXCL_WIN, False); + ex_grabwin = _atom_grab_or_excl_win; + } + else + return; + + if (XGetWindowProperty(disp, DefaultRootWindow(disp), + ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL, + &ret_type, &ret_format, &nr_item, + &sz_remains_data, (unsigned char**)&key_list) != Success) + { + nr_item = 0; + } + + if (nr_item == 0) + { + fprintf(stderr, "[utilX][%s] keycode = %d\n", __FUNCTION__, keycode); + goto out; + } + + for( i=0 ; i < nr_item ; i++ ) + { + if( key_list[i] == keycode )//&& grab_mode == EXCLUSIVE_GRAB ) + { + continue; + } + cnt++; + } + +#ifdef __DEBUG__ + fprintf(stderr, "[utilX][%s] cnt = %d, nr_item = %d\n", __FUNCTION__, cnt, nr_item); +#endif + + if( 0 < cnt ) + { + new_key_list = malloc(sizeof(int)*cnt); + cnt = 0; + } + else + new_key_list = NULL; + + if( !new_key_list ) + { + //fprintf(stderr, "[utilX][%s] Fail to allocation memory for new_key_list ! \n", __FUNCTION__); + XDeleteProperty(disp, DefaultRootWindow(disp), ex_grabwin); + XSync(disp, False); + goto out; + } + + for( i=0 ; i < nr_item ; i++ ) + { + if( key_list[i] == keycode )//&& grab_mode == EXCLUSIVE_GRAB ) + { + continue; + } + else + new_key_list[cnt++] = key_list[i]; + } + + if (new_key_list) { + XChangeProperty(disp, DefaultRootWindow(disp), ex_grabwin, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)new_key_list, cnt); + } + else { + XDeleteProperty(disp, DefaultRootWindow(disp), ex_grabwin); + } + XSync(disp, False); + + if(new_key_list) + free(new_key_list); + +out: + return; +} + + +static int _is_grabbed_key_exclusively (Display* disp, int keycode, int grab_mode) +{ + int i, result = 0; + int *key_list = NULL; + + Atom ret_type; + int ret_format; + unsigned long nr_item; + unsigned long sz_remains_data; + Window ex_grabwin; + + if( grab_mode == EXCLUSIVE_GRAB ) + { + if( _atom_grab_excl_win == None ) + _atom_grab_excl_win = XInternAtom(disp, STR_ATOM_GRAB_EXCL_WIN, False); + ex_grabwin = _atom_grab_excl_win; + } + else if( grab_mode == OR_EXCLUSIVE_GRAB ) + { + if( _atom_grab_or_excl_win == None ) + _atom_grab_or_excl_win = XInternAtom(disp, STR_ATOM_GRAB_OR_EXCL_WIN, False); + ex_grabwin = _atom_grab_or_excl_win; + } + else + return result; + + if (XGetWindowProperty(disp, DefaultRootWindow(disp), + ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL, + &ret_type, &ret_format, &nr_item, + &sz_remains_data, (unsigned char**)&key_list) != Success) + { + fprintf(stderr, "[%s] Fail to get root window property !\n", __FUNCTION__); + goto out; + } + + for( i=0 ; i < nr_item ; i++ ) + { + if( key_list[i] == keycode ) + return EXCLUSIVE_GRABBED_ALREADY; + } + +out: + return result; +} + +API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mode) +{ + unsigned long cnt; + int *key_list = NULL; + int i, result = 0; + int keycode = 0; + KeySym keysym; + errno = EINVAL; + + if( NULL == disp ) + { + fprintf(stderr, "[%s] Display is NULL\n", __FUNCTION__); + return -1; + } + + if (_atom_grab_key == None) { + _atom_grab_key = XInternAtom(disp, STR_ATOM_GRAB_KEY, False); + } + + if (!strncmp(key, "Keycode-", 8)) { + keycode = atoi(key + 8); + } else { + keysym = XStringToKeysym(key); + if (keysym == NoSymbol) goto out; + keycode = XKeysymToKeycode(disp, XStringToKeysym(key)); + } + if (keycode == 0) goto out; + + if( grab_mode == EXCLUSIVE_GRAB ) + { + //Window grabWin; + result = _is_grabbed_key_exclusively(disp, keycode, grab_mode); + +#ifdef __DEBUG__ + printf("[%s] _is_grabbed_key_exclusively returns result = %d\n", __FUNCTION__, result); +#endif + + if( result ) + { + fprintf(stderr, "[%s] keycode(%d) was already grabbed exclusively (grab_mode=0x%X) !\n", __FUNCTION__, keycode, grab_mode); + goto out; + } + } + else if( grab_mode == OR_EXCLUSIVE_GRAB ) + { + result = _is_grabbed_key_exclusively(disp, keycode, grab_mode); + + if( result ) + { + fprintf(stderr, "[%s] Keycode(%d) was already grabbed with overridable exclusive mode (grab_mode=0x%x)\n", __FUNCTION__, keycode, grab_mode); + fprintf(stderr, "[%s] Now it will be overridden by a new window(0x%x) !\n", __FUNCTION__, win); + utilx_ungrab_key(disp, win, key); + } + } + + keycode |= grab_mode; + + cnt = _get_list_of_grabbed_key(disp, win, &key_list); + if (cnt > 0) { + i = _search_grabbed_key(key_list, keycode, cnt); + _free_list_of_grabbed_key(key_list); + if ( i != -1 ) { + fprintf(stderr, "Key is already grabbed\n"); + goto out; + } + } + + XChangeProperty(disp, win, _atom_grab_key, XA_CARDINAL, 32, + cnt ? PropModeAppend : PropModeReplace, (unsigned char *)&keycode, 1); + XSync(disp, False); + keycode = keycode & (~GRAB_MODE_MASK); +#ifdef __DEBUG__ + printf("[%s] keycode = %d\n", __FUNCTION__, keycode); +#endif + + if( EXCLUSIVE_GRAB == grab_mode || OR_EXCLUSIVE_GRAB == grab_mode ) + _set_exclusive_grab_info_to_root(disp, keycode, win, grab_mode); + + errno = 0; + +out: + + return result; +} + + +API int utilx_ungrab_key (Display* disp, Window win, const char* key) +{ + int i; + unsigned long cnt; + int *key_list = NULL; + int *new_key_list = NULL; + long keycode = 0; + KeySym keysym; + int ret = -1; + errno = EINVAL; + + if( NULL == disp ) + { + fprintf(stderr, "[%s] Display is NULL\n", __FUNCTION__); + return -1; + } + + if (_atom_grab_key == None) { + _atom_grab_key = XInternAtom(disp, STR_ATOM_GRAB_KEY, False); + } + + if (!strncmp(key, "Keycode-", 8)) { + keycode = atoi(key + 8); + } else { + keysym = XStringToKeysym(key); + if (keysym == NoSymbol) goto out; + keycode = XKeysymToKeycode(disp, XStringToKeysym(key)); + } + if (keycode == 0) goto out; + + cnt = _get_list_of_grabbed_key(disp, win, &key_list); + if (cnt == 0) goto out; + + //EXCLUSIVE mode + i = _search_grabbed_key(key_list, keycode | EXCLUSIVE_GRAB, cnt); + + if ( i == -1) + { + //OR_EXCLUSIVE mode + i = _search_grabbed_key(key_list, keycode | OR_EXCLUSIVE_GRAB, cnt); + + if ( i == -1) + { + //TOP_POSITION mode + i = _search_grabbed_key(key_list, keycode | TOP_POSITION_GRAB, cnt); + + if (i == -1) + { + //SHARED mode + i = _search_grabbed_key(key_list, keycode | SHARED_GRAB, cnt); + + if (i == -1) + { + _free_list_of_grabbed_key(key_list); + goto out; + } + } + } + else + { + _unset_exclusive_grab_info_to_root(disp, keycode, OR_EXCLUSIVE_GRAB); + } + } + else + { + _unset_exclusive_grab_info_to_root(disp, keycode, EXCLUSIVE_GRAB); + } + + new_key_list = _del_grabbed_key(key_list, i, &cnt); + _free_list_of_grabbed_key(key_list); + + if (new_key_list) { + XChangeProperty(disp, win, _atom_grab_key, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)new_key_list, cnt); + } + else { + XDeleteProperty(disp, win, _atom_grab_key); + } + XSync(disp, False); + + _free_new_list_of_grabbed_key(new_key_list); + ret = 0; + errno = 0; + +out: + + return ret; +} + +API Utilx_Key_Status utilx_get_key_status(Display* dpy, char *key_name) +{ + unsigned char keymap[32]; + static unsigned int masktable[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; + Utilx_Key_Status status = UTILX_KEY_STATUS_UNKNOWN; + + if( !strncmp(key_name, KEY_VOLUMEDOWN, LEN_KEY_VOLUMEDOWN) || + !strncmp(key_name, KEY_VOLUMEUP, LEN_KEY_VOLUMEUP) || + !strncmp(key_name, KEY_PAUSE, LEN_KEY_PAUSE) || + !strncmp(key_name, KEY_SEND, LEN_KEY_SEND) || + !strncmp(key_name, KEY_SELECT, LEN_KEY_VOLUMEDOWN) || + !strncmp(key_name, KEY_END, LEN_KEY_END) || + !strncmp(key_name, KEY_POWER, LEN_KEY_POWER) || + !strncmp(key_name, KEY_CAMERA, LEN_KEY_CAMERA) || + !strncmp(key_name, KEY_CONFIG, LEN_KEY_CONFIG) || + !strncmp(key_name, KEY_PLAYCD, LEN_KEY_PLAYCD) || + !strncmp(key_name, KEY_STOPCD, LEN_KEY_STOPCD) || + !strncmp(key_name, KEY_PAUSECD, LEN_KEY_PAUSECD) || + !strncmp(key_name, KEY_NEXTSONG, LEN_KEY_NEXTSONG) || + !strncmp(key_name, KEY_PREVIOUSSONG, LEN_KEY_PREVIOUSSONG) || + !strncmp(key_name, KEY_REWIND, LEN_KEY_REWIND) || + !strncmp(key_name, KEY_FASTFORWARD, LEN_KEY_FASTFORWARD) ) + { + KeySym ks = XStringToKeysym(key_name); + KeyCode kc = XKeysymToKeycode(dpy, ks); + + if( kc ) + { + XQueryKeymap(dpy, (char *)keymap); + if( keymap[kc >> 3] & masktable[kc & 7] ) + status = UTILX_KEY_STATUS_PRESSED; + else + status = UTILX_KEY_STATUS_RELEASED; + } + } + + return status; +} + +API void utilx_set_window_effect_state(Display* dpy, Window win, int state) +{ + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return; + } + if( !_atom_comp_effect_state) + _atom_comp_effect_state = XInternAtom(dpy, "_NET_CM_WINDOW_EFFECT_ENABLE",False); + + _utilx_set_window_property(dpy, win, _atom_comp_effect_state, XA_CARDINAL, (unsigned int *)&state, 1); + + XSync(dpy, 0 ); +} + +API int utilx_get_window_effect_state(Display* dpy, Window win) +{ + int state = 0; + if( !_atom_comp_effect_state) + _atom_comp_effect_state = XInternAtom(dpy, "_NET_CM_WINDOW_EFFECT_ENABLE",False); + _utilx_get_window_property(dpy, win, _atom_comp_effect_state, XA_CARDINAL, (unsigned int *)&state, 1); + return state; +} + +static void +_utilx_string_set_window_property( Display *dpy, Window win, Atom atom, char *val, unsigned int num) +{ + XChangeProperty( dpy, win, atom, XA_STRING, 8, PropModeReplace, (unsigned char*)val, val ? strlen(val):0 ); +} + +API void utilx_set_fake_launch_img(Display* dpy, Window win, char *file_name) +{ + //UTILX_TRACE ("[UTILX] utilx_set_effect_state... win = %x, show_state = %d\n", win, enable); + + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return; + } + if( !_atom_comp_fake_launch_image) + _atom_comp_fake_launch_image = XInternAtom(dpy, "_E_COMP_FAKE_LAUNCH_IMAGE",False); + + _utilx_string_set_window_property(dpy, win, _atom_comp_fake_launch_image, file_name, 1); +} + +API void utilx_show_fake_effect( Display *dpy, Window win, char *fake_image_file ) +{ + XEvent xev; + + _atom_comp_fake_launch = XInternAtom( dpy, "_E_COMP_FAKE_LAUNCH", False ); + + if( !_atom_comp_fake_launch ) + { + fprintf( stderr, "XInternAtom(_E_COMP_FAKE_LAUNCH) failed.\n" ); + return; + } + + utilx_set_fake_launch_img(dpy, win, fake_image_file); + + XSync(dpy, 0 ); + + // send fake client message + xev.xclient.type = ClientMessage; + xev.xclient.display = dpy; + xev.xclient.window = win; + xev.xclient.message_type = _atom_comp_fake_launch; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; // 1 : start effect , 0 : end effect + xev.xclient.data.l[1] = 0; + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent( dpy, win, False, + SubstructureRedirectMask | SubstructureNotifyMask, + &xev ); + XSync(dpy, 0 ); + +} + + +API void utilx_hide_fake_effect( Display *dpy, Window win) +{ + XEvent xev; + + _atom_comp_fake_launch = XInternAtom( dpy, "_E_COMP_FAKE_LAUNCH", False ); + if( !_atom_comp_fake_launch ) + { + fprintf( stderr, "XInternAtom(_E_COMP_FAKE_LAUNCH) failed.\n" ); + return; + } + + // send fake client message + xev.xclient.type = ClientMessage; + xev.xclient.display = dpy; + xev.xclient.window = win; + xev.xclient.message_type = _atom_comp_fake_launch; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 0; // 1 : start effect , 0 : end effect + xev.xclient.data.l[1] = 0; + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent( dpy, win, False, + SubstructureRedirectMask | SubstructureNotifyMask, + &xev ); + XSync(dpy, 0 ); +} + +static void _utilx_effect_atom_check( Display* dpy ) +{ + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return; + } + + if( !_atom_comp_window_effect_type) + _atom_comp_window_effect_type = XInternAtom(dpy, "_NET_CM_WINDOW_EFFECT_TYPE",False); + if( !_atom_comp_effect_default ) + _atom_comp_effect_default = XInternAtom(dpy, "_NET_CM_EFFECT_DEFAULT",False); + if( !_atom_comp_effect_none ) + _atom_comp_effect_none = XInternAtom(dpy, "_NET_CM_EFFECT_NONE",False); + if( !_atom_comp_effect_custom0 ) + _atom_comp_effect_custom0 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM0",False); + if( !_atom_comp_effect_custom1 ) + _atom_comp_effect_custom1 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM1",False); + if( !_atom_comp_effect_custom2 ) + _atom_comp_effect_custom2 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM2",False); + if( !_atom_comp_effect_custom3 ) + _atom_comp_effect_custom3 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM3",False); + if( !_atom_comp_effect_custom4 ) + _atom_comp_effect_custom4 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM4",False); + if( !_atom_comp_effect_custom5 ) + _atom_comp_effect_custom5 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM5",False); + if( !_atom_comp_effect_custom6 ) + _atom_comp_effect_custom6 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM6",False); + if( !_atom_comp_effect_custom7 ) + _atom_comp_effect_custom7 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM7",False); + if( !_atom_comp_effect_custom8 ) + _atom_comp_effect_custom8 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM8",False); + if( !_atom_comp_effect_custom9 ) + _atom_comp_effect_custom9 = XInternAtom(dpy, "_NET_CM_EFFECT_CUSTOM9",False); +} + +static Atom _utilx_convert_style_to_atom( Display* dpy, Utilx_Effect_Style style ) +{ + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return _atom_comp_effect_none; + } + _utilx_effect_atom_check(dpy); + + if ( style == UTILX_EFFECT_STYLE_DEFAULT ) return _atom_comp_effect_default; + else if ( style == UTILX_EFFECT_STYLE_NONE ) return _atom_comp_effect_none; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM0 ) return _atom_comp_effect_custom0; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM1 ) return _atom_comp_effect_custom1; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM2 ) return _atom_comp_effect_custom2; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM3 ) return _atom_comp_effect_custom3; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM4 ) return _atom_comp_effect_custom4; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM5 ) return _atom_comp_effect_custom5; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM6 ) return _atom_comp_effect_custom6; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM7 ) return _atom_comp_effect_custom7; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM8 ) return _atom_comp_effect_custom8; + else if ( style == UTILX_EFFECT_STYLE_CUSTOM9 ) return _atom_comp_effect_custom9; + else return _atom_comp_effect_none; + +} + +static Utilx_Effect_Style _utilx_convert_atom_to_style( Display* dpy, Atom style ) +{ + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return UTILX_EFFECT_STYLE_NONE; + } + _utilx_effect_atom_check(dpy); + + if ( style == _atom_comp_effect_default ) return UTILX_EFFECT_STYLE_DEFAULT; + else if ( style == _atom_comp_effect_none ) return UTILX_EFFECT_STYLE_NONE; + else if ( style == _atom_comp_effect_custom0 ) return UTILX_EFFECT_STYLE_CUSTOM0; + else if ( style == _atom_comp_effect_custom1 ) return UTILX_EFFECT_STYLE_CUSTOM1; + else if ( style == _atom_comp_effect_custom2 ) return UTILX_EFFECT_STYLE_CUSTOM2; + else if ( style == _atom_comp_effect_custom3 ) return UTILX_EFFECT_STYLE_CUSTOM3; + else if ( style == _atom_comp_effect_custom4 ) return UTILX_EFFECT_STYLE_CUSTOM4; + else if ( style == _atom_comp_effect_custom5 ) return UTILX_EFFECT_STYLE_CUSTOM5; + else if ( style == _atom_comp_effect_custom6 ) return UTILX_EFFECT_STYLE_CUSTOM6; + else if ( style == _atom_comp_effect_custom7 ) return UTILX_EFFECT_STYLE_CUSTOM7; + else if ( style == _atom_comp_effect_custom8 ) return UTILX_EFFECT_STYLE_CUSTOM8; + else if ( style == _atom_comp_effect_custom9 ) return UTILX_EFFECT_STYLE_CUSTOM9; + else return UTILX_EFFECT_STYLE_DEFAULT; +} + +API void utilx_set_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type, Utilx_Effect_Style style) +{ + Atom *window_effect_type_list = NULL; + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return; + } + _utilx_effect_atom_check(dpy); + + window_effect_type_list = (Atom *)malloc(sizeof(Atom) * 6); + + if ( !window_effect_type_list ) + { + fprintf (stderr, "[UTILX] Error.. malloc().. %s (%d)\n", __func__, __LINE__); + return; + } + + window_effect_type_list[0] = _atom_comp_effect_default; + window_effect_type_list[1] = _atom_comp_effect_default; + window_effect_type_list[2] = _atom_comp_effect_default; + window_effect_type_list[3] = _atom_comp_effect_default; + window_effect_type_list[4] = _atom_comp_effect_default; + window_effect_type_list[5] = _atom_comp_effect_default; + + _utilx_get_window_property(dpy, win, _atom_comp_window_effect_type, XA_ATOM, (unsigned int *)window_effect_type_list, 6); + + if ( type == UTILX_EFFECT_TYPE_MAP ) window_effect_type_list[0] = _utilx_convert_style_to_atom(dpy, style); + else if ( type == UTILX_EFFECT_TYPE_UNMAP ) window_effect_type_list[1] = _utilx_convert_style_to_atom(dpy, style); + else if ( type == UTILX_EFFECT_TYPE_RAISEABOVE ) window_effect_type_list[2] = _utilx_convert_style_to_atom(dpy, style); + else if ( type == UTILX_EFFECT_TYPE_ROTATION ) window_effect_type_list[3] = _utilx_convert_style_to_atom(dpy, style); + else if ( type == UTILX_EFFECT_TYPE_FOCUSIN ) window_effect_type_list[4] = _utilx_convert_style_to_atom(dpy, style); + else if ( type == UTILX_EFFECT_TYPE_FOCUSOUT ) window_effect_type_list[5] = _utilx_convert_style_to_atom(dpy, style); + + _utilx_set_window_property(dpy, win, _atom_comp_window_effect_type, XA_ATOM, (unsigned int *)window_effect_type_list, 6); + + XSync(dpy, 0 ); + free(window_effect_type_list); +} + +API Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type) +{ + Atom *window_effect_type_list = NULL; + Utilx_Effect_Style style = UTILX_EFFECT_STYLE_DEFAULT; + + if ( dpy == NULL ) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return UTILX_EFFECT_STYLE_NONE; + } + _utilx_effect_atom_check(dpy); + + window_effect_type_list = (Atom *)malloc(sizeof(Atom) * 6); + + if ( !window_effect_type_list ) + { + fprintf (stderr, "[UTILX] Error.. malloc().. %s (%d)\n", __func__, __LINE__); + return UTILX_EFFECT_STYLE_NONE; + } + + if ( _utilx_get_window_property(dpy, win, _atom_comp_window_effect_type, XA_ATOM, (unsigned int *)window_effect_type_list, 6) != 6 ) + { + fprintf (stderr, "[UTILX] Error.. get property failed!.. %s (%d)\n", __func__, __LINE__); + free(window_effect_type_list); + return UTILX_EFFECT_STYLE_NONE; + } + + if ( type == UTILX_EFFECT_TYPE_MAP ) style = _utilx_convert_atom_to_style(dpy, window_effect_type_list[0]); + else if ( type == UTILX_EFFECT_TYPE_UNMAP ) style = _utilx_convert_atom_to_style(dpy, window_effect_type_list[1]); + else if ( type == UTILX_EFFECT_TYPE_RAISEABOVE ) style = _utilx_convert_atom_to_style(dpy, window_effect_type_list[2]); + else if ( type == UTILX_EFFECT_TYPE_ROTATION ) style = _utilx_convert_atom_to_style(dpy, window_effect_type_list[3]); + else if ( type == UTILX_EFFECT_TYPE_FOCUSIN ) style = _utilx_convert_atom_to_style(dpy, window_effect_type_list[4]); + else if ( type == UTILX_EFFECT_TYPE_FOCUSOUT ) style = _utilx_convert_atom_to_style(dpy, window_effect_type_list[5]); + + XSync(dpy, 0 ); + free(window_effect_type_list); + return style; +} + +API int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state) +{ + UTILX_TRACE ("[UTILX] utilx_set_window_opaque_state... win = %x, show_state = %d\n", win, state); + + unsigned int is_opaque; + + if (dpy == NULL) + { + fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); + return 0; + } + + switch (state) + { + case UTILX_OPAQUE_STATE_OFF: + is_opaque = 0; + break; + + case UTILX_OPAQUE_STATE_ON: + is_opaque = 1; + break; + + default: + fprintf (stderr, "[UTILX] Error.. Invald State.. %s (%d)\n", __func__, __LINE__); + return 0; + } + + if (!_atom_window_opaque) + { + _atom_window_opaque = XInternAtom (dpy, "_E_ILLUME_WINDOW_REGION_OPAQUE", False); + if (!_atom_window_opaque) + { + fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_WINDOW_REGION_OPAQUE atom.. %s (%d)\n", __func__, __LINE__); + return 0; + } + } + + _utilx_set_window_property (dpy, win, _atom_window_opaque, XA_CARDINAL, + (unsigned int *)&is_opaque, 1); + + return 1; +} + +static void +_utilx_screen_capture_atom_ensure (Display* dpy) +{ + if (_atom_screen_capture_disable) + return; + + _atom_screen_capture_disable = XInternAtom (dpy, "_CB_SCREEN_CAPTURE_DISABLE", False); + if (_atom_screen_capture_disable) + return; + + fprintf (stderr, "[UTILX] Error.. Cannot create _CB_SCREEN_CAPTURE_DISABLE atom.. %s (%d)\n", __func__, __LINE__); +} + +API int +utilx_set_screen_capture(Display* dpy, int enable) +{ + Window root; + int disable; + + if (!dpy) + { + fprintf (stderr, "[UTILX] Error.. dpy is NULL %s (%d)\n", __func__, __LINE__); + return 0; + } + + root = RootWindow (dpy, DefaultScreen(dpy)); + disable = (enable) ? 0 : 1; + + _utilx_screen_capture_atom_ensure (dpy); + + _utilx_set_window_property (dpy, root, _atom_screen_capture_disable, XA_CARDINAL, (unsigned int *)&disable, 1); + + return 1; +} + +API int +utilx_get_screen_capture(Display* dpy) +{ + Window root; + int disable = 0; + + if (!dpy) + { + fprintf (stderr, "[UTILX] Error.. dpy is NULL %s (%d)\n", __func__, __LINE__); + return 0; + } + + root = RootWindow (dpy, DefaultScreen(dpy)); + + _utilx_screen_capture_atom_ensure (dpy); + + _utilx_get_window_property(dpy, root, _atom_screen_capture_disable, XA_CARDINAL, + (unsigned int *)&disable, 1); + + return (disable) ? 0 : 1; +} + +API void utilx_set_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value) +{ + _utilx_set_window_property(dpy, win, atom, XA_CARDINAL, value, 1); +} + +API int utilx_get_window_cardinal_property (Display* dpy, Window win, Atom atom, unsigned int *value) +{ + return _utilx_get_window_property(dpy, win, atom, XA_CARDINAL, value, 1); +} + +API void utilx_show_capture_effect( Display *dpy, Window win) +{ + XEvent xev; + + _atom_comp_capture_effect = XInternAtom( dpy, "_E_COMP_CAPTURE_EFFECT", False ); + if( !_atom_comp_capture_effect ) + { + fprintf( stderr, "XInternAtom(_E_COMP_CAPTURE_EFFECT) failed.\n" ); + return; + } + + // send capture effect client message + xev.xclient.type = ClientMessage; + xev.xclient.display = dpy; + xev.xclient.window = win; + xev.xclient.message_type = _atom_comp_capture_effect; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 0; + xev.xclient.data.l[1] = 0; + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent( dpy, win, False, + SubstructureRedirectMask | SubstructureNotifyMask, + &xev ); + XSync(dpy, 0 ); +}