2007-01-05 16:45:56 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Testing of handling input in effects. This testing effect moves all windows
|
|
|
|
by 100 pixels down, creates an input window that'll intercept all mouse events
|
|
|
|
and activates the window that's been clicked (click position needs to be
|
|
|
|
transformed). This is useful for effects that present something on the screen
|
|
|
|
and let the user interact with it (e.g. a list of window thumbnails and the
|
|
|
|
user can activate the window by clicking its thumbnail).
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test_input.h"
|
|
|
|
|
2007-04-11 15:53:32 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <qcursor.h>
|
|
|
|
#include <qevent.h>
|
2007-01-05 16:45:56 +00:00
|
|
|
|
2007-04-05 12:07:35 +00:00
|
|
|
namespace KWin
|
2007-01-05 16:45:56 +00:00
|
|
|
{
|
|
|
|
|
2007-04-11 15:53:32 +00:00
|
|
|
KWIN_EFFECT( TestInput, TestInputEffect )
|
|
|
|
|
2007-01-05 16:45:56 +00:00
|
|
|
TestInputEffect::TestInputEffect()
|
|
|
|
{
|
|
|
|
input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(), Qt::CrossCursor );
|
|
|
|
}
|
|
|
|
|
|
|
|
TestInputEffect::~TestInputEffect()
|
|
|
|
{
|
|
|
|
effects->destroyInputWindow( input );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestInputEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
|
|
|
{
|
2007-04-11 15:53:32 +00:00
|
|
|
*mask |= PAINT_SCREEN_TRANSFORMED;
|
2007-01-05 16:45:56 +00:00
|
|
|
effects->prePaintScreen( mask, region, time );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestInputEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
|
|
|
{
|
|
|
|
data.yTranslate += 100;
|
|
|
|
effects->paintScreen( mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestInputEffect::windowInputMouseEvent( Window w, QEvent* e )
|
|
|
|
{
|
|
|
|
assert( w == input );
|
|
|
|
if( e->type() != QEvent::MouseButtonPress )
|
|
|
|
return;
|
|
|
|
QPoint pos = static_cast< QMouseEvent* >( e )->pos();
|
|
|
|
pos -= QPoint( 0, 100 ); // adjust for transformation
|
2007-04-11 15:53:32 +00:00
|
|
|
foreach( EffectWindow* c, effects->stackingOrder())
|
2007-01-05 16:45:56 +00:00
|
|
|
{
|
2007-04-11 15:53:32 +00:00
|
|
|
if( /* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
|
2007-01-05 16:45:56 +00:00
|
|
|
&& c->geometry().contains( pos ))
|
|
|
|
{
|
2007-04-11 15:53:32 +00:00
|
|
|
effects->activateWindow( c );
|
2007-01-05 16:45:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|