desktop: cleanup, unify desktop elements as views (#12563)

This commit is contained in:
Vaxry 2025-12-08 15:04:40 +00:00 committed by GitHub
parent 834f019bab
commit 920353370b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
105 changed files with 2636 additions and 2337 deletions

View file

@ -356,7 +356,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
break;
if (c->m_surface.expired())
continue;
nodes2.push_back(c->m_surface.lock());
nodes2.emplace_back(c->m_surface.lock());
}
}
@ -381,7 +381,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
continue;
if (c->m_surface.expired())
continue;
nodes2.push_back(c->m_surface.lock());
nodes2.emplace_back(c->m_surface.lock());
}
}
@ -391,7 +391,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data) {
std::vector<SP<CWLSurfaceResource>> surfs;
surfs.push_back(m_self.lock());
surfs.emplace_back(m_self.lock());
bfHelper(surfs, fn, data);
}
@ -558,7 +558,9 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
SImageDescription CWLSurfaceResource::getPreferredImageDescription() {
static const auto PFORCE_HDR = CConfigValue<Hyprlang::INT>("quirks:prefer_hdr");
if (*PFORCE_HDR == 1 || (*PFORCE_HDR == 2 && m_hlSurface && m_hlSurface->getWindow() && m_hlSurface->getWindow()->m_class == "gamescope"))
const auto WINDOW = Desktop::View::CWindow::fromView(m_hlSurface->view());
if (*PFORCE_HDR == 1 || (*PFORCE_HDR == 2 && m_hlSurface && WINDOW && WINDOW->m_class == "gamescope"))
return g_pCompositor->getHDRImageDescription();
auto parent = m_self;
@ -569,8 +571,8 @@ SImageDescription CWLSurfaceResource::getPreferredImageDescription() {
WP<CMonitor> monitor;
if (parent->m_enteredOutputs.size() == 1)
monitor = parent->m_enteredOutputs[0];
else if (m_hlSurface.valid() && m_hlSurface->getWindow())
monitor = m_hlSurface->getWindow()->m_monitor;
else if (m_hlSurface.valid() && WINDOW)
monitor = WINDOW->m_monitor;
return monitor ? monitor->m_imageDescription : g_pCompositor->getPreferredImageDescription();
}

View file

@ -15,6 +15,7 @@
#include "../../render/Texture.hpp"
#include "../types/SurfaceStateQueue.hpp"
#include "wayland.hpp"
#include "../../desktop/view/WLSurface.hpp"
#include "../../helpers/signal/Signal.hpp"
#include "../../helpers/math/Math.hpp"
#include "../../helpers/time/Time.hpp"
@ -25,7 +26,6 @@
class CWLOutputResource;
class CMonitor;
class CWLSurface;
class CWLSurfaceResource;
class CWLSubsurfaceResource;
class CViewportResource;
@ -109,7 +109,7 @@ class CWLSurfaceResource {
CSurfaceStateQueue m_stateQueue;
WP<CWLSurfaceResource> m_self;
WP<CWLSurface> m_hlSurface;
WP<Desktop::View::CWLSurface> m_hlSurface;
std::vector<PHLMONITORREF> m_enteredOutputs;
bool m_mapped = false;
std::vector<WP<CWLSubsurfaceResource>> m_subsurfaces;

View file

@ -603,7 +603,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
m_dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) {
auto V = std::any_cast<const Vector2D>(e);
if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
if (!surf)
return;
@ -621,7 +621,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
m_dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) {
auto E = std::any_cast<ITouch::SMotionEvent>(e);
if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
if (!surf)
return;

View file

@ -31,7 +31,7 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonito
updateState();
PROTO::compositor->forEachSurface([](SP<CWLSurfaceResource> surf) {
auto HLSurf = CWLSurface::fromResource(surf);
auto HLSurf = Desktop::View::CWLSurface::fromResource(surf);
if (!HLSurf)
return;