store scale and scale windows with monitor

This commit is contained in:
vaxerski 2022-04-17 18:47:10 +02:00
parent 748a787ba2
commit b0f5e4ab56
6 changed files with 21 additions and 11 deletions

View file

@ -157,6 +157,8 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;
PNEWMONITOR->scale = monitorRule.scale;
g_pCompositor->deactivateAllWLRWorkspaces(); g_pCompositor->deactivateAllWLRWorkspaces();
wlr_ext_workspace_handle_v1_set_active(PNEWWORKSPACE->m_pWlrHandle, true); wlr_ext_workspace_handle_v1_set_active(PNEWWORKSPACE->m_pWlrHandle, true);
// //

View file

@ -54,4 +54,11 @@ std::string getFormat(const char *fmt, ...) {
va_end(args); va_end(args);
return std::string(buf); return std::string(buf);
}
void scaleBox(wlr_box* box, float scale) {
box->width = std::round((box->x + box->width) * scale) - std::round(box->x * scale);
box->height = std::round((box->y + box->height) * scale) - std::round(box->y * scale);
box->x = std::round(box->x * scale);
box->y = std::round(box->y * scale);
} }

View file

@ -4,4 +4,5 @@
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString); void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
void wlr_signal_emit_safe(struct wl_signal *signal, void *data); void wlr_signal_emit_safe(struct wl_signal *signal, void *data);
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
void scaleBox(wlr_box*, float);

View file

@ -14,6 +14,7 @@ struct SMonitor {
uint64_t ID = -1; uint64_t ID = -1;
int activeWorkspace = -1; int activeWorkspace = -1;
float scale = 1;
std::string szName = ""; std::string szName = "";

View file

@ -1,5 +1,6 @@
#include "OpenGL.hpp" #include "OpenGL.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "../helpers/MiscFunctions.hpp"
CHyprOpenGLImpl::CHyprOpenGLImpl() { CHyprOpenGLImpl::CHyprOpenGLImpl() {
RASSERT(eglMakeCurrent(g_pCompositor->m_sWLREGL->display, EGL_NO_SURFACE, EGL_NO_SURFACE, g_pCompositor->m_sWLREGL->context), "Couldn't make the EGL current!"); RASSERT(eglMakeCurrent(g_pCompositor->m_sWLREGL->display, EGL_NO_SURFACE, EGL_NO_SURFACE, g_pCompositor->m_sWLREGL->context), "Couldn't make the EGL current!");
@ -140,8 +141,8 @@ void CHyprOpenGLImpl::begin(SMonitor* pMonitor, pixman_region32_t* pDamage) {
m_mMonitorRenderResources[pMonitor].primaryFB.m_pStencilTex = &m_mMonitorRenderResources[pMonitor].stencilTex; m_mMonitorRenderResources[pMonitor].primaryFB.m_pStencilTex = &m_mMonitorRenderResources[pMonitor].stencilTex;
m_mMonitorRenderResources[pMonitor].mirrorFB.m_pStencilTex = &m_mMonitorRenderResources[pMonitor].stencilTex; m_mMonitorRenderResources[pMonitor].mirrorFB.m_pStencilTex = &m_mMonitorRenderResources[pMonitor].stencilTex;
m_mMonitorRenderResources[pMonitor].primaryFB.alloc(pMonitor->vecSize.x, pMonitor->vecSize.y); m_mMonitorRenderResources[pMonitor].primaryFB.alloc(pMonitor->vecSize.x * pMonitor->scale, pMonitor->vecSize.y * pMonitor->scale);
m_mMonitorRenderResources[pMonitor].mirrorFB.alloc(pMonitor->vecSize.x, pMonitor->vecSize.y); m_mMonitorRenderResources[pMonitor].mirrorFB.alloc(pMonitor->vecSize.x * pMonitor->scale, pMonitor->vecSize.y * pMonitor->scale);
createBGTextureForMonitor(pMonitor); createBGTextureForMonitor(pMonitor);
} }
@ -162,6 +163,7 @@ void CHyprOpenGLImpl::end() {
clear(CColor(11, 11, 11, 255)); clear(CColor(11, 11, 11, 255));
scaleBox(&windowBox, m_RenderData.pMonitor->scale);
renderTexture(m_mMonitorRenderResources[m_RenderData.pMonitor].primaryFB.m_cTex, &windowBox, 255.f, 0); renderTexture(m_mMonitorRenderResources[m_RenderData.pMonitor].primaryFB.m_cTex, &windowBox, 255.f, 0);
// reset our data // reset our data
@ -470,6 +472,8 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int thick, i
RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!"); RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!");
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
scaleBox(box, m_RenderData.pMonitor->scale);
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here

View file

@ -1,13 +1,6 @@
#include "Renderer.hpp" #include "Renderer.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
void scaleBox(wlr_box* box, float scale) {
box->width = std::round((box->x + box->width) * scale) - std::round(box->x * scale);
box->height = std::round((box->y + box->height) * scale) - std::round(box->y * scale);
box->x = std::round(box->x * scale);
box->y = std::round(box->y * scale);
}
void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
const auto TEXTURE = wlr_surface_get_texture(surface); const auto TEXTURE = wlr_surface_get_texture(surface);
const auto RDATA = (SRenderData*)data; const auto RDATA = (SRenderData*)data;
@ -465,12 +458,14 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) {
void CHyprRenderer::damageMonitor(SMonitor* pMonitor) { void CHyprRenderer::damageMonitor(SMonitor* pMonitor) {
wlr_box damageBox = {pMonitor->vecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y}; wlr_box damageBox = {pMonitor->vecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y};
scaleBox(&damageBox, pMonitor->scale);
wlr_output_damage_add_box(pMonitor->damage, &damageBox); wlr_output_damage_add_box(pMonitor->damage, &damageBox);
} }
void CHyprRenderer::damageBox(wlr_box* pBox) { void CHyprRenderer::damageBox(wlr_box* pBox) {
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_lMonitors) {
wlr_output_damage_add_box(m.damage, pBox); wlr_output_damage_add_box(m.damage, pBox);
}
} }
void CHyprRenderer::renderDragIcon(SMonitor* pMonitor, timespec* time) { void CHyprRenderer::renderDragIcon(SMonitor* pMonitor, timespec* time) {