Effect which can temporarily mark places on the screen.
svn path=/branches/work/kwin_composite/; revision=656547
This commit is contained in:
parent
ffc75a2214
commit
bf29f2c3e1
5 changed files with 147 additions and 1 deletions
|
@ -73,6 +73,9 @@ General TODO
|
|||
|
||||
* window grouping is not implemented for unmanaged windows (used e.g. by DimInactive)
|
||||
|
||||
% clean up and sort out shortcuts so that they don't conflict and make sense
|
||||
- also make configurable etc.
|
||||
|
||||
|
||||
OpenGL TODO
|
||||
=================================
|
||||
|
|
|
@ -41,6 +41,7 @@ if(OPENGL_FOUND)
|
|||
SET(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
||||
explosioneffect.cpp
|
||||
magnifier.cpp
|
||||
mousemark.cpp
|
||||
shadow.cpp
|
||||
trackmouse.cpp
|
||||
wavywindows.cpp
|
||||
|
@ -53,6 +54,7 @@ if(OPENGL_FOUND)
|
|||
install( FILES
|
||||
explosion.desktop
|
||||
magnifier.desktop
|
||||
mousemark.desktop
|
||||
shadow.desktop
|
||||
trackmouse.desktop
|
||||
wavywindows.desktop
|
||||
|
@ -103,7 +105,6 @@ install( FILES
|
|||
fallapart.desktop
|
||||
flame.desktop
|
||||
howto.desktop
|
||||
magnifier.desktop
|
||||
maketransparent.desktop
|
||||
minimizeanimation.desktop
|
||||
presentwindows.desktop
|
||||
|
|
99
effects/mousemark.cpp
Normal file
99
effects/mousemark.cpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*****************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2006 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.
|
||||
******************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mousemark.h"
|
||||
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( MouseMark, MouseMarkEffect )
|
||||
|
||||
MouseMarkEffect::MouseMarkEffect()
|
||||
{
|
||||
KActionCollection* actionCollection = new KActionCollection( this );
|
||||
KAction* a = static_cast< KAction* >( actionCollection->addAction( "ClearMouseMarks" ));
|
||||
a->setText( i18n( "ClearMouseMarks" ));
|
||||
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
|
||||
connect( a, SIGNAL( triggered( bool )), this, SLOT( clear()));
|
||||
}
|
||||
|
||||
void MouseMarkEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
{
|
||||
effects->paintScreen( mask, region, data ); // paint normal screen
|
||||
if( marks.isEmpty() && drawing.isEmpty())
|
||||
return;
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LINE_BIT );
|
||||
glColor4f( 1, 0, 0, 1 ); // red
|
||||
glEnable( GL_LINE_SMOOTH );
|
||||
glLineWidth( 3 );
|
||||
foreach( const Mark& mark, marks )
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
foreach( const QPoint& p, mark )
|
||||
glVertex2i( p.x(), p.y());
|
||||
glEnd();
|
||||
}
|
||||
if( !drawing.isEmpty())
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
foreach( const QPoint& p, drawing )
|
||||
glVertex2i( p.x(), p.y());
|
||||
glEnd();
|
||||
}
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
void MouseMarkEffect::mouseChanged( const QPoint& pos, const QPoint&,
|
||||
Qt::MouseButtons, Qt::KeyboardModifiers modifiers )
|
||||
{
|
||||
if( modifiers == ( Qt::META | Qt::SHIFT )) // activated
|
||||
{
|
||||
if( drawing.isEmpty())
|
||||
drawing.append( pos );
|
||||
if( drawing.last() == pos )
|
||||
return;
|
||||
QPoint pos2 = drawing.last();
|
||||
drawing.append( pos );
|
||||
effects->addRepaint( QRect( qMin( pos.x(), pos2.x()), qMin( pos.y(), pos2.y()),
|
||||
qMax( pos.x(), pos2.x()), qMax( pos.y(), pos2.y())));
|
||||
}
|
||||
else if( !drawing.isEmpty())
|
||||
{
|
||||
marks.append( drawing );
|
||||
drawing.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseMarkEffect::clear()
|
||||
{
|
||||
drawing.clear();
|
||||
marks.clear();
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "mousemark.moc"
|
4
effects/mousemark.desktop
Normal file
4
effects/mousemark.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=MouseMark
|
||||
X-KDE-Library=kwin4_effect_builtins
|
39
effects/mousemark.h
Normal file
39
effects/mousemark.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*****************************************************************
|
||||
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.
|
||||
******************************************************************/
|
||||
|
||||
#ifndef KWIN_MOUSEMARK_H
|
||||
#define KWIN_MOUSEMARK_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <kwinglutils.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class MouseMarkEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MouseMarkEffect();
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void mouseChanged( const QPoint& pos, const QPoint& old,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers );
|
||||
private slots:
|
||||
void clear();
|
||||
private:
|
||||
typedef QVector< QPoint > Mark;
|
||||
QVector< Mark > marks;
|
||||
Mark drawing;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue