output: send enter events on late wl_output binds

fixes #6560
This commit is contained in:
Vaxry 2024-10-16 21:59:29 +01:00
parent 0baf166d39
commit 781828a56e
3 changed files with 29 additions and 0 deletions

View file

@ -589,3 +589,9 @@ void CWLCompositorProtocol::destroyResource(CWLSurfaceResource* resource) {
void CWLCompositorProtocol::destroyResource(CWLRegionResource* resource) {
std::erase_if(m_vRegions, [&](const auto& other) { return other.get() == resource; });
}
void CWLCompositorProtocol::forEachSurface(std::function<void(SP<CWLSurfaceResource>)> fn) {
for (auto& surf : m_vSurfaces) {
fn(surf);
}
}

View file

@ -169,6 +169,8 @@ class CWLCompositorProtocol : public IWaylandProtocol {
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
void forEachSurface(std::function<void(SP<CWLSurfaceResource>)> fn);
struct {
CSignal newSurface; // SP<CWLSurfaceResource>
} events;

View file

@ -1,4 +1,6 @@
#include "Output.hpp"
#include "Compositor.hpp"
#include "../../Compositor.hpp"
#include "../../helpers/Monitor.hpp"
CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, SP<CMonitor> pMonitor) : monitor(pMonitor), resource(resource_) {
@ -27,6 +29,25 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, SP<CMonitor> pMoni
}
updateState();
PROTO::compositor->forEachSurface([](SP<CWLSurfaceResource> surf) {
auto HLSurf = CWLSurface::fromResource(surf);
if (!HLSurf)
return;
const auto GEOMETRY = HLSurf->getSurfaceBoxGlobal();
if (!GEOMETRY.has_value())
return;
for (auto& m : g_pCompositor->m_vMonitors) {
if (!m->logicalBox().overlaps(*GEOMETRY))
continue;
surf->enter(m);
}
});
}
SP<CWLOutputResource> CWLOutputResource::fromResource(wl_resource* res) {