summaryrefslogtreecommitdiff
path: root/tests/test_monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_monitor.c')
-rw-r--r--tests/test_monitor.c54
1 files changed, 25 insertions, 29 deletions
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 );