summaryrefslogtreecommitdiff
path: root/src/Main.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.cxx')
-rw-r--r--src/Main.cxx129
1 files changed, 98 insertions, 31 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 20e7d2c..0fb9fc0 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -3,23 +3,37 @@ namespace PluggIt {
D_DEBUG_DOMAIN( PluggIt_Main, "PluggIt/Main", "PluggIt Main" );
D_DEBUG_DOMAIN( PluggIt_View, "PluggIt/View", "PluggIt View" );
+#define NOTRCSOURCEMASK 0x20
+#define HK_REMOTEAPP DIKS_CUSTOM97
+
+
class Main extends View, Runnable
{
class Config {
public DFBDimension m_size;
public DFBPoint m_offset;
public DFBDimension m_resolution;
+ public DFBLocation m_destination;
public DFBSurfacePixelFormat m_format;
public std::string m_title;
public bool m_interactive;
- public bool m_updating;
- public bool m_use_driver;
+ public bool m_always_all;
+ public long m_interval_all;
+ public long m_interval_hot;
+ public long m_focus_timeout;
public Config() :
m_format(DSPF_UNKNOWN),
m_interactive(false),
- m_updating(false)
+ m_always_all(false),
+ m_interval_all(400),
+ m_interval_hot(100),
+ m_focus_timeout(0)
{
+ m_destination.x = 0.0f;
+ m_destination.y = 0.0f;
+ m_destination.w = 1.0f;
+ m_destination.h = 1.0f;
}
};
@@ -43,21 +57,29 @@ class Main extends View, Runnable
private bool m_view_visible;
private DFBSurfacePixelFormat m_view_format;
+ private u8 m_opacity;
+
+ private IDiVine *m_divine;
+
public Main() :
m_source(NULL),
- m_view_visible(false)
+ m_view_visible(false),
+ m_opacity(255)
{
D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
m_options.addOption( new Options::OptionDimension( "-s", "--size", "<width>x<height>", "Size of view", m_config.m_size ) );
m_options.addOption( new Options::OptionPoint ( "-o", "--offset", "<x>,<y>", "Offset of view", m_config.m_offset ) );
m_options.addOption( new Options::OptionDimension( "-r", "--resolution", "<X>x<Y>", "Resolution of view", m_config.m_resolution ) );
+ m_options.addOption( new Options::OptionLocation ( "-d", "--destination", "<x>,<y>-<w>x<h>", "Destination location", m_config.m_destination ) );
m_options.addOption( new Options::OptionFormat ( "-f", "--format", "<pixelformat>", "Pixel format of view", m_config.m_format ) );
m_options.addOption( new Options::OptionString ( "-t", "--title", "<string>", "Title of window to show", m_config.m_title ) );
m_options.addOption( new Options::OptionBool ( "-i", "--interactive", "", "Use interactive window picking", m_config.m_interactive ) );
- m_options.addOption( new Options::OptionBool ( "-u", "--updating", "", "Update continuously", m_config.m_updating ) );
- m_options.addOption( new Options::OptionBool ( "-d", "--driver", "", "Use driver mode", m_config.m_use_driver ) );
+ m_options.addOption( new Options::OptionBool ( "-a", "--all", "", "Always all", m_config.m_always_all ) );
+ m_options.addOption( new Options::OptionLong ( "-A", "--inter-all", "<ms>", "Interval all", m_config.m_interval_all ) );
+ m_options.addOption( new Options::OptionLong ( "-H", "--inter-hot", "<ms>", "Interval hot", m_config.m_interval_hot ) );
+ m_options.addOption( new Options::OptionLong ( "-F", "--focus", "<seconds>", "Focus timeout", m_config.m_focus_timeout ) );
}
public void main( int argc, char *argv[] ) {
@@ -71,7 +93,29 @@ class Main extends View, Runnable
return;
initDFB();
- initSource();
+
+
+ DiVineCreate( &m_divine );
+
+#ifdef __WIN32__
+ SourceWin32::Config config( m_config.m_interactive ?
+ SourceWin32::Config::WINDOW_SELECTION_INTERACTIVE :
+ (m_config.m_title.size() > 0 ?
+ SourceWin32::Config::WINDOW_SELECTION_TITLE :
+ SourceWin32::Config::WINDOW_SELECTION_NONE), m_config.m_title,
+ m_config.m_always_all, m_config.m_interval_all, m_config.m_interval_hot );
+
+ m_source = new SourceWin32( this, config );
+#else
+ SourceX11::Config config( m_config.m_interactive ?
+ SourceX11::Config::WINDOW_SELECTION_INTERACTIVE :
+ (m_config.m_title.size() > 0 ?
+ SourceX11::Config::WINDOW_SELECTION_TITLE :
+ SourceX11::Config::WINDOW_SELECTION_NONE), m_config.m_title );
+
+ m_source = new SourceX11( this, config );
+#endif
+
Thread *thread = new Thread( this, "Main" );
@@ -115,7 +159,19 @@ class Main extends View, Runnable
up = true;
case DWET_KEYDOWN:
- key = CKeySend::MapDfbKeyEventToVK( event->key_symbol );
+ if (event->key_symbol == DIKS_0 && !up) {
+ m_opacity = (m_opacity == 255 ? 0 : 255);
+ m_window.SetOpacity( m_opacity );
+ }
+ else
+ key = CKeySend::MapDfbKeyEventToVK( event->key_symbol );
+ break;
+
+ case DWET_LOSTFOCUS:
+ if (m_config.m_focus_timeout) {
+ sleep( m_config.m_focus_timeout );
+ hk_SendKey( HK_REMOTEAPP, 0, 0, 1 );
+ }
break;
default:
@@ -143,29 +199,6 @@ class Main extends View, Runnable
m_events = m_dfb.CreateEventBuffer();
}
- private void initSource() {
- D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
-
-#ifdef __WIN32__
- SourceWin32::Config config( m_config.m_interactive ?
- SourceWin32::Config::WINDOW_SELECTION_INTERACTIVE :
- (m_config.m_title.size() > 0 ?
- SourceWin32::Config::WINDOW_SELECTION_TITLE :
- SourceWin32::Config::WINDOW_SELECTION_NONE), m_config.m_title,
- m_config.m_updating, m_config.m_use_driver );
-
- m_source = new SourceWin32( this, config );
-#else
- SourceX11::Config config( m_config.m_interactive ?
- SourceX11::Config::WINDOW_SELECTION_INTERACTIVE :
- (m_config.m_title.size() > 0 ?
- SourceX11::Config::WINDOW_SELECTION_TITLE :
- SourceX11::Config::WINDOW_SELECTION_NONE), m_config.m_title );
-
- m_source = new SourceX11( this, config );
-#endif
- }
-
private void run() {
try {
m_source->MainLoop();
@@ -271,6 +304,14 @@ class Main extends View, Runnable
m_view_format = m_surface.GetPixelFormat();
m_window.AttachEventBuffer( m_events );
+
+
+ DFBWindowGeometry geometry;
+
+ geometry.mode = DWGM_LOCATION;
+ geometry.location = m_config.m_destination;
+
+ m_window.SetDstGeometry( &geometry );
}
m_view_size = size;
@@ -466,6 +507,32 @@ class Main extends View, Runnable
m_view_visible = true;
}
}
+
+ void
+ hk_SendKey( int keyname,
+ int src,
+ int sys,
+ int cmd )
+ {
+ if (m_divine) {
+ DFBResult ret;
+ DFBInputEvent event;
+
+ src |= NOTRCSOURCEMASK;
+
+ event.clazz = DFEC_INPUT;
+ event.type = DIET_KEYPRESS;
+ event.key_code = (((unsigned int)src & 0xff) << 24) | (((unsigned int)sys & 0xff) << 16) | ((unsigned int)cmd & 0xffff);
+ event.key_symbol = (DFBInputDeviceKeySymbol)keyname;
+ event.flags = (DFBInputEventFlags)(DIEF_KEYCODE | DIEF_KEYSYMBOL);
+
+ ret = m_divine->SendEvent( m_divine, &event );
+ if (ret)
+ D_DERROR( (DirectResult) ret, "IDiVine::SendEvent() failed!\n" );
+ }
+ else
+ D_ERROR( "IDiVine interface is null!\n" );
+ }
};
}