Currently, the focus tracking functionality in the zoom effect does not work because it relies on kaccessibleapp, which is dead. Luckily for us, there is a library called libqaccessibilityclient that provides a way to monitor focus changes. BUG: 421234remotes/origin/work/tabbedwindows
parent
7226e75bc8
commit
c1ea0412a4
10 changed files with 216 additions and 83 deletions
@ -0,0 +1,91 @@ |
||||
/********************************************************************
|
||||
KWin - the KDE window manager |
||||
This file is part of the KDE project. |
||||
|
||||
Copyright (C) 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/ |
||||
|
||||
#include "accessibilityintegration.h" |
||||
|
||||
using namespace QAccessibleClient; // Whatever, sue me...
|
||||
|
||||
namespace KWin |
||||
{ |
||||
|
||||
ZoomAccessibilityIntegration::ZoomAccessibilityIntegration(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
} |
||||
|
||||
void ZoomAccessibilityIntegration::setFocusTrackingEnabled(bool enabled) |
||||
{ |
||||
if (m_isFocusTrackingEnabled == enabled) { |
||||
return; |
||||
} |
||||
m_isFocusTrackingEnabled = enabled; |
||||
updateAccessibilityRegistry(); |
||||
} |
||||
|
||||
bool ZoomAccessibilityIntegration::isFocusTrackingEnabled() const |
||||
{ |
||||
return m_isFocusTrackingEnabled; |
||||
} |
||||
|
||||
void ZoomAccessibilityIntegration::updateAccessibilityRegistry() |
||||
{ |
||||
Registry::EventListeners eventListeners = Registry::NoEventListeners; |
||||
|
||||
if (isFocusTrackingEnabled()) { |
||||
eventListeners |= Registry::Focus; |
||||
} |
||||
|
||||
if (eventListeners == Registry::NoEventListeners) { |
||||
destroyAccessibilityRegistry(); |
||||
return; |
||||
} |
||||
if (!m_accessibilityRegistry) { |
||||
createAccessibilityRegistry(); |
||||
} |
||||
|
||||
m_accessibilityRegistry->subscribeEventListeners(eventListeners); |
||||
} |
||||
|
||||
void ZoomAccessibilityIntegration::createAccessibilityRegistry() |
||||
{ |
||||
m_accessibilityRegistry = new Registry(this); |
||||
|
||||
connect(m_accessibilityRegistry, &Registry::focusChanged, |
||||
this, &ZoomAccessibilityIntegration::slotFocusChanged); |
||||
} |
||||
|
||||
void ZoomAccessibilityIntegration::destroyAccessibilityRegistry() |
||||
{ |
||||
if (!m_accessibilityRegistry) { |
||||
return; |
||||
} |
||||
|
||||
disconnect(m_accessibilityRegistry, nullptr, this, nullptr); |
||||
|
||||
m_accessibilityRegistry->deleteLater(); |
||||
m_accessibilityRegistry = nullptr; |
||||
} |
||||
|
||||
void ZoomAccessibilityIntegration::slotFocusChanged(const AccessibleObject &object) |
||||
{ |
||||
emit focusPointChanged(object.focusPoint()); |
||||
} |
||||
|
||||
} // namespace KWin
|
||||
@ -0,0 +1,53 @@ |
||||
/********************************************************************
|
||||
KWin - the KDE window manager |
||||
This file is part of the KDE project. |
||||
|
||||
Copyright (C) 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <qaccessibilityclient/registry.h> |
||||
|
||||
namespace KWin |
||||
{ |
||||
|
||||
class ZoomAccessibilityIntegration : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit ZoomAccessibilityIntegration(QObject *parent = nullptr); |
||||
|
||||
void setFocusTrackingEnabled(bool enabled); |
||||
bool isFocusTrackingEnabled() const; |
||||
|
||||
Q_SIGNALS: |
||||
void focusPointChanged(const QPoint &point); |
||||
|
||||
private Q_SLOTS: |
||||
void slotFocusChanged(const QAccessibleClient::AccessibleObject &object); |
||||
|
||||
private: |
||||
void createAccessibilityRegistry(); |
||||
void destroyAccessibilityRegistry(); |
||||
void updateAccessibilityRegistry(); |
||||
|
||||
QAccessibleClient::Registry *m_accessibilityRegistry = nullptr; |
||||
bool m_isFocusTrackingEnabled = false; |
||||
}; |
||||
|
||||
} // namespace KWin
|
||||
Loading…
Reference in new issue