diff --git a/src/protocols/core/Seat.cpp b/src/protocols/core/Seat.cpp index 21a47575..7a295372 100644 --- a/src/protocols/core/Seat.cpp +++ b/src/protocols/core/Seat.cpp @@ -27,6 +27,9 @@ void CWLTouchResource::sendDown(SP surface, uint32_t timeMs, if (!owner) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + ASSERT(surface->client() == owner->client()); currentSurface = surface; @@ -41,6 +44,9 @@ void CWLTouchResource::sendUp(uint32_t timeMs, int32_t id) { if (!owner) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + resource->sendUp(g_pSeatManager->nextSerial(owner.lock()), timeMs, id); fingers--; if (fingers <= 0) { @@ -54,6 +60,9 @@ void CWLTouchResource::sendMotion(uint32_t timeMs, int32_t id, const Vector2D& l if (!owner) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + resource->sendMotion(timeMs, id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } @@ -61,6 +70,9 @@ void CWLTouchResource::sendFrame() { if (!owner) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + resource->sendFrame(); } @@ -68,6 +80,9 @@ void CWLTouchResource::sendCancel() { if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + resource->sendCancel(); } @@ -75,6 +90,9 @@ void CWLTouchResource::sendShape(int32_t id, const Vector2D& shape) { if (!owner || !currentSurface || resource->version() < 6) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + resource->sendShape(id, wl_fixed_from_double(shape.x), wl_fixed_from_double(shape.y)); } @@ -82,6 +100,9 @@ void CWLTouchResource::sendOrientation(int32_t id, double angle) { if (!owner || !currentSurface || resource->version() < 6) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + return; + resource->sendOrientation(id, wl_fixed_from_double(angle)); } @@ -113,6 +134,9 @@ void CWLPointerResource::sendEnter(SP surface, const Vector2 if (!owner || currentSurface == surface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + if (currentSurface) { LOGM(WARN, "requested CWLPointerResource::sendEnter without sendLeave first."); sendLeave(); @@ -130,6 +154,9 @@ void CWLPointerResource::sendLeave() { if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + // release all buttons unless we have a dnd going on in which case // the events shall be lost. if (!PROTO::data->dndActive()) { @@ -151,6 +178,9 @@ void CWLPointerResource::sendMotion(uint32_t timeMs, const Vector2D& local) { if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } @@ -158,6 +188,9 @@ void CWLPointerResource::sendButton(uint32_t timeMs, uint32_t button, wl_pointer if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + if (state == WL_POINTER_BUTTON_STATE_RELEASED && std::find(pressedButtons.begin(), pressedButtons.end(), button) == pressedButtons.end()) { LOGM(ERR, "sendButton release on a non-pressed button"); return; @@ -178,6 +211,9 @@ void CWLPointerResource::sendAxis(uint32_t timeMs, wl_pointer_axis axis, double if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendAxis(timeMs, axis, wl_fixed_from_double(value)); } @@ -185,6 +221,9 @@ void CWLPointerResource::sendFrame() { if (!owner || resource->version() < 5) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendFrame(); } @@ -192,6 +231,9 @@ void CWLPointerResource::sendAxisSource(wl_pointer_axis_source source) { if (!owner || !currentSurface || resource->version() < 5) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendAxisSource(source); } @@ -199,6 +241,9 @@ void CWLPointerResource::sendAxisStop(uint32_t timeMs, wl_pointer_axis axis) { if (!owner || !currentSurface || resource->version() < 5) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendAxisStop(timeMs, axis); } @@ -206,6 +251,9 @@ void CWLPointerResource::sendAxisDiscrete(wl_pointer_axis axis, int32_t discrete if (!owner || !currentSurface || resource->version() < 5) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendAxisDiscrete(axis, discrete); } @@ -213,6 +261,9 @@ void CWLPointerResource::sendAxisValue120(wl_pointer_axis axis, int32_t value120 if (!owner || !currentSurface || resource->version() < 8) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendAxisValue120(axis, value120); } @@ -220,6 +271,9 @@ void CWLPointerResource::sendAxisRelativeDirection(wl_pointer_axis axis, wl_poin if (!owner || !currentSurface || resource->version() < 9) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + return; + resource->sendAxisRelativeDirection(axis, direction); } @@ -250,6 +304,9 @@ void CWLKeyboardResource::sendKeymap(SP keyboard) { if (!keyboard) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + return; + wl_keyboard_keymap_format format = keyboard ? WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 : WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP; int fd; uint32_t size; @@ -275,6 +332,9 @@ void CWLKeyboardResource::sendEnter(SP surface) { if (!owner || currentSurface == surface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + return; + if (currentSurface) { LOGM(WARN, "requested CWLKeyboardResource::sendEnter without sendLeave first."); sendLeave(); @@ -297,6 +357,9 @@ void CWLKeyboardResource::sendLeave() { if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + return; + resource->sendLeave(g_pSeatManager->nextSerial(owner.lock()), currentSurface->getResource().get()); currentSurface.reset(); listeners.destroySurface.reset(); @@ -306,6 +369,9 @@ void CWLKeyboardResource::sendKey(uint32_t timeMs, uint32_t key, wl_keyboard_key if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + return; + resource->sendKey(g_pSeatManager->nextSerial(owner.lock()), timeMs, key, state); } @@ -313,6 +379,9 @@ void CWLKeyboardResource::sendMods(uint32_t depressed, uint32_t latched, uint32_ if (!owner || !currentSurface) return; + if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + return; + resource->sendModifiers(g_pSeatManager->nextSerial(owner.lock()), depressed, latched, locked, group); }