From fa199457afda7eb3dc1a4d938467846d10b8c91f Mon Sep 17 00:00:00 2001 From: Alex Fiestas Date: Sun, 24 Jul 2011 22:56:55 +0200 Subject: [PATCH] Try to call desktopRezie once intead of doing it in all XRandR events. When a screen is disconnected XRandR emits 3 events instead of just one: 1-Disconnected screen resized 2-Disconnected screen moved 3-Disconnected screen removed Before this commit we were calling desktopResize on each event which between other things restart the composite (not necessarily the faster thing to do...). So, in order to be able to call desktopResize only once, now we're handling individually each event, when one of them happens a QTimer is started/restarted on each event and desktopResized is called owhen QTimer.timeout The current interval is 100msec --- workspace.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- workspace.h | 11 ++++++++++- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/workspace.cpp b/workspace.cpp index 1a48194baf..98b41f9303 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -243,14 +243,48 @@ Workspace::Workspace(bool restore) init(); - connect(Kephal::Screens::self(), SIGNAL(screenAdded(Kephal::Screen*)), SLOT(desktopResized())); - connect(Kephal::Screens::self(), SIGNAL(screenRemoved(int)), SLOT(desktopResized())); - connect(Kephal::Screens::self(), SIGNAL(screenResized(Kephal::Screen*, QSize, QSize)), SLOT(desktopResized())); - connect(Kephal::Screens::self(), SIGNAL(screenMoved(Kephal::Screen*, QPoint, QPoint)), SLOT(desktopResized())); + connect(Kephal::Screens::self(), SIGNAL(screenAdded(Kephal::Screen*)), SLOT(screenAdded(Kephal::Screen*))); + connect(Kephal::Screens::self(), SIGNAL(screenRemoved(int)), SLOT(screenRemoved(int))); + connect(Kephal::Screens::self(), SIGNAL(screenResized(Kephal::Screen*, QSize, QSize)), SLOT(screenResized(Kephal::Screen*, QSize, QSize))); + connect(Kephal::Screens::self(), SIGNAL(screenMoved(Kephal::Screen*, QPoint, QPoint)), SLOT(screenMoved(Kephal::Screen*, QPoint, QPoint))); connect(&activityController_, SIGNAL(currentActivityChanged(QString)), SLOT(updateCurrentActivity(QString))); connect(&activityController_, SIGNAL(activityRemoved(QString)), SLOT(activityRemoved(QString))); connect(&activityController_, SIGNAL(activityAdded(QString)), SLOT(activityAdded(QString))); + + connect(&screenChangedTimer, SIGNAL(timeout()), SLOT(screenChangeTimeout())); + screenChangedTimer.setSingleShot(true); + screenChangedTimer.setInterval(100); +} + +void Workspace::screenChangeTimeout() +{ + kDebug() << "It is time to call desktopResized"; + desktopResized(); +} + +void Workspace::screenAdded(Kephal::Screen* screen) +{ + kDebug(); + screenChangedTimer.start(); +} + +void Workspace::screenRemoved(int screen) +{ + kDebug(); + screenChangedTimer.start(); +} + +void Workspace::screenResized(Kephal::Screen* screen, QSize old, QSize newSize) +{ + kDebug(); + screenChangedTimer.start(); +} + +void Workspace::screenMoved(Kephal::Screen* screen, QPoint old, QPoint newPos) +{ + kDebug(); + screenChangedTimer.start(); } void Workspace::init() diff --git a/workspace.h b/workspace.h index fa3d7bdaba..79c1e2d691 100644 --- a/workspace.h +++ b/workspace.h @@ -58,6 +58,10 @@ class KStartupInfoData; class QSlider; class QPushButton; +namespace Kephal +{ + class Screen; +} namespace KWin { @@ -675,6 +679,11 @@ private slots: void clientPopupActivated(QAction*); void configureWM(); void desktopResized(); + void screenChangeTimeout(); + void screenAdded(Kephal::Screen*); + void screenRemoved(int); + void screenResized(Kephal::Screen*, QSize, QSize); + void screenMoved(Kephal::Screen*, QPoint, QPoint); void slotUpdateToolWindows(); void delayFocus(); void gotTemporaryRulesMessage(const QString&); @@ -769,7 +778,6 @@ private: QMenu* clientPopup(); void closeActivePopup(); - void updateClientArea(bool force); bool windowRepaintsPending() const; @@ -791,6 +799,7 @@ private: QList rules; KXMessages temporaryRulesMessages; QTimer rulesUpdatedTimer; + QTimer screenChangedTimer; bool rules_updates_disabled; static const char* windowTypeToTxt(NET::WindowType type); static NET::WindowType txtToWindowType(const char* txt);