93e0265e4e
Once in a while, we receive complaints from other fellow KDE developers about the file organization of kwin. This change addresses some of those complaints by moving all of source code in a separate directory, src/, thus making the project structure more traditional. Things such as tests are kept in their own toplevel directories. This change may wreak havoc on merge requests that add new files to kwin, but if a patch modifies an already existing file, git should be smart enough to figure out that the file has been relocated. We may potentially split the src/ directory further to make navigating the source code easier, but hopefully this is good enough already.
137 lines
2.9 KiB
C++
137 lines
2.9 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2017 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
#ifndef KWIN_KEYBOARD_LAYOUT_SWITCHING_H
|
|
#define KWIN_KEYBOARD_LAYOUT_SWITCHING_H
|
|
|
|
#include <QObject>
|
|
#include <QHash>
|
|
#include <KConfigGroup>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
class AbstractClient;
|
|
class KeyboardLayout;
|
|
class Xkb;
|
|
class VirtualDesktop;
|
|
|
|
namespace KeyboardLayoutSwitching
|
|
{
|
|
|
|
class Policy : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
~Policy() override;
|
|
|
|
virtual QString name() const = 0;
|
|
|
|
static Policy *create(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config, const QString &policy);
|
|
|
|
protected:
|
|
explicit Policy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config = KConfigGroup());
|
|
virtual void clearCache() = 0;
|
|
virtual void layoutChanged(uint index) = 0;
|
|
|
|
void setLayout(uint index);
|
|
|
|
KConfigGroup m_config;
|
|
virtual const QString defaultLayoutEntryKey() const;
|
|
void clearLayouts();
|
|
|
|
static const char defaultLayoutEntryKeyPrefix[];
|
|
Xkb *m_xkb;
|
|
|
|
private:
|
|
KeyboardLayout *m_layout;
|
|
};
|
|
|
|
class GlobalPolicy : public Policy
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit GlobalPolicy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config);
|
|
~GlobalPolicy() override;
|
|
|
|
QString name() const override {
|
|
return QStringLiteral("Global");
|
|
}
|
|
|
|
protected:
|
|
void clearCache() override {}
|
|
void layoutChanged(uint index) override {Q_UNUSED(index)}
|
|
|
|
private:
|
|
const QString defaultLayoutEntryKey() const override;
|
|
};
|
|
|
|
class VirtualDesktopPolicy : public Policy
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit VirtualDesktopPolicy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config);
|
|
~VirtualDesktopPolicy() override;
|
|
|
|
QString name() const override {
|
|
return QStringLiteral("Desktop");
|
|
}
|
|
|
|
protected:
|
|
void clearCache() override;
|
|
void layoutChanged(uint index) override;
|
|
|
|
private:
|
|
void desktopChanged();
|
|
QHash<VirtualDesktop *, quint32> m_layouts;
|
|
};
|
|
|
|
class WindowPolicy : public Policy
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit WindowPolicy(Xkb *xkb, KeyboardLayout *layout);
|
|
~WindowPolicy() override;
|
|
|
|
QString name() const override {
|
|
return QStringLiteral("Window");
|
|
}
|
|
|
|
protected:
|
|
void clearCache() override;
|
|
void layoutChanged(uint index) override;
|
|
|
|
private:
|
|
QHash<AbstractClient*, quint32> m_layouts;
|
|
};
|
|
|
|
class ApplicationPolicy : public Policy
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ApplicationPolicy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config);
|
|
~ApplicationPolicy() override;
|
|
|
|
QString name() const override {
|
|
return QStringLiteral("WinClass");
|
|
}
|
|
|
|
protected:
|
|
void clearCache() override;
|
|
void layoutChanged(uint index) override;
|
|
|
|
private:
|
|
void clientActivated(AbstractClient *c);
|
|
QHash<AbstractClient*, quint32> m_layouts;
|
|
QHash<QByteArray, quint32> m_layoutsRestored;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|