diff --git a/CMakeLists.txt b/CMakeLists.txt index fe9bc5f7..9f7df0c7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,7 +274,6 @@ protocol("stable/xdg-shell/xdg-shell.xml" "xdg-shell" false) protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false) protocol("unstable/xdg-output/xdg-output-unstable-v1.xml" "xdg-output-unstable-v1" false) protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false) -protocol("staging/tearing-control/tearing-control-v1.xml" "tearing-control-v1" false) protocol("unstable/text-input/text-input-unstable-v1.xml" "text-input-unstable-v1" false) protocol("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false) protocolNew("staging/tearing-control/tearing-control-v1.xml" "tearing-control-v1" false) diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index f6cb66df..31220276 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -3,7 +3,7 @@ #include "../protocols/TearingControl.hpp" #include "xdg-output-unstable-v1-protocol.h" -#include "tearing-control-v1-protocol.h" +#include "tearing-control-v1.hpp" CProtocolManager::CProtocolManager() { m_pToplevelExportProtocolManager = std::make_unique(); diff --git a/src/protocols/TearingControl.cpp b/src/protocols/TearingControl.cpp index 4cc7a9c2..d7225fd3 100644 --- a/src/protocols/TearingControl.cpp +++ b/src/protocols/TearingControl.cpp @@ -1,5 +1,4 @@ #include "TearingControl.hpp" -#include "tearing-control-v1-protocol.h" #include "../managers/ProtocolManager.hpp" #include "../desktop/Window.hpp" #include "../Compositor.hpp" @@ -22,10 +21,8 @@ void CTearingControlProtocol::onManagerResourceDestroy(wl_resource* res) { } void CTearingControlProtocol::onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf) { - const auto CONTROLLER = m_vTearingControllers - .emplace_back(std::make_unique( - std::make_shared(client, wl_resource_get_version(resource), id), surf)) - .get(); + const auto CONTROLLER = + m_vTearingControllers.emplace_back(std::make_unique(std::make_shared(client, wl_resource_get_version(resource), id), surf)).get(); if (!CONTROLLER->good()) { m_vTearingControllers.pop_back(); @@ -50,7 +47,7 @@ CTearingControl::CTearingControl(SP resource_, wlr_surface* resource->setData(this); resource->setOnDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); }); resource->setDestroy([this](wl_client* c, wl_resource* res) { PROTO::tearing->onControllerDestroy(this); }); - resource->setSetPresentationHint([this](wl_client* c, wl_resource* res, uint32_t hint) { this->onHint(hint); }); + resource->setSetPresentationHint([this](wl_client* c, wl_resource* res, tearingControlV1PresentationHint hint) { this->onHint(hint); }); for (auto& w : g_pCompositor->m_vWindows) { if (w->m_pWLSurface.wlr() == surf_) { @@ -60,8 +57,8 @@ CTearingControl::CTearingControl(SP resource_, wlr_surface* } } -void CTearingControl::onHint(uint32_t hint_) { - hint = hint_ == WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC ? TEARING_VSYNC : TEARING_ASYNC; +void CTearingControl::onHint(tearingControlV1PresentationHint hint_) { + hint = hint_; updateWindow(); } @@ -69,7 +66,7 @@ void CTearingControl::updateWindow() { if (!pWindow) return; - pWindow->m_bTearingHint = hint == TEARING_ASYNC; + pWindow->m_bTearingHint = hint == PRESENTATION_HINT_ASYNC; } bool CTearingControl::good() { diff --git a/src/protocols/TearingControl.hpp b/src/protocols/TearingControl.hpp index 249c0472..169c3fff 100644 --- a/src/protocols/TearingControl.hpp +++ b/src/protocols/TearingControl.hpp @@ -5,19 +5,13 @@ #include "tearing-control-v1.hpp" class CWindow; - -enum eTearingPresentationHint { - TEARING_VSYNC = 0, - TEARING_ASYNC, -}; - class CTearingControlProtocol; class CTearingControl { public: CTearingControl(SP resource_, wlr_surface* surf_); - void onHint(uint32_t hint_); + void onHint(tearingControlV1PresentationHint hint_); bool good(); @@ -30,11 +24,11 @@ class CTearingControl { } private: - void updateWindow(); + void updateWindow(); - SP resource; - CWindow* pWindow = nullptr; - eTearingPresentationHint hint = TEARING_VSYNC; + SP resource; + CWindow* pWindow = nullptr; + tearingControlV1PresentationHint hint = PRESENTATION_HINT_VSYNC; friend class CTearingControlProtocol; }; @@ -50,10 +44,10 @@ class CTearingControlProtocol : public IWaylandProtocol { void onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf); private: - void onWindowDestroy(CWindow* pWindow); + void onWindowDestroy(CWindow* pWindow); std::vector> m_vManagers; - std::vector> m_vTearingControllers; + std::vector> m_vTearingControllers; }; namespace PROTO {