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