From 19c646ab4705baaabd8101ce77b7fb5a3ebe4930 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 15 Jul 2022 19:07:06 +0200 Subject: [PATCH 1/6] Minor changes to the renderer's overflow behavior Won't squish base layers anymore --- src/helpers/WLClasses.hpp | 4 ++-- src/render/Renderer.cpp | 31 ++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index ce2d7248..58b6ce72 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -68,8 +68,8 @@ struct SRenderData { // for blurring bool blur = false; - // for windows that animate poorly - bool squishOversized = false; + // only for windows, not popups + bool squishOversized = true; }; struct SExtensionFindingData { diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index d2b5efa9..f9f7d0e3 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -17,11 +17,15 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { else // here we clamp to 2, these might be some tiny specks windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::clamp(surface->current.width, 2, 1337420), std::clamp(surface->current.height, 2, 1337420)}; - // squish all oversized + // squish all oversized but dont in some cases, jesus christ this is a mess + // TODO: this shouldn't be done this way. Custom UV here as well. + // this is fucking horrible + // Issue: will cause oversized apps with reserved area to overflow from the window box. (see chromium on ozone wayland) + const auto PRESQUISHSIZE = Vector2D(windowBox.width, windowBox.height); if (RDATA->squishOversized) { if (x + windowBox.width > RDATA->w) windowBox.width = RDATA->w - x; - if (y + windowBox.height > RDATA->h) + if (y + windowBox.height > RDATA->h) windowBox.height = RDATA->h - y; } @@ -48,6 +52,12 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { wlr_box geo; wlr_xdg_surface_get_geometry(wlr_xdg_surface_from_wlr_surface(RDATA->surface), &geo); + // TODO: continuation of the above madness. + if (geo.x != 0 || geo.y != 0) { + windowBox.width = PRESQUISHSIZE.x; + windowBox.height = PRESQUISHSIZE.y; + } + windowBox.x -= geo.x; windowBox.y -= geo.y; } @@ -182,7 +192,6 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL); renderdata.rounding = pWindow->m_sAdditionalConfigData.rounding; renderdata.blur = true; // if it shouldn't, it will be ignored later - renderdata.squishOversized = pWindow->m_vRealPosition.isBeingAnimated(); // apply window special data if (pWindow->m_sSpecialRenderData.alphaInactive == -1) @@ -202,6 +211,8 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* wlr_box geom; wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom); + // first, check for poorly sized windows. + 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); @@ -210,6 +221,19 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); } + + // then, if the surface is too big, modify the pos UV + if (geom.width > renderdata.w + 1 || geom.height > renderdata.h + 1) { + const auto OFF = Vector2D(renderdata.w / (double)geom.width, renderdata.h / (double)geom.height); + + if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1)) + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0); + + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D( + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * ((double)renderdata.w / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)), + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * ((double)renderdata.h / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y)) + ); + } } else { g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); @@ -225,6 +249,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* if (!pWindow->m_bIsX11) { renderdata.dontRound = false; // restore dontround renderdata.pMonitor = pMonitor; + renderdata.squishOversized = false; // don't squish popups wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata); } } From 144185681125df1567ada00c301e9ce242909f27 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 15 Jul 2022 19:21:13 +0200 Subject: [PATCH 2/6] fix blur on oversized, default to enabled --- src/config/ConfigManager.cpp | 2 +- src/render/OpenGL.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index e3db1856..e67eda30 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -63,7 +63,7 @@ void CConfigManager::setDefaultVars() { configValues["decoration:inactive_opacity"].floatValue = 1; configValues["decoration:fullscreen_opacity"].floatValue = 1; configValues["decoration:multisample_edges"].intValue = 1; - configValues["decoration:no_blur_on_oversized"].intValue = 1; + configValues["decoration:no_blur_on_oversized"].intValue = 0; configValues["decoration:drop_shadow"].intValue = 1; configValues["decoration:shadow_range"].intValue = 4; configValues["decoration:shadow_render_power"].intValue = 3; diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index d60e827e..a8c669d7 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -567,7 +567,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, } if (!pixman_region32_not_empty(&inverseOpaque)) { - renderTexture(tex, pBox, a, round, false); // reject blurring a fully opaque window + renderTexture(tex, pBox, a, round, false, true); // reject blurring a fully opaque window return; } @@ -590,7 +590,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - renderTexture(tex, pBox, a, round, true); // discard opaque + renderTexture(tex, pBox, a, round, true, true); // discard opaque glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilFunc(GL_EQUAL, 1, -1); @@ -601,7 +601,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, if (pixman_region32_not_empty(&damage)) { // render our great blurred FB static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue; - renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, true); + renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, false); // render the window, but clear stencil glClearStencil(0); From 90ebeaa881453c2870b6847b3b533363a293f5ba Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 15 Jul 2022 19:33:09 +0200 Subject: [PATCH 3/6] fixed fullscreen opacity on fullscreen 1 --- src/layout/DwindleLayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 2d9eab0f..c356c8cc 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -548,8 +548,6 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree pWindow->m_bIsFullscreen = on; PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow; - g_pCompositor->updateWindowAnimatedDecorationValues(pWindow); - g_pEventManager->postEvent(SHyprIPCEvent("fullscreen", std::to_string((int)on))); if (!pWindow->m_bIsFullscreen) { @@ -594,6 +592,8 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree } } + g_pCompositor->updateWindowAnimatedDecorationValues(pWindow); + g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv()); g_pCompositor->moveWindowToTop(pWindow); From fbcc6936f4dc676ff2970e44a919ebc6e24627d3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 15 Jul 2022 20:07:52 +0200 Subject: [PATCH 4/6] fix dashes in hyprctl --- hyprctl/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 92ab4f5e..f2f4b712 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -215,7 +215,7 @@ int main(int argc, char** argv) { const auto ARGS = splitArgs(argc, argv); for (auto i = 0; i < ARGS.size(); ++i) { - if (ARGS[i].contains("-")) { + if (ARGS[i][0] == '-') { // parse if (ARGS[i] == "-j" && !fullArgs.contains("j")) { fullArgs += "j"; From db693ec7e590138517fe1b1f3ac0e409dbbea211 Mon Sep 17 00:00:00 2001 From: Daniel Gerblick Date: Fri, 15 Jul 2022 15:39:39 -0400 Subject: [PATCH 5/6] Fixed SEGFAULT when running hyprctl with only the -j option --- hyprctl/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 92ab4f5e..b52d6d15 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -232,6 +232,11 @@ int main(int argc, char** argv) { fullRequest += ARGS[i] + " "; } + if (fullRequest.empty()) { + printf("%s\n", USAGE.c_str()); + return 1; + } + fullRequest.pop_back(); // remove trailing space fullRequest = fullArgs + "/" + fullRequest; From b2650928eac06e3181ad07efe6ec55b2550f89b8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Jul 2022 00:11:21 +0200 Subject: [PATCH 6/6] obey xdg reqs better --- src/Window.hpp | 4 ++++ src/events/Events.hpp | 4 ++++ src/events/Windows.cpp | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/Window.hpp b/src/Window.hpp index 3bef02b1..26046aa0 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -31,6 +31,10 @@ public: DYNLISTENER(setGeometryX11U); DYNLISTENER(fullscreenWindow); DYNLISTENER(newPopupXDG); + DYNLISTENER(requestMove); + DYNLISTENER(requestMinimize); + DYNLISTENER(requestMaximize); + DYNLISTENER(requestResize); // DYNLISTENER(newSubsurfaceWindow); union { diff --git a/src/events/Events.hpp b/src/events/Events.hpp index 63e65fdc..320feaa4 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -50,6 +50,10 @@ namespace Events { DYNLISTENFUNC(activateX11); DYNLISTENFUNC(configureX11); DYNLISTENFUNC(unmanagedSetGeometry); + DYNLISTENFUNC(requestMove); + DYNLISTENFUNC(requestResize); + DYNLISTENFUNC(requestMinimize); + DYNLISTENFUNC(requestMaximize); // Window subsurfaces // LISTENER(newSubsurfaceWindow); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 3d46931e..afedcf34 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -251,6 +251,10 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XDG Window Late"); PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XDG Window Late"); PWINDOW->hyprListener_newPopupXDG.initCallback(&PWINDOW->m_uSurface.xdg->events.new_popup, &Events::listener_newPopupXDG, PWINDOW, "XDG Window Late"); + PWINDOW->hyprListener_requestMaximize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_maximize, &Events::listener_requestMaximize, PWINDOW, "XDG Window Late"); + PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_minimize, &Events::listener_requestMinimize, PWINDOW, "XDG Window Late"); + PWINDOW->hyprListener_requestMove.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_move, &Events::listener_requestMove, PWINDOW, "XDG Window Late"); + PWINDOW->hyprListener_requestResize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_resize, &Events::listener_requestResize, PWINDOW, "XDG Window Late"); } else { PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late"); @@ -309,6 +313,10 @@ void Events::listener_unmapWindow(void* owner, void* data) { PWINDOW->hyprListener_setTitleWindow.removeCallback(); PWINDOW->hyprListener_fullscreenWindow.removeCallback(); PWINDOW->hyprListener_newPopupXDG.removeCallback(); + PWINDOW->hyprListener_requestMaximize.removeCallback(); + PWINDOW->hyprListener_requestMinimize.removeCallback(); + PWINDOW->hyprListener_requestMove.removeCallback(); + PWINDOW->hyprListener_requestResize.removeCallback(); } else { Debug::log(LOG, "Unregistered late callbacks XWL: %x %x %x %x", &PWINDOW->hyprListener_fullscreenWindow.m_sListener.link, &PWINDOW->hyprListener_activateX11.m_sListener.link, &PWINDOW->hyprListener_configureX11.m_sListener.link, &PWINDOW->hyprListener_setTitleWindow.m_sListener.link); PWINDOW->hyprListener_fullscreenWindow.removeCallback(); @@ -442,6 +450,8 @@ void Events::listener_fullscreenWindow(void* owner, void* data) { if (REQUESTED->fullscreen != PWINDOW->m_bIsFullscreen) g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW, FULLSCREEN_FULL, REQUESTED->fullscreen); + + wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg); } else { g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW, FULLSCREEN_FULL, !PWINDOW->m_bIsFullscreen); } @@ -564,3 +574,28 @@ void Events::listener_NewXDGDeco(wl_listener* listener, void* data) { const auto WLRDECO = (wlr_xdg_toplevel_decoration_v1*)data; wlr_xdg_toplevel_decoration_v1_set_mode(WLRDECO, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } + +void Events::listener_requestMaximize(void* owner, void* data) { + const auto PWINDOW = (CWindow*)owner; + + // ignore + wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg); +} + +void Events::listener_requestMinimize(void* owner, void* data) { + // ignore +} + +void Events::listener_requestMove(void* owner, void* data) { + const auto PWINDOW = (CWindow*)owner; + + // ignore + wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg); +} + +void Events::listener_requestResize(void* owner, void* data) { + const auto PWINDOW = (CWindow*)owner; + + // ignore + wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg); +} \ No newline at end of file