diff --git a/screens.cpp b/screens.cpp index 3dd2584d79..23caf59352 100644 --- a/screens.cpp +++ b/screens.cpp @@ -37,7 +37,7 @@ Screens::Screens(QObject *parent) , m_count(0) , m_current(0) , m_currentFollowsMouse(false) - , m_changedTimer(new ScreenCountTimer(this)) + , m_changedTimer(new QTimer(this)) { m_changedTimer->setSingleShot(true); m_changedTimer->setInterval(100); @@ -117,19 +117,6 @@ int Screens::current() const return m_current; } -ScreenCountTimer::ScreenCountTimer(QObject * parent) : QTimer(parent) -{ -} - -void ScreenCountTimer::finish() -{ - if (isActive()) { - stop(); - Screens::self()->updateCount(); - QMetaObject::invokeMethod(Screens::self(), "changed", Qt::QueuedConnection); - } -} - DesktopWidgetScreens::DesktopWidgetScreens(QObject *parent) : Screens(parent) , m_desktop(QApplication::desktop()) @@ -145,13 +132,15 @@ DesktopWidgetScreens::~DesktopWidgetScreens() QRect DesktopWidgetScreens::geometry(int screen) const { - finishChangedTimer(); + if (Screens::self()->isChanging()) + const_cast(this)->updateCount(); return m_desktop->screenGeometry(screen); } int DesktopWidgetScreens::number(const QPoint &pos) const { - finishChangedTimer(); + if (Screens::self()->isChanging()) + const_cast(this)->updateCount(); return m_desktop->screenNumber(pos); } diff --git a/screens.h b/screens.h index 6bdc9689b3..f05f818519 100644 --- a/screens.h +++ b/screens.h @@ -35,15 +35,6 @@ namespace KWin { class Client; -class ScreenCountTimer : public QTimer { - public: - ScreenCountTimer(QObject * parent = 0); - /** - * if isActive, stop AND emit timeout() - */ - void finish(); -}; - class Screens : public QObject { Q_OBJECT @@ -75,6 +66,8 @@ public: virtual QRect geometry(int screen) const = 0; virtual int number(const QPoint &pos) const = 0; + inline bool isChanging() { return m_changedTimer->isActive(); } + public Q_SLOTS: void reconfigure(); @@ -85,11 +78,7 @@ Q_SIGNALS: **/ void changed(); -protected: - void finishChangedTimer() const; - protected Q_SLOTS: - friend class ScreenCountTimer; void setCount(int count); void startChangedTimer(); virtual void updateCount() = 0; @@ -98,7 +87,7 @@ private: int m_count; int m_current; bool m_currentFollowsMouse; - ScreenCountTimer *m_changedTimer; + QTimer *m_changedTimer; KSharedConfig::Ptr m_config; KWIN_SINGLETON(Screens) @@ -131,12 +120,6 @@ int Screens::count() const return m_count; } -inline -void Screens::finishChangedTimer() const -{ - const_cast(m_changedTimer)->finish(); -} - inline bool Screens::isCurrentFollowsMouse() const {