From: jk7744.park Date: Sun, 1 Feb 2015 05:07:49 +0000 (+0900) Subject: tizen 2.3 release X-Git-Tag: submit/tizen_2.3/20150202.070134^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3ffbb4253c654ea71d4d78182e19741d43f8cb9;p=framework%2Fuifw%2Fxorg%2Flibslp-utilx.git tizen 2.3 release --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 930bf5e..d0baa57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(utilX C) SET(SRCS x11.c) -SET(HEADERS utilX.h) +SET(HEADERS utilX.h utilX_ext.h) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") diff --git a/TC/_export_env.sh b/TC/_export_env.sh index 72a11ec..467c30b 100755 --- a/TC/_export_env.sh +++ b/TC/_export_env.sh @@ -1,6 +1,7 @@ #!/bin/sh -. ./config +source ./config + export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path export PATH=$TET_TARGET_PATH/bin:$PATH diff --git a/TC/config b/TC/config index c7eae66..dc96c8d 100755 --- a/TC/config +++ b/TC/config @@ -1,2 +1,3 @@ -TET_INSTALL_HOST_PATH=/home/nfs_mount/TETware -TET_INSTALL_TARGET_PATH=/mnt/nfs/TETware +PKG_NAME=utilX +TET_INSTALL_HOST_PATH=/var/tmp/dts_fw/TC/TETware +TET_INSTALL_TARGET_PATH=/opt/home/$PKG_NAME/TETware diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile index dbbc399..0982f06 100755 --- a/TC/testcase/Makefile +++ b/TC/testcase/Makefile @@ -1,20 +1,21 @@ -CC = gcc +include ../config -C_FILES = $(shell ls *.c) +CC ?= gcc -PKGS = elementary ecore-x ecore evas x11 dlog glib-2.0 utilX +C_FILES = $(shell ls *.c) +PKGS = $(PKG_NAME) +PKGS += glib-2.0 +PKGS += ecore-x ecore-evas x11 ecore +LDFLAGS = `pkg-config --libs $(PKGS)` LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s -LDFLAGS += `pkg-config --libs $(PKGS)` -CFLAGS += `pkg-config --cflags $(PKGS)` -CFLAGS += -I. +CFLAGS = -I. `pkg-config --cflags $(PKGS)` CFLAGS += -I$(TET_ROOT)/inc/tet3 CFLAGS += -Wall -#TARGETS = $(C_FILES:%.c=tc-%) TCS := $(shell ls -1 *.c | cut -d. -f1) all: $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist index 81af698..4caa7d1 100755 --- a/TC/testcase/tslist +++ b/TC/testcase/tslist @@ -1 +1,5 @@ -/testcase/utc_utilx_test +/testcase/utc_utilx_key_grab_test +/testcase/utc_utilx_notification_level_test +/testcase/utc_utilx_screen_shot_test +/testcase/utc_utilx_opaque_test + diff --git a/TC/testcase/utc_utilx_key_grab_test.c b/TC/testcase/utc_utilx_key_grab_test.c new file mode 100644 index 0000000..7f7bbb4 --- /dev/null +++ b/TC/testcase/utc_utilx_key_grab_test.c @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2012 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 + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_utilx_grab_key_excl_p(void); +static void utc_utilx_grab_key_top_p(void); +static void utc_utilx_grab_key_share_p(void); +static void utc_utilx_grab_key_excl_n(void); +static void utc_utilx_grab_key_top_n(void); +static void utc_utilx_grab_key_share_n(void); +static void utc_utilx_ungrab_key_p(void); +static void utc_utilx_ungrab_key_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_utilx_grab_key_excl_p, 1 }, + { utc_utilx_grab_key_top_p, 1 }, + { utc_utilx_grab_key_share_p, 1 }, + { utc_utilx_grab_key_excl_n, 1 }, + { utc_utilx_grab_key_top_n, 1 }, + { utc_utilx_grab_key_share_n, 1 }, + { utc_utilx_ungrab_key_p, 1 }, + { utc_utilx_ungrab_key_n, 1 }, + // Do not remove below line + { NULL, 0 } +}; + +Ecore_Evas *ee; +Ecore_X_Display *disp; +Ecore_X_Window win; + +static void startup(void) +{ + /* start of TC */ + if(!ecore_init()){ + dts_fail("utilx_grab_key", "failed ecore_init"); + } + if(!ecore_evas_init()){ + dts_fail("utilx_grab_key", "failed ecore_evas_init"); + } + + ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 720, 1280); + if(!ee){ + dts_fail("utilx_grab_key", "failed to make window"); + } + ecore_evas_title_set(ee, "Ecore_Evas Template"); + ecore_evas_borderless_set(ee, 0); + ecore_evas_show(ee); + + disp = ecore_x_display_get(); + if(!disp){ + dts_fail("utilx_grab_key", "failed to get display"); + } + + win = ecore_evas_software_x11_window_get(ee); + if(!win){ + dts_fail("utilx_grab_key", "failed to get ecore_x_window"); + } +} + +static void cleanup(void) +{ + /* end of TC */ + ecore_evas_shutdown(); + ecore_shutdown(); +} + + +/** + * @brief test case of utilx_grab_key() / utilx_ungrab_key() + */ + +static void utc_utilx_grab_key_excl_p(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(disp, win, KEY_MEDIA, EXCLUSIVE_GRAB); + if( grab_result == 0 ) + { + dts_pass("utilx_grab_key", "passed"); + ungrab_result = utilx_ungrab_key(disp, win, KEY_MEDIA); + if( ungrab_result != 0) + dts_fail("utilx_grab_key", "ungrab failed"); + } + else + { + dts_fail("utilx_grab_key", "failed"); + } +} + +static void utc_utilx_grab_key_top_p(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(disp, win, KEY_STOPCD, TOP_POSITION_GRAB); + if( grab_result == 0 ) + { + dts_pass("utilx_grab_key", "passed"); + ungrab_result = utilx_ungrab_key(disp, win, KEY_STOPCD); + if( ungrab_result != 0) + dts_fail("utilx_grab_key", "ungrab failed"); + + } + else + { + dts_fail("utilx_grab_key", "failed"); + } +} + +static void utc_utilx_grab_key_share_p(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(disp, win, KEY_STOPCD, SHARED_GRAB); + if( grab_result == 0 ) + { + dts_pass("utilx_grab_key", "passed"); + ungrab_result = utilx_ungrab_key(disp, win, KEY_STOPCD); + if( ungrab_result != 0) + dts_fail("utilx_grab_key", "ungrab failed"); + } + else + { + dts_fail("utilx_grab_key", "failed"); + } +} + +static void utc_utilx_grab_key_excl_n(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(NULL, win, KEY_STOPCD, EXCLUSIVE_GRAB); + if( grab_result != 0 ) + { + dts_pass("utilx_grab_key", "passed"); + } + else + { + dts_fail("utilx_grab_key", "failed"); + ungrab_result = utilx_ungrab_key(disp, win, KEY_STOPCD); + if( ungrab_result != 0) + dts_fail("utilx_grab_key", "ungrab failed"); + + } +} + +static void utc_utilx_grab_key_top_n(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(NULL, win, KEY_STOPCD, TOP_POSITION_GRAB); + if( grab_result != 0 ) + { + dts_pass("utilx_grab_key", "passed"); + } + else + { + dts_fail("utilx_grab_key", "failed"); + ungrab_result = utilx_ungrab_key(disp, win, KEY_STOPCD); + if( ungrab_result != 0) + dts_fail("utilx_grab_key", "ungrab failed"); + + } +} + +static void utc_utilx_grab_key_share_n(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(NULL, win, KEY_STOPCD, SHARED_GRAB); + if( grab_result != 0 ) + { + dts_pass("utilx_grab_key", "passed"); + } + else + { + dts_fail("utilx_grab_key", "failed"); + ungrab_result = utilx_ungrab_key(disp, win, KEY_STOPCD); + if( ungrab_result != 0) + dts_fail("utilx_grab_key", "ungrab failed"); + + } +} + +static void utc_utilx_ungrab_key_p(void) +{ + int grab_result; + int ungrab_result; + + grab_result = utilx_grab_key(disp, win, KEY_STOPCD, SHARED_GRAB); + if( grab_result != 0 ){ + dts_fail("utilx_ungrab_key", "failed to grab the key"); + } + + ungrab_result = utilx_ungrab_key(disp, win, KEY_STOPCD); + if(ungrab_result == 0) + { + dts_pass("utilx_ungrab_key", "passed"); + } + else + { + dts_fail("utilx_ungrab_key", "failed"); + } +} + +static void utc_utilx_ungrab_key_n(void) +{ + int grab_result; + int ungrab_result; + + ungrab_result = utilx_ungrab_key(NULL, win, KEY_STOPCD); + if(ungrab_result != 0) + { + dts_pass("utilx_ungrab_key", "passed"); + } + else + { + dts_fail("utilx_ungrab_key", "failed"); + } +} diff --git a/TC/testcase/utc_utilx_notification_level_test.c b/TC/testcase/utc_utilx_notification_level_test.c new file mode 100644 index 0000000..cd97990 --- /dev/null +++ b/TC/testcase/utc_utilx_notification_level_test.c @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2012 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 + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_utilx_system_notification_level_test_positive_1(void); +static void utc_utilx_system_notification_level_test_positive_2(void); +static void utc_utilx_system_notification_level_test_positive_3(void); +static void utc_utilx_system_notification_level_test_positive_4(void); +static void utc_utilx_system_notification_level_test_negative_1(void); +static void utc_utilx_system_notification_level_test_negative_2(void); + + +struct tet_testlist tet_testlist[] = { + { utc_utilx_system_notification_level_test_positive_1, 1 }, + { utc_utilx_system_notification_level_test_positive_2, 1 }, + { utc_utilx_system_notification_level_test_positive_3, 1 }, + { utc_utilx_system_notification_level_test_positive_4, 1 }, + { utc_utilx_system_notification_level_test_negative_1, 1 }, + { utc_utilx_system_notification_level_test_negative_2, 1 }, + // Do not remove below line + { NULL, 0 }, +}; + +Display* dpy; +Window root, win; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + + dpy = XOpenDisplay(NULL); + root = XDefaultRootWindow(dpy); + + win = XCreateSimpleWindow(dpy, root, 0, 0, 480, 800, 2, BlackPixel(dpy,0), WhitePixel(dpy,0)); + XMapWindow(dpy, win); +} + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); +} + +/** + * @brief test case of utc_utilx_system_notification_level_test_positive_1() + */ +static void utc_utilx_system_notification_level_test_positive_1(void) +{ + Utilx_Notification_Level level = UTILX_NOTIFICATION_LEVEL_HIGH; + + utilx_set_system_notification_level(dpy, win, UTILX_NOTIFICATION_LEVEL_LOW); + XFlush(dpy); + + level = utilx_get_system_notification_level(dpy, win); + + if (level == UTILX_NOTIFICATION_LEVEL_LOW) + { + dts_pass("utc_utilx_system_notification_level_test_positive_1", "passed"); + } + else + { + dts_fail("utc_utilx_system_notification_level_test_positive_1", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_system_notification_level_test_positive_2() + */ +static void utc_utilx_system_notification_level_test_positive_2(void) +{ + Utilx_Notification_Level level = UTILX_NOTIFICATION_LEVEL_HIGH; + + utilx_set_system_notification_level(dpy, win, UTILX_NOTIFICATION_LEVEL_NORMAL); + XFlush(dpy); + + level = utilx_get_system_notification_level(dpy, win); + + if (level == UTILX_NOTIFICATION_LEVEL_NORMAL) + { + dts_pass("utc_utilx_system_notification_level_test_positive_2", "passed"); + } + else + { + dts_fail("utc_utilx_system_notification_level_test_positive_2", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_system_notification_level_test_positive_3() + */ +static void utc_utilx_system_notification_level_test_positive_3(void) +{ + Utilx_Notification_Level level = UTILX_NOTIFICATION_LEVEL_NORMAL; + + utilx_set_system_notification_level(dpy, win, UTILX_NOTIFICATION_LEVEL_HIGH); + XFlush(dpy); + + level = utilx_get_system_notification_level(dpy, win); + + if (level == UTILX_NOTIFICATION_LEVEL_HIGH) + { + dts_pass("utc_utilx_system_notification_level_test_positive_3", "passed"); + } + else + { + dts_fail("utc_utilx_system_notification_level_test_positive_3", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_system_notification_level_test_positive_4() + */ +static void utc_utilx_system_notification_level_test_positive_4(void) +{ + Utilx_Notification_Level level = UTILX_NOTIFICATION_LEVEL_HIGH; + + utilx_set_system_notification_level(dpy, win, 100); + XFlush(dpy); + + level = utilx_get_system_notification_level(dpy, win); + + if (level == UTILX_NOTIFICATION_LEVEL_LOW) + { + dts_pass("utc_utilx_system_notification_level_test_positive_4", "passed"); + } + else + { + dts_fail("utc_utilx_system_notification_level_test_positive_4", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_system_notification_level_test_negative_1() + */ +static void utc_utilx_system_notification_level_test_negative_1(void) +{ + Ecore_X_Display *dpy2 = NULL; + Utilx_Notification_Level level = UTILX_NOTIFICATION_LEVEL_HIGH; + + // invalid display parameter + utilx_set_system_notification_level(dpy2, win, UTILX_NOTIFICATION_LEVEL_NORMAL); + XFlush(dpy); + + level = utilx_get_system_notification_level(dpy, win); + + if (level == UTILX_NOTIFICATION_LEVEL_LOW) + { + dts_pass("utc_utilx_system_notification_level_test_negative_1", "passed"); + } + else + { + dts_fail("utc_utilx_system_notification_level_test_negative_1", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_system_notification_level_test_negative_2() + */ +static void utc_utilx_system_notification_level_test_negative_2(void) +{ + Ecore_X_Display *dpy2 = NULL; + Utilx_Notification_Level level = UTILX_NOTIFICATION_LEVEL_HIGH; + + utilx_set_system_notification_level(dpy, win, UTILX_NOTIFICATION_LEVEL_NORMAL); + XFlush(dpy); + + // invalid display parameter + level = utilx_get_system_notification_level(dpy2, win); + + if (level == UTILX_NOTIFICATION_LEVEL_LOW) + { + dts_pass("utc_utilx_system_notification_level_test_negative_2", "passed"); + } + else + { + dts_fail("utc_utilx_system_notification_level_test_negative_2", "failed"); + } +} + diff --git a/TC/testcase/utc_utilx_opaque_test.c b/TC/testcase/utc_utilx_opaque_test.c new file mode 100644 index 0000000..e09d4a6 --- /dev/null +++ b/TC/testcase/utc_utilx_opaque_test.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2012 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 + + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_utilx_window_opaque_state_test_positive_1(void); +static void utc_utilx_window_opaque_state_test_positive_2(void); +static void utc_utilx_window_opaque_state_test_negative_1(void); +static void utc_utilx_window_opaque_state_test_negative_2(void); + + +struct tet_testlist tet_testlist[] = { + { utc_utilx_window_opaque_state_test_positive_1, 1 }, + { utc_utilx_window_opaque_state_test_positive_2, 1 }, + { utc_utilx_window_opaque_state_test_negative_1, 1 }, + { utc_utilx_window_opaque_state_test_negative_2, 1 }, + // Do not remove below line + { NULL, 0 }, +}; + +Display* dpy; +Window root, win; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + + dpy = XOpenDisplay(NULL); + root = XDefaultRootWindow(dpy); + + win = XCreateSimpleWindow(dpy, root, 0, 0, 480, 800, 2, BlackPixel(dpy,0), WhitePixel(dpy,0)); + XMapWindow(dpy, win); +} + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); +} + + +/** + * @brief test case of utc_utilx_window_opaque_state_test_positive_1() + */ +static void utc_utilx_window_opaque_state_test_positive_1(void) +{ + int ret; + + ret = utilx_set_window_opaque_state(dpy, win, UTILX_OPAQUE_STATE_ON); + XFlush(dpy); + + if (ret == 1) + { + dts_pass("utc_utilx_window_opaque_state_test_positive_1", "passed"); + } + else + { + dts_fail("utc_utilx_window_opaque_state_test_positive_1", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_window_opaque_state_test_positive_2() + */ +static void utc_utilx_window_opaque_state_test_positive_2(void) +{ + int ret; + + ret = utilx_set_window_opaque_state(dpy, win, UTILX_OPAQUE_STATE_OFF); + XFlush(dpy); + + if (ret == 1) + { + dts_pass("utc_utilx_window_opaque_state_test_positive_2", "passed"); + } + else + { + dts_fail("utc_utilx_window_opaque_state_test_positive_2", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_window_opaque_state_test_negative_1() + */ +static void utc_utilx_window_opaque_state_test_negative_1(void) +{ + int ret; + + ret = utilx_set_window_opaque_state(dpy, win, 100); + XFlush(dpy); + + if (ret == 0) + { + dts_pass("utc_utilx_window_opaque_state_test_positive_2", "passed"); + } + else + { + dts_fail("utc_utilx_window_opaque_state_test_positive_2", "failed"); + } +} + + +/** + * @brief test case of utc_utilx_window_opaque_state_test_negative_2() + */ +static void utc_utilx_window_opaque_state_test_negative_2(void) +{ + int ret; + + ret = utilx_set_window_opaque_state(NULL, win, UTILX_OPAQUE_STATE_ON); + XFlush(dpy); + + if (ret == 0) + { + dts_pass("utc_utilx_window_opaque_state_test_positive_2", "passed"); + } + else + { + dts_fail("utc_utilx_window_opaque_state_test_positive_2", "failed"); + } +} + + + diff --git a/TC/testcase/utc_utilx_screen_shot_test.c b/TC/testcase/utc_utilx_screen_shot_test.c new file mode 100644 index 0000000..b9755ef --- /dev/null +++ b/TC/testcase/utc_utilx_screen_shot_test.c @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2012 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 + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_utilx_screen_shot_test_positive_1(void); +static void utc_utilx_screen_shot_test_positive_2(void); +static void utc_utilx_screen_shot_test_positive_3(void); +static void utc_utilx_screen_shot_test_negative_1(void); +static void utc_utilx_screen_shot_test_negative_2(void); +static void utc_utilx_screen_shot_test_negative_3(void); + +struct tet_testlist tet_testlist[] = { + { utc_utilx_screen_shot_test_positive_1, 1 }, + { utc_utilx_screen_shot_test_positive_2, 1 }, + { utc_utilx_screen_shot_test_positive_3, 1 }, + { utc_utilx_screen_shot_test_negative_1, 1 }, + { utc_utilx_screen_shot_test_negative_2, 1 }, + { utc_utilx_screen_shot_test_negative_3, 1 }, + // Do not remove below line + { NULL, 0 }, +}; + +Display *dpy; +int width, height; +void *dump; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); +} + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); +} + +/** + * @brief test case of utc_utilx_screen_shot_test_positive_1() + */ +static void utc_utilx_screen_shot_test_positive_1(void) +{ + dpy = XOpenDisplay (NULL); + + dump = utilx_create_screen_shot (dpy, 720, 1280); + + dts_pass ("utc_utilx_screen_shot_test_positive_1", "passed"); + + utilx_release_screen_shot (); + + XCloseDisplay(dpy); +} + + +/** + * @brief test case of utc_utilx_screen_shot_test_positive_2() + */ +static void utc_utilx_screen_shot_test_positive_2(void) +{ + dpy = XOpenDisplay (NULL); + + dump = utilx_create_screen_shot (dpy, 400, 400); + + dts_pass ("utc_utilx_screen_shot_test_positive_2", "passed"); + + utilx_release_screen_shot (); + + XCloseDisplay(dpy); +} + + +/** + * @brief test case of utc_utilx_screen_shot_test_positive_3() + */ +static void utc_utilx_screen_shot_test_positive_3(void) +{ + dpy = XOpenDisplay (NULL); + + dump = utilx_create_screen_shot (dpy, 1280, 720); + + dts_pass ("utc_utilx_screen_shot_test_positive_3", "passed"); + + utilx_release_screen_shot (); + + XCloseDisplay(dpy); +} + +/** + * @brief test case of utc_utilx_screen_shot_test_negative_1() + */ +static void utc_utilx_screen_shot_test_negative_1(void) +{ + dump = utilx_create_screen_shot (NULL, 720, 720); + + if (dump == NULL) + dts_pass ("utc_utilx_screen_shot_test_negative_1", "passed"); + else + dts_fail ("utc_utilx_screen_shot_test_negative_1", "failed"); +} + + +/** + * @brief test case of utc_utilx_screen_shot_test_negative_2() + */ +static void utc_utilx_screen_shot_test_negative_2(void) +{ + dpy = XOpenDisplay (NULL); + + dump = utilx_create_screen_shot (dpy, 0, 720); + + if (dump == NULL) + dts_pass ("utc_utilx_screen_shot_test_negative_2", "passed"); + else + dts_fail ("utc_utilx_screen_shot_test_negative_2", "failed"); + + XCloseDisplay(dpy); +} + + +/** + * @brief test case of utc_utilx_screen_shot_test_negative_3() + */ +static void utc_utilx_screen_shot_test_negative_3(void) +{ + dpy = XOpenDisplay (NULL); + + dump = utilx_create_screen_shot (dpy, 720, 0); + + if (dump == NULL) + dts_pass ("utc_utilx_screen_shot_test_negative_3", "passed"); + else + dts_fail ("utc_utilx_screen_shot_test_negative_3", "failed"); + + XCloseDisplay(dpy); +} diff --git a/TC/testcase/utc_utilx_test.c b/TC/testcase/utc_utilx_test.c deleted file mode 100644 index 7934c62..0000000 --- a/TC/testcase/utc_utilx_test.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2012 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 - - -static void startup(void); -static void cleanup(void); - -void (*tet_startup)(void) = startup; -void (*tet_cleanup)(void) = cleanup; - -static void utc_utilx_enable_indicator(void); - - -struct tet_testlist tet_testlist[] = { - { utc_utilx_enable_indicator, 1 }, - // Do not remove below line - { NULL, 0 }, -}; - -static void startup(void) -{ - /* start of TC */ -} - -static void cleanup(void) -{ - /* end of TC */ -} - - -/** - * @brief test case of utilx_enable_indicator() - */ -static void utc_utilx_enable_indicator(void) -{ - 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); - - // If the win want to show indicator, enables indicator. - utilx_enable_indicator(dpy, win, 1); - XFlush(dpy); - - ret = 1; - - if(ret) - { - dts_pass("utc_efl_util_set_notification_window_level_positive", "passed"); - } - else - { - dts_fail("utc_efl_util_set_notification_window_level_positive", "failed"); - } -} - diff --git a/doc/ui_utilx_doc.h b/doc/ui_utilx_doc.h new file mode 100644 index 0000000..a4b04c4 --- /dev/null +++ b/doc/ui_utilx_doc.h @@ -0,0 +1,36 @@ +/* + * 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 __TIZEN_UI_UTILX_DOC_H__ +#define __TIZEN_UI_UTILX_DOC_H__ + +/** + * @internal + * @defgroup CAPI_UI_UTILX_MODULE utilX + * @brief The utilX API contains Tizen Linux platform X11 utilties. + * @ingroup CAPI_UI_FRAMEWORK + * + * @section CAPI_UI_UTILX_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_UI_UTILX_MODULE_OVERVIEW Overview + * The utilX is a common X11 utility. + * It provides functions used by x clients, mainly to get or set the state of X11 resources's information. + * + */ + +#endif /* __TIZEN_UI_UTILX_DOC_H__ */ diff --git a/packaging/libslp-utilx.spec b/packaging/libslp-utilx.spec index 29cf2eb..392a87c 100644 --- a/packaging/libslp-utilx.spec +++ b/packaging/libslp-utilx.spec @@ -1,9 +1,8 @@ #sbs-git:slp/pkgs/l/libslp-utilx libslp-utilx 0.1.7 5957503c84e65113399e346c7d5618e73957d6ff Name: libslp-utilx Summary: utilX -Version: 0.1.32 -Release: 1.1 -VCS: framework/uifw/xorg/libslp-utilx#libslp-utilx-0.1.23-1.1-27-ga47333741b68616ea6a0dc58e55951c2b2089cdc +Version: 0.4.5 +Release: 1 Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -29,6 +28,7 @@ Utility functions for the XWindow Summary: utilX Group: Development/Libraries Requires: %{name} = %{version}-%{release} +Requires: pkgconfig(xproto) Requires: pkgconfig(x11) %description devel @@ -64,7 +64,7 @@ cp %{_builddir}/%{buildsubdir}/LICENSE.APLv2 %{buildroot}/usr/share/license/%{na %files devel %defattr(-,root,root,-) -/usr/include/utilX.h +/usr/include/* /usr/lib/libutilX.so /usr/lib/pkgconfig/utilX.pc diff --git a/utilX.h b/utilX.h index ab95bd9..c956520 100755 --- a/utilX.h +++ b/utilX.h @@ -17,8 +17,8 @@ * */ -#ifndef __SAMSUNG_LINUX_UTIL_X11_H__ -#define __SAMSUNG_LINUX_UTIL_X11_H__ +#ifndef __TIZEN_LINUX_UTIL_X11_H__ +#define __TIZEN_LINUX_UTIL_X11_H__ #ifdef __GNUC__ #define DEPRECATED __attribute__((deprecated)) @@ -27,19 +27,8 @@ #endif /** - * @ingroup CORE_LIB_GROUP - * @defgroup UTILX_MODULE utilX - * @brief Samsung Linux platform X11 utilties - * - * @section UTILX_MODULE_HEADER Required Header - * \#include - * @section UTILX_MODULE_OVERVIEW Overview - * The utilX is common X11 utility. - * It provides functions used by xclients, mainly to get or set state of X11 resources's information. - */ - -/** -* @addtogroup UTILX_MODULE +* @internal +* @addtogroup CAPI_UI_UTILX_MODULE * @{ */ @@ -51,743 +40,501 @@ extern "C" { #endif +/** +* @internal + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Volume Up' key. + */ +#define KEY_VOLUMEUP "XF86AudioRaiseVolume" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Volume Down' key. + */ +#define KEY_VOLUMEDOWN "XF86AudioLowerVolume" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Half-Press of Camera' key. + */ +#define KEY_CAMERA "XF86WebCam" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Full-Press of Camera' key. + */ +#define KEY_CONFIG "XF86Pictures" -#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 */ +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Power' key. + */ +#define KEY_POWER "XF86PowerOff" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Pause' key. + */ +#define KEY_PAUSE "XF86Standby" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Cancel' key. + */ +#define KEY_CANCEL "Cancel" // 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 */ -#define KEY_MEDIA "XF86AudioMedia" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Media' key */ -#define KEY_PLAYPAUSE "XF86AudioPlayPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'PlayPause' key */ -#define KEY_MUTE "XF86AudioMute" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Mute' key */ +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Play Audio' key. + */ +#define KEY_PLAYCD "XF86AudioPlay" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Stop Audio' key. + */ +#define KEY_STOPCD "XF86AudioStop" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Pause Audio' key. + */ +#define KEY_PAUSECD "XF86AudioPause" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Next Song' key. + */ +#define KEY_NEXTSONG "XF86AudioNext" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Previous Song' key. + */ +#define KEY_PREVIOUSSONG "XF86AudioPrev" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Rewind Song' key. + */ +#define KEY_REWIND "XF86AudioRewind" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Forward Song' key. + */ +#define KEY_FASTFORWARD "XF86AudioForward" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Media' key. + */ +#define KEY_MEDIA "XF86AudioMedia" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'PlayPause' key. + */ +#define KEY_PLAYPAUSE "XF86AudioPlayPause" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Mute' key. + */ +#define KEY_MUTE "XF86AudioMute" // 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 */ +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Send' key. + */ +#define KEY_SEND "XF86Send" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Home' key. + */ +#define KEY_SELECT "XF86Phone" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'End' key. + */ +#define KEY_END "XF86Stop" // 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 */ +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Send' key. + */ +#define KEY_MENU "XF86Send" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Home' key. + */ +#define KEY_HOME "XF86Phone" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'End' key. + */ +#define KEY_BACK "XF86Stop" //Other functions keys -#define KEY_HOMEPAGE "XF86HomePage" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'HomePage' key */ -#define KEY_WEBPAGE "XF86WWW" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'WWW' key */ -#define KEY_MAIL "XF86Mail" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Mail' key */ -#define KEY_SCREENSAVER "XF86ScreenSaver" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'ScreenSaver' key */ -#define KEY_BRIGHTNESSUP "XF86MonBrightnessUp" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'BrightnessUp' key */ -#define KEY_BRIGHTNESSDOWN "XF86MonBrightnessDown" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'BrightnessDown' key */ -#define KEY_SOFTKBD "XF86MenuKB" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Soft keyboard(toggle)' key */ -#define KEY_QUICKPANEL "XF86Tools" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Quick panel(toggle)' key */ -#define KEY_TASKSWITCH "XF86TaskPane" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Task switcher(toggle)' key */ -#define KEY_APPS "XF86Launch0" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Apptray(toggle)' key */ -#define KEY_SEARCH "XF86Search" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Search(toggle)' key */ -#define KEY_VOICE "XF86Launch2" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Voice(toggle)' key */ -#define KEY_LANGUAGE "Hangul" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Language(toggle)' 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 */ +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'HomePage' key. + */ +#define KEY_HOMEPAGE "XF86HomePage" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'WWW' key. + */ +#define KEY_WEBPAGE "XF86WWW" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Mail' key. + */ +#define KEY_MAIL "XF86Mail" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'ScreenSaver' key. + */ +#define KEY_SCREENSAVER "XF86ScreenSaver" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'BrightnessUp' key. + */ +#define KEY_BRIGHTNESSUP "XF86MonBrightnessUp" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'BrightnessDown' key. + */ +#define KEY_BRIGHTNESSDOWN "XF86MonBrightnessDown" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Soft keyboard(toggle)' key. + */ +#define KEY_SOFTKBD "XF86MenuKB" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Quick panel(toggle)' key. + */ +#define KEY_QUICKPANEL "XF86Tools" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Task switcher(toggle)' key. + */ +#define KEY_TASKSWITCH "XF86TaskPane" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Apptray(toggle)' key. + */ +#define KEY_APPS "XF86Launch0" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Search(toggle)' key. + */ +#define KEY_SEARCH "XF86Search" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice(toggle)' key. + */ +#define KEY_VOICE "XF86Launch2" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Language(toggle)' key. + */ +#define KEY_LANGUAGE "Hangul" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Call(toggle)' key. + */ +#define KEY_CONNECT "XF86Go" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Play(toggle)' key. + */ +#define KEY_GAMEPLAY "XF86Game" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice Wakeup LPSD' key. + */ +#define KEY_VOICEWAKEUP_LPSD "XF86Launch3" +/** + * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice Wakeup' key. + */ +#define KEY_VOICEWAKEUP "XF86Launch4" + +/** + * @brief Definition for the length of a string corresponding to the 'Volume Up' key. + */ +#define LEN_KEY_VOLUMEUP 20 +/** + * @brief Definition for the length of a string corresponding to the 'Volume Down' key. + */ +#define LEN_KEY_VOLUMEDOWN 20 + +/** + * @brief Definition for the length of a string corresponding to the 'Half-Press of Camera' key. + */ +#define LEN_KEY_CAMERA 10 +/** + * @brief Definition for the length of a string corresponding to the 'Full-Press of Camera' key. + */ +#define LEN_KEY_CONFIG 12 + +/** + * @brief Definition for the length of a string corresponding to the 'Power' key. + */ +#define LEN_KEY_POWER 12 +/** + * @brief Definition for the length of a string corresponding to the 'Pause' key. + */ +#define LEN_KEY_PAUSE 11 // 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 */ -#define LEN_KEY_MEDIA 14/**< this macro is the length of string corresponds to 'Media' key */ -#define LEN_KEY_PLAYPAUSE 13 /**< this macro is the length of string corresponds to 'PlayPause' key */ -#define LEN_KEY_MUTE 13 /**< this macro is the length of string corresponds to 'Mute' key */ +/** + * @brief Definition for the length of a string corresponding to the 'Play Audio' key. + */ +#define LEN_KEY_PLAYCD 13 +/** + * @brief Definition for the length of a string corresponding to the 'Stop Audio' key. + */ +#define LEN_KEY_STOPCD 13 +/** + * @brief Definition for the length of a string corresponding to the 'Pause Audio' key. + */ +#define LEN_KEY_PAUSECD 14 +/** + * @brief Definition for the length of a string corresponding to the 'Next Song' key. + */ +#define LEN_KEY_NEXTSONG 13 +/** + * @brief Definition for the length of a string corresponding to the 'Previous Song' key. + */ +#define LEN_KEY_PREVIOUSSONG 13 +/** + * @brief Definition for the length of a string corresponding to the 'Rewind Song' key. + */ +#define LEN_KEY_REWIND 15 +/** + * @brief Definition for the length of a string corresponding to the 'Forwand Song' key. + */ +#define LEN_KEY_FASTFORWARD 16 +/** + * @brief Definition for the length of a string corresponding to the 'Media' key. + */ +#define LEN_KEY_MEDIA 14 +/** + * @brief Definition for the length of a string corresponding to the 'PlayPause' key. + */ +#define LEN_KEY_PLAYPAUSE 13 +/** + * @brief Definition for the length of a string corresponding to the 'Mute' key. + */ +#define LEN_KEY_MUTE 13 // 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 */ +/** + * @brief Definition for the length of a string corresponding to the 'Send' key. + */ +#define LEN_KEY_SEND 8 +/** + * @brief Definition for the length of a string corresponding to the 'Home' key. + */ +#define LEN_KEY_SELECT 9 +/** + * @brief Definition for the length of a string corresponding to the 'End' key. + */ +#define LEN_KEY_END 8 // 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 */ +/** + * @brief Definition for the length of a string corresponding to the 'Send' key. + */ +#define LEN_KEY_MENU 8 +/** + * @brief Definition for the length of a string corresponding to the 'Home' key. + */ +#define LEN_KEY_HOME 9 +/** + * @brief Definition for the length of a string corresponding to the 'End' key. + */ +#define LEN_KEY_BACK 8 //Other functions keys -#define LEN_KEY_HOMEPAGE 12 /**< this macro is the length of string corresponds to 'HomePage' key */ -#define LEN_KEY_WEBPAGE 7 /**< this macro is the length of string corresponds to 'WWW' key */ -#define LEN_KEY_MAIL 8 /**< this macro is the length of string corresponds to 'Mail' key */ -#define LEN_KEY_SCREENSAVER 15 /**< this macro is the length of string corresponds to 'ScreenSaver' key */ -#define LEN_KEY_BRIGHTNESSUP 19 /**< this macro is the length of string corresponds to 'BrightnessUp' key */ -#define LEN_KEY_BRIGHTNESSDOWN 21 /**< this macro is the length of string corresponds to 'BrightnessDown' key */ - -#define LEN_KEY_SOFTKBD 10 /**< this macro is the length of string corresponds to 'Soft keyboard(toggle)' key */ -#define LEN_KEY_QUICKPANEL 9 /**< this macro is the length of string corresponds to 'Quick panel(toggle)' key */ -#define LEN_KEY_TASKSWITCH 12 /**< this macro is the length of string corresponds to 'Task switcher(toggle)' key */ -#define LEN_KEY_APPS 11 /**< this macro is the length of string corresponds to 'Apptray(toggle)' key */ -#define LEN_KEY_SEARCH 10 /**< this macro is the length of string corresponds to 'Search(toggle)' key */ -#define LEN_KEY_VOICE 11 /**< this macro is the length of string corresponds to 'Voice(toggle)' key */ -#define LEN_KEY_LANGUAGE 6 /**< this macro is the length of string corresponds to 'Language(toggle)' 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 */ - -#define STR_ATOM_SCRNCONF_STATUS "_SCRNCONF_STATUS" /**< this is an XATOM for getting the status of the screen configuration through the client message */ - /** - * @brief Enumeration of screen configuration status + * @brief Definition for the length of a string corresponding to the 'HomePage' key. */ -typedef enum _Utilx_Scrnconf_Status -{ - UTILX_SCRNCONF_STATUS_NULL, /**< screen configuration status is null */ - UTILX_SCRNCONF_STATUS_CONNECT, /**< screen configuration status is connect */ - UTILX_SCRNCONF_STATUS_ACTIVE /**< screen configuration status is active */ -} Utilx_Scrnconf_Status; - +#define LEN_KEY_HOMEPAGE 12 /** - * @brief Enumeration of screen configuration display mode + * @brief Definition for the length of a string corresponding to the 'WWW' key. */ -typedef enum _Utilx_Scrnconf_Dispmode -{ - UTILX_SCRNCONF_DISPMODE_NULL, /**< display mode of screen configuration is null */ - UTILX_SCRNCONF_DISPMODE_CLONE, /**< display mode of screen configuration is clone */ - UTILX_SCRNCONF_DISPMODE_EXTENDED /**< display mode of screen configuration is extended */ -} Utilx_Scrnconf_Dispmode; - - +#define LEN_KEY_WEBPAGE 7 /** - * @brief Enumeration of key status + * @brief Definition for the length of a string corresponding to the 'Mail' key. */ -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; - +#define LEN_KEY_MAIL 8 /** - * @brief Enumeration of notification window's priority level + * @brief Definition for the length of a string corresponding to the 'ScreenSaver' key. */ -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; - +#define LEN_KEY_SCREENSAVER 15 /** - * @brief Enumeration of Compositing Window Manager's Effect Type + * @brief Definition for the length of a string corresponding to the 'BrightnessUp' key. */ -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; - +#define LEN_KEY_BRIGHTNESSUP 19 /** - * @brief Enumeration of Compositing Window Manager's Effect Style + * @brief Definition for the length of a string corresponding to the 'BrightnessDown' key. */ -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 +#define LEN_KEY_BRIGHTNESSDOWN 21 +/** + * @brief Definition for the length of a string corresponding to the 'Soft keyboard(toggle)' key. */ -typedef enum _Utilx_Opaque_State -{ - UTILX_OPAQUE_STATE_OFF = 0, /**< Transparent state */ - UTILX_OPAQUE_STATE_ON = 1, /**< Opaque state */ -} Utilx_Opaque_State; - +#define LEN_KEY_SOFTKBD 10 /** - * @brief Enumeration of Fb's type + * @brief Definition for the length of a string corresponding to the 'Quick panel(toggle)' key. */ -typedef enum _Utilx_Fb_Type -{ - UTILX_FB_TYPE_NONE = 0, /**< None type */ - UTILX_FB_TYPE_UI = 1, /**< Framebuffer type is 'UI' */ - UTILX_FB_TYPE_OVERLAY = 2, /**< Framebuffer type is 'Overlay' */ -} Utilx_Fb_Type; - +#define LEN_KEY_QUICKPANEL 9 /** - * @brief Structure of screen configuration information + * @brief Definition for the length of a string corresponding to the 'Task switcher(toggle)' key. */ -typedef struct _UtilxScrnConf -{ - char *str_output; /**< string value for the connector type */ - Utilx_Scrnconf_Status status; /**< status of screen configurtaion */ - char *str_resolution; /**< string value for the resolution to be active status */ - Utilx_Scrnconf_Dispmode dispmode; /**< display mode of screen configuration to be active status */ -} UtilxScrnConf; - +#define LEN_KEY_TASKSWITCH 12 /** - * @fn ScrnConf *utilx_scrnconf_allocate(void) - * @brief allocate the UtilxScrnConf structure - * - * This function allocate the UtilxScrnConf structure.\n - * - * @remark This is used only application which want to know the screen configuration info. - * @pre This api does not require any pre-condition. - * @post This api does not change any condition. - * @see utilx_scrnconf_allocate - * @par Example - @code - #include - ... - - UtilxScrnConf *scrnconf = NULL; - - // Allocate the UtilxScrnConf structure - scrnconf = utilx_scrnconf_allocate(); - ... - @endcode + * @brief Definition for the length of a string corresponding to the 'Apptray(toggle)' key. */ -UtilxScrnConf *utilx_scrnconf_allocate (void); - +#define LEN_KEY_APPS 11 /** - * @fn void utilx_scrnconf_free (UtilxScrnConf *scrnconf) - * @brief free the UtilxScrnConf structure - * - * This function free the UtilxScrnConf structure.\n - * - * @param[in] scrnconf Specifies the UtilxScrnConf structure - * @return instance of the UtilxScrnConf structure - * @remark This is used only application which want to know the screen configuration info. - * @pre This api does not require any pre-condition. - * @post This api does not change any condition. - * @see utilx_scrnconf_free - * @par Example - @code - #include - ... - - UtilxScrnConf *scrnconf = NULL; - - // Allocate the UtilxScrnConf structure - scrnconf = utilx_scrnconf_allocate(); - ... - - // Free the UtilxScrnConf structure - utilx_scrnconf_free(scrnconf); - ... - @endcode + * @brief Definition for the length of a string corresponding to the 'Search(toggle)' key. */ -void utilx_scrnconf_free (UtilxScrnConf *scrnconf); - +#define LEN_KEY_SEARCH 10 /** - * @fn void utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf) - * @brief get the information of the screen configuration - * - * This function get the information of the screen configuration.\n - * - * This function is a asynchronous call. - * - * @param[in] dpy Specifies the connection to the X server - * @param[in] scrnconf Specifies the information structure of the screen configuration - * @remark This is used only application which want to know the screen configuration info. - * @pre This api does not require any pre-condition. - * @post This api does not change any condition. - * @see utilx_scrnconf_get_info - * @par Example - @code - #include - #include - ... - - Display* dpy; - UtilxScrnConf *scrnconf = NULL; - int ret = 0; - - dpy = XOpenDisplay (NULL); - - // Allocate the UtilxScrnConf structure - scrnconf = utilx_scrnconf_allocate(); - ... - - // Set the display mode for the screen configuration - ret = utilx_scrnconf_get_info (dpy, scrnconf); - ... - - // Free the UtilxScrnConf structure - utilx_scrnconf_free(scrnconf); - ... - - @endcode + * @brief Definition for the length of a string corresponding to the 'Voice(toggle)' key. */ -int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf); - - +#define LEN_KEY_VOICE 11 /** - * @fn void utilx_scrnconf_set_dispmode (Display *dpy, Utilx_Scrnconf_Dispmode dispmode) - * @brief set the display mode for the screen configuration - * - * This function set the display mode for the screen configuration.\n - * - * This function is a asynchronous call. - * - * @param[in] dpy Specifies the connection to the X server - * @param[in] dipmode Specifies the display mode of the screen configuration - * @return 1 if setting the dispmode is succeeded, 0 if setting the dispmode is failed. - * @remark This is used only application which want to set the display mode of the screen configuration. - * @pre This api does not require any pre-condition. - * @post This api does not change any condition. - * @see utilx_scrnconf_set_dispmode - * @par Example - @code - #include - #include - ... - - Display* dpy; - - dpy = XOpenDisplay (NULL); - - // Set the display mode for the screen configuration - utilx_scrnconf_set_dispmode (dpy, UTILX_SCRNCONF_DISPMODE_CLONE); - ... - @endcode + * @brief Definition for the length of a string corresponding to the 'Language(toggle)' key. */ -int utilx_scrnconf_set_dispmode (Display *dpy, Utilx_Scrnconf_Dispmode dispmode); - - +#define LEN_KEY_LANGUAGE 6 /** - * @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, asynchronously - * - * @details 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. - * - * - * @remarks This is used only notification window. - * @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) - * @pre The win should be notification type window - * @post None - * @see #Utilx_Notification_Level - * @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 + * @brief Definition for the length of a string corresponding to the 'Call(toggle)' key. */ -void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level); - +#define LEN_KEY_CONNECT 6 /** - * @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 + * @brief Definition for the length of a string corresponding to the 'Play(toggle)' key. */ -Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win); - +#define LEN_KEY_GAMEPLAY 8 /** - * @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 + * @brief Definition for the length of a string corresponding to the 'Voice Wakeup LPSD' key. */ -void utilx_enable_indicator (Display* dpy, Window win, int enable); - +#define LEN_KEY_VOICEWAKEUP_LPSD 11 /** - * @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 + * @brief Definition for the length of a string corresponding to the 'Voice Wakeup' key. */ -int utilx_get_indicator_state (Display* dpy, Window win); - +#define LEN_KEY_VOICEWAKEUP 11 /** - * @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 - * - * @details 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. - * - * @remarks 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. - * @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 - * @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); + * @brief Definition for getting the grabbed-key exclusively regardless of its position on the window stack with the possibility of overriding the grab by the other client window mode. + */ +#define OR_EXCLUSIVE_GRAB 0xf00000 +/** + * @brief Definition for getting the grabbed-key exclusively regardless of its position on the window stack mode. + */ +#define EXCLUSIVE_GRAB 0x0f0000 +/** + * @brief Definition for getting the grabbed-key only when on the top of the grabbing-window stack mode. + */ +#define TOP_POSITION_GRAB 0x00f000 +/** + * @brief Definition for getting the grabbed-key together with the other client window(s) mode. + */ +#define SHARED_GRAB 0x000f00 +/** + * @brief Definition for getting the key-grab mode of a client window. + */ +#define GRAB_MODE_MASK 0xffff00 - int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB); - if( EXCLUSIVE_GRABBED_ALREADY == grab_result ) - return -1; +/** + * @brief Definition for the client window grabbing the key which is already in the EXCLUSIVE mode. + */ +#define EXCLUSIVE_GRABBED_ALREADY 1 - ... +/** + * @brief Definition for getting/setting the property while grabbing a key for a window. + */ +#define STR_ATOM_GRAB_KEY "_GRAB_KEY" +/** + * @brief Definition for the key grabbed by a client window in the EXCLUSIVE mode. + */ +#define STR_ATOM_GRAB_EXCL_WIN "_GRAB_EXCL_WIN_KEYCODE" +/** + * @brief Definition for the key grabbed by a client window in the OR_EXCLUSIVE mode. + */ +#define STR_ATOM_GRAB_OR_EXCL_WIN "_GRAB_OR_EXCL_WIN_KEYCODE" - utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ - return 0; - } +/** + * @brief Enumeration for 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; - // TOP_POSITION_GRAB // +/** + * @brief Enumeration for the opaque state. + */ +typedef enum _Utilx_Opaque_State +{ + UTILX_OPAQUE_STATE_OFF = 0, /**< Transparent state */ + UTILX_OPAQUE_STATE_ON = 1, /**< Opaque state */ +} Utilx_Opaque_State; +/** + * @brief Sets the priority level for the specified notification window, asynchronously. + * + * @details This function sets the priority level of 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 with the priority set to #UTILX_NOTIFICATION_LEVEL_HIGH will be placed at the top of the notification windows.\n + * If there are notification windows which have same priorities, the last created notification window will be placed on the other window. + * + * @since_tizen 2.3 + * @remarks This is used only for notification windows. + * @param[in] dpy The connection to the X server + * @param[in] win The window to set + * @param[in] level The level (#UTILX_NOTIFICATION_LEVEL_LOW, #UTILX_NOTIFICATION_LEVEL_NORMAL, #UTILX_NOTIFICATION_LEVEL_HIGH) + * @pre The window should be a notification type window. + * @see #Utilx_Notification_Level + * @see utilx_get_system_notification_level() + * @par Example + @code #include - #include - #include - int main() - { - ... + ... - Ecore_X_Display* disp = ecore_x_display_get(); - Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + Evas_Object *win; + Ecore_X_Window xwin; - utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB); + win = create_mwnd(); + xwin = elm_win_xwindow_get(win); - ... + // Set Notification type + ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION); - utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ - return 0; - } + // Set Notification's priority + utilx_set_system_notification_level (ecore_x_display_get(), xwin, UTILX_NOTIFICATION_LEVEL_HIGH); - // SHARED_GRAB // + ... + @endcode + */ +void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level); +/** + * @brief Gets the priority level for the specified notification window. + * + * @details This function returns the priority level of notification windows.\n + * If a user didn't set the notification's priority level, this function returns the default value (#UTILX_NOTIFICATION_LEVEL_LOW). + * + * This function is a synchronous call. + * + * @since_tizen 2.3 + * @remarks This is used only for notification windows. + * @param[in] dpy The connection to the X server + * @param[in] win The window to get + * @return The current notification level (#UTILX_NOTIFICATION_LEVEL_LOW, #UTILX_NOTIFICATION_LEVEL_NORMAL, #UTILX_NOTIFICATION_LEVEL_HIGH) + * @pre The window should be a notification type window. + * @see utilx_set_system_notification_level() + * @par Example + @code #include - #include - #include - int main() - { - ... + ... - Ecore_X_Display* disp = ecore_x_display_get(); - Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); + Evas_Object *win; + Ecore_X_Window xwin; + Utilx_Notification_Level level; - utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB); + 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); - 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); +Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win); /** - * @fn int utilx_ungrab_key (Display* dpy, Window win, const char* key_name) - * @brief Ungrabs a key specfied by key_name for win - * - * @details 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. - * - * @remarks No additional information - * @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 - * @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 + * @brief Grabs the key specfied by @a key_name for a window in the @a grab_mode. + * + * @details This function establishes a grab of the specified key for the specified window.\n + * Once a key is grabbed, all events originating from the key will only be reported to the specfied window.\n + * The grab of the key can be released by calling utilx_ungrab_key(). + * + * This function is synchronous. + * + * @since_tizen 2.3 + * @remarks If utilx_grab_key() returns @c 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 + * A trial for choosing a proper grab mode will be needed. + * @param[in] dpy The connection to the X server + * @param[in] win The window to grab a key + * @param[in] key_name The name of a key in the string (ex> #KEY_VOLUMEUP, #KEY_VOLUMEDOWN, #KEY_SEND, and so on) + * @param[in] grab_mode The grab mode (such as #EXCLUSIVE_GRAB, #TOP_POSITION_GRAB, and #SHARED_GRAB) + * @return @c 0 on success, + * otherwise failure + * @pre This API must be called after the window 'win' has been mapped. + * @post This API adds/changes the window property related to the grabbed key. + * @see utilx_ungrab_key() * @par Example (using X11 APIs) @code @@ -904,9 +651,10 @@ int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mod 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 ¡¦ + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to return 0; } @@ -927,8 +675,7 @@ int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mod ... - utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦ - + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to return 0; } @@ -938,618 +685,271 @@ int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mod #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, asynchronously. - * - * @details 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 - * - * @remarks This is used only client window. ( not root window ) - * @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 ) - * @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_Effect_Type - * @see #Utilx_Effect_Style - * @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. - * - * @remark This is used only client window. ( not root window ) - * @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 ) - * @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) ); + int main() + { + ... - style = utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP); // get effect style with window's show effet type + 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); - style = utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP); // get effect style with window's show effet type + ... - ... + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to + return 0; + } @endcode */ -Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type); +int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mode); /** - * @fn void utilx_set_window_opaque_state (Display* dpy, Window win, int opaque) - * @brief Sets the window's opaque state + * @brief Ungrabs the key specfied by @a key_name for a window. * - * 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 + * @details This function releases the already established grab of the specfied key for the specified window.\n + * Once the grab of the key is released, delivery of the key events for the specfied window is going to be stopped. + * + * This function is synchronous. + * + * @since_tizen 2.3 + * @param[in] dpy The connection to the X server + * @param[in] win The window to grab a key + * @param[in] key_name The name of a key in the string (ex> #KEY_VOLUMEUP, #KEY_VOLUMEDOWN, #KEY_SEND, and so on) + * @return @c 0 on success, + * otherwise failure + * @pre This API must be called after the window 'win' is mapped. + * @post This API changes/removes the window property related to the 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); - Display* dpy; - Window root, win; - int ret; + 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; + } + ... + } + ... - dpy = XOpenDisplay (NULL); - root = XDefaultRootWindow (dpy); + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } - win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0)); - XMapWindow (dpy, win); + // TOP_POSITION_GRAB // - ret = utilx_set_window_opaque_state (dpy, win, UTILX_OPAQUE_STATE_ON); - if (!ret) + #include + #include + + int main() { - printf ("Error! Failed to set opaque state.\n"); - } + 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); - XFlush (dpy); + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB); + break; + } + ... + } + ... - ... - @endcode - */ -int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state); + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } + + // SHARED_GRAB // -/** - * @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 ; + 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); - dpy = XOpenDisplay(NULL) ; + while(1) + { + XNextEvent(disp, &e); + switch(e.type) + { + case MapNotify: + utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB); + break; + } + ... + } + ... - utilx_set_screen_capture (dpy, 1); + utilx_ungrab_key(disp, win, KEY_POWER); + return 0; + } - ... @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 + * @par Example (using EFL APIs) @code - #include - #include + + // EXCLUSIVE_GRAB // + #include - ... + #include + #include - Display *dpy ; - int enable; + int main() + { + ... - dpy = XOpenDisplay(NULL) ; + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); - enable = utilx_set_screen_capture (dpy); + int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB); + if( EXCLUSIVE_GRABBED_ALREADY == grab_result ) + return -1; + ... - ... - @endcode - */ -int utilx_get_screen_capture(Display* dpy); + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to + return 0; + } + + // TOP_POSITION_GRAB // -/** - * @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 - ... + #include + #include - Display *dpy ; - Window root; - Atom atom = None; - int value = 1; + int main() + { + ... - dpy = XOpenDisplay (NULL); - root = XDefaultRootWindow (dpy); + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); - atom = XInternAtom(dpy, "TEST_ATOM", False); + utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB); - 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); + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to + + return 0; + } + + // SHARED_GRAB // -/** - * @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 - ... + #include + #include - Display *dpy ; - Window root; - Atom atom = None; - int value; + int main() + { + ... - dpy = XOpenDisplay (NULL); - root = XDefaultRootWindow (dpy); + Ecore_X_Display* disp = ecore_x_display_get(); + Ecore_X_Window win = ecore_evas_software_x11_window_get(ee); - atom = XInternAtom(dpy, "TEST_ATOM", False); + utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB); - if (utilx_set_window_cardinal_property (dpy, root, atom, (unsigned int*)&value) > 0) - { - success; - } + ... - ... + utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to + return 0; + } @endcode */ -int utilx_get_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value); +int utilx_ungrab_key (Display* dpy, Window win, const char* key_name); /** - * @fn void utilx_show_capture_effect(Display *dpy, Window win ) - * @brief Shows a capture effect animation + * @brief Sets the window's opaque state. * - * This function show capture effect animation.\n - * This function is only used by Screen Capture Application. + * @details This function sets the window's visibility to opaque even if the window is an alpha window. + * This function is available only for an alpha window. + * An alpha window's default opaque state is #UTILX_OPAQUE_STATE_OFF. * - * This function is a asynchronous call. + * This function is an 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 + * @since_tizen 2.3 + * @remarks This is used only for alpha windows. + * @param[in] dpy The connection to the X server + * @param[in] win The window handle + * @param[in] state The value that indicates whether the window has set a visible state to opaque(#UTILX_OPAQUE_STATE_ON) or not(#UTILX_OPAQUE_STATE_OFF) + * @return @c 1 on success, + otherwise failure * @par Example @code #include #include + ... Display* dpy; - Window root; + Window root, win; + int ret; dpy = XOpenDisplay (NULL); root = XDefaultRootWindow (dpy); - // Shows a Shows a capture effect animation - utilx_show_capture_effect( dpy, root); - ... + 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 */ -void utilx_show_capture_effect(Display *dpy, Window win ); +int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state); /** - * @fn void* utilx_create_screen_shot (Display* dpy, int width, int height) - * @brief Create a screenshot image. - * - * This function create a screenshot image.\n - * To use this function, you should get the permission first. Once this functions - * is called, utilx_release_screen_shot should be called after it. - * - * @param[in] dpy Specifies the connection to the X server - * @param[in] width Specifies the root window handle - * @param[in] height Specifies the root window handle - * @remark You should get the permission to use. - * @post This api does not change any condition. - * @see utilx_release_screen_shot + * @brief Creates a screenshot image. + * + * @details This function creates a screenshot image of the display.\n + * To use this function, you should get the permission first.\n + * In addition, device LCD must be turned on; otherwise, this function fails.\n + * Once this functions is called, utilx_release_screen_shot() should be called after it. + * + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/screenshot + * @remarks You should get the permission to use. Device LCD must be on. + * @param[in] dpy The connection to the X server + * @param[in] width The root window handle + * @param[in] height The root window handle + * @see utilx_release_screen_shot() * @par Example @code Display* dpy; @@ -1577,14 +977,16 @@ void utilx_show_capture_effect(Display *dpy, Window win ); void* utilx_create_screen_shot (Display* dpy, int width, int height); /** - * @fn void utilx_release_screen_shot (void) - * @brief Release screenshot resources. + * @brief Releases screenshot resources. * - * This function release screenshot resources.\n - * utilx_release_screen_shot should be called once utilx_create_screen_shot is - * called. + * @details This function releases resources associated with screenshot + * image of the display. utilx_release_screen_shot() should be called once + * utilx_create_screen_shot() is called. * - * @see utilx_create_screen_shot + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/screenshot + * @see utilx_create_screen_shot() * @par Example @code Display* dpy; @@ -1611,77 +1013,6 @@ void* utilx_create_screen_shot (Display* dpy, int width, int height); */ void utilx_release_screen_shot (void); -/** - * @fn void utilx_set_fb_visible (Display* dpy, Utilx_Fb_Type fb_type, Bool visible) - * @brief Set fb's visibility. - * - * @details This function can make a framebuffer visible or non-visible. \n - * By the way, in case of UTILX_FB_TYPE_UI, if there is the request for UI update, - * the visibility of UI framebuffer will be changed from False to True automatically. - * Please note this. - * - * @param[in] dpy Specifies the connection to the X server - * @param[in] fb_type Specifies the fb type to set visibility of a framebuffer - * @param[in] visible Visible/Non-Visible - * @see #Utilx_Fb_Type - * @see utilx_get_fb_visible - * @par Example - @code - #include - ... - Display* dpy = XOpenDisplay (NULL); - - // Hide the UI framebuffer of main lcd. - utilx_set_fb_visible (dpy, UTILX_FB_TYPE_UI, False); - ... - @endcode - */ -void utilx_set_fb_visible (Display* dpy, Utilx_Fb_Type fb_type, Bool visible); - -/** - * @fn Bool utilx_get_fb_visible (Display* dpy, Utilx_Fb_Type fb_type) - * @brief Get framebuffer's visibility. - * - * This function get the visibility of a framebuffer. \n - * - * @param[in] dpy Specifies the connection to the X server - * @param[in] fb_type Specifies the fb type to get visibility of a framebuffer - * @return Current visibility of a framebuffer - * @see utilx_set_fb_visible - * @par Example - @code - #include - ... - Display* dpy = XOpenDisplay (NULL); - Bool visible; - - visible = utilx_get_fb_visible (dpy, UTILX_FB_TYPE_UI); - ... - @endcode - */ -Bool utilx_get_fb_visible (Display* dpy, Utilx_Fb_Type fb_type); - -/** - * @fn void utilx_set_video_offset (Display* dpy, int x, int y) - * @brief Set the offset of video. - * - * This function sets the offset of video layer. \n - * - * @param[in] dpy Specifies the connection to the X server - * @param[in] x x offset - * @param[in] y y offset - * @par Example - @code - #include - ... - Display* dpy = XOpenDisplay (NULL); - - utilx_set_video_offset (dpy, 0, 100); - ... - @endcode - */ -void utilx_set_video_offset (Display* dpy, int x, int y); - #ifdef __cplusplus } #endif @@ -1690,5 +1021,5 @@ void utilx_set_video_offset (Display* dpy, int x, int y); *@} */ -#endif /* __SAMSUNG_LINUX_UTIL_X11_H__ */ +#endif /* __TIZEN_LINUX_UTIL_X11_H__ */ diff --git a/utilX.pc b/utilX.pc index f0fd703..66e984f 100644 --- a/utilX.pc +++ b/utilX.pc @@ -8,5 +8,6 @@ includedir=${prefix}/include Name: libSLP-utilX Description: SAMSUNG Linux platform X11 utilities library Version: 1.1.0 +Requires: xproto x11 Libs: -L${libdir} -lutilX Cflags: -I${includedir} diff --git a/utilX.pc.in b/utilX.pc.in index 5079edf..54b2e91 100644 --- a/utilX.pc.in +++ b/utilX.pc.in @@ -8,5 +8,6 @@ includedir=@INCLUDEDIR@ Name: libSLP-utilX Description: SAMSUNG Linux platform X11 utilities library Version: @VERSION@ +Requires: xproto x11 Libs: -L${libdir} -lutilX Cflags: -I${includedir} diff --git a/utilX_ext.h b/utilX_ext.h new file mode 100644 index 0000000..9bf7b2c --- /dev/null +++ b/utilX_ext.h @@ -0,0 +1,76 @@ +/* + * libslp-utilx + * + Copyright (c) 2012 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_EXT_H__ +#define __SAMSUNG_LINUX_UTIL_X11_EXT_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define STR_ATOM_SCRNCONF_STATUS "_SCRNCONF_STATUS" + +typedef enum _Utilx_Scrnconf_Status +{ + UTILX_SCRNCONF_STATUS_NULL, + UTILX_SCRNCONF_STATUS_CONNECT, + UTILX_SCRNCONF_STATUS_ACTIVE +} Utilx_Scrnconf_Status; + +typedef enum _Utilx_Scrnconf_Dispmode +{ + UTILX_SCRNCONF_DISPMODE_NULL, + UTILX_SCRNCONF_DISPMODE_CLONE, + UTILX_SCRNCONF_DISPMODE_EXTENDED +} Utilx_Scrnconf_Dispmode; + +typedef enum _Utilx_Fb_Type +{ + UTILX_FB_TYPE_NONE, + UTILX_FB_TYPE_UI, + UTILX_FB_TYPE_OVERLAY, +} Utilx_Fb_Type; + +typedef struct _UtilxScrnConf +{ + char *str_output; + Utilx_Scrnconf_Status status; + char *str_resolution; + Utilx_Scrnconf_Dispmode dispmode; +} UtilxScrnConf; + +UtilxScrnConf *utilx_scrnconf_allocate (void); +void utilx_scrnconf_free (UtilxScrnConf *scrnconf); +int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf); +int utilx_scrnconf_set_dispmode (Display *dpy, Utilx_Scrnconf_Dispmode dispmode); + +void* utilx_create_video_screen_shot (Display* dpy, Window win, int width, int height); +void utilx_set_fb_visible (Display* dpy, Utilx_Fb_Type fb_type, Bool visible); +Bool utilx_get_fb_visible (Display* dpy, Utilx_Fb_Type fb_type); + +#ifdef __cplusplus +} +#endif + +#endif /* __SAMSUNG_LINUX_UTIL_X11_EXT_H__ */ + diff --git a/x11.c b/x11.c index ac4dce1..4b3cb17 100644 --- a/x11.c +++ b/x11.c @@ -30,6 +30,7 @@ #include #include "utilX.h" +#include "utilX_ext.h" #include "util_x11.h" #include @@ -54,44 +55,18 @@ 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_indicator_visible_state_on = None; -static Atom _atom_indicator_visible_state_off = 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; +static Atom _atom_window_pixman = 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 ); - -static int _utilx_get_indicator_atoms(Display *dpy); API void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level) { @@ -198,105 +173,6 @@ error: return noti_level; } -static int _utilx_get_indicator_atoms(Display *dpy) -{ - 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 0; - } - } - - if (!_atom_indicator_visible_state_on) - { - _atom_indicator_visible_state_on = XInternAtom (dpy, "_E_ILLUME_INDICATOR_ON", False); - if (!_atom_indicator_visible_state_on) - { - fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_INDICATOR_ON atom.. %s (%d)\n", __func__, __LINE__); - return 0; - } - } - - if (!_atom_indicator_visible_state_off) - { - _atom_indicator_visible_state_off = XInternAtom (dpy, "_E_ILLUME_INDICATOR_OFF", False); - if (!_atom_indicator_visible_state_off) - { - fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_INDICATOR_OFF atom.. %s (%d)\n", __func__, __LINE__); - return 0; - } - } - - return 1; -} - -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 (!_utilx_get_indicator_atoms(dpy)) - { - fprintf (stderr, "[UTILX] Error.. Cannot create atoms.. %s (%d)\n", __func__, __LINE__); - return; - } - - if (enable == 1) - { - _utilx_set_window_property (dpy, win, _atom_indicator_visible_state, XA_ATOM, - (unsigned int *)&_atom_indicator_visible_state_on, 1); - } - else - { - _utilx_set_window_property (dpy, win, _atom_indicator_visible_state, XA_ATOM, - (unsigned int *)&_atom_indicator_visible_state_off, 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; - Atom state; - - if (dpy == NULL) - { - fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__); - return -1; - } - - if (!_utilx_get_indicator_atoms(dpy)) - { - fprintf (stderr, "[UTILX] Error.. Cannot create atoms.. %s (%d)\n", __func__, __LINE__); - return -1; - } - - ret = _utilx_get_window_property (dpy, win, _atom_indicator_visible_state, XA_ATOM, - (unsigned int *)&state, 1); - - if (ret > 0) - { - if (state == _atom_indicator_visible_state_on) - return 1; - else if (state == _atom_indicator_visible_state_off) - return 0; - else - return -1; - } - else - return -1; -} - static void _utilx_set_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num) { @@ -628,7 +504,7 @@ API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mod { unsigned long cnt; int *key_list = NULL; - int i, result = 0; + int i, result=0, ret = 0; int keycode = 0; KeySym keysym; errno = EINVAL; @@ -662,15 +538,6 @@ API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mod goto out; } } - else if( grab_mode == OR_EXCLUSIVE_GRAB ) - { - result = _is_grabbed_key_exclusively(disp, keycode, grab_mode); - - if( result ) - { - utilx_ungrab_key(disp, win, key); - } - } keycode |= grab_mode; @@ -679,15 +546,8 @@ API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mod i = _search_grabbed_key(key_list, keycode, cnt); _free_list_of_grabbed_key(key_list); if ( i != -1 ) { - if( grab_mode == OR_EXCLUSIVE_GRAB ) - { - utilx_ungrab_key(disp, win, key); - } - else - { fprintf(stderr, "Key is already grabbed\n"); goto out; - } } } @@ -696,8 +556,17 @@ API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mod XSync(disp, False); keycode = keycode & (~GRAB_MODE_MASK); - if( EXCLUSIVE_GRAB == grab_mode || OR_EXCLUSIVE_GRAB == grab_mode ) + if( EXCLUSIVE_GRAB == grab_mode ) _set_exclusive_grab_info_to_root(disp, keycode, win, grab_mode); + if( OR_EXCLUSIVE_GRAB == grab_mode ) + { + ret = _is_grabbed_key_exclusively(disp, keycode, grab_mode); + + if( !ret ) + { + _set_exclusive_grab_info_to_root(disp, keycode, win, grab_mode); + } + } errno = 0; @@ -765,10 +634,6 @@ API int utilx_ungrab_key (Display* disp, Window win, const char* key) } } } - else - { - _unset_exclusive_grab_info_to_root(disp, keycode, OR_EXCLUSIVE_GRAB); - } } else { @@ -796,70 +661,6 @@ 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) || - !strncmp(key_name, KEY_MEDIA, LEN_KEY_MEDIA) ) - { - 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) { @@ -881,235 +682,6 @@ API void utilx_set_fake_launch_img(Display* dpy, Window win, char *file_name) _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); @@ -1153,102 +725,6 @@ API int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_St 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 ); -} - API UtilxScrnConf *utilx_scrnconf_allocate (void) { UtilxScrnConf *scrnconf = calloc (1, sizeof(UtilxScrnConf)); @@ -1278,7 +754,7 @@ API void utilx_scrnconf_free (UtilxScrnConf *scrnconf) API int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf) { - Window win = DefaultRootWindow(dpy); + Window win; Atom scrnconf_atom = None; XTextProperty xtp; char *str = NULL; @@ -1288,6 +764,14 @@ API int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf) int i = 0; int s; + if (!dpy) + goto fail; + + if (!scrnconf) + goto fail; + + win = DefaultRootWindow(dpy); + scrnconf_atom = XInternAtom (dpy, "_SCRNCONF_INFO", False); /* get property */ @@ -1311,7 +795,7 @@ API int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf) { if (i == 0) { - scrnconf->str_output = calloc (1, strlen(ptr)); + scrnconf->str_output = calloc (1, strlen(ptr)+1); if (!scrnconf->str_output) goto fail; @@ -1328,7 +812,7 @@ API int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf) } else if (i == 2) { - scrnconf->str_resolution = calloc (1, strlen(ptr)); + scrnconf->str_resolution = calloc (1, strlen(ptr)+1); if (!scrnconf->str_resolution) goto fail; @@ -1440,7 +924,7 @@ static Bool x_error_caught; static ShotInfo *shot_info; static int -_get_port (Display *dpy, unsigned int id) +_get_port (Display *dpy, unsigned int id, Window win) { unsigned int ver, rev, req_base, evt_base, err_base; unsigned int adaptors; @@ -1455,7 +939,7 @@ _get_port (Display *dpy, unsigned int id) return -1; } - if (XvQueryAdaptors (dpy, DefaultRootWindow (dpy), &adaptors, &ai) != Success) + if (XvQueryAdaptors (dpy, win, &adaptors, &ai) != Success) { fprintf (stderr, "[UTILX] fail : query adaptors. \n"); return -1; @@ -1657,7 +1141,7 @@ _init_screen_shot (Display* dpy, unsigned int width, unsigned int height) info->shminfo.shmaddr = (void*)-1; /* port */ - info->port = _get_port (info->dpy, FOURCC_RGB32); + info->port = _get_port (info->dpy, FOURCC_RGB32, DefaultRootWindow (dpy)); if (info->port <= 0) goto fail_init; @@ -1821,6 +1305,210 @@ utilx_create_screen_shot (Display* dpy, int width, int height) return NULL; } +static ShotInfo* +_init_video_screen_shot (Display* dpy, unsigned int width, unsigned int height, Window win) +{ + ShotInfo *info = NULL; + static Atom atom_capture = None; + static Atom atom_capture_on_win = None; + XErrorHandler old_handler = NULL; + + if (shot_info) + { + if (shot_info->width == width && shot_info->height == height) + return shot_info; + + _deinit_screen_shot (shot_info); + } + + info = calloc (1, sizeof (ShotInfo)); + if (!info) + goto fail_init; + + shot_info = info; + + /* dpy */ + info->dpy = dpy; + info->shminfo.shmid = -1; + info->shminfo.shmaddr = (void*)-1; + + /* port */ + info->port = _get_port (info->dpy, FOURCC_RGB32, win); + if (info->port <= 0) + goto fail_init; + + /* width, height */ + if (atom_capture == None) + atom_capture = XInternAtom (info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE", False); + + if (atom_capture_on_win == None) + atom_capture_on_win = XInternAtom (info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE_ON_WINDOW", False); + + XSync (info->dpy, 0); + x_error_caught = False; + old_handler = XSetErrorHandler (_screen_shot_x_error_handle); + + XvSetPortAttribute (info->dpy, info->port, atom_capture, 3); + XvSetPortAttribute (info->dpy, info->port, atom_capture_on_win, 1); + + XSync (info->dpy, 0); + + x_error_caught = False; + XSetErrorHandler (old_handler); + + XvQueryBestSize (info->dpy, info->port, 0, 0, 0, width, height, &width, &height); + if (width <= 0 || height <= 0) + goto fail_init; + info->width = width; + info->height = height; + + /* pixmap */ + info->pixmap = XCreatePixmap (info->dpy, + win, + width, height, + DefaultDepth (info->dpy, DefaultScreen (info->dpy))); + if (info->pixmap <= 0) + { + fprintf (stderr, "[UTILX] fail : create pixmap. \n"); + goto fail_init; + } + + /* gc */ + info->gc = XCreateGC (info->dpy, info->pixmap, 0, 0); + if (info->gc == NULL) + { + fprintf (stderr, "[UTILX] fail : create gc. \n"); + goto fail_init; + } + + XSetForeground (info->dpy, info->gc, 0xFF000000); + XFillRectangle (info->dpy, info->pixmap, info->gc, 0, 0, width, height); + + if (!_init_screen_shot_damage (info)) + goto fail_init; + + if (!_init_screen_shot_shm (info)) + goto fail_init; + else + fprintf (stderr, "[UTILX] XShm success. !!\n"); + + if (!info->virtual) + { + fprintf (stderr, "[UTILX] fail : get virtual \n"); + goto fail_init; + } + + XFlush (info->dpy); + + return info; + +fail_init: + _deinit_screen_shot (info); + return NULL; +} + +Bool +predicate_proc(Display *dpy, XEvent *event, char *arg) +{ + ShotInfo *info = (ShotInfo *)arg; + + if(event->type == (info->damage_base + XDamageNotify)) + return True; + else + return False; +} +API void* +utilx_create_video_screen_shot (Display* dpy, Window win, int width, int height) +{ + ShotInfo *info; + XEvent ev = {0,}; + XErrorHandler old_handler = NULL; + unsigned int pixmap = 0; + + if (dpy == NULL) + { + fprintf (stderr, "[UTILX] invalid display(%p) \n", dpy); + return NULL; + } + + if (width <= 0 || height <= 0) + { + fprintf (stderr, "[UTILX] invalid size(%dx%d) \n", width, height); + return NULL; + } + + XSync (dpy, 0); + + info = _init_video_screen_shot (dpy, width, height, win); + + if (!info) + { + fprintf (stderr, "[UTILX] fail : initialize screenshot. \n"); + return NULL; + } + + if (!_atom_window_pixman) + { + _atom_window_pixman = XInternAtom (dpy, "_UTIL_WINDOW_PIXMAP_HANDLE", False); + if (!_atom_window_pixman) + { + fprintf (stderr, "[UTILX] Error.. Cannot create _UTIL_WINDOW_PIXMAP_HANDLE atom.. %s (%d)\n", __func__, __LINE__); + return 0; + } + } + + x_error_caught = False; + old_handler = XSetErrorHandler (_screen_shot_x_error_handle); + + pixmap = (unsigned int)info->pixmap; + XChangeProperty (dpy, win, _atom_window_pixman, XA_PIXMAP, 32, PropModeReplace, (unsigned char *)((unsigned int *)&pixmap), 1); + XSync (dpy, 0); + + if (x_error_caught) + { + x_error_caught = False; + XSetErrorHandler (old_handler); + return NULL; + } + + XvPutStill (info->dpy, info->port, info->pixmap, info->gc, + 0, 0, info->width, info->height, + 0, 0, info->width, info->height); + XSync (dpy, 0); + + if (x_error_caught) + { + x_error_caught = False; + XSetErrorHandler (old_handler); + return NULL; + } + + XDeleteProperty(info->dpy, win, _atom_window_pixman); + _atom_window_pixman = None; + XSync (dpy, 0); + + x_error_caught = False; + XSetErrorHandler (old_handler); + + XIfEvent(info->dpy, &ev, predicate_proc, info); + if (ev.type == (info->damage_base + XDamageNotify)) + { + XDamageNotifyEvent *damage_ev = (XDamageNotifyEvent *)&ev; + if (damage_ev->drawable == info->pixmap) + { + XShmGetImage (info->dpy, info->pixmap, info->image, 0, 0, AllPlanes); + XDamageSubtract (info->dpy, info->damage, None, None ); + return info->virtual; + } + + XDamageSubtract (info->dpy, info->damage, None, None ); + } + + utilx_release_screen_shot (); + + return NULL; +} + API void utilx_release_screen_shot (void) { @@ -1993,40 +1681,3 @@ utilx_get_fb_visible (Display* dpy, Utilx_Fb_Type fb) return visible; } - -API void -utilx_set_video_offset (Display* dpy, int x, int y) -{ - static Atom property = None; - char buf[32] = {0,}; - char *p = buf; - int buf_len = 0; - - if (!dpy) - { - fprintf (stderr, "[UTILX] invalid display(%p).. %s (%d)\n", dpy, __func__, __LINE__); - return; - } - - p += sprintf (p, "%d,%d", x, y); - - *p = '\0'; - p++; - - buf_len = p - buf; - - if (property == None) - property = XInternAtom (dpy, XRR_PROPERTY_VIDEO_OFFSET, False); - - if (property == None) - { - fprintf (stderr, "[UTILX] Warning : VIDEO_OFFSET property is None.. %s (%d)\n", __func__, __LINE__); - return; - } - - if (!_utilx_xrr_set_property (dpy, property, (unsigned char*)buf, buf_len, NULL)) - { - fprintf (stderr, "[UTILX] Warning : set_property failed.. %s (%d)\n", __func__, __LINE__); - return; - } -}