[kwin] Block global shortcuts without KGlobalSettings

DBus call directly to kglobalacceld and don't wait for a signal to
come back.
This commit is contained in:
Martin Gräßlin 2013-12-06 10:28:42 +01:00
parent 9f6f0dd688
commit 81a7a528bb
2 changed files with 7 additions and 19 deletions

View file

@ -64,7 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDE/KActionCollection> #include <KDE/KActionCollection>
#include <KDE/KConfig> #include <KDE/KConfig>
#include <KDE/KConfigGroup> #include <KDE/KConfigGroup>
#include <KDE/KGlobalSettings>
#include <KDE/KLocalizedString> #include <KDE/KLocalizedString>
#include <KDE/KStartupInfo> #include <KDE/KStartupInfo>
#include <KDE/KWindowInfo> #include <KDE/KWindowInfo>
@ -323,8 +322,6 @@ void Workspace::init()
connect(&reconfigureTimer, SIGNAL(timeout()), this, SLOT(slotReconfigure())); connect(&reconfigureTimer, SIGNAL(timeout()), this, SLOT(slotReconfigure()));
connect(&updateToolWindowsTimer, SIGNAL(timeout()), this, SLOT(slotUpdateToolWindows())); connect(&updateToolWindowsTimer, SIGNAL(timeout()), this, SLOT(slotUpdateToolWindows()));
connect(KGlobalSettings::self(), SIGNAL(blockShortcuts(int)), this, SLOT(slotBlockShortcuts(int)));
// TODO: do we really need to reconfigure everything when fonts change? // TODO: do we really need to reconfigure everything when fonts change?
// maybe just reconfigure the decorations? Move this into libkdecoration? // maybe just reconfigure the decorations? Move this into libkdecoration?
QDBusConnection::sessionBus().connect(QString(), QDBusConnection::sessionBus().connect(QString(),
@ -1374,26 +1371,18 @@ void Workspace::resetShowingDesktop(bool keep_hidden)
--block_showing_desktop; --block_showing_desktop;
} }
static bool pending_dfc = false;
void Workspace::disableGlobalShortcutsForClient(bool disable) void Workspace::disableGlobalShortcutsForClient(bool disable)
{ {
if (global_shortcuts_disabled_for_client == disable) if (global_shortcuts_disabled_for_client == disable)
return; return;
if (disable) QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kglobalaccel"),
pending_dfc = true; QStringLiteral("/kglobalaccel"),
KGlobalSettings::self()->emitChange(KGlobalSettings::BlockShortcuts, disable); QStringLiteral("org.kde.KGlobalAccel"),
// KWin will get the kipc message too QStringLiteral("blockGlobalShortcuts"));
} message.setArguments(QList<QVariant>() << disable);
QDBusConnection::sessionBus().asyncCall(message);
void Workspace::slotBlockShortcuts(int data) global_shortcuts_disabled_for_client = disable;
{
if (pending_dfc && data) {
global_shortcuts_disabled_for_client = true;
pending_dfc = false;
} else {
global_shortcuts_disabled_for_client = false;
}
// Update also Alt+LMB actions etc. // Update also Alt+LMB actions etc.
for (ClientList::ConstIterator it = clients.constBegin(); for (ClientList::ConstIterator it = clients.constBegin();
it != clients.constEnd(); it != clients.constEnd();

View file

@ -377,7 +377,6 @@ private Q_SLOTS:
void desktopResized(); void desktopResized();
void slotUpdateToolWindows(); void slotUpdateToolWindows();
void delayFocus(); void delayFocus();
void slotBlockShortcuts(int data);
void slotReloadConfig(); void slotReloadConfig();
void updateCurrentActivity(const QString &new_activity); void updateCurrentActivity(const QString &new_activity);
// virtual desktop handling // virtual desktop handling