File indexing completed on 2024-11-10 04:57:01
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "kglobalaccel_plugin.h" 0010 0011 #include "input.h" 0012 0013 #include <QDebug> 0014 0015 KGlobalAccelImpl::KGlobalAccelImpl(QObject *parent) 0016 : KGlobalAccelInterface(parent) 0017 { 0018 } 0019 0020 KGlobalAccelImpl::~KGlobalAccelImpl() = default; 0021 0022 bool KGlobalAccelImpl::grabKey(int key, bool grab) 0023 { 0024 return true; 0025 } 0026 0027 void KGlobalAccelImpl::setEnabled(bool enabled) 0028 { 0029 if (m_shuttingDown) { 0030 return; 0031 } 0032 static KWin::InputRedirection *s_input = KWin::InputRedirection::self(); 0033 if (!s_input) { 0034 qFatal("This plugin is intended to be used with KWin and this is not KWin, exiting now"); 0035 } else { 0036 if (!m_inputDestroyedConnection) { 0037 m_inputDestroyedConnection = connect(s_input, &QObject::destroyed, this, [this] { 0038 m_shuttingDown = true; 0039 }); 0040 } 0041 } 0042 s_input->registerGlobalAccel(enabled ? this : nullptr); 0043 } 0044 0045 bool KGlobalAccelImpl::checkKeyPressed(int keyQt) 0046 { 0047 return keyPressed(keyQt); 0048 } 0049 0050 bool KGlobalAccelImpl::checkKeyReleased(int keyQt) 0051 { 0052 return keyReleased(keyQt); 0053 } 0054 0055 #include "moc_kglobalaccel_plugin.cpp"