mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 12:49:49 +01:00
store scale and scale windows with monitor
This commit is contained in:
parent
748a787ba2
commit
b0f5e4ab56
6 changed files with 21 additions and 11 deletions
|
@ -157,6 +157,8 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||
|
||||
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;
|
||||
|
||||
PNEWMONITOR->scale = monitorRule.scale;
|
||||
|
||||
g_pCompositor->deactivateAllWLRWorkspaces();
|
||||
wlr_ext_workspace_handle_v1_set_active(PNEWWORKSPACE->m_pWlrHandle, true);
|
||||
//
|
||||
|
|
|
@ -54,4 +54,11 @@ std::string getFormat(const char *fmt, ...) {
|
|||
va_end(args);
|
||||
|
||||
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);
|
||||
}
|
|
@ -4,4 +4,5 @@
|
|||
|
||||
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
|
||||
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);
|
|
@ -14,6 +14,7 @@ struct SMonitor {
|
|||
|
||||
uint64_t ID = -1;
|
||||
int activeWorkspace = -1;
|
||||
float scale = 1;
|
||||
|
||||
std::string szName = "";
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "OpenGL.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../helpers/MiscFunctions.hpp"
|
||||
|
||||
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!");
|
||||
|
@ -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].mirrorFB.m_pStencilTex = &m_mMonitorRenderResources[pMonitor].stencilTex;
|
||||
|
||||
m_mMonitorRenderResources[pMonitor].primaryFB.alloc(pMonitor->vecSize.x, pMonitor->vecSize.y);
|
||||
m_mMonitorRenderResources[pMonitor].mirrorFB.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->scale, pMonitor->vecSize.y * pMonitor->scale);
|
||||
|
||||
createBGTextureForMonitor(pMonitor);
|
||||
}
|
||||
|
@ -162,6 +163,7 @@ void CHyprOpenGLImpl::end() {
|
|||
|
||||
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);
|
||||
|
||||
// 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(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
||||
|
||||
scaleBox(box, m_RenderData.pMonitor->scale);
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
#include "Renderer.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) {
|
||||
const auto TEXTURE = wlr_surface_get_texture(surface);
|
||||
const auto RDATA = (SRenderData*)data;
|
||||
|
@ -465,12 +458,14 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) {
|
|||
|
||||
void CHyprRenderer::damageMonitor(SMonitor* pMonitor) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void CHyprRenderer::renderDragIcon(SMonitor* pMonitor, timespec* time) {
|
||||
|
|
Loading…
Reference in a new issue