chore: rename x11layoutsparser -> xkblayoutsparser

This commit is contained in:
sithlord48 2026-07-31 07:56:36 -04:00 committed by Nick Bolton
parent 7a90a30ec8
commit cc813f016e
7 changed files with 25 additions and 25 deletions

View file

@ -19,8 +19,8 @@ elseif(UNIX)
unix/DeskflowXkbKeyboard.cpp unix/DeskflowXkbKeyboard.cpp
unix/DeskflowXkbKeyboard.h unix/DeskflowXkbKeyboard.h
unix/ISO639Table.h unix/ISO639Table.h
unix/X11LayoutsParser.cpp unix/XkbLayoutsParser.cpp
unix/X11LayoutsParser.h unix/XkbLayoutsParser.h
) )
endif() endif()

View file

@ -12,8 +12,8 @@
#include "common/PlatformInfo.h" #include "common/PlatformInfo.h"
#if WINAPI_XWINDOWS #if WINAPI_XWINDOWS
#include "deskflow/unix/X11LayoutsParser.h"
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#include <deskflow/unix/XkbLayoutsParser.h>
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <platform/OSXAutoTypes.h> #include <platform/OSXAutoTypes.h>
@ -44,7 +44,7 @@ std::vector<std::string> AppUtilUnix::getKeyboardLayoutList()
std::vector<std::string> layoutLangCodes; std::vector<std::string> layoutLangCodes;
#if WINAPI_XWINDOWS #if WINAPI_XWINDOWS
layoutLangCodes = X11LayoutsParser::getX11LanguageList(); layoutLangCodes = XkbLayoutsParser::getXkbLanguageList();
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
CFStringRef keys[] = {kTISPropertyInputSourceCategory}; CFStringRef keys[] = {kTISPropertyInputSourceCategory};
@ -140,7 +140,7 @@ std::string AppUtilUnix::getCurrentLanguageCode()
XFree(kbdDescr); XFree(kbdDescr);
XCloseDisplay(display); XCloseDisplay(display);
result = X11LayoutsParser::convertLayoutToISO(result); result = XkbLayoutsParser::convertLayoutToISO(result);
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
AutoTISInputSourceRef source(nullptr, CFRelease); AutoTISInputSourceRef source(nullptr, CFRelease);

View file

@ -14,7 +14,7 @@
#include "DeskflowXkbKeyboard.h" #include "DeskflowXkbKeyboard.h"
#include "ISO639Table.h" #include "ISO639Table.h"
#include "X11LayoutsParser.h" #include "XkbLayoutsParser.h"
#include <xkbcommon/xkbregistry.h> #include <xkbcommon/xkbregistry.h>
@ -32,7 +32,7 @@ void splitLine(std::vector<std::string> &parts, const std::string &line, char de
} // namespace } // namespace
std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData() std::vector<XkbLayoutsParser::Lang> XkbLayoutsParser::getAllLanguageData()
{ {
std::vector<Lang> allCodes; std::vector<Lang> allCodes;
@ -81,7 +81,7 @@ std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData()
return allCodes; return allCodes;
} }
void X11LayoutsParser::appendVectorUniq(const std::vector<std::string> &source, std::vector<std::string> &dst) void XkbLayoutsParser::appendVectorUniq(const std::vector<std::string> &source, std::vector<std::string> &dst)
{ {
for (const auto &elem : source) { for (const auto &elem : source) {
if (std::ranges::find_if(dst, [&elem](const std::string_view &s) { return s == elem; }) == dst.end()) { if (std::ranges::find_if(dst, [&elem](const std::string_view &s) { return s == elem; }) == dst.end()) {
@ -90,12 +90,12 @@ void X11LayoutsParser::appendVectorUniq(const std::vector<std::string> &source,
} }
} }
void X11LayoutsParser::convertLayoutToISO639_2( void XkbLayoutsParser::convertLayoutToISO639_2(
const std::vector<std::string> &layoutNames, const std::vector<std::string> &layoutVariantNames, const std::vector<std::string> &layoutNames, const std::vector<std::string> &layoutVariantNames,
std::vector<std::string> &iso639_2Codes std::vector<std::string> &iso639_2Codes
) )
{ {
static std::vector<X11LayoutsParser::Lang> allLang; static std::vector<XkbLayoutsParser::Lang> allLang;
if (allLang.empty()) { if (allLang.empty()) {
allLang = getAllLanguageData(); allLang = getAllLanguageData();
} }
@ -144,7 +144,7 @@ void X11LayoutsParser::convertLayoutToISO639_2(
} }
} }
std::vector<std::string> X11LayoutsParser::getX11LanguageList() std::vector<std::string> XkbLayoutsParser::getXkbLanguageList()
{ {
std::vector<std::string> layoutNames; std::vector<std::string> layoutNames;
std::vector<std::string> layoutVariantNames; std::vector<std::string> layoutVariantNames;
@ -159,7 +159,7 @@ std::vector<std::string> X11LayoutsParser::getX11LanguageList()
return convertISO639_2ToISO639_1(iso639_2Codes); return convertISO639_2ToISO639_1(iso639_2Codes);
} }
std::string X11LayoutsParser::convertLayoutToISO(const std::string &layoutLangCode) std::string XkbLayoutsParser::convertLayoutToISO(const std::string &layoutLangCode)
{ {
if (layoutLangCode.empty()) { if (layoutLangCode.empty()) {
LOG_VERBOSE("skip converting empty layout lang code"); LOG_VERBOSE("skip converting empty layout lang code");
@ -182,7 +182,7 @@ std::string X11LayoutsParser::convertLayoutToISO(const std::string &layoutLangCo
return *iso639_1Codes.begin(); return *iso639_1Codes.begin();
} }
std::vector<std::string> X11LayoutsParser::convertISO639_2ToISO639_1(const std::vector<std::string> &iso639_2Codes) std::vector<std::string> XkbLayoutsParser::convertISO639_2ToISO639_1(const std::vector<std::string> &iso639_2Codes)
{ {
std::vector<std::string> result; std::vector<std::string> result;
for (const auto &isoCode : iso639_2Codes) { for (const auto &isoCode : iso639_2Codes) {

View file

@ -12,10 +12,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
class X11LayoutsParser class XkbLayoutsParser
{ {
public: public:
static std::vector<std::string> getX11LanguageList(); static std::vector<std::string> getXkbLanguageList();
static std::string convertLayoutToISO(const std::string &layoutLangCode); static std::string convertLayoutToISO(const std::string &layoutLangCode);
private: private:

View file

@ -55,10 +55,10 @@ create_test(
if(BUILD_X11_SUPPORT) if(BUILD_X11_SUPPORT)
create_test( create_test(
NAME X11LayoutParserTests NAME XkbLayoutParserTests
DEPENDS app DEPENDS app
LIBS arch base ${extra_libs} LIBS arch base ${extra_libs}
SOURCE X11LayoutParserTests.cpp SOURCE XkbLayoutParserTests.cpp
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/deskflow" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/deskflow"
) )
endif() endif()

View file

@ -6,21 +6,21 @@
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/ */
#include "X11LayoutParserTests.h" #include "XkbLayoutParserTests.h"
#include "deskflow/unix/X11LayoutsParser.h" #include "deskflow/unix/XkbLayoutsParser.h"
void X11LayoutParserTests::convertLayouts() void XkbLayoutParserTests::convertLayouts()
{ {
// An empty layout name yields an empty result. // An empty layout name yields an empty result.
QCOMPARE(X11LayoutsParser::convertLayoutToISO(""), ""); QCOMPARE(XkbLayoutsParser::convertLayoutToISO(""), "");
// An unknown layout name is not present in the registry. // An unknown layout name is not present in the registry.
QCOMPARE(X11LayoutsParser::convertLayoutToISO("notARealLayout"), ""); QCOMPARE(XkbLayoutsParser::convertLayoutToISO("notARealLayout"), "");
// A well-known layout resolves to its ISO 639-1 code. "us" is always // A well-known layout resolves to its ISO 639-1 code. "us" is always
// present in the xkeyboard-config data and maps to "eng" -> "en". // present in the xkeyboard-config data and maps to "eng" -> "en".
QCOMPARE(X11LayoutsParser::convertLayoutToISO("us"), "en"); QCOMPARE(XkbLayoutsParser::convertLayoutToISO("us"), "en");
} }
QTEST_MAIN(X11LayoutParserTests) QTEST_MAIN(XkbLayoutParserTests)

View file

@ -9,7 +9,7 @@
#include <QTest> #include <QTest>
class X11LayoutParserTests : public QObject class XkbLayoutParserTests : public QObject
{ {
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS: