Summary: On X11 the SNI for keyboard layout is provided by the keyboard kded. On Wayland that kded has no real access to the layouts and cannot properly implement switching. Given that it's better to integrate the SNI directly in KWin. The implementation of the SNI is largly based on the existing SNI from plasma-desktop/kcms/keyboard. The implementation so far supports: * Switching to next layout on toggle * Presenting all layouts in a context menu * Switching to a specific layout through the context menu * Opening the keyboard layout configuration module * scroll on SNI to switch layout * config option whether to show the SNI Not yet supported are: * flags and/or short text for the layouts The last point needs more explanation. On X11 the layout name is something like "de" or "us". This can be directly mapped to a flag and can be added as a short note. Xkbcommon does not provide this information directly. Instead it provides us the full name of the layout, e.g. "German" or "English (us)". There is no way in the API to go from "German" to "de". Instead we need to parse the evdev.xml file to gather all information about layouts. This is already done in the keyboard kcm to configure layouts. The implementation needs to be split out into a small helper library. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D4220
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
/********************************************************************
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
Copyright (C) 2016, 2017 Martin Gräßlin <mgraesslin@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/>.
|
|
*********************************************************************/
|
|
#ifndef KWIN_KEYBOARD_LAYOUT_H
|
|
#define KWIN_KEYBOARD_LAYOUT_H
|
|
|
|
#include "input_event_spy.h"
|
|
#include <QObject>
|
|
|
|
#include <KSharedConfig>
|
|
typedef uint32_t xkb_layout_index_t;
|
|
|
|
class KStatusNotifierItem;
|
|
|
|
namespace KWin
|
|
{
|
|
class Xkb;
|
|
|
|
class KeyboardLayout : public QObject, public InputEventSpy
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit KeyboardLayout(Xkb *xkb);
|
|
~KeyboardLayout() override;
|
|
|
|
void setConfig(KSharedConfigPtr config) {
|
|
m_config = config;
|
|
}
|
|
|
|
void init();
|
|
|
|
void checkLayoutChange();
|
|
void resetLayout();
|
|
|
|
void keyEvent(KeyEvent *event) override;
|
|
|
|
private Q_SLOTS:
|
|
void reconfigure();
|
|
|
|
private:
|
|
void notifyLayoutChange();
|
|
void initNotifierItem();
|
|
void switchToNextLayout();
|
|
void switchToPreviousLayout();
|
|
void updateNotifier();
|
|
void reinitNotifierMenu();
|
|
Xkb *m_xkb;
|
|
xkb_layout_index_t m_layout = 0;
|
|
KStatusNotifierItem *m_notifierItem;
|
|
KSharedConfigPtr m_config;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|