This commit is contained in:
tempox777 2025-12-18 19:51:28 +01:00 committed by GitHub
commit af3d69f197
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View file

@ -310,6 +310,12 @@ void CWLSurfaceResource::leave(PHLMONITOR monitor) {
return;
}
if (!m_current.callbacks.empty()) {
if (std::ranges::find(m_pendingLeaveOutputs, monitor) == m_pendingLeaveOutputs.end())
m_pendingLeaveOutputs.emplace_back(monitor);
return;
}
std::erase(m_enteredOutputs, monitor);
m_resource->sendLeave(output->getResource().get());
@ -337,6 +343,26 @@ void CWLSurfaceResource::frame(const Time::steady_tp& now) {
}
m_current.callbacks.clear();
if (!m_pendingLeaveOutputs.empty()) {
for (auto const& monitor : m_pendingLeaveOutputs) {
if UNLIKELY (std::ranges::find(m_enteredOutputs, monitor) == m_enteredOutputs.end())
continue;
if UNLIKELY (!PROTO::outputs.contains(monitor->m_name))
continue;
auto output = PROTO::outputs.at(monitor->m_name)->outputResourceFrom(m_client);
if UNLIKELY (!output)
continue;
std::erase(m_enteredOutputs, monitor);
m_resource->sendLeave(output->getResource().get());
m_events.leave.emit(monitor);
}
m_pendingLeaveOutputs.clear();
}
}
void CWLSurfaceResource::resetRole() {
@ -457,6 +483,8 @@ void CWLSurfaceResource::unmap() {
m_mapped = false;
m_pendingLeaveOutputs.clear();
// release the buffers.
// this is necessary for XWayland to function correctly,
// as it does not unmap via the traditional commit(null buffer) method, but via the X11 protocol.

View file

@ -138,6 +138,8 @@ class CWLSurfaceResource {
SP<CWlSurface> m_resource;
wl_client* m_client = nullptr;
std::vector<PHLMONITORREF> m_pendingLeaveOutputs;
void destroy();
void releaseBuffers(bool onlyCurrent = true);
void dropPendingBuffer();