seat: send events to all bound seats for a client

some apps are legitimately braindead and bind wl_seat a bazillion times and expect the events to be sent to all of them

ref #6159
This commit is contained in:
Vaxry 2024-06-07 20:16:26 +02:00
parent 40ce17bbbd
commit 6b6b02c27a

View file

@ -110,12 +110,6 @@ void CSeatManager::setKeyboardFocus(wlr_surface* surf) {
hyprListener_keyboardSurfaceDestroy.removeCallback(); hyprListener_keyboardSurfaceDestroy.removeCallback();
if (state.keyboardFocusResource) { if (state.keyboardFocusResource) {
// we will iterate over all bound wl_seat
// resources here, because some idiotic apps (e.g. those based on smithay)
// tend to bind wl_seat twice.
// I can't be arsed to actually pass all events to all seat resources, so we will
// only pass enter and leave.
// If you have an issue with that, fix your app.
auto client = state.keyboardFocusResource->client(); auto client = state.keyboardFocusResource->client();
for (auto& s : seatResources) { for (auto& s : seatResources) {
if (s->resource->client() != client) if (s->resource->client() != client)
@ -163,25 +157,35 @@ void CSeatManager::sendKeyboardKey(uint32_t timeMs, uint32_t key, wl_keyboard_ke
if (!state.keyboardFocusResource) if (!state.keyboardFocusResource)
return; return;
for (auto& k : state.keyboardFocusResource->keyboards) { for (auto& s : seatResources) {
if (s->resource->client() != state.keyboardFocusResource->client())
continue;
for (auto& k : s->resource->keyboards) {
if (!k) if (!k)
continue; continue;
k->sendKey(timeMs, key, state_); k->sendKey(timeMs, key, state_);
} }
} }
}
void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
if (!state.keyboardFocusResource) if (!state.keyboardFocusResource)
return; return;
for (auto& k : state.keyboardFocusResource->keyboards) { for (auto& s : seatResources) {
if (s->resource->client() != state.keyboardFocusResource->client())
continue;
for (auto& k : s->resource->keyboards) {
if (!k) if (!k)
continue; continue;
k->sendMods(depressed, latched, locked, group); k->sendMods(depressed, latched, locked, group);
} }
} }
}
void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) { void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) {
if (state.pointerFocus == surf) if (state.pointerFocus == surf)
@ -249,12 +253,17 @@ void CSeatManager::sendPointerMotion(uint32_t timeMs, const Vector2D& local) {
if (!state.pointerFocusResource) if (!state.pointerFocusResource)
return; return;
for (auto& p : state.pointerFocusResource->pointers) { for (auto& s : seatResources) {
if (s->resource->client() != state.pointerFocusResource->client())
continue;
for (auto& p : s->resource->pointers) {
if (!p) if (!p)
continue; continue;
p->sendMotion(timeMs, local); p->sendMotion(timeMs, local);
} }
}
lastLocalCoords = local; lastLocalCoords = local;
} }
@ -263,13 +272,18 @@ void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_b
if (!state.pointerFocusResource) if (!state.pointerFocusResource)
return; return;
for (auto& p : state.pointerFocusResource->pointers) { for (auto& s : seatResources) {
if (s->resource->client() != state.pointerFocusResource->client())
continue;
for (auto& p : s->resource->pointers) {
if (!p) if (!p)
continue; continue;
p->sendButton(timeMs, key, state_); p->sendButton(timeMs, key, state_);
} }
} }
}
void CSeatManager::sendPointerFrame() { void CSeatManager::sendPointerFrame() {
if (!state.pointerFocusResource) if (!state.pointerFocusResource)
@ -282,20 +296,32 @@ void CSeatManager::sendPointerFrame(WP<CWLSeatResource> pResource) {
if (!pResource) if (!pResource)
return; return;
for (auto& p : pResource->pointers) { if (!state.pointerFocusResource)
return;
for (auto& s : seatResources) {
if (s->resource->client() != state.pointerFocusResource->client())
continue;
for (auto& p : s->resource->pointers) {
if (!p) if (!p)
continue; continue;
p->sendFrame(); p->sendFrame();
} }
} }
}
void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double value, int32_t discrete, int32_t value120, wl_pointer_axis_source source, void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double value, int32_t discrete, int32_t value120, wl_pointer_axis_source source,
wl_pointer_axis_relative_direction relative) { wl_pointer_axis_relative_direction relative) {
if (!state.pointerFocusResource) if (!state.pointerFocusResource)
return; return;
for (auto& p : state.pointerFocusResource->pointers) { for (auto& s : seatResources) {
if (s->resource->client() != state.pointerFocusResource->client())
continue;
for (auto& p : s->resource->pointers) {
if (!p) if (!p)
continue; continue;
@ -312,6 +338,7 @@ void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double
p->sendAxisStop(timeMs, axis); p->sendAxisStop(timeMs, axis);
} }
} }
}
void CSeatManager::sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id, const Vector2D& local) { void CSeatManager::sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id, const Vector2D& local) {
if (state.touchFocus == surf) if (state.touchFocus == surf)
@ -370,61 +397,86 @@ void CSeatManager::sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D&
if (!state.touchFocusResource) if (!state.touchFocusResource)
return; return;
for (auto& t : state.touchFocusResource->touches) { for (auto& s : seatResources) {
if (s->resource->client() != state.touchFocusResource->client())
continue;
for (auto& t : s->resource->touches) {
if (!t) if (!t)
continue; continue;
t->sendMotion(timeMs, id, local); t->sendMotion(timeMs, id, local);
} }
} }
}
void CSeatManager::sendTouchFrame() { void CSeatManager::sendTouchFrame() {
if (!state.touchFocusResource) if (!state.touchFocusResource)
return; return;
for (auto& t : state.touchFocusResource->touches) { for (auto& s : seatResources) {
if (s->resource->client() != state.touchFocusResource->client())
continue;
for (auto& t : s->resource->touches) {
if (!t) if (!t)
continue; continue;
t->sendFrame(); t->sendFrame();
} }
} }
}
void CSeatManager::sendTouchCancel() { void CSeatManager::sendTouchCancel() {
if (!state.touchFocusResource) if (!state.touchFocusResource)
return; return;
for (auto& t : state.touchFocusResource->touches) { for (auto& s : seatResources) {
if (s->resource->client() != state.touchFocusResource->client())
continue;
for (auto& t : s->resource->touches) {
if (!t) if (!t)
continue; continue;
t->sendCancel(); t->sendCancel();
} }
} }
}
void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) { void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) {
if (!state.touchFocusResource) if (!state.touchFocusResource)
return; return;
for (auto& t : state.touchFocusResource->touches) { for (auto& s : seatResources) {
if (s->resource->client() != state.touchFocusResource->client())
continue;
for (auto& t : s->resource->touches) {
if (!t) if (!t)
continue; continue;
t->sendShape(id, shape); t->sendShape(id, shape);
} }
} }
}
void CSeatManager::sendTouchOrientation(int32_t id, double angle) { void CSeatManager::sendTouchOrientation(int32_t id, double angle) {
if (!state.touchFocusResource) if (!state.touchFocusResource)
return; return;
for (auto& t : state.touchFocusResource->touches) { for (auto& s : seatResources) {
if (s->resource->client() != state.touchFocusResource->client())
continue;
for (auto& t : s->resource->touches) {
if (!t) if (!t)
continue; continue;
t->sendOrientation(id, angle); t->sendOrientation(id, angle);
} }
} }
}
void CSeatManager::refocusGrab() { void CSeatManager::refocusGrab() {
if (!seatGrab) if (!seatGrab)