mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 20:25:59 +01:00
parent
9f5a57ff45
commit
ae50f8614d
7 changed files with 61 additions and 31 deletions
|
@ -175,10 +175,6 @@ CLayerShellResource::~CLayerShellResource() {
|
|||
surface->resetRole();
|
||||
}
|
||||
|
||||
eSurfaceRole CLayerShellResource::role() {
|
||||
return SURFACE_ROLE_LAYER_SHELL;
|
||||
}
|
||||
|
||||
bool CLayerShellResource::good() {
|
||||
return resource->resource();
|
||||
}
|
||||
|
@ -245,8 +241,12 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
|
|||
return;
|
||||
}
|
||||
|
||||
SURF->role = RESOURCE;
|
||||
SURF->role = makeShared<CLayerShellRole>(RESOURCE);
|
||||
g_pCompositor->m_vLayers.emplace_back(CLayerSurface::create(RESOURCE));
|
||||
|
||||
LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get());
|
||||
}
|
||||
|
||||
CLayerShellRole::CLayerShellRole(SP<CLayerShellResource> ls) : layerSurface(ls) {
|
||||
;
|
||||
}
|
||||
|
|
|
@ -12,16 +12,26 @@
|
|||
|
||||
class CMonitor;
|
||||
class CWLSurfaceResource;
|
||||
class CLayerShellResource;
|
||||
|
||||
class CLayerShellResource : public ISurfaceRole {
|
||||
class CLayerShellRole : public ISurfaceRole {
|
||||
public:
|
||||
CLayerShellRole(SP<CLayerShellResource> ls);
|
||||
|
||||
virtual eSurfaceRole role() {
|
||||
return SURFACE_ROLE_LAYER_SHELL;
|
||||
}
|
||||
|
||||
WP<CLayerShellResource> layerSurface;
|
||||
};
|
||||
class CLayerShellResource {
|
||||
public:
|
||||
CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, CMonitor* pMonitor, zwlrLayerShellV1Layer layer);
|
||||
~CLayerShellResource();
|
||||
|
||||
bool good();
|
||||
void configure(const Vector2D& size);
|
||||
void sendClosed();
|
||||
virtual eSurfaceRole role();
|
||||
bool good();
|
||||
void configure(const Vector2D& size);
|
||||
void sendClosed();
|
||||
|
||||
enum eCommittedState {
|
||||
STATE_SIZE = (1 << 0),
|
||||
|
|
|
@ -443,10 +443,6 @@ CXDGSurfaceResource::~CXDGSurfaceResource() {
|
|||
surface->resetRole();
|
||||
}
|
||||
|
||||
eSurfaceRole CXDGSurfaceResource::role() {
|
||||
return SURFACE_ROLE_XDG_SHELL;
|
||||
}
|
||||
|
||||
bool CXDGSurfaceResource::good() {
|
||||
return resource->resource();
|
||||
}
|
||||
|
@ -668,7 +664,7 @@ CXDGWMBase::CXDGWMBase(SP<CXdgWmBase> resource_) : resource(resource_) {
|
|||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->surface = SURF;
|
||||
SURF->role = RESOURCE;
|
||||
SURF->role = makeShared<CXDGSurfaceRole>(RESOURCE);
|
||||
|
||||
surfaces.emplace_back(RESOURCE);
|
||||
|
||||
|
@ -765,3 +761,7 @@ void CXDGShellProtocol::onPopupDestroy(WP<CXDGPopupResource> popup) {
|
|||
if (popup->surface)
|
||||
grab->remove(popup->surface->surface.lock());
|
||||
}
|
||||
|
||||
CXDGSurfaceRole::CXDGSurfaceRole(SP<CXDGSurfaceResource> xdg) : xdgSurface(xdg) {
|
||||
;
|
||||
}
|
||||
|
|
|
@ -141,15 +141,24 @@ class CXDGToplevelResource {
|
|||
void applyState();
|
||||
};
|
||||
|
||||
class CXDGSurfaceResource : public ISurfaceRole {
|
||||
class CXDGSurfaceRole : public ISurfaceRole {
|
||||
public:
|
||||
CXDGSurfaceRole(SP<CXDGSurfaceResource> xdg);
|
||||
|
||||
virtual eSurfaceRole role() {
|
||||
return SURFACE_ROLE_XDG_SHELL;
|
||||
}
|
||||
|
||||
WP<CXDGSurfaceResource> xdgSurface;
|
||||
};
|
||||
|
||||
class CXDGSurfaceResource {
|
||||
public:
|
||||
CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBase> owner_, SP<CWLSurfaceResource> surface_);
|
||||
~CXDGSurfaceResource();
|
||||
|
||||
static SP<CXDGSurfaceResource> fromResource(wl_resource*);
|
||||
|
||||
virtual eSurfaceRole role();
|
||||
|
||||
bool good();
|
||||
|
||||
WP<CXDGWMBase> owner;
|
||||
|
|
|
@ -277,7 +277,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> nodes, std
|
|||
for (auto& n : nodes) {
|
||||
Vector2D offset = {};
|
||||
if (n->role->role() == SURFACE_ROLE_SUBSURFACE) {
|
||||
auto subsurface = (CWLSubsurfaceResource*)n->role.get();
|
||||
auto subsurface = ((CSubsurfaceRole*)n->role.get())->subsurface.lock();
|
||||
offset = subsurface->posRelativeToParent();
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ void CWLSurfaceResource::commitPendingState() {
|
|||
|
||||
// TODO: we should _accumulate_ and not replace above if sync
|
||||
if (role->role() == SURFACE_ROLE_SUBSURFACE) {
|
||||
auto subsurface = (CWLSubsurfaceResource*)role.get();
|
||||
auto subsurface = ((CSubsurfaceRole*)role.get())->subsurface.lock();
|
||||
if (subsurface->sync)
|
||||
return;
|
||||
|
||||
|
@ -458,7 +458,7 @@ void CWLSurfaceResource::commitPendingState() {
|
|||
breadthfirst(
|
||||
[](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) {
|
||||
if (surf->role->role() == SURFACE_ROLE_SUBSURFACE) {
|
||||
auto subsurface = (CWLSubsurfaceResource*)surf->role.get();
|
||||
auto subsurface = ((CSubsurfaceRole*)surf->role.get())->subsurface.lock();
|
||||
if (!subsurface->sync)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ Vector2D CWLSubsurfaceResource::posRelativeToParent() {
|
|||
while (surf->role->role() == SURFACE_ROLE_SUBSURFACE &&
|
||||
std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
|
||||
surfacesVisited.emplace_back(surf);
|
||||
auto subsurface = (CWLSubsurfaceResource*)parent->role.get();
|
||||
auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock();
|
||||
pos += subsurface->position;
|
||||
surf = subsurface->parent.lock();
|
||||
}
|
||||
|
@ -130,10 +130,6 @@ bool CWLSubsurfaceResource::good() {
|
|||
return resource->resource();
|
||||
}
|
||||
|
||||
eSurfaceRole CWLSubsurfaceResource::role() {
|
||||
return SURFACE_ROLE_SUBSURFACE;
|
||||
}
|
||||
|
||||
SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
|
||||
SP<CWLSurfaceResource> surf = parent.lock();
|
||||
std::vector<SP<CWLSurfaceResource>> surfacesVisited;
|
||||
|
@ -141,7 +137,7 @@ SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
|
|||
while (surf->role->role() == SURFACE_ROLE_SUBSURFACE &&
|
||||
std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
|
||||
surfacesVisited.emplace_back(surf);
|
||||
auto subsurface = (CWLSubsurfaceResource*)parent->role.get();
|
||||
auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock();
|
||||
surf = subsurface->parent.lock();
|
||||
}
|
||||
return surf;
|
||||
|
@ -171,7 +167,7 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
|
|||
SP<CWLSurfaceResource> t1Parent = nullptr;
|
||||
|
||||
if (PARENT->role->role() == SURFACE_ROLE_SUBSURFACE) {
|
||||
auto subsurface = (CWLSubsurfaceResource*)PARENT->role.get();
|
||||
auto subsurface = ((CSubsurfaceRole*)PARENT->role.get())->subsurface.lock();
|
||||
t1Parent = subsurface->t1Parent();
|
||||
} else
|
||||
t1Parent = PARENT;
|
||||
|
@ -191,7 +187,7 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
|
|||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
SURF->role = RESOURCE;
|
||||
SURF->role = makeShared<CSubsurfaceRole>(RESOURCE);
|
||||
PARENT->subsurfaces.emplace_back(RESOURCE);
|
||||
|
||||
LOGM(LOG, "New wl_subsurface with id {} at {:x}", id, (uintptr_t)RESOURCE.get());
|
||||
|
@ -225,3 +221,7 @@ void CWLSubcompositorProtocol::destroyResource(CWLSubcompositorResource* resourc
|
|||
void CWLSubcompositorProtocol::destroyResource(CWLSubsurfaceResource* resource) {
|
||||
std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
CSubsurfaceRole::CSubsurfaceRole(SP<CWLSubsurfaceResource> sub) : subsurface(sub) {
|
||||
;
|
||||
}
|
||||
|
|
|
@ -16,15 +16,26 @@
|
|||
#include "../types/SurfaceRole.hpp"
|
||||
|
||||
class CWLSurfaceResource;
|
||||
class CWLSubsurfaceResource;
|
||||
|
||||
class CWLSubsurfaceResource : public ISurfaceRole {
|
||||
class CSubsurfaceRole : public ISurfaceRole {
|
||||
public:
|
||||
CSubsurfaceRole(SP<CWLSubsurfaceResource> sub);
|
||||
|
||||
virtual eSurfaceRole role() {
|
||||
return SURFACE_ROLE_SUBSURFACE;
|
||||
}
|
||||
|
||||
WP<CWLSubsurfaceResource> subsurface;
|
||||
};
|
||||
|
||||
class CWLSubsurfaceResource {
|
||||
public:
|
||||
CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWLSurfaceResource> surface_, SP<CWLSurfaceResource> parent_);
|
||||
~CWLSubsurfaceResource();
|
||||
|
||||
Vector2D posRelativeToParent();
|
||||
bool good();
|
||||
virtual eSurfaceRole role();
|
||||
SP<CWLSurfaceResource> t1Parent();
|
||||
|
||||
bool sync = false;
|
||||
|
|
Loading…
Reference in a new issue