diff options
Diffstat (limited to 'src/Main.cxx')
-rw-r--r-- | src/Main.cxx | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index 10013d8..20e7d2c 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -3,7 +3,7 @@ namespace PluggIt { D_DEBUG_DOMAIN( PluggIt_Main, "PluggIt/Main", "PluggIt Main" ); D_DEBUG_DOMAIN( PluggIt_View, "PluggIt/View", "PluggIt View" ); -class Main extends View +class Main extends View, Runnable { class Config { public DFBDimension m_size; @@ -73,7 +73,26 @@ class Main extends View initDFB(); initSource(); - run(); + Thread *thread = new Thread( this, "Main" ); + + thread->start(); + + while (true) { + DFBEvent event; + + m_events.WaitForEvent(); + + m_events.GetEvent( &event ); + + switch (event.clazz) { + case DFEC_WINDOW: + handleWindowEvent( &event.window ); + break; + + default: + break; + } + } } catch (DFBException *e) { cerr << endl; @@ -87,6 +106,32 @@ class Main extends View } } + public void handleWindowEvent( const DFBWindowEvent *event ) { + int key = -1; + bool up = false; + + switch (event->type) { + case DWET_KEYUP: + up = true; + + case DWET_KEYDOWN: + key = CKeySend::MapDfbKeyEventToVK( event->key_symbol ); + break; + + default: + break; + } + + if (key != -1) { + D_INFO( "Sending key %d (%s)\n", key, up ? "up" : "down" ); + + if (up) + CKeySend::SendKeyUp( key ); + else + CKeySend::SendKeyDown( key ); + } + } + private void initDFB() { D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ ); @@ -122,7 +167,19 @@ class Main extends View } private void run() { - m_source->MainLoop(); + try { + m_source->MainLoop(); + } + catch (DFBException *e) { + cerr << endl; + cerr << "Caught exception!" << endl; + cerr << " ==> " << e << endl; + } + catch (Exception *e) { + cerr << endl; + cerr << "Caught exception!" << endl; + cerr << " ==> " << e << endl; + } } public virtual void config( DFBDimension &source_resolution ) { |