1
/*****************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2006 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
******************************************************************/
11
#include "mousemark.h"
13
#include <config-X11.h>
16
#include <kactioncollection.h>
19
#include <kstandarddirs.h>
32
KWIN_EFFECT( mousemark, MouseMarkEffect )
34
MouseMarkEffect::MouseMarkEffect()
36
KActionCollection* actionCollection = new KActionCollection( this );
37
KAction* a = static_cast< KAction* >( actionCollection->addAction( "ClearMouseMarks" ));
38
a->setText( i18n( "ClearMouseMarks" ));
39
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
40
connect( a, SIGNAL( triggered( bool )), this, SLOT( clear()));
43
void MouseMarkEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
45
effects->paintScreen( mask, region, data ); // paint normal screen
46
if( marks.isEmpty() && drawing.isEmpty())
48
glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LINE_BIT );
49
glColor4f( 1, 0, 0, 1 ); // red
50
glEnable( GL_LINE_SMOOTH );
52
foreach( const Mark& mark, marks )
54
glBegin( GL_LINE_STRIP );
55
foreach( const QPoint& p, mark )
56
glVertex2i( p.x(), p.y());
59
if( !drawing.isEmpty())
61
glBegin( GL_LINE_STRIP );
62
foreach( const QPoint& p, drawing )
63
glVertex2i( p.x(), p.y());
69
void MouseMarkEffect::mouseChanged( const QPoint& pos, const QPoint&,
70
Qt::MouseButtons, Qt::KeyboardModifiers modifiers )
72
if( modifiers == ( Qt::META | Qt::SHIFT )) // activated
74
if( drawing.isEmpty())
75
drawing.append( pos );
76
if( drawing.last() == pos )
78
QPoint pos2 = drawing.last();
79
drawing.append( pos );
80
effects->addRepaint( QRect( qMin( pos.x(), pos2.x()), qMin( pos.y(), pos2.y()),
81
qMax( pos.x(), pos2.x()), qMax( pos.y(), pos2.y())));
83
else if( !drawing.isEmpty())
85
marks.append( drawing );
90
void MouseMarkEffect::clear()
94
effects->addRepaintFull();
99
#include "mousemark.moc"