summaryrefslogtreecommitdiff
path: root/src/protocols/TearingControl.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-04-19 22:16:35 +0100
committerGitHub <noreply@github.com>2024-04-19 22:16:35 +0100
commitb52a49b4c4c344784b3085cb93d3882d3ce9b4bb (patch)
treea8c3ab6cf77cec5e22565f0f2a3adacfaa6edf30 /src/protocols/TearingControl.hpp
parent1016faea53fd2d6a9bc12340425230b84676d7cd (diff)
tearing-control: hyprland impl (#5655)
* tearing: hl impl * format
Diffstat (limited to 'src/protocols/TearingControl.hpp')
-rw-r--r--src/protocols/TearingControl.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/protocols/TearingControl.hpp b/src/protocols/TearingControl.hpp
new file mode 100644
index 00000000..f0dd8bfa
--- /dev/null
+++ b/src/protocols/TearingControl.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <memory>
+#include "WaylandProtocol.hpp"
+
+class CWindow;
+
+enum eTearingPresentationHint {
+ TEARING_VSYNC = 0,
+ TEARING_ASYNC,
+};
+
+class CTearingControlProtocol;
+
+class CTearingControl {
+ public:
+ CTearingControl(SP<CWaylandResource> resource_, wlr_surface* surf_);
+
+ void onHint(uint32_t hint_);
+
+ bool good();
+
+ bool operator==(const wl_resource* other) const {
+ return other == resource->resource();
+ }
+
+ bool operator==(const CTearingControl* other) const {
+ return other->resource == resource;
+ }
+
+ private:
+ void updateWindow();
+
+ SP<CWaylandResource> resource;
+ CWindow* pWindow = nullptr;
+ eTearingPresentationHint hint = TEARING_VSYNC;
+
+ friend class CTearingControlProtocol;
+};
+
+class CTearingControlProtocol : public IWaylandProtocol {
+ public:
+ CTearingControlProtocol(const wl_interface* iface, const int& ver, const std::string& name);
+
+ virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
+
+ void onManagerResourceDestroy(wl_resource* res);
+ void onControllerDestroy(CTearingControl* control);
+ void onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf);
+
+ private:
+ void onWindowDestroy(CWindow* pWindow);
+
+ std::vector<UP<CWaylandResource>> m_vManagers;
+ std::vector<UP<CTearingControl>> m_vTearingControllers;
+};
+
+namespace PROTO {
+ inline UP<CTearingControlProtocol> tearing;
+}; \ No newline at end of file