aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-08-27 11:56:55 +0200
committervaxerski <[email protected]>2022-08-27 11:56:55 +0200
commitce5b19cd64bbe79d6124240dc1f21eecefaa65ae (patch)
treef19ffa0b093df841ca27d9b12ede1054ea7b3780
parenta648b452ddc64f1f9507f4f4ec995fb5c6764b9a (diff)
downloadHyprland-ce5b19cd64bbe79d6124240dc1f21eecefaa65ae.tar.gz
Hyprland-ce5b19cd64bbe79d6124240dc1f21eecefaa65ae.zip
initial viewporter implementation
chromium still broken
-rw-r--r--src/Compositor.cpp2
-rw-r--r--src/helpers/Vector2D.hpp4
-rw-r--r--src/render/Renderer.cpp28
3 files changed, 30 insertions, 4 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index f172ce56..10f3ac60 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -94,7 +94,7 @@ CCompositor::CCompositor() {
wlr_data_control_manager_v1_create(m_sWLDisplay);
wlr_gamma_control_manager_v1_create(m_sWLDisplay);
wlr_primary_selection_v1_device_manager_create(m_sWLDisplay);
- // wlr_viewporter_create(m_sWLDisplay); // TODO: support wl_viewporter
+ wlr_viewporter_create(m_sWLDisplay);
m_sWLROutputLayout = wlr_output_layout_create();
diff --git a/src/helpers/Vector2D.hpp b/src/helpers/Vector2D.hpp
index 7ca52a68..557cdb53 100644
--- a/src/helpers/Vector2D.hpp
+++ b/src/helpers/Vector2D.hpp
@@ -35,6 +35,10 @@ class Vector2D {
return a.x != x || a.y != y;
}
+ Vector2D operator*(const Vector2D& a) const {
+ return Vector2D(this->x * a.x, this->y * a.y);
+ }
+
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D());
Vector2D floor();
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 05cde0ba..f5bf7af0 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -233,13 +233,35 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f);
if (!pWindow->m_bIsX11) {
+
+ Vector2D uvTL;
+ Vector2D uvBR = Vector2D(1, 1);
+
+ Vector2D adjustedSurfaceScale = Vector2D(1,1);
+
wlr_box geom;
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
- // first, check for poorly sized windows.
+ // wp_viewporter_v1 implementation
+ if (pWindow->m_uSurface.xdg->surface->current.viewport.has_src) {
+ wlr_fbox bufferSource;
+ wlr_surface_get_buffer_source_box(pWindow->m_uSurface.xdg->surface, &bufferSource);
+
+ Vector2D surfaceSize = Vector2D(pWindow->m_uSurface.xdg->surface->buffer->texture->width, pWindow->m_uSurface.xdg->surface->buffer->texture->height);
- g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D((double)geom.x / (double)pWindow->m_uSurface.xdg->surface->current.width, (double)geom.y / (double)pWindow->m_uSurface.xdg->surface->current.height);
- g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D((double)(geom.width + geom.x) / (double)pWindow->m_uSurface.xdg->surface->current.width, (double)(geom.y + geom.height) / (double)pWindow->m_uSurface.xdg->surface->current.height);
+ uvTL = Vector2D(bufferSource.x / surfaceSize.x, bufferSource.y / surfaceSize.y);
+ uvBR = Vector2D((bufferSource.x + bufferSource.width) / surfaceSize.x, (bufferSource.y + bufferSource.height) / surfaceSize.y);
+
+ adjustedSurfaceScale = Vector2D(bufferSource.width / surfaceSize.x, bufferSource.y / surfaceSize.y);
+ } else {
+ // oversized windows' UV adjusting
+ uvTL = Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width * adjustedSurfaceScale.x), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height * adjustedSurfaceScale.y));
+ uvBR = Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width * adjustedSurfaceScale.x), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height * adjustedSurfaceScale.y));
+ }
+
+ // set UV
+ g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
+ g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR;
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) {
// No special UV mods needed