• Skip to content
  • Skip to link menu
KDE 4.2 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 #ifdef HAVE_XFIXES
00024 #  include "cursornotificationhandler.h"
00025 #endif
00026 
00027 
00028 MouseEngine::MouseEngine(QObject* parent, const QVariantList& args)
00029     : Plasma::DataEngine(parent, args), timerId(0)
00030 #ifdef HAVE_XFIXES
00031 , handler(0)
00032 #endif
00033 {
00034     Q_UNUSED(args)
00035 }
00036 
00037 
00038 MouseEngine::~MouseEngine()
00039 {
00040     if (timerId)
00041         killTimer(timerId);
00042 #ifdef HAVE_XFIXES
00043     delete handler;
00044 #endif
00045 }
00046 
00047 
00048 QStringList MouseEngine::sources() const
00049 {
00050    QStringList list;
00051 
00052    list << QLatin1String("Position");
00053 #ifdef HAVE_XFIXES
00054    list << QLatin1String("Name");
00055 #endif
00056 
00057    return list;
00058 }
00059 
00060 
00061 void MouseEngine::init()
00062 {
00063     if (!timerId)
00064         timerId = startTimer(40);
00065 
00066     // Init cursor position
00067     QPoint pos = QCursor::pos();
00068     setData(QLatin1String("Position"), QVariant(pos));
00069     lastPosition = pos;
00070 
00071 #ifdef HAVE_XFIXES
00072     handler = new CursorNotificationHandler;
00073     connect(handler, SIGNAL(cursorNameChanged(QString)), SLOT(updateCursorName(QString)));
00074 
00075     setData(QLatin1String("Name"), QVariant(handler->cursorName()));
00076 #endif
00077 
00078     scheduleSourcesUpdated();
00079 }
00080 
00081 
00082 void MouseEngine::timerEvent(QTimerEvent *)
00083 {
00084     QPoint pos = QCursor::pos();
00085 
00086     if (pos != lastPosition)
00087     {
00088         setData(QLatin1String("Position"), QVariant(pos));
00089         lastPosition = pos;
00090 
00091         scheduleSourcesUpdated();
00092     }
00093 }
00094 
00095 
00096 void MouseEngine::updateCursorName(const QString &name)
00097 {
00098     setData(QLatin1String("Name"), QVariant(name));
00099     scheduleSourcesUpdated();
00100 }
00101 
00102 #include "mouseengine.moc"
00103 

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
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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