diff --git a/COMPOSITE_TODO b/COMPOSITE_TODO index 8ebecc5d1d..74c7092d2f 100644 --- a/COMPOSITE_TODO +++ b/COMPOSITE_TODO @@ -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 ================================= diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 7e4aa257e8..108fd83bbe 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -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 diff --git a/effects/mousemark.cpp b/effects/mousemark.cpp new file mode 100644 index 0000000000..7e844d7903 --- /dev/null +++ b/effects/mousemark.cpp @@ -0,0 +1,99 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2006 Lubos Lunak + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + +#include + +#include "mousemark.h" + +#include +#include +#include +#include +#include + +#include + +#ifdef HAVE_OPENGL +#include +#endif + +#include + +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" diff --git a/effects/mousemark.desktop b/effects/mousemark.desktop new file mode 100644 index 0000000000..d714767b52 --- /dev/null +++ b/effects/mousemark.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=MouseMark +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/mousemark.h b/effects/mousemark.h new file mode 100644 index 0000000000..f189aedc29 --- /dev/null +++ b/effects/mousemark.h @@ -0,0 +1,39 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Lubos Lunak + +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 +#include + +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