mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-09-14 23:38:22 +00:00
managers: refactor class member vars (#10242)
This commit is contained in:
@@ -14,20 +14,20 @@
|
||||
#include <ranges>
|
||||
|
||||
CSeatManager::CSeatManager() {
|
||||
listeners.newSeatResource = PROTO::seat->events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast<SP<CWLSeatResource>>(res)); });
|
||||
m_listeners.newSeatResource = PROTO::seat->events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast<SP<CWLSeatResource>>(res)); });
|
||||
}
|
||||
|
||||
CSeatManager::SSeatResourceContainer::SSeatResourceContainer(SP<CWLSeatResource> res) : resource(res) {
|
||||
listeners.destroy = res->events.destroy.registerListener(
|
||||
[this](std::any data) { std::erase_if(g_pSeatManager->seatResources, [this](const auto& e) { return e->resource.expired() || e->resource == resource; }); });
|
||||
[this](std::any data) { std::erase_if(g_pSeatManager->m_seatResources, [this](const auto& e) { return e->resource.expired() || e->resource == resource; }); });
|
||||
}
|
||||
|
||||
void CSeatManager::onNewSeatResource(SP<CWLSeatResource> resource) {
|
||||
seatResources.emplace_back(makeShared<SSeatResourceContainer>(resource));
|
||||
m_seatResources.emplace_back(makeShared<SSeatResourceContainer>(resource));
|
||||
}
|
||||
|
||||
SP<CSeatManager::SSeatResourceContainer> CSeatManager::containerForResource(SP<CWLSeatResource> seatResource) {
|
||||
for (auto const& c : seatResources) {
|
||||
for (auto const& c : m_seatResources) {
|
||||
if (c->resource == seatResource)
|
||||
return c;
|
||||
}
|
||||
@@ -76,19 +76,19 @@ void CSeatManager::updateCapabilities(uint32_t capabilities) {
|
||||
}
|
||||
|
||||
void CSeatManager::setMouse(SP<IPointer> MAUZ) {
|
||||
if (mouse == MAUZ)
|
||||
if (m_mouse == MAUZ)
|
||||
return;
|
||||
|
||||
mouse = MAUZ;
|
||||
m_mouse = MAUZ;
|
||||
}
|
||||
|
||||
void CSeatManager::setKeyboard(SP<IKeyboard> KEEB) {
|
||||
if (keyboard == KEEB)
|
||||
if (m_keyboard == KEEB)
|
||||
return;
|
||||
|
||||
if (keyboard)
|
||||
keyboard->m_active = false;
|
||||
keyboard = KEEB;
|
||||
if (m_keyboard)
|
||||
m_keyboard->m_active = false;
|
||||
m_keyboard = KEEB;
|
||||
|
||||
if (KEEB)
|
||||
KEEB->m_active = true;
|
||||
@@ -97,25 +97,25 @@ void CSeatManager::setKeyboard(SP<IKeyboard> KEEB) {
|
||||
}
|
||||
|
||||
void CSeatManager::updateActiveKeyboardData() {
|
||||
if (keyboard)
|
||||
PROTO::seat->updateRepeatInfo(keyboard->m_repeatRate, keyboard->m_repeatDelay);
|
||||
if (m_keyboard)
|
||||
PROTO::seat->updateRepeatInfo(m_keyboard->m_repeatRate, m_keyboard->m_repeatDelay);
|
||||
PROTO::seat->updateKeymap();
|
||||
}
|
||||
|
||||
void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
|
||||
if (state.keyboardFocus == surf)
|
||||
if (m_state.keyboardFocus == surf)
|
||||
return;
|
||||
|
||||
if (!keyboard) {
|
||||
if (!m_keyboard) {
|
||||
Debug::log(ERR, "BUG THIS: setKeyboardFocus without a valid keyboard set");
|
||||
return;
|
||||
}
|
||||
|
||||
listeners.keyboardSurfaceDestroy.reset();
|
||||
m_listeners.keyboardSurfaceDestroy.reset();
|
||||
|
||||
if (state.keyboardFocusResource) {
|
||||
auto client = state.keyboardFocusResource->client();
|
||||
for (auto const& s : seatResources) {
|
||||
if (m_state.keyboardFocusResource) {
|
||||
auto client = m_state.keyboardFocusResource->client();
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != client)
|
||||
continue;
|
||||
|
||||
@@ -128,40 +128,40 @@ void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
|
||||
}
|
||||
}
|
||||
|
||||
state.keyboardFocusResource.reset();
|
||||
state.keyboardFocus = surf;
|
||||
m_state.keyboardFocusResource.reset();
|
||||
m_state.keyboardFocus = surf;
|
||||
|
||||
if (!surf) {
|
||||
events.keyboardFocusChange.emit();
|
||||
m_events.keyboardFocusChange.emit();
|
||||
return;
|
||||
}
|
||||
|
||||
auto client = surf->client();
|
||||
for (auto const& r : seatResources | std::views::reverse) {
|
||||
for (auto const& r : m_seatResources | std::views::reverse) {
|
||||
if (r->resource->client() != client)
|
||||
continue;
|
||||
|
||||
state.keyboardFocusResource = r->resource;
|
||||
m_state.keyboardFocusResource = r->resource;
|
||||
for (auto const& k : r->resource->keyboards) {
|
||||
if (!k)
|
||||
continue;
|
||||
|
||||
k->sendEnter(surf);
|
||||
k->sendMods(keyboard->m_modifiersState.depressed, keyboard->m_modifiersState.latched, keyboard->m_modifiersState.locked, keyboard->m_modifiersState.group);
|
||||
k->sendMods(m_keyboard->m_modifiersState.depressed, m_keyboard->m_modifiersState.latched, m_keyboard->m_modifiersState.locked, m_keyboard->m_modifiersState.group);
|
||||
}
|
||||
}
|
||||
|
||||
listeners.keyboardSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setKeyboardFocus(nullptr); });
|
||||
m_listeners.keyboardSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setKeyboardFocus(nullptr); });
|
||||
|
||||
events.keyboardFocusChange.emit();
|
||||
m_events.keyboardFocusChange.emit();
|
||||
}
|
||||
|
||||
void CSeatManager::sendKeyboardKey(uint32_t timeMs, uint32_t key, wl_keyboard_key_state state_) {
|
||||
if (!state.keyboardFocusResource)
|
||||
if (!m_state.keyboardFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.keyboardFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.keyboardFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& k : s->resource->keyboards) {
|
||||
@@ -174,11 +174,11 @@ void CSeatManager::sendKeyboardKey(uint32_t timeMs, uint32_t key, wl_keyboard_ke
|
||||
}
|
||||
|
||||
void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
|
||||
if (!state.keyboardFocusResource)
|
||||
if (!m_state.keyboardFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.keyboardFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.keyboardFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& k : s->resource->keyboards) {
|
||||
@@ -191,28 +191,28 @@ void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32
|
||||
}
|
||||
|
||||
void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D& local) {
|
||||
if (state.pointerFocus == surf)
|
||||
if (m_state.pointerFocus == surf)
|
||||
return;
|
||||
|
||||
if (PROTO::data->dndActive() && surf) {
|
||||
if (state.dndPointerFocus == surf)
|
||||
if (m_state.dndPointerFocus == surf)
|
||||
return;
|
||||
Debug::log(LOG, "[seatmgr] Refusing pointer focus during an active dnd, but setting dndPointerFocus");
|
||||
state.dndPointerFocus = surf;
|
||||
events.dndPointerFocusChange.emit();
|
||||
m_state.dndPointerFocus = surf;
|
||||
m_events.dndPointerFocusChange.emit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mouse) {
|
||||
if (!m_mouse) {
|
||||
Debug::log(ERR, "BUG THIS: setPointerFocus without a valid mouse set");
|
||||
return;
|
||||
}
|
||||
|
||||
listeners.pointerSurfaceDestroy.reset();
|
||||
m_listeners.pointerSurfaceDestroy.reset();
|
||||
|
||||
if (state.pointerFocusResource) {
|
||||
auto client = state.pointerFocusResource->client();
|
||||
for (auto const& s : seatResources) {
|
||||
if (m_state.pointerFocusResource) {
|
||||
auto client = m_state.pointerFocusResource->client();
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != client)
|
||||
continue;
|
||||
|
||||
@@ -225,26 +225,26 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
|
||||
}
|
||||
}
|
||||
|
||||
auto lastPointerFocusResource = state.pointerFocusResource;
|
||||
auto lastPointerFocusResource = m_state.pointerFocusResource;
|
||||
|
||||
state.dndPointerFocus.reset();
|
||||
state.pointerFocusResource.reset();
|
||||
state.pointerFocus = surf;
|
||||
m_state.dndPointerFocus.reset();
|
||||
m_state.pointerFocusResource.reset();
|
||||
m_state.pointerFocus = surf;
|
||||
|
||||
if (!surf) {
|
||||
sendPointerFrame(lastPointerFocusResource);
|
||||
events.pointerFocusChange.emit();
|
||||
m_events.pointerFocusChange.emit();
|
||||
return;
|
||||
}
|
||||
|
||||
state.dndPointerFocus = surf;
|
||||
m_state.dndPointerFocus = surf;
|
||||
|
||||
auto client = surf->client();
|
||||
for (auto const& r : seatResources | std::views::reverse) {
|
||||
for (auto const& r : m_seatResources | std::views::reverse) {
|
||||
if (r->resource->client() != client)
|
||||
continue;
|
||||
|
||||
state.pointerFocusResource = r->resource;
|
||||
m_state.pointerFocusResource = r->resource;
|
||||
for (auto const& p : r->resource->pointers) {
|
||||
if (!p)
|
||||
continue;
|
||||
@@ -253,23 +253,23 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
|
||||
}
|
||||
}
|
||||
|
||||
if (state.pointerFocusResource != lastPointerFocusResource)
|
||||
if (m_state.pointerFocusResource != lastPointerFocusResource)
|
||||
sendPointerFrame(lastPointerFocusResource);
|
||||
|
||||
sendPointerFrame();
|
||||
|
||||
listeners.pointerSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setPointerFocus(nullptr, {}); });
|
||||
m_listeners.pointerSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setPointerFocus(nullptr, {}); });
|
||||
|
||||
events.pointerFocusChange.emit();
|
||||
events.dndPointerFocusChange.emit();
|
||||
m_events.pointerFocusChange.emit();
|
||||
m_events.dndPointerFocusChange.emit();
|
||||
}
|
||||
|
||||
void CSeatManager::sendPointerMotion(uint32_t timeMs, const Vector2D& local) {
|
||||
if (!state.pointerFocusResource)
|
||||
if (!m_state.pointerFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.pointerFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.pointerFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& p : s->resource->pointers) {
|
||||
@@ -280,15 +280,15 @@ void CSeatManager::sendPointerMotion(uint32_t timeMs, const Vector2D& local) {
|
||||
}
|
||||
}
|
||||
|
||||
lastLocalCoords = local;
|
||||
m_lastLocalCoords = local;
|
||||
}
|
||||
|
||||
void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_button_state state_) {
|
||||
if (!state.pointerFocusResource || PROTO::data->dndActive())
|
||||
if (!m_state.pointerFocusResource || PROTO::data->dndActive())
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.pointerFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.pointerFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& p : s->resource->pointers) {
|
||||
@@ -301,17 +301,17 @@ void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_b
|
||||
}
|
||||
|
||||
void CSeatManager::sendPointerFrame() {
|
||||
if (!state.pointerFocusResource)
|
||||
if (!m_state.pointerFocusResource)
|
||||
return;
|
||||
|
||||
sendPointerFrame(state.pointerFocusResource);
|
||||
sendPointerFrame(m_state.pointerFocusResource);
|
||||
}
|
||||
|
||||
void CSeatManager::sendPointerFrame(WP<CWLSeatResource> pResource) {
|
||||
if (!pResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != pResource->client())
|
||||
continue;
|
||||
|
||||
@@ -326,11 +326,11 @@ void CSeatManager::sendPointerFrame(WP<CWLSeatResource> pResource) {
|
||||
|
||||
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) {
|
||||
if (!state.pointerFocusResource)
|
||||
if (!m_state.pointerFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.pointerFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.pointerFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& p : s->resource->pointers) {
|
||||
@@ -353,17 +353,17 @@ void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchDown(SP<CWLSurfaceResource> surf, uint32_t timeMs, int32_t id, const Vector2D& local) {
|
||||
listeners.touchSurfaceDestroy.reset();
|
||||
m_listeners.touchSurfaceDestroy.reset();
|
||||
|
||||
state.touchFocusResource.reset();
|
||||
state.touchFocus = surf;
|
||||
m_state.touchFocusResource.reset();
|
||||
m_state.touchFocus = surf;
|
||||
|
||||
auto client = surf->client();
|
||||
for (auto const& r : seatResources | std::views::reverse) {
|
||||
for (auto const& r : m_seatResources | std::views::reverse) {
|
||||
if (r->resource->client() != client)
|
||||
continue;
|
||||
|
||||
state.touchFocusResource = r->resource;
|
||||
m_state.touchFocusResource = r->resource;
|
||||
for (auto const& t : r->resource->touches) {
|
||||
if (!t)
|
||||
continue;
|
||||
@@ -372,24 +372,24 @@ void CSeatManager::sendTouchDown(SP<CWLSurfaceResource> surf, uint32_t timeMs, i
|
||||
}
|
||||
}
|
||||
|
||||
listeners.touchSurfaceDestroy = surf->events.destroy.registerListener([this, timeMs, id](std::any d) { sendTouchUp(timeMs + 10, id); });
|
||||
m_listeners.touchSurfaceDestroy = surf->events.destroy.registerListener([this, timeMs, id](std::any d) { sendTouchUp(timeMs + 10, id); });
|
||||
|
||||
touchLocks++;
|
||||
m_touchLocks++;
|
||||
|
||||
if (touchLocks <= 1)
|
||||
events.touchFocusChange.emit();
|
||||
if (m_touchLocks <= 1)
|
||||
m_events.touchFocusChange.emit();
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchUp(uint32_t timeMs, int32_t id) {
|
||||
if (!state.touchFocusResource || touchLocks <= 0)
|
||||
if (!m_state.touchFocusResource || m_touchLocks <= 0)
|
||||
return;
|
||||
|
||||
auto client = state.touchFocusResource->client();
|
||||
for (auto const& r : seatResources | std::views::reverse) {
|
||||
auto client = m_state.touchFocusResource->client();
|
||||
for (auto const& r : m_seatResources | std::views::reverse) {
|
||||
if (r->resource->client() != client)
|
||||
continue;
|
||||
|
||||
state.touchFocusResource = r->resource;
|
||||
m_state.touchFocusResource = r->resource;
|
||||
for (auto const& t : r->resource->touches) {
|
||||
if (!t)
|
||||
continue;
|
||||
@@ -398,18 +398,18 @@ void CSeatManager::sendTouchUp(uint32_t timeMs, int32_t id) {
|
||||
}
|
||||
}
|
||||
|
||||
touchLocks--;
|
||||
m_touchLocks--;
|
||||
|
||||
if (touchLocks <= 0)
|
||||
events.touchFocusChange.emit();
|
||||
if (m_touchLocks <= 0)
|
||||
m_events.touchFocusChange.emit();
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D& local) {
|
||||
if (!state.touchFocusResource)
|
||||
if (!m_state.touchFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.touchFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.touchFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& t : s->resource->touches) {
|
||||
@@ -422,11 +422,11 @@ void CSeatManager::sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D&
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchFrame() {
|
||||
if (!state.touchFocusResource)
|
||||
if (!m_state.touchFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.touchFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.touchFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& t : s->resource->touches) {
|
||||
@@ -439,11 +439,11 @@ void CSeatManager::sendTouchFrame() {
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchCancel() {
|
||||
if (!state.touchFocusResource)
|
||||
if (!m_state.touchFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.touchFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.touchFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& t : s->resource->touches) {
|
||||
@@ -456,11 +456,11 @@ void CSeatManager::sendTouchCancel() {
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) {
|
||||
if (!state.touchFocusResource)
|
||||
if (!m_state.touchFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.touchFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.touchFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& t : s->resource->touches) {
|
||||
@@ -473,11 +473,11 @@ void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) {
|
||||
}
|
||||
|
||||
void CSeatManager::sendTouchOrientation(int32_t id, double angle) {
|
||||
if (!state.touchFocusResource)
|
||||
if (!m_state.touchFocusResource)
|
||||
return;
|
||||
|
||||
for (auto const& s : seatResources) {
|
||||
if (s->resource->client() != state.touchFocusResource->client())
|
||||
for (auto const& s : m_seatResources) {
|
||||
if (s->resource->client() != m_state.touchFocusResource->client())
|
||||
continue;
|
||||
|
||||
for (auto const& t : s->resource->touches) {
|
||||
@@ -490,13 +490,13 @@ void CSeatManager::sendTouchOrientation(int32_t id, double angle) {
|
||||
}
|
||||
|
||||
void CSeatManager::refocusGrab() {
|
||||
if (!seatGrab)
|
||||
if (!m_seatGrab)
|
||||
return;
|
||||
|
||||
if (seatGrab->surfs.size() > 0) {
|
||||
if (m_seatGrab->m_surfs.size() > 0) {
|
||||
// try to find a surf in focus first
|
||||
const auto MOUSE = g_pInputManager->getMouseCoordsInternal();
|
||||
for (auto const& s : seatGrab->surfs) {
|
||||
for (auto const& s : m_seatGrab->m_surfs) {
|
||||
auto hlSurf = CWLSurface::fromResource(s.lock());
|
||||
if (!hlSurf)
|
||||
continue;
|
||||
@@ -508,23 +508,23 @@ void CSeatManager::refocusGrab() {
|
||||
if (!b->containsPoint(MOUSE))
|
||||
continue;
|
||||
|
||||
if (seatGrab->keyboard)
|
||||
if (m_seatGrab->m_keyboard)
|
||||
setKeyboardFocus(s.lock());
|
||||
if (seatGrab->pointer)
|
||||
if (m_seatGrab->m_pointer)
|
||||
setPointerFocus(s.lock(), MOUSE - b->pos());
|
||||
return;
|
||||
}
|
||||
|
||||
SP<CWLSurfaceResource> surf = seatGrab->surfs.at(0).lock();
|
||||
if (seatGrab->keyboard)
|
||||
SP<CWLSurfaceResource> surf = m_seatGrab->m_surfs.at(0).lock();
|
||||
if (m_seatGrab->m_keyboard)
|
||||
setKeyboardFocus(surf);
|
||||
if (seatGrab->pointer)
|
||||
if (m_seatGrab->m_pointer)
|
||||
setPointerFocus(surf, {});
|
||||
}
|
||||
}
|
||||
|
||||
void CSeatManager::onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& hotspot) {
|
||||
if (!state.pointerFocusResource || !seatResource || seatResource->client() != state.pointerFocusResource->client()) {
|
||||
if (!m_state.pointerFocusResource || !seatResource || seatResource->client() != m_state.pointerFocusResource->client()) {
|
||||
Debug::log(LOG, "[seatmgr] Rejecting a setCursor because the client ain't in focus");
|
||||
return;
|
||||
}
|
||||
@@ -535,7 +535,7 @@ void CSeatManager::onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial
|
||||
// return;
|
||||
// }
|
||||
|
||||
events.setCursor.emit(SSetCursorEvent{surf, hotspot});
|
||||
m_events.setCursor.emit(SSetCursorEvent{surf, hotspot});
|
||||
}
|
||||
|
||||
SP<CWLSeatResource> CSeatManager::seatResourceForClient(wl_client* client) {
|
||||
@@ -543,62 +543,62 @@ SP<CWLSeatResource> CSeatManager::seatResourceForClient(wl_client* client) {
|
||||
}
|
||||
|
||||
void CSeatManager::setCurrentSelection(SP<IDataSource> source) {
|
||||
if (source == selection.currentSelection) {
|
||||
if (source == m_selection.currentSelection) {
|
||||
Debug::log(WARN, "[seat] duplicated setCurrentSelection?");
|
||||
return;
|
||||
}
|
||||
|
||||
selection.destroySelection.reset();
|
||||
m_selection.destroySelection.reset();
|
||||
|
||||
if (selection.currentSelection)
|
||||
selection.currentSelection->cancelled();
|
||||
if (m_selection.currentSelection)
|
||||
m_selection.currentSelection->cancelled();
|
||||
|
||||
if (!source)
|
||||
PROTO::data->setSelection(nullptr);
|
||||
|
||||
selection.currentSelection = source;
|
||||
m_selection.currentSelection = source;
|
||||
|
||||
if (source) {
|
||||
selection.destroySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); });
|
||||
m_selection.destroySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); });
|
||||
PROTO::data->setSelection(source);
|
||||
PROTO::dataWlr->setSelection(source, false);
|
||||
}
|
||||
|
||||
events.setSelection.emit();
|
||||
m_events.setSelection.emit();
|
||||
}
|
||||
|
||||
void CSeatManager::setCurrentPrimarySelection(SP<IDataSource> source) {
|
||||
if (source == selection.currentPrimarySelection) {
|
||||
if (source == m_selection.currentPrimarySelection) {
|
||||
Debug::log(WARN, "[seat] duplicated setCurrentPrimarySelection?");
|
||||
return;
|
||||
}
|
||||
|
||||
selection.destroyPrimarySelection.reset();
|
||||
m_selection.destroyPrimarySelection.reset();
|
||||
|
||||
if (selection.currentPrimarySelection)
|
||||
selection.currentPrimarySelection->cancelled();
|
||||
if (m_selection.currentPrimarySelection)
|
||||
m_selection.currentPrimarySelection->cancelled();
|
||||
|
||||
if (!source)
|
||||
PROTO::primarySelection->setSelection(nullptr);
|
||||
|
||||
selection.currentPrimarySelection = source;
|
||||
m_selection.currentPrimarySelection = source;
|
||||
|
||||
if (source) {
|
||||
selection.destroyPrimarySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentPrimarySelection(nullptr); });
|
||||
m_selection.destroyPrimarySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentPrimarySelection(nullptr); });
|
||||
PROTO::primarySelection->setSelection(source);
|
||||
PROTO::dataWlr->setSelection(source, true);
|
||||
}
|
||||
|
||||
events.setPrimarySelection.emit();
|
||||
m_events.setPrimarySelection.emit();
|
||||
}
|
||||
|
||||
void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
||||
if (seatGrab) {
|
||||
auto oldGrab = seatGrab;
|
||||
seatGrab.reset();
|
||||
if (m_seatGrab) {
|
||||
auto oldGrab = m_seatGrab;
|
||||
m_seatGrab.reset();
|
||||
g_pInputManager->refocus();
|
||||
|
||||
auto currentFocus = state.keyboardFocus.lock();
|
||||
auto currentFocus = m_state.keyboardFocus.lock();
|
||||
auto refocus = !currentFocus;
|
||||
|
||||
SP<CWLSurface> surf;
|
||||
@@ -627,23 +627,23 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
||||
g_pCompositor->focusWindow(candidate);
|
||||
}
|
||||
|
||||
if (oldGrab->onEnd)
|
||||
oldGrab->onEnd();
|
||||
if (oldGrab->m_onEnd)
|
||||
oldGrab->m_onEnd();
|
||||
}
|
||||
|
||||
if (!grab)
|
||||
return;
|
||||
|
||||
seatGrab = grab;
|
||||
m_seatGrab = grab;
|
||||
|
||||
refocusGrab();
|
||||
}
|
||||
|
||||
void CSeatManager::resendEnterEvents() {
|
||||
SP<CWLSurfaceResource> kb = state.keyboardFocus.lock();
|
||||
SP<CWLSurfaceResource> pt = state.pointerFocus.lock();
|
||||
SP<CWLSurfaceResource> kb = m_state.keyboardFocus.lock();
|
||||
SP<CWLSurfaceResource> pt = m_state.pointerFocus.lock();
|
||||
|
||||
auto last = lastLocalCoords;
|
||||
auto last = m_lastLocalCoords;
|
||||
|
||||
setKeyboardFocus(nullptr);
|
||||
setPointerFocus(nullptr, {});
|
||||
@@ -653,23 +653,23 @@ void CSeatManager::resendEnterEvents() {
|
||||
}
|
||||
|
||||
bool CSeatGrab::accepts(SP<CWLSurfaceResource> surf) {
|
||||
return std::find(surfs.begin(), surfs.end(), surf) != surfs.end();
|
||||
return std::find(m_surfs.begin(), m_surfs.end(), surf) != m_surfs.end();
|
||||
}
|
||||
|
||||
void CSeatGrab::add(SP<CWLSurfaceResource> surf) {
|
||||
surfs.emplace_back(surf);
|
||||
m_surfs.emplace_back(surf);
|
||||
}
|
||||
|
||||
void CSeatGrab::remove(SP<CWLSurfaceResource> surf) {
|
||||
std::erase(surfs, surf);
|
||||
if ((keyboard && g_pSeatManager->state.keyboardFocus == surf) || (pointer && g_pSeatManager->state.pointerFocus == surf))
|
||||
std::erase(m_surfs, surf);
|
||||
if ((m_keyboard && g_pSeatManager->m_state.keyboardFocus == surf) || (m_pointer && g_pSeatManager->m_state.pointerFocus == surf))
|
||||
g_pSeatManager->refocusGrab();
|
||||
}
|
||||
|
||||
void CSeatGrab::setCallback(std::function<void()> onEnd_) {
|
||||
onEnd = onEnd_;
|
||||
m_onEnd = onEnd_;
|
||||
}
|
||||
|
||||
void CSeatGrab::clear() {
|
||||
surfs.clear();
|
||||
m_surfs.clear();
|
||||
}
|
||||
|
Reference in New Issue
Block a user