- Double-space replaced the space via a Backspace keysym, which clients apply after the commit: use delete_surrounding_text with the commit - Tests use a shared FakeEngine that applies ops to a simulated field - Double-tap shift locks at a sentence start; typing between taps doesn't - Organization name set: config lives in ~/.config/sloposk/ - Settings (auto-capitalization, double-space period) with a ⚙ panel - Letter rows come from the compositor's XKB keymap; other letters of the layout become long-press alternates; globe switches the system layout over org.kde.keyboard - One JSON template for non-letter layers; stretch keys even out rows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "layout/KeymapLetters.h"
|
|
#include "layout/LayoutBuilder.h"
|
|
#include "layout/LayoutLoader.h"
|
|
|
|
#include <QTest>
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
#include <memory>
|
|
|
|
// Builds layouts the way the app does: the built-in template filled from a
|
|
// keymap, here compiled from XKB names instead of received from a compositor.
|
|
// Q_INIT_RESOURCE can't be used inside a namespace.
|
|
inline void initLayoutResources() { Q_INIT_RESOURCE(layouts); }
|
|
|
|
namespace TestLayouts {
|
|
|
|
inline Layout builtinTemplate()
|
|
{
|
|
initLayoutResources();
|
|
QString error;
|
|
const auto layout = LayoutLoader::load(QStringLiteral(":/layouts/template.json"), &error);
|
|
if (!layout)
|
|
qFatal("template.json: %s", qPrintable(error));
|
|
return *layout;
|
|
}
|
|
|
|
inline KeymapLetters letters(const char *layout, const char *variant = nullptr)
|
|
{
|
|
const std::unique_ptr<xkb_context, void (*)(xkb_context *)> context(
|
|
xkb_context_new(XKB_CONTEXT_NO_ENVIRONMENT_NAMES), xkb_context_unref);
|
|
const xkb_rule_names names{.rules = "evdev", .model = "pc105", .layout = layout, .variant = variant,
|
|
.options = nullptr};
|
|
const std::unique_ptr<xkb_keymap, void (*)(xkb_keymap *)> keymap(
|
|
xkb_keymap_new_from_names(context.get(), &names, XKB_KEYMAP_COMPILE_NO_FLAGS), xkb_keymap_unref);
|
|
if (!keymap)
|
|
qFatal("no XKB keymap for %s", layout);
|
|
return readKeymapLetters(keymap.get(), 0);
|
|
}
|
|
|
|
inline Layout build(const char *layout, const char *variant = nullptr)
|
|
{
|
|
return buildLayout(builtinTemplate(), letters(layout, variant));
|
|
}
|
|
|
|
} // namespace TestLayouts
|