placeholderinputeventfilter: don't block media keys

While blindly typing with no outputs connected is unlikely to be intentional,
using the media keys likely is.

BUG: 491531
This commit is contained in:
Xaver Hugl 2024-08-11 15:46:16 +02:00
parent 85f2e85fe4
commit cfc0f05c94
3 changed files with 43 additions and 18 deletions

View file

@ -12,6 +12,7 @@
#include "core/session.h"
#include "input_event.h"
#include "main.h"
#include "utils/keys.h"
#include "wayland/seat.h"
#include "wayland_server.h"
#include "workspace.h"
@ -54,23 +55,7 @@ bool DpmsInputEventFilter::wheelEvent(WheelEvent *event)
bool DpmsInputEventFilter::keyEvent(KeyEvent *event)
{
static constexpr std::array s_mediaKeys = {
Qt::Key::Key_MediaLast,
Qt::Key::Key_MediaNext,
Qt::Key::Key_MediaPause,
Qt::Key::Key_MediaPlay,
Qt::Key::Key_MediaPrevious,
Qt::Key::Key_MediaRecord,
Qt::Key::Key_MediaStop,
Qt::Key::Key_MediaTogglePlayPause,
Qt::Key::Key_VolumeUp,
Qt::Key::Key_VolumeDown,
Qt::Key::Key_VolumeMute,
Qt::Key::Key_MicVolumeUp,
Qt::Key::Key_MicVolumeDown,
Qt::Key::Key_MicMute,
};
if (std::ranges::find(s_mediaKeys, event->key()) != s_mediaKeys.end()) {
if (isMediaKey(event->key())) {
// don't wake up the screens for media or volume keys
return false;
}

View file

@ -8,6 +8,8 @@
*/
#include "placeholderinputeventfilter.h"
#include "input_event.h"
#include "utils/keys.h"
namespace KWin
{
@ -29,7 +31,7 @@ bool PlaceholderInputEventFilter::wheelEvent(WheelEvent *event)
bool PlaceholderInputEventFilter::keyEvent(KeyEvent *event)
{
return true;
return !isMediaKey(event->key());
}
bool PlaceholderInputEventFilter::touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time)

38
src/utils/keys.h Normal file
View file

@ -0,0 +1,38 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2024 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QInputEvent>
#include <array>
namespace KWin
{
static constexpr std::array s_mediaKeys = {
Qt::Key::Key_MediaLast,
Qt::Key::Key_MediaNext,
Qt::Key::Key_MediaPause,
Qt::Key::Key_MediaPlay,
Qt::Key::Key_MediaPrevious,
Qt::Key::Key_MediaRecord,
Qt::Key::Key_MediaStop,
Qt::Key::Key_MediaTogglePlayPause,
Qt::Key::Key_VolumeUp,
Qt::Key::Key_VolumeDown,
Qt::Key::Key_VolumeMute,
Qt::Key::Key_MicVolumeUp,
Qt::Key::Key_MicVolumeDown,
Qt::Key::Key_MicMute,
};
static inline bool isMediaKey(int key)
{
return std::ranges::find(s_mediaKeys, key) != s_mediaKeys.end();
}
}