MouseMark effect supports QPainter compositor

This commit is contained in:
Martin Gräßlin 2013-06-24 08:08:55 +02:00
parent 2dc14be640
commit 9cecbc0135
2 changed files with 25 additions and 0 deletions

View file

@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDE/KGlobalAccel>
#include <KDE/KLocalizedString>
#include <QPainter>
#include <math.h>
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
@ -171,6 +173,28 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
}
}
#endif
if (effects->compositingType() == QPainterCompositing) {
QPainter *painter = effects->scenePainter();
painter->save();
QPen pen(color);
pen.setWidth(width);
painter->setPen(pen);
foreach (const Mark &mark, marks) {
drawMark(painter, mark);
}
drawMark(painter, drawing);
painter->restore();
}
}
void MouseMarkEffect::drawMark(QPainter *painter, const Mark &mark)
{
if (mark.count() <= 1) {
return;
}
for (int i = 0; i < mark.count() - 1; ++i) {
painter->drawLine(mark[i], mark[i+1]);
}
}
void MouseMarkEffect::slotMouseChanged(const QPoint& pos, const QPoint&,

View file

@ -59,6 +59,7 @@ private Q_SLOTS:
void screenLockingChanged(bool locked);
private:
typedef QVector< QPoint > Mark;
void drawMark(QPainter *painter, const Mark &mark);
static Mark createArrow(QPoint arrow_start, QPoint arrow_end);
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
void addRect(const QPoint &p1, const QPoint &p2, xcb_rectangle_t *r, xcb_render_color_t *c);