Commit c7e15616 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik Committed by Kai Uwe Broulik
Browse files

inputmethod_v1_interface: Use RamFile for passing keymap to clients

This uses a sealed anonymous file (memfd) instead of a `QTemporaryFile`,
which is more efficient.

Ideally, this file was also reused if the keymap didn't change.

Signed-off-by: default avatarVictoria Fischer <>
parent 7e33e85c
Pipeline #220231 passed with stage
in 13 minutes and 58 seconds
......@@ -13,9 +13,9 @@
#include "surface_interface.h"
#include "surfacerole_p.h"
#include "utils/common.h"
#include "utils/ramfile.h"
#include <QHash>
#include <QTemporaryFile>
#include <unistd.h>
......@@ -47,30 +47,11 @@ InputMethodGrabV1::~InputMethodGrabV1()
void InputMethodGrabV1::sendKeymap(const QByteArray &keymap)
std::unique_ptr<QTemporaryFile> tmp(new QTemporaryFile());
if (!tmp->open()) {
qCWarning(KWIN_CORE) << "Failed to create keymap file:" << tmp->errorString();
if (!tmp->resize(keymap.size())) {
qCWarning(KWIN_CORE) << "Failed to resize keymap file:" << tmp->errorString();
uchar *address = tmp->map(0, keymap.size());
if (!address) {
qCWarning(KWIN_CORE) << "Failed to map keymap file:" << tmp->errorString();
qstrncpy(reinterpret_cast<char *>(address), keymap.constData(), keymap.size() + 1);
KWin::RamFile keymapFile("kwin-xkb-input-method-grab-keymap", keymap.constData(), keymap.size() + 1); // include QByteArray null terminator
const auto resources = d->resourceMap();
for (auto r : resources) {
d->send_keymap(r->handle, QtWaylandServer::wl_keyboard::keymap_format::keymap_format_xkb_v1, tmp->handle(), tmp->size());
d->send_keymap(r->handle, QtWaylandServer::wl_keyboard::keymap_format::keymap_format_xkb_v1, keymapFile.fd(), keymapFile.size());
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment