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"
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)
59
if (e->type() != QEvent::MouseButtonPress)
61
QPoint pos = static_cast< QMouseEvent* >(e)->pos();
62
pos -= QPoint(0, 100); // adjust for transformation
63
foreach (EffectWindow * c, effects->stackingOrder()) {
64
if (/* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
65
&& c->geometry().contains(pos)) {
66
effects->activateWindow(c);