2007-04-29 17:35:43 +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"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <qcursor.h>
|
|
|
|
#include <qevent.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EFFECT(test_input, TestInputEffect)
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
TestInputEffect::TestInputEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
input = effects->createInputWindow(this, 0, 0, displayWidth(), displayHeight(), Qt::CrossCursor);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
TestInputEffect::~TestInputEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
effects->destroyInputWindow(input);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void TestInputEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
2007-07-07 14:01:32 +00:00
|
|
|
data.mask |= PAINT_SCREEN_TRANSFORMED;
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void TestInputEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
data.yTranslate += 100;
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintScreen(mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void TestInputEffect::windowInputMouseEvent(Window w, QEvent* e)
|
|
|
|
{
|
|
|
|
assert(w == input);
|
|
|
|
if (e->type() != QEvent::MouseButtonPress)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
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);
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|