mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
kcms/keyboard: Drop X11 code
Mostly straight-forward, but touches the KCM code a bit to drop calling functions that return empty on Wayland anyway
This commit is contained in:
parent
f4caf16f44
commit
4a4576405e
7 changed files with 2 additions and 484 deletions
|
|
@ -62,10 +62,6 @@ target_link_libraries(kcm_keyboard_static
|
|||
Plasma::Plasma
|
||||
KF6::XmlGui
|
||||
KF6::GuiAddons
|
||||
XCB::XCB
|
||||
XCB::XKB
|
||||
X11::X11
|
||||
X11::xkbfile
|
||||
PkgConfig::XKBREGISTRY
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,11 +43,6 @@ KCMKeyboard::KCMKeyboard(QObject *parent, const KPluginMetaData &data)
|
|||
|
||||
connect(m_data->keyboardSettings(), &KeyboardSettings::configureLayoutsChanged, this, [this]() -> void {
|
||||
if (m_data->keyboardSettings()->configureLayouts()) {
|
||||
const QList<LayoutUnit> layouts = X11Helper::getLayoutsList();
|
||||
for (const auto &layoutUnit : layouts) {
|
||||
m_config->layouts().append(layoutUnit);
|
||||
}
|
||||
|
||||
m_userLayoutModel->reset();
|
||||
} else {
|
||||
m_userLayoutModel->clear();
|
||||
|
|
@ -56,7 +51,6 @@ KCMKeyboard::KCMKeyboard(QObject *parent, const KPluginMetaData &data)
|
|||
|
||||
connect(m_data->keyboardSettings(), &KeyboardSettings::resetOldXkbOptionsChanged, this, [this]() -> void {
|
||||
if (m_data->keyboardSettings()->resetOldXkbOptions()) {
|
||||
m_xkbOptionsModel->populateWithCurrentXkbOptions();
|
||||
m_data->keyboardSettings()->setXkbOptions(m_xkbOptionsModel->xkbOptions());
|
||||
}
|
||||
});
|
||||
|
|
@ -110,7 +104,8 @@ XkbOptionsModel *KCMKeyboard::xkbOptionsModel() const
|
|||
|
||||
int KCMKeyboard::maxGroupCount() const
|
||||
{
|
||||
return X11Helper::MAX_GROUP_COUNT;
|
||||
// more information about the limit https://bugs.freedesktop.org/show_bug.cgi?id=19501
|
||||
return 4;
|
||||
}
|
||||
|
||||
bool KCMKeyboard::hasAccentSupport()
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ macro(KEYBOARD_DAEMON_UNIT_TESTS _testname)
|
|||
Qt::Test
|
||||
KF6::I18n
|
||||
KF6::WindowSystem
|
||||
X11::xkbfile
|
||||
X11::X11
|
||||
PkgConfig::XKBREGISTRY
|
||||
)
|
||||
target_link_libraries(${_testname}_test Qt::GuiPrivate)
|
||||
|
|
@ -34,11 +32,7 @@ target_link_libraries(flags_test
|
|||
KF6::I18n
|
||||
Plasma::Plasma
|
||||
KF6::WindowSystem
|
||||
XCB::XCB
|
||||
XCB::XKB
|
||||
PkgConfig::XKBREGISTRY
|
||||
X11::xkbfile
|
||||
X11::X11
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/base.1.1.xml ${CMAKE_CURRENT_BINARY_DIR}/config/base.1.1.xml COPYONLY)
|
||||
|
|
|
|||
|
|
@ -5,367 +5,9 @@
|
|||
*/
|
||||
|
||||
#include "x11_helper.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XKBrules.h>
|
||||
|
||||
#include <fixx11h.h>
|
||||
|
||||
// more information about the limit https://bugs.freedesktop.org/show_bug.cgi?id=19501
|
||||
const int X11Helper::MAX_GROUP_COUNT = 4;
|
||||
|
||||
const char X11Helper::LEFT_VARIANT_STR[] = "(";
|
||||
const char X11Helper::RIGHT_VARIANT_STR[] = ")";
|
||||
|
||||
bool X11Helper::xkbSupported(int *xkbOpcode)
|
||||
{
|
||||
if (!QX11Info::isPlatformX11()) {
|
||||
return false;
|
||||
}
|
||||
// Verify the Xlib has matching XKB extension.
|
||||
|
||||
int major = XkbMajorVersion;
|
||||
int minor = XkbMinorVersion;
|
||||
|
||||
if (!XkbLibraryVersion(&major, &minor)) {
|
||||
qCWarning(KCM_KEYBOARD) << "Xlib XKB extension " << major << '.' << minor << " != " << XkbMajorVersion << '.' << XkbMinorVersion;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify the X server has matching XKB extension.
|
||||
|
||||
int opcode_rtrn;
|
||||
int error_rtrn;
|
||||
int xkb_opcode;
|
||||
if (!XkbQueryExtension(QX11Info::display(), &opcode_rtrn, &xkb_opcode, &error_rtrn, &major, &minor)) {
|
||||
qCWarning(KCM_KEYBOARD) << "X server XKB extension " << major << '.' << minor << " != " << XkbMajorVersion << '.' << XkbMinorVersion;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xkbOpcode != nullptr) {
|
||||
*xkbOpcode = xkb_opcode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void X11Helper::switchToNextLayout()
|
||||
{
|
||||
int size = getLayoutsList().size(); // TODO: could optimize a bit as we don't need the layouts - just count
|
||||
int group = (X11Helper::getGroup() + 1) % size;
|
||||
X11Helper::setGroup(group);
|
||||
}
|
||||
|
||||
void X11Helper::scrollLayouts(int delta)
|
||||
{
|
||||
int size = getLayoutsList().size(); // TODO: could optimize a bit as we don't need the layouts - just count
|
||||
int group = X11Helper::getGroup() + delta;
|
||||
group = group < 0 ? size - ((-group) % size) : group % size;
|
||||
|
||||
X11Helper::setGroup(group);
|
||||
}
|
||||
|
||||
QStringList X11Helper::getLayoutsListAsString(const QList<LayoutUnit> &layoutsList)
|
||||
{
|
||||
QStringList stringList;
|
||||
for (const auto &layoutUnit : layoutsList) {
|
||||
stringList << layoutUnit.toString();
|
||||
}
|
||||
return stringList;
|
||||
}
|
||||
|
||||
bool X11Helper::setLayout(const LayoutUnit &layout)
|
||||
{
|
||||
QList<LayoutUnit> currentLayouts = getLayoutsList();
|
||||
int idx = currentLayouts.indexOf(layout);
|
||||
if (idx == -1 || idx >= X11Helper::MAX_GROUP_COUNT) {
|
||||
qCWarning(KCM_KEYBOARD) << "Layout" << layout.toString() << "is not found in current layout list" << getLayoutsListAsString(currentLayouts);
|
||||
return false;
|
||||
}
|
||||
|
||||
return X11Helper::setGroup((unsigned int)idx);
|
||||
}
|
||||
|
||||
bool X11Helper::setDefaultLayout()
|
||||
{
|
||||
return X11Helper::setGroup(0);
|
||||
}
|
||||
|
||||
bool X11Helper::isDefaultLayout()
|
||||
{
|
||||
return X11Helper::getGroup() == 0;
|
||||
}
|
||||
|
||||
LayoutUnit X11Helper::getCurrentLayout()
|
||||
{
|
||||
if (!QX11Info::isPlatformX11()) {
|
||||
return LayoutUnit();
|
||||
}
|
||||
QList<LayoutUnit> currentLayouts = getLayoutsList();
|
||||
unsigned int group = X11Helper::getGroup();
|
||||
if (group < static_cast<unsigned int>(currentLayouts.size()))
|
||||
return currentLayouts.at(static_cast<int>(group));
|
||||
|
||||
qCWarning(KCM_KEYBOARD) << "Current group number" << group << "is outside of current layout list" << getLayoutsListAsString(currentLayouts);
|
||||
return LayoutUnit();
|
||||
}
|
||||
|
||||
LayoutSet X11Helper::getCurrentLayouts()
|
||||
{
|
||||
LayoutSet layoutSet;
|
||||
|
||||
QList<LayoutUnit> currentLayouts = getLayoutsList();
|
||||
layoutSet.layouts = currentLayouts;
|
||||
|
||||
unsigned int group = X11Helper::getGroup();
|
||||
if (group < (unsigned int)currentLayouts.size()) {
|
||||
layoutSet.currentLayout = currentLayouts[group];
|
||||
} else {
|
||||
qCWarning(KCM_KEYBOARD) << "Current group number" << group << "is outside of current layout list" << getLayoutsListAsString(currentLayouts);
|
||||
layoutSet.currentLayout = LayoutUnit();
|
||||
}
|
||||
|
||||
return layoutSet;
|
||||
}
|
||||
|
||||
QList<LayoutUnit> X11Helper::getLayoutsList()
|
||||
{
|
||||
if (!QX11Info::isPlatformX11()) {
|
||||
return QList<LayoutUnit>();
|
||||
}
|
||||
XkbConfig xkbConfig;
|
||||
QList<LayoutUnit> layouts;
|
||||
if (X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::LAYOUTS_ONLY)) {
|
||||
for (int i = 0; i < xkbConfig.layouts.size(); i++) {
|
||||
QString layout(xkbConfig.layouts[i]);
|
||||
QString variant;
|
||||
if (i < xkbConfig.variants.size() && !xkbConfig.variants[i].isEmpty()) {
|
||||
variant = xkbConfig.variants[i];
|
||||
}
|
||||
layouts << LayoutUnit(layout, variant);
|
||||
}
|
||||
} else {
|
||||
qCWarning(KCM_KEYBOARD) << "Failed to get layout groups from X server";
|
||||
}
|
||||
return layouts;
|
||||
}
|
||||
|
||||
bool X11Helper::setGroup(unsigned int group)
|
||||
{
|
||||
qCDebug(KCM_KEYBOARD) << group;
|
||||
xcb_void_cookie_t cookie;
|
||||
cookie = xcb_xkb_latch_lock_state(QX11Info::connection(), XCB_XKB_ID_USE_CORE_KBD, 0, 0, 1, group, 0, 0, 0);
|
||||
xcb_generic_error_t *error = nullptr;
|
||||
error = xcb_request_check(QX11Info::connection(), cookie);
|
||||
if (error) {
|
||||
qCDebug(KCM_KEYBOARD) << "Couldn't change the group" << error->error_code;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int X11Helper::getGroup()
|
||||
{
|
||||
XkbStateRec xkbState;
|
||||
XkbGetState(QX11Info::display(), XkbUseCoreKbd, &xkbState);
|
||||
return xkbState.group;
|
||||
}
|
||||
|
||||
bool X11Helper::getGroupNames(Display *display, XkbConfig *xkbConfig, FetchType fetchType)
|
||||
{
|
||||
static const char OPTIONS_SEPARATOR[] = ",";
|
||||
|
||||
Atom real_prop_type;
|
||||
int fmt;
|
||||
unsigned long nitems, extra_bytes;
|
||||
char *prop_data = nullptr;
|
||||
Status ret;
|
||||
|
||||
Atom rules_atom = XInternAtom(display, _XKB_RF_NAMES_PROP_ATOM, False);
|
||||
|
||||
/* no such atom! */
|
||||
if (rules_atom == None) { /* property cannot exist */
|
||||
qCWarning(KCM_KEYBOARD) << "Failed to fetch layouts from server:"
|
||||
<< "could not find the atom" << _XKB_RF_NAMES_PROP_ATOM;
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = XGetWindowProperty(display,
|
||||
DefaultRootWindow(display),
|
||||
rules_atom,
|
||||
0L,
|
||||
_XKB_RF_NAMES_PROP_MAXLEN,
|
||||
False,
|
||||
XA_STRING,
|
||||
&real_prop_type,
|
||||
&fmt,
|
||||
&nitems,
|
||||
&extra_bytes,
|
||||
(unsigned char **)(void *)&prop_data);
|
||||
|
||||
/* property not found! */
|
||||
if (ret != Success) {
|
||||
qCWarning(KCM_KEYBOARD) << "Failed to fetch layouts from server:"
|
||||
<< "Could not get the property";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* has to be array of strings */
|
||||
if ((extra_bytes > 0) || (real_prop_type != XA_STRING) || (fmt != 8)) {
|
||||
if (prop_data)
|
||||
XFree(prop_data);
|
||||
qCWarning(KCM_KEYBOARD) << "Failed to fetch layouts from server:"
|
||||
<< "Wrong property format";
|
||||
return false;
|
||||
}
|
||||
|
||||
// qCDebug(KCM_KEYBOARD) << "prop_data:" << nitems << prop_data;
|
||||
QStringList names;
|
||||
for (char *p = prop_data; p - prop_data < (long)nitems && p != nullptr; p += strlen(p) + 1) {
|
||||
names.append(p);
|
||||
// qDebug() << " " << p;
|
||||
}
|
||||
|
||||
if (names.count() < 4) { //{ rules, model, layouts, variants, options }
|
||||
XFree(prop_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fetchType == ALL || fetchType == LAYOUTS_ONLY) {
|
||||
QStringList layouts = names[2].split(OPTIONS_SEPARATOR);
|
||||
QStringList variants = names[3].split(OPTIONS_SEPARATOR);
|
||||
|
||||
for (int ii = 0; ii < layouts.count(); ii++) {
|
||||
xkbConfig->layouts << layouts[ii];
|
||||
xkbConfig->variants << variants.value(ii); // Empty if not specified
|
||||
}
|
||||
qCDebug(KCM_KEYBOARD) << "Fetched layout groups from X server:"
|
||||
<< "\tlayouts:" << xkbConfig->layouts << "\tvariants:" << xkbConfig->variants;
|
||||
}
|
||||
|
||||
if (fetchType == ALL || fetchType == MODEL_ONLY) {
|
||||
xkbConfig->keyboardModel = names[1];
|
||||
qCDebug(KCM_KEYBOARD) << "Fetched keyboard model from X server:" << xkbConfig->keyboardModel;
|
||||
}
|
||||
|
||||
if (fetchType == ALL) {
|
||||
if (names.count() >= 5) {
|
||||
if (!names[4].isEmpty())
|
||||
xkbConfig->options = names[4].split(OPTIONS_SEPARATOR);
|
||||
else
|
||||
xkbConfig->options.clear();
|
||||
|
||||
qCDebug(KCM_KEYBOARD) << "Fetched xkbOptions from X server:" << xkbConfig->options;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(prop_data);
|
||||
return true;
|
||||
}
|
||||
|
||||
XEventNotifier::XEventNotifier()
|
||||
: xkbOpcode(-1)
|
||||
{
|
||||
if (QCoreApplication::instance() == nullptr) {
|
||||
qCWarning(KCM_KEYBOARD) << "Layout Widget won't work properly without QCoreApplication instance";
|
||||
}
|
||||
}
|
||||
|
||||
void XEventNotifier::start()
|
||||
{
|
||||
qCDebug(KCM_KEYBOARD) << "qCoreApp" << QCoreApplication::instance();
|
||||
if (QCoreApplication::instance() != nullptr && X11Helper::xkbSupported(&xkbOpcode)) {
|
||||
registerForXkbEvents(QX11Info::display());
|
||||
|
||||
// start the event loop
|
||||
QCoreApplication::instance()->installNativeEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
void XEventNotifier::stop()
|
||||
{
|
||||
if (QCoreApplication::instance() != nullptr) {
|
||||
// TODO: unregister
|
||||
// XEventNotifier::unregisterForXkbEvents(QX11Info::display());
|
||||
|
||||
// stop the event loop
|
||||
QCoreApplication::instance()->removeNativeEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool XEventNotifier::isXkbEvent(xcb_generic_event_t *event)
|
||||
{
|
||||
// qDebug() << "event response type:" << (event->response_type & ~0x80) << xkbOpcode << ((event->response_type & ~0x80) == xkbOpcode + XkbEventCode);
|
||||
return (event->response_type & ~0x80) == xkbOpcode + XkbEventCode;
|
||||
}
|
||||
|
||||
bool XEventNotifier::processOtherEvents(xcb_generic_event_t * /*event*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XEventNotifier::processXkbEvents(xcb_generic_event_t *event)
|
||||
{
|
||||
_xkb_event *xkbevt = reinterpret_cast<_xkb_event *>(event);
|
||||
if (XEventNotifier::isGroupSwitchEvent(xkbevt)) {
|
||||
// qDebug() << "group switch event";
|
||||
Q_EMIT layoutChanged();
|
||||
} else if (XEventNotifier::isLayoutSwitchEvent(xkbevt)) {
|
||||
// qDebug() << "layout switch event";
|
||||
Q_EMIT layoutMapChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XEventNotifier::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *)
|
||||
{
|
||||
// qDebug() << "event type:" << eventType;
|
||||
if (eventType == "xcb_generic_event_t") {
|
||||
xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message);
|
||||
if (isXkbEvent(ev)) {
|
||||
processXkbEvents(ev);
|
||||
} else {
|
||||
processOtherEvents(ev);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool XEventNotifier::isGroupSwitchEvent(_xkb_event *xkbEvent)
|
||||
{
|
||||
// XkbEvent *xkbEvent = (XkbEvent*) event;
|
||||
#define GROUP_CHANGE_MASK (XkbGroupStateMask | XkbGroupBaseMask | XkbGroupLatchMask | XkbGroupLockMask)
|
||||
|
||||
return xkbEvent->any.xkbType == XkbStateNotify && (xkbEvent->state_notify.changed & GROUP_CHANGE_MASK);
|
||||
}
|
||||
|
||||
bool XEventNotifier::isLayoutSwitchEvent(_xkb_event *xkbEvent)
|
||||
{
|
||||
// XkbEvent *xkbEvent = (XkbEvent*) event;
|
||||
|
||||
return //( (xkbEvent->any.xkb_type == XkbMapNotify) && (xkbEvent->map.changed & XkbKeySymsMask) ) ||
|
||||
/* || ( (xkbEvent->any.xkb_type == XkbNamesNotify) && (xkbEvent->names.changed & XkbGroupNamesMask) || )*/
|
||||
(xkbEvent->any.xkbType == XkbNewKeyboardNotify);
|
||||
}
|
||||
|
||||
int XEventNotifier::registerForXkbEvents(Display *display)
|
||||
{
|
||||
int eventMask = XkbNewKeyboardNotifyMask | XkbStateNotifyMask;
|
||||
if (!XkbSelectEvents(display, XkbUseCoreKbd, eventMask, eventMask)) {
|
||||
qCWarning(KCM_KEYBOARD) << "Couldn't select desired XKB events";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char LAYOUT_VARIANT_SEPARATOR_PREFIX[] = "(";
|
||||
static const char LAYOUT_VARIANT_SEPARATOR_SUFFIX[] = ")";
|
||||
|
||||
|
|
|
|||
|
|
@ -6,67 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QKeySequence>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
#include <QtGui/private/qtx11extras_p.h>
|
||||
|
||||
QT_WARNING_DISABLE_CLANG("-Wkeyword-macro")
|
||||
#define explicit explicit_is_keyword_in_cpp
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xkb.h>
|
||||
#undef explicit
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef union {
|
||||
/* All XKB events share these fields. */
|
||||
struct {
|
||||
uint8_t response_type;
|
||||
uint8_t xkbType;
|
||||
uint16_t sequence;
|
||||
xcb_timestamp_t time;
|
||||
uint8_t deviceID;
|
||||
} any;
|
||||
xcb_xkb_new_keyboard_notify_event_t new_keyboard_notify;
|
||||
xcb_xkb_map_notify_event_t map_notify;
|
||||
xcb_xkb_state_notify_event_t state_notify;
|
||||
} _xkb_event;
|
||||
}
|
||||
|
||||
class XEventNotifier : public QObject, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_SIGNALS:
|
||||
void layoutChanged();
|
||||
void layoutMapChanged();
|
||||
|
||||
public:
|
||||
XEventNotifier();
|
||||
~XEventNotifier() override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
|
||||
protected:
|
||||
virtual bool processOtherEvents(xcb_generic_event_t *e);
|
||||
virtual bool processXkbEvents(xcb_generic_event_t *e);
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
|
||||
|
||||
private:
|
||||
int registerForXkbEvents(Display *display);
|
||||
bool isXkbEvent(xcb_generic_event_t *event);
|
||||
bool isGroupSwitchEvent(_xkb_event *event);
|
||||
bool isLayoutSwitchEvent(_xkb_event *event);
|
||||
|
||||
int xkbOpcode;
|
||||
};
|
||||
|
||||
struct XkbConfig {
|
||||
QString keyboardModel;
|
||||
|
|
@ -223,34 +165,3 @@ struct LayoutSet {
|
|||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
class X11Helper
|
||||
{
|
||||
public:
|
||||
static const int MAX_GROUP_COUNT;
|
||||
|
||||
static const char LEFT_VARIANT_STR[];
|
||||
static const char RIGHT_VARIANT_STR[];
|
||||
|
||||
static bool xkbSupported(int *xkbOpcode);
|
||||
|
||||
static void switchToNextLayout();
|
||||
static void scrollLayouts(int delta);
|
||||
static bool isDefaultLayout();
|
||||
static bool setDefaultLayout();
|
||||
static bool setLayout(const LayoutUnit &layout);
|
||||
static LayoutUnit getCurrentLayout();
|
||||
static LayoutSet getCurrentLayouts();
|
||||
static QList<LayoutUnit> getLayoutsList();
|
||||
static QStringList getLayoutsListAsString(const QList<LayoutUnit> &layoutsList);
|
||||
|
||||
enum FetchType {
|
||||
ALL,
|
||||
LAYOUTS_ONLY,
|
||||
MODEL_ONLY,
|
||||
};
|
||||
static bool getGroupNames(Display *dpy, XkbConfig *xkbConfig, FetchType fetchType);
|
||||
|
||||
static unsigned int getGroup();
|
||||
static bool setGroup(unsigned int group);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
#include <KWindowSystem>
|
||||
|
||||
#include "debug.h"
|
||||
#include "keyboardsettings.h"
|
||||
#include "x11_helper.h"
|
||||
#include "xkb_rules.h"
|
||||
|
||||
XkbOptionsModel::XkbOptionsModel(QObject *parent)
|
||||
|
|
@ -195,22 +193,6 @@ void XkbOptionsModel::navigateToGroup(const QString &group)
|
|||
}
|
||||
}
|
||||
|
||||
void XkbOptionsModel::populateWithCurrentXkbOptions()
|
||||
{
|
||||
if (!KWindowSystem::isPlatformX11()) {
|
||||
// TODO: implement for Wayland - query dbus maybe?
|
||||
return;
|
||||
}
|
||||
|
||||
XkbConfig xkbConfig;
|
||||
QStringList xkbOptions;
|
||||
if (X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::ALL)) {
|
||||
xkbOptions = xkbConfig.options;
|
||||
}
|
||||
|
||||
setXkbOptions(xkbOptions);
|
||||
}
|
||||
|
||||
bool XkbOptionsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || !index.parent().isValid()) {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ public:
|
|||
Q_INVOKABLE void clearXkbGroup(const QString &group);
|
||||
Q_INVOKABLE void navigateToGroup(const QString &group);
|
||||
|
||||
void populateWithCurrentXkbOptions();
|
||||
|
||||
Q_SIGNALS:
|
||||
void navigateTo(const QModelIndex &index);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue