Move reinitializeCompositing and restartKWin into the Compositor

The DBus signal which causes KWin to reinitialize the Compositor
is moved into the Compositor as everything can be handled from
there as well. This comes together with moving the restartKWin
functionality into the Compositor as it is only relevant there.
Restart will only happen if the wrong Qt graphicssystem is used
for the chosen compositing backend.
icc-effect-5.14.5
Martin Gräßlin 2012-08-17 10:15:33 +02:00
parent df6c423962
commit 0f2e5e61a8
4 changed files with 41 additions and 50 deletions

View File

@ -93,7 +93,6 @@ Compositor::Compositor(QObject* workspace)
connect(&unredirectTimer, SIGNAL(timeout()), SLOT(delayedCheckUnredirect()));
connect(&compositeResetTimer, SIGNAL(timeout()), SLOT(restart()));
connect(workspace, SIGNAL(configChanged()), SLOT(slotConfigChanged()));
connect(workspace, SIGNAL(reinitializeCompositing()), SLOT(slotReinitialize()));
connect(&mousePollingTimer, SIGNAL(timeout()), SLOT(performMousePoll()));
unredirectTimer.setSingleShot(true);
compositeResetTimer.setSingleShot(true);
@ -289,7 +288,7 @@ void Compositor::fallbackToXRenderCompositing()
config.writeEntry("GraphicsSystem", "native");
config.sync();
if (Extensions::nonNativePixmaps()) { // must restart to change the graphicssystem
emit signalRestartKWin("automatic graphicssystem change for XRender backend");
restartKWin("automatic graphicssystem change for XRender backend");
return;
} else {
options->setCompositingMode(XRenderCompositing);
@ -310,12 +309,30 @@ void Compositor::slotConfigChanged()
void Compositor::slotReinitialize()
{
// Reparse config. Config options will be reloaded by setup()
KGlobal::config()->reparseConfiguration();
const QString graphicsSystem = KConfigGroup(KGlobal::config(), "Compositing").readEntry("GraphicsSystem", "");
if ((Extensions::nonNativePixmaps() && graphicsSystem == "native") ||
(!Extensions::nonNativePixmaps() && (graphicsSystem == "raster" || graphicsSystem == "opengl")) ) {
restartKWin("explicitly reconfigured graphicsSystem change");
return;
}
// Update any settings that can be set in the compositing kcm.
#ifdef KWIN_BUILD_SCREENEDGES
Workspace::self()->screenEdge()->update();
#endif
// Restart compositing
finish();
// resume compositing if suspended
m_suspended = false;
options->setCompositingInitialized(false);
setup();
if (effects) { // setup() may fail
effects->reconfigure();
}
emit compositingToggled(!m_suspended);
}
// for the shortcut
@ -640,6 +657,14 @@ void Compositor::setOverlayWindowVisibility(bool visible)
}
}
void Compositor::restartKWin(const QString &reason)
{
kDebug(1212) << "restarting kwin for:" << reason;
char cmd[1024]; // copied from crashhandler - maybe not the best way to do?
sprintf(cmd, "%s --replace &", QFile::encodeName(QCoreApplication::applicationFilePath()).constData());
system(cmd);
}
/*****************************************************
* Compositing related D-Bus interface from Workspace
****************************************************/

View File

@ -102,10 +102,14 @@ public Q_SLOTS:
* TODO: make private slot
**/
void slotToggleCompositing();
/**
* Re-initializes the Compositor completely.
* Connected to the D-Bus signal org.kde.KWin /KWin reinitCompositing
**/
void slotReinitialize();
Q_SIGNALS:
void compositingToggled(bool active);
void signalRestartKWin(const QString &reason);
protected:
void timerEvent(QTimerEvent *te);
@ -127,7 +131,6 @@ private Q_SLOTS:
void performMousePoll();
void delayedCheckUnredirect();
void slotConfigChanged();
void slotReinitialize();
private:
/**
@ -140,6 +143,13 @@ private:
void setCompositeTimer();
bool windowRepaintsPending() const;
/**
* Restarts the Window Manager in case that the Qt's GraphicsSystem need to be changed
* for the chosen Compositing backend.
* @param reason The reason why the Window Manager is being restarted, this is logged
**/
void restartKWin(const QString &reason);
/**
* Whether the Compositor is currently suspended.
**/

View File

@ -153,8 +153,6 @@ Workspace::Workspace(bool restore)
dbus.registerObject("/KWin", this);
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig",
this, SLOT(slotReloadConfig()));
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reinitCompositing",
this, SLOT(slotReinitCompositing()));
// Initialize desktop grid array
desktopGrid_[0] = 0;
@ -209,7 +207,8 @@ Workspace::Workspace(bool restore)
m_compositor = new Compositor(this);
connect(m_compositor, SIGNAL(compositingToggled(bool)), SIGNAL(compositingToggled(bool)));
connect(m_compositor, SIGNAL(compositingToggled(bool)), SLOT(slotCompositingToggled()));
connect(m_compositor, SIGNAL(signalRestartKWin(QString)), SLOT(slotRestartKwin(QString)));
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reinitCompositing",
m_compositor, SLOT(slotReinitialize()));
// Compatibility
long data = 1;
@ -1012,46 +1011,6 @@ void Workspace::slotReconfigure()
}
}
void Workspace::slotRestartKwin(const QString& reason)
{
restartKWin(reason);
}
void Workspace::restartKWin(const QString &reason)
{
kDebug(1212) << "restarting kwin for:" << reason;
char cmd[1024]; // copied from crashhandler - maybe not the best way to do?
sprintf(cmd, "%s --replace &", QFile::encodeName(QCoreApplication::applicationFilePath()).constData());
system(cmd);
}
void Workspace::slotReinitCompositing()
{
// Reparse config. Config options will be reloaded by setupCompositing()
KGlobal::config()->reparseConfiguration();
const QString graphicsSystem = KConfigGroup(KGlobal::config(), "Compositing").readEntry("GraphicsSystem", "");
if ((Extensions::nonNativePixmaps() && graphicsSystem == "native") ||
(!Extensions::nonNativePixmaps() && (graphicsSystem == "raster" || graphicsSystem == "opengl")) ) {
restartKWin("explicitly reconfigured graphicsSystem change");
return;
}
// Update any settings that can be set in the compositing kcm.
#ifdef KWIN_BUILD_SCREENEDGES
m_screenEdge.update();
#endif
emit reinitializeCompositing();
if (hasDecorationPlugin()) {
KDecorationFactory* factory = mgr->factory();
factory->reset(SettingCompositing);
}
if (effects) { // setupCompositing() may fail
effects->reconfigure();
emit compositingToggled(true);
}
}
static bool _loading_desktop_settings = false;
void Workspace::loadDesktopSettings()
{

View File

@ -614,7 +614,6 @@ public slots:
void reconfigure();
void slotReconfigure();
void slotReinitCompositing();
void slotCompositingToggled();
void slotKillWindow();
@ -646,7 +645,6 @@ private slots:
void slotActivityAdded(const QString &activity);
void reallyStopActivity(const QString &id); //dbus deadlocks suck
void handleActivityReply();
void slotRestartKwin(const QString &reason);
Q_SIGNALS:
Q_SCRIPTABLE void compositingToggled(bool active);
@ -695,7 +693,6 @@ signals:
private:
void init();
void initShortcuts();
void restartKWin(const QString &reason);
void setupWindowShortcut(Client* c);
enum Direction {
DirectionNorth,