3
0
mirror of https://github.com/hyprwm/Hyprland.git synced 2026-08-18 11:02:10 +00:00

input/seat: check HID caps directly for focus enters (#15841)

ref #15765
This commit is contained in:
Vaxry
2026-08-12 20:57:58 +02:00
committed by GitHub
parent 153df31d2c
commit 6d43ce8453
3 changed files with 11 additions and 4 deletions

View File

@ -13,6 +13,7 @@
#include "../desktop/view/LayerSurface.hpp"
#include "../managers/input/InputManager.hpp"
#include "../state/MonitorState.hpp"
#include "devices/IHID.hpp"
#include "wlr-layer-shell-unstable-v1.hpp"
#include <algorithm>
#include <hyprutils/utils/ScopeGuard.hpp>
@ -183,8 +184,8 @@ void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
if (m_state.keyboardFocus == surf)
return;
if (!m_keyboard) {
Log::logger->log(Log::ERR, "BUG THIS: setKeyboardFocus without a valid keyboard set");
if (!g_pInputManager->anyHidHasCap(HID_INPUT_CAPABILITY_KEYBOARD)) {
Log::logger->log(Log::ERR, "BUG THIS: setKeyboardFocus without a valid keyboard capability");
return;
}
@ -301,8 +302,8 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
return;
}
if (!m_mouse) {
Log::logger->log(Log::ERR, "BUG THIS: setPointerFocus without a valid mouse set");
if (!g_pInputManager->anyHidHasCap(HID_INPUT_CAPABILITY_POINTER)) {
Log::logger->log(Log::ERR, "BUG THIS: setPointerFocus without a valid pointer input");
return;
}

View File

@ -1543,6 +1543,10 @@ static void removeFromHIDs(WP<IHID> hid) {
g_pInputManager->updateCapabilities();
}
bool CInputManager::anyHidHasCap(eHIDCapabilityType type) {
return std::ranges::any_of(m_hids, [&type](const auto& hid) { return hid && (hid->getCapabilities() & type) != 0; });
}
void CInputManager::destroyKeyboard(SP<IKeyboard> pKeyboard) {
Log::logger->log(Log::DEBUG, "Keyboard at {:x} removed", rc<uintptr_t>(pKeyboard.get()));

View File

@ -118,6 +118,8 @@ class CInputManager {
bool isLocked();
bool hasHeldButtons();
bool anyHidHasCap(eHIDCapabilityType type);
Vector2D getMouseCoordsInternal();
void refocus(std::optional<Vector2D> overridePos = std::nullopt);
bool refocusLastWindow(PHLMONITOR pMonitor);