This commit is contained in:
Vaxry 2024-04-20 03:16:01 +01:00
parent 63ff7997e8
commit 558dd1c734
4 changed files with 14 additions and 24 deletions

View file

@ -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)

View file

@ -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<CToplevelExportProtocolManager>();

View file

@ -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<CTearingControl>(
std::make_shared<CWpTearingControlV1>(client, wl_resource_get_version(resource), id), surf))
.get();
const auto CONTROLLER =
m_vTearingControllers.emplace_back(std::make_unique<CTearingControl>(std::make_shared<CWpTearingControlV1>(client, wl_resource_get_version(resource), id), surf)).get();
if (!CONTROLLER->good()) {
m_vTearingControllers.pop_back();
@ -50,7 +47,7 @@ CTearingControl::CTearingControl(SP<CWpTearingControlV1> 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<CWpTearingControlV1> 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() {

View file

@ -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<CWpTearingControlV1> 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<CWpTearingControlV1> resource;
CWindow* pWindow = nullptr;
eTearingPresentationHint hint = TEARING_VSYNC;
SP<CWpTearingControlV1> 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<UP<CWpTearingControlManagerV1>> m_vManagers;
std::vector<UP<CTearingControl>> m_vTearingControllers;
std::vector<UP<CTearingControl>> m_vTearingControllers;
};
namespace PROTO {