not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / effects / test / test_input.cpp
blob9eb94ffec062b5c69849b63ca0dd43807afc0a8e
1 /*****************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
7 You can Freely distribute this program under the GNU General Public
8 License. See the file "COPYING" for the exact licensing terms.
9 ******************************************************************/
13 Testing of handling input in effects. This testing effect moves all windows
14 by 100 pixels down, creates an input window that'll intercept all mouse events
15 and activates the window that's been clicked (click position needs to be
16 transformed). This is useful for effects that present something on the screen
17 and let the user interact with it (e.g. a list of window thumbnails and the
18 user can activate the window by clicking its thumbnail).
22 #include "test_input.h"
24 #include <assert.h>
26 #include <qcursor.h>
27 #include <qevent.h>
29 namespace KWin
32 KWIN_EFFECT( test_input, TestInputEffect )
34 TestInputEffect::TestInputEffect()
36 input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(), Qt::CrossCursor );
39 TestInputEffect::~TestInputEffect()
41 effects->destroyInputWindow( input );
44 void TestInputEffect::prePaintScreen( ScreenPrePaintData& data, int time )
46 data.mask |= PAINT_SCREEN_TRANSFORMED;
47 effects->prePaintScreen( data, time );
50 void TestInputEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
52 data.yTranslate += 100;
53 effects->paintScreen( mask, region, data );
56 void TestInputEffect::windowInputMouseEvent( Window w, QEvent* e )
58 assert( w == input );
59 if( e->type() != QEvent::MouseButtonPress )
60 return;
61 QPoint pos = static_cast< QMouseEvent* >( e )->pos();
62 pos -= QPoint( 0, 100 ); // adjust for transformation
63 foreach( EffectWindow* c, effects->stackingOrder())
65 if( /* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
66 && c->geometry().contains( pos ))
68 effects->activateWindow( c );
69 return;
74 } // namespace