Create interface to system bell

Only the xlib implementation is done. It's calling XBell() to alert user.



SVN revision: 50290
This commit is contained in:
Lucas De Marchi 2010-07-16 20:54:18 +00:00
parent 793c66b5dc
commit 01d20339dd
5 changed files with 69 additions and 3 deletions

View File

@ -1074,6 +1074,7 @@ EAPI void ecore_x_sync(void);
EAPI void ecore_x_killall(Ecore_X_Window root);
EAPI void ecore_x_kill(Ecore_X_Window win);
EAPI int ecore_x_dpi_get(void);
EAPI Eina_Bool ecore_x_bell(int percent);
EAPI Ecore_X_Time ecore_x_current_time_get(void);

View File

@ -888,6 +888,15 @@ ecore_x_kill(Ecore_X_Window window)
xcb_kill_client(_ecore_xcb_conn, window);
}
/**
* TODO: Invoke the standard system beep to alert users
*/
EAPI Eina_Bool
ecore_x_bell(int percent)
{
return 0;
}
/**
* Return the last event time
*/

View File

@ -823,6 +823,30 @@ ecore_x_dpi_get(void)
return (((s->width * 254) / s->mwidth) + 5) / 10;
}
/**
* Invoke the standard system beep to alert users
*
* @param percent The volume at which the bell rings. Must be in the range
* [-100,+100]. If percent >= 0, the final volume will be:
* base - [(base * percent) / 100] + percent
* Otherwise, it's calculated as:
* base + [(base * percent) / 100]
* where @c base is the bell's base volume as set by XChangeKeyboardControl(3).
*
* @returns EINA_TRUE on success, EINA_FALSE otherwise.
*/
EAPI Eina_Bool
ecore_x_bell(int percent)
{
int ret;
ret = XBell(_ecore_x_disp, percent);
if (ret == BadValue)
return EINA_FALSE;
return EINA_TRUE;
}
static Eina_Bool
_ecore_x_fd_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
{

View File

@ -22,6 +22,11 @@ ecore_suite_LDADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_con/libecore_con.la
if BUILD_ECORE_X
ecore_suite_LDADD += \
$(top_builddir)/src/lib/ecore_x/libecore_x.la
endif
endif
EXTRA_DIST = ecore_suite.h

View File

@ -2,12 +2,12 @@
# include <config.h>
#endif
#include "ecore_suite.h"
#include <Ecore.h>
#include <Eina.h>
#include <unistd.h>
#include "ecore_suite.h"
#include <stdio.h>
static int _log_dom;
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
@ -340,6 +340,28 @@ START_TEST(ecore_test_ecore_main_loop_event_recursive)
}
END_TEST
/* TODO: change to HAVE_ECORE_X when xcb implementation is done */
#ifdef HAVE_ECORE_X_XLIB
START_TEST(ecore_test_ecore_x_bell)
{
int ret = 0, i;
ecore_x_init(NULL);
printf("You should hear 3 beeps now.\n");
for (i=0; i < 3; i++)
{
ret = ecore_x_bell(0);
fail_if(ret != EINA_TRUE);
ecore_x_sync();
sleep(1);
}
ecore_x_shutdown();
}
END_TEST
#endif
void ecore_test_ecore(TCase *tc)
{
tcase_add_test(tc, ecore_test_ecore_init);
@ -352,4 +374,9 @@ void ecore_test_ecore(TCase *tc)
tcase_add_test(tc, ecore_test_ecore_main_loop_event);
tcase_add_test(tc, ecore_test_ecore_main_loop_timer_inner);
tcase_add_test(tc, ecore_test_ecore_main_loop_event_recursive);
/* TODO: change to HAVE_ECORE_X when xcb implementation is done */
#ifdef HAVE_ECORE_X_XLIB
tcase_add_test(tc, ecore_test_ecore_x_bell);
#endif
}