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
This commit is contained in:
Alex Fiestas 2011-07-24 22:56:55 +02:00
parent 30de988de8
commit fa199457af
2 changed files with 48 additions and 5 deletions

View file

@ -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()

View file

@ -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*> 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);