Files
ericek111andClaude Opus 5.5 ba2f17d665 Full keyboard mode, Ctrl/Alt/Super, dead keys, shift levels
- Full (iPad Pro) mode: every typing key from the keymap, number row,
  tab, caps lock, ctrl/super/alt; shifted symbol shown above and flickable
- Dead keys compose with the locale's XKB compose table
- Ctrl/Alt/Super stick like shift and turn keys into shortcuts; a tapped
  or held shift joins shortcuts and non-text keys, auto-shift and caps
  lock don't
- Auto-capitalization and caps lock only capitalize letters; the user's
  shift picks the keymap's shifted level
- Mode switch in settings keeps key size by resizing the window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 21:29:24 +02:00

48 lines
1.6 KiB
C++

#pragma once
#include "layout/KeymapKeys.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 KeymapKeys keymapKeys(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 readKeymapKeys(keymap.get(), 0);
}
inline Layout build(const char *layout, KeyboardMode mode = KeyboardMode::Compact)
{
return buildLayout(builtinTemplate(), keymapKeys(layout), mode);
}
} // namespace TestLayouts