5faa397849
for use in effects (and not only). Now a list of window quads (=window areas) is created at the beginning of the paint pass, prepaint calls can modify the split itself (i.e. divide it into more parts). The actual paint calls can then modify these quads (i.e. transform their geometry). This will allow better control of how the split is done and also allow painting e.g. only the decoration differently. Still work in progress, but it works. Also pass data to prepaint functions in a struct, as there is already quite a number of them. svn path=/trunk/KDE/kdebase/workspace/; revision=684893
74 lines
2.1 KiB
C++
74 lines
2.1 KiB
C++
/*****************************************************************
|
|
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"
|
|
|
|
#include <assert.h>
|
|
|
|
#include <qcursor.h>
|
|
#include <qevent.h>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
KWIN_EFFECT( test_input, TestInputEffect )
|
|
|
|
TestInputEffect::TestInputEffect()
|
|
{
|
|
input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(), Qt::CrossCursor );
|
|
}
|
|
|
|
TestInputEffect::~TestInputEffect()
|
|
{
|
|
effects->destroyInputWindow( input );
|
|
}
|
|
|
|
void TestInputEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
|
{
|
|
data.mask |= PAINT_SCREEN_TRANSFORMED;
|
|
effects->prePaintScreen( data, 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
|
|
foreach( EffectWindow* c, effects->stackingOrder())
|
|
{
|
|
if( /* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
|
|
&& c->geometry().contains( pos ))
|
|
{
|
|
effects->activateWindow( c );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace
|