• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Engines

mouseengine.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright © 2007 Fredrik Höglund <fredrik@kde.org>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License version 2 as
00006  *   published by the Free Software Foundation
00007  *
00008  *   This program is distributed in the hope that it will be useful,
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *   GNU General Public License for more details
00012  *
00013  *   You should have received a copy of the GNU Library General Public
00014  *   License along with this program; if not, write to the
00015  *   Free Software Foundation, Inc.,
00016  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  */
00018 
00019 #include "mouseengine.h"
00020 
00021 #include <QCursor>
00022 
00023 #include <config-X11.h>
00024 
00025 #ifdef HAVE_XFIXES
00026 #  include "cursornotificationhandler.h"
00027 #endif
00028 
00029 
00030 MouseEngine::MouseEngine(QObject* parent, const QVariantList& args)
00031     : Plasma::DataEngine(parent, args), timerId(0), handler(0)
00032 {
00033     Q_UNUSED(args)
00034 }
00035 
00036 
00037 MouseEngine::~MouseEngine()
00038 {
00039     if (timerId)
00040         killTimer(timerId);
00041 #ifdef HAVE_XFIXES
00042     delete handler;
00043 #endif
00044 }
00045 
00046 
00047 QStringList MouseEngine::sources() const
00048 {
00049    QStringList list;
00050 
00051    list << QLatin1String("Position");
00052 #ifdef HAVE_XFIXES
00053    list << QLatin1String("Name");
00054 #endif
00055 
00056    return list;
00057 }
00058 
00059 
00060 void MouseEngine::init()
00061 {
00062     if (!timerId)
00063         timerId = startTimer(40);
00064 
00065     // Init cursor position
00066     QPoint pos = QCursor::pos();
00067     setData(QLatin1String("Position"), QVariant(pos));
00068     lastPosition = pos;
00069 
00070 #ifdef HAVE_XFIXES
00071     handler = new CursorNotificationHandler;
00072     connect(handler, SIGNAL(cursorNameChanged(QString)), SLOT(updateCursorName(QString)));
00073 
00074     setData(QLatin1String("Name"), QVariant(handler->cursorName()));
00075 #endif
00076 
00077     scheduleSourcesUpdated();
00078 }
00079 
00080 
00081 void MouseEngine::timerEvent(QTimerEvent *)
00082 {
00083     QPoint pos = QCursor::pos();
00084 
00085     if (pos != lastPosition)
00086     {
00087         setData(QLatin1String("Position"), QVariant(pos));
00088         lastPosition = pos;
00089 
00090         scheduleSourcesUpdated();
00091     }
00092 }
00093 
00094 
00095 void MouseEngine::updateCursorName(const QString &name)
00096 {
00097     setData(QLatin1String("Name"), QVariant(name));
00098     scheduleSourcesUpdated();
00099 }
00100 
00101 #include "mouseengine.moc"
00102 

Engines

Skip menu "Engines"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal