Move loading of the TabBox Config XML into a thread
This should improve the KWin startup time as some IO is moved into another thread. Till the config is loaded the TabBox blocks all signals to activate the TabBox, but it is unlikely that alt+tab is tried to be used before KWin is completely started.
This commit is contained in:
parent
74c816832a
commit
2ce4d166a1
4 changed files with 47 additions and 8 deletions
36
tabbox.cpp
36
tabbox.cpp
|
@ -280,6 +280,7 @@ TabBox::TabBox(QObject *parent)
|
|||
, m_desktopGrab(false)
|
||||
, m_tabGrab(false)
|
||||
, m_forcedGlobalMouseGrab(false)
|
||||
, m_ready(false)
|
||||
{
|
||||
m_isShown = false;
|
||||
m_defaultConfig = TabBoxConfig();
|
||||
|
@ -308,11 +309,9 @@ TabBox::TabBox(QObject *parent)
|
|||
m_desktopListConfig.setDesktopSwitchingMode(TabBoxConfig::StaticDesktopSwitching);
|
||||
m_desktopListConfig.setLayout(TabBoxConfig::VerticalLayout);
|
||||
m_tabBox = new TabBoxHandlerImpl(this);
|
||||
m_tabBox->setConfig(m_defaultConfig);
|
||||
|
||||
connect(m_tabBox, SIGNAL(ready()), SLOT(handlerReady()));
|
||||
|
||||
m_tabBoxMode = TabBoxDesktopMode; // init variables
|
||||
reconfigure();
|
||||
connect(&m_delayedShowTimer, SIGNAL(timeout()), this, SLOT(show()));
|
||||
}
|
||||
|
||||
|
@ -320,6 +319,13 @@ TabBox::~TabBox()
|
|||
{
|
||||
}
|
||||
|
||||
void TabBox::handlerReady()
|
||||
{
|
||||
m_tabBox->setConfig(m_defaultConfig);
|
||||
reconfigure();
|
||||
m_ready = true;
|
||||
}
|
||||
|
||||
void TabBox::initShortcuts(KActionCollection* keys)
|
||||
{
|
||||
KAction *a = NULL;
|
||||
|
@ -752,26 +758,41 @@ void TabBox::navigatingThroughWindows(bool forward, const KShortcut& shortcut, T
|
|||
|
||||
void TabBox::slotWalkThroughWindows()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
navigatingThroughWindows(true, m_cutWalkThroughWindows, TabBoxWindowsMode);
|
||||
}
|
||||
|
||||
void TabBox::slotWalkBackThroughWindows()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
navigatingThroughWindows(false, m_cutWalkThroughWindowsReverse, TabBoxWindowsMode);
|
||||
}
|
||||
|
||||
void TabBox::slotWalkThroughWindowsAlternative()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
navigatingThroughWindows(true, m_cutWalkThroughWindowsAlternative, TabBoxWindowsAlternativeMode);
|
||||
}
|
||||
|
||||
void TabBox::slotWalkBackThroughWindowsAlternative()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
navigatingThroughWindows(false, m_cutWalkThroughWindowsAlternativeReverse, TabBoxWindowsAlternativeMode);
|
||||
}
|
||||
|
||||
void TabBox::slotWalkThroughDesktops()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
if (isGrabbed())
|
||||
return;
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktops)) {
|
||||
|
@ -784,6 +805,9 @@ void TabBox::slotWalkThroughDesktops()
|
|||
|
||||
void TabBox::slotWalkBackThroughDesktops()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
if (isGrabbed())
|
||||
return;
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktopsReverse)) {
|
||||
|
@ -796,6 +820,9 @@ void TabBox::slotWalkBackThroughDesktops()
|
|||
|
||||
void TabBox::slotWalkThroughDesktopList()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
if (isGrabbed())
|
||||
return;
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktopList)) {
|
||||
|
@ -808,6 +835,9 @@ void TabBox::slotWalkThroughDesktopList()
|
|||
|
||||
void TabBox::slotWalkBackThroughDesktopList()
|
||||
{
|
||||
if (!m_ready){
|
||||
return;
|
||||
}
|
||||
if (isGrabbed())
|
||||
return;
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktopListReverse)) {
|
||||
|
|
3
tabbox.h
3
tabbox.h
|
@ -188,6 +188,8 @@ public slots:
|
|||
void slotWalkThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
|
||||
void slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
|
||||
|
||||
void handlerReady();
|
||||
|
||||
signals:
|
||||
void tabBoxAdded(int);
|
||||
void tabBoxClosed();
|
||||
|
@ -239,6 +241,7 @@ private:
|
|||
KShortcut m_cutWalkThroughGroupWindows, m_cutWalkThroughGroupWindowsReverse;
|
||||
KShortcut m_cutWalkThroughWindowsAlternative, m_cutWalkThroughWindowsAlternativeReverse;
|
||||
bool m_forcedGlobalMouseGrab;
|
||||
bool m_ready; // indicates whether the config is completely loaded
|
||||
};
|
||||
} // namespace TabBox
|
||||
} // namespace
|
||||
|
|
|
@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "tabboxview.h"
|
||||
// Qt
|
||||
#include <qdom.h>
|
||||
#include <QtCore/QtConcurrentRun>
|
||||
#include <QtCore/QFutureWatcher>
|
||||
#include <QFile>
|
||||
#include <QKeyEvent>
|
||||
#include <QModelIndex>
|
||||
|
@ -94,11 +96,10 @@ TabBoxHandlerPrivate::TabBoxHandlerPrivate(TabBoxHandler *q)
|
|||
view = new TabBoxView();
|
||||
|
||||
// load the layouts
|
||||
parseConfig(KStandardDirs::locate("data", "kwin/DefaultTabBoxLayouts.xml"));
|
||||
view->clientDelegate()->setConfig(tabBoxLayouts.value("Default"));
|
||||
view->additionalClientDelegate()->setConfig(tabBoxLayouts.value("Text"));
|
||||
view->desktopDelegate()->setConfig(tabBoxLayouts.value("Desktop"));
|
||||
view->desktopDelegate()->setLayouts(tabBoxLayouts);
|
||||
QFuture< void> future = QtConcurrent::run(this, &TabBoxHandlerPrivate::parseConfig, KStandardDirs::locate("data", "kwin/DefaultTabBoxLayouts.xml"));
|
||||
QFutureWatcher< void > *watcher = new QFutureWatcher< void >(q);
|
||||
watcher->setFuture(future);
|
||||
q->connect(watcher, SIGNAL(finished()), q, SIGNAL(ready()));
|
||||
}
|
||||
|
||||
TabBoxHandlerPrivate::~TabBoxHandlerPrivate()
|
||||
|
@ -325,6 +326,10 @@ void TabBoxHandlerPrivate::parseConfig(const QString& fileName)
|
|||
tabBoxLayouts.insert(layoutName, currentLayout);
|
||||
}
|
||||
} // for loop layouts
|
||||
view->clientDelegate()->setConfig(tabBoxLayouts.value("Default"));
|
||||
view->additionalClientDelegate()->setConfig(tabBoxLayouts.value("Text"));
|
||||
view->desktopDelegate()->setConfig(tabBoxLayouts.value("Desktop"));
|
||||
view->desktopDelegate()->setLayouts(tabBoxLayouts);
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
|
|
|
@ -339,6 +339,7 @@ signals:
|
|||
* @see setConfig
|
||||
*/
|
||||
void configChanged();
|
||||
void ready();
|
||||
|
||||
private:
|
||||
friend class TabBoxHandlerPrivate;
|
||||
|
|
Loading…
Reference in a new issue