summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Udaltsov <svu@gnome.org>2004-11-25 23:17:30 +0000
committerSergey Udaltsov <svu@gnome.org>2004-11-25 23:17:30 +0000
commitd431ef4a3ca6228954ddb21e2e4a88f0cf9e8624 (patch)
treebf8eb5bf48f308bfe325e1d7dcffa89bdfb9245e /tests
parentd5c0ab08dad47f5a9d1c17eb18f80aceca5843b9 (diff)
downloadlibxklavier-d431ef4a3ca6228954ddb21e2e4a88f0cf9e8624.tar.gz
first commit with xmodmap support
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config.c49
-rw-r--r--tests/test_monitor.c54
2 files changed, 44 insertions, 59 deletions
diff --git a/tests/test_config.c b/tests/test_config.c
index ad2c4f0..cf01482 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -1,12 +1,22 @@
#include <config.h>
#include <stdio.h>
#include <unistd.h>
+#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <libxklavier/xklavier.h>
#include <libxklavier/xklavier_config.h>
+#ifdef __STRICT_ANSI__
+/* these are functions which are NOT in ANSI C.
+ Probably we should provide the implementation */
+extern char *strdup( const char *s );
+#endif
+
+extern void XklConfigDump( FILE* file,
+ XklConfigRecPtr data );
+
enum { ACTION_NONE, ACTION_GET, ACTION_SET, ACTION_WRITE };
static void printUsage()
@@ -21,28 +31,6 @@ static void printUsage()
printf( " -h - Show this help\n" );
}
-static void dump( XklConfigRecPtr ptr )
-{
- int i,j;
- char**p;
- XklDebug( 0, " model: [%s]\n", ptr->model );
-
- XklDebug( 0, " layouts(%d):\n", ptr->numLayouts );
- p = ptr->layouts;
- for( i = ptr->numLayouts, j = 0; --i >= 0; )
- XklDebug( 0, " %d: [%s]\n", j++, *p++ );
-
- XklDebug( 0, " variants(%d):\n", ptr->numVariants );
- p = ptr->variants;
- for( i = ptr->numVariants, j = 0; --i >= 0; )
- XklDebug( 0, " %d: [%s]\n", j++, *p++ );
-
- XklDebug( 0, " options(%d):\n", ptr->numOptions );
- p = ptr->options;
- for( i = ptr->numOptions, j = 0; --i >= 0; )
- XklDebug( 0, " %d: [%s]\n", j++, *p++ );
-}
-
int main( int argc, char * const argv[] )
{
int c, i;
@@ -50,7 +38,7 @@ int main( int argc, char * const argv[] )
const char* model = NULL;
const char* layouts = NULL;
const char* options = NULL;
- int debugLevel = 0;
+ int debugLevel = -1;
int binary = 0;
Display *dpy;
@@ -109,13 +97,14 @@ int main( int argc, char * const argv[] )
if ( !XklInit( dpy ) )
{
XklConfigRec currentConfig, r2;
- XklSetDebugLevel( debugLevel );
+ if( debugLevel != -1 )
+ XklSetDebugLevel( debugLevel );
XklDebug( 0, "Xklavier initialized\n" );
XklConfigInit();
XklConfigLoadRegistry();
XklDebug( 0, "Xklavier registry loaded\n" );
- XklDebug( 0, "Multiple layouts are %ssupported\n",
- XklMultipleLayoutsSupported() ? "" : "not " );
+ XklDebug( 0, "Bakend: [%s]\n", XklGetBackendName() );
+ XklDebug( 0, "Supported features: 0x0%X\n", XklGetBackendFeatures() );
XklConfigRecInit( &currentConfig );
XklConfigGetFromServer( &currentConfig );
@@ -124,14 +113,14 @@ int main( int argc, char * const argv[] )
{
case ACTION_GET:
XklDebug( 0, "Got config from the server\n" );
- dump( &currentConfig );
+ XklConfigDump( stdout, &currentConfig );
XklConfigRecInit( &r2 );
if ( XklConfigGetFromBackup( &r2 ) )
{
XklDebug( 0, "Got config from the backup\n" );
- dump( &r2 );
+ XklConfigDump( stdout, &r2 );
}
if ( XklConfigActivate( &r2 ) )
@@ -191,7 +180,7 @@ int main( int argc, char * const argv[] )
}
XklDebug( 0, "New config:\n" );
- dump( &currentConfig );
+ XklConfigDump( stdout, &currentConfig );
if ( XklConfigActivate( &currentConfig ) )
XklDebug( 0, "Set the config\n" );
else
@@ -215,7 +204,7 @@ int main( int argc, char * const argv[] )
XklTerm();
} else
{
- fprintf( stderr, "Could not init Xklavier\n" );
+ fprintf( stderr, "Could not init Xklavier: %s\n", XklGetLastError() );
exit(2);
}
printf( "closing display: %p\n", dpy );
diff --git a/tests/test_monitor.c b/tests/test_monitor.c
index 8808b62..515c328 100644
--- a/tests/test_monitor.c
+++ b/tests/test_monitor.c
@@ -1,52 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <getopt.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <libxklavier/xklavier.h>
#include <libxklavier/xklavier_config.h>
+extern void XklConfigDump( FILE* file,
+ XklConfigRecPtr data );
+
static void printUsage()
{
- printf( "Usage: test_monitor (-h)|(-d <debugLevel>)\n" );
+ printf( "Usage: test_monitor (-l1)(-l2)(-l3)(-h)(-d <debugLevel>)\n" );
printf( "Options:\n" );
printf( " -d - Set the debug level (by default, 0)\n" );
printf( " -h - Show this help\n" );
-}
-
-void dump( XklConfigRecPtr ptr )
-{
- int i,j;
- char**p;
- XklDebug( 0, " model: [%s]\n", ptr->model );
-
- XklDebug( 0, " layouts(%d):\n", ptr->numLayouts );
- p = ptr->layouts;
- for( i = ptr->numLayouts, j = 0; --i >= 0; )
- XklDebug( 0, " %d: [%s]\n", j++, *p++ );
-
- XklDebug( 0, " variants(%d):\n", ptr->numVariants );
- p = ptr->variants;
- for( i = ptr->numVariants, j = 0; --i >= 0; )
- XklDebug( 0, " %d: [%s]\n", j++, *p++ );
-
- XklDebug( 0, " options(%d):\n", ptr->numOptions );
- p = ptr->options;
- for( i = ptr->numOptions, j = 0; --i >= 0; )
- XklDebug( 0, " %d: [%s]\n", j++, *p++ );
+ printf( " -l1 - listen to manage layouts\n" );
+ printf( " -l2 - listen to manage window states\n" );
+ printf( " -l3 - listen to track the keyboard state\n" );
}
int main( int argc, char * argv[] )
{
int c;
- int debugLevel = 0;
+ int debugLevel = -1;
XkbEvent ev;
Display* dpy;
+ int listenerType = 0, lt;
+ int listenerTypes[] = { XKLL_MANAGE_LAYOUTS,
+ XKLL_MANAGE_WINDOW_STATES,
+ XKLL_TRACK_KEYBOARD_STATE };
while (1)
{
- c = getopt( argc, argv, "hd:" );
+ c = getopt( argc, argv, "hd:l:" );
if ( c == -1 )
break;
switch (c)
@@ -57,6 +46,11 @@ int main( int argc, char * argv[] )
case 'd':
debugLevel = atoi( optarg );
break;
+ case 'l':
+ lt = optarg[0] - '1';
+ if( lt >= 0 && lt < sizeof(listenerTypes)/sizeof(listenerTypes[0]) )
+ listenerType |= listenerTypes[lt];
+ break;
default:
fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
printUsage();
@@ -71,10 +65,11 @@ int main( int argc, char * argv[] )
exit(1);
}
printf( "opened display: %p\n", dpy );
- if ( !XklInit( dpy ) )
+ if( !XklInit( dpy ) )
{
XklConfigRec currentConfig;
- XklSetDebugLevel( debugLevel );
+ if( debugLevel != -1 )
+ XklSetDebugLevel( debugLevel );
XklDebug( 0, "Xklavier initialized\n" );
XklConfigInit();
XklConfigLoadRegistry();
@@ -83,7 +78,8 @@ int main( int argc, char * argv[] )
XklConfigRecInit( &currentConfig );
XklConfigGetFromServer( &currentConfig );
- XklStartListen();
+ XklDebug( 0, "Now, listening...\n" );
+ XklStartListen( listenerType );
while (1)
{
@@ -103,7 +99,7 @@ int main( int argc, char * argv[] )
XklTerm();
} else
{
- fprintf( stderr, "Could not init Xklavier\n" );
+ fprintf( stderr, "Could not init Xklavier: %s\n", XklGetLastError() );
exit(2);
}
printf( "closing display: %p\n", dpy );