diff --git a/csgo-vulkan-fix/main.cpp b/csgo-vulkan-fix/main.cpp index 0940c33..0aed29d 100644 --- a/csgo-vulkan-fix/main.cpp +++ b/csgo-vulkan-fix/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "globals.hpp" @@ -14,7 +15,7 @@ inline CFunctionHook* g_pSurfaceSizeHook = nullptr; inline CFunctionHook* g_pSurfaceDamageHook = nullptr; inline CFunctionHook* g_pWLSurfaceDamageHook = nullptr; typedef void (*origMotion)(wlr_seat*, uint32_t, double, double); -typedef void (*origSurfaceSize)(wlr_xwayland_surface*, int16_t, int16_t, uint16_t, uint16_t); +typedef void (*origSurfaceSize)(CXWaylandSurface*, const CBox&); typedef void (*origSurfaceDamage)(wlr_surface*, pixman_region32_t*); typedef CRegion (*origWLSurfaceDamage)(CWLSurface*); @@ -37,27 +38,29 @@ void hkNotifyMotion(wlr_seat* wlr_seat, uint32_t time_msec, double sx, double sy (*(origMotion)g_pMouseMotionHook->m_pOriginal)(wlr_seat, time_msec, sx, sy); } -void hkSetWindowSize(wlr_xwayland_surface* surface, int16_t x, int16_t y, uint16_t width, uint16_t height) { +void hkSetWindowSize(CXWaylandSurface* surface, const CBox& box) { static auto* const RESX = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_w")->getDataStaticPtr(); static auto* const RESY = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h")->getDataStaticPtr(); static auto* const PCLASS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:class")->getDataStaticPtr(); if (!surface) { - (*(origSurfaceSize)g_pSurfaceSizeHook->m_pOriginal)(surface, x, y, width, height); + (*(origSurfaceSize)g_pSurfaceSizeHook->m_pOriginal)(surface, box); return; } const auto SURF = surface->surface; const auto PWINDOW = g_pCompositor->getWindowFromSurface(SURF); + CBox newBox = box; + if (PWINDOW && PWINDOW->m_szInitialClass == *PCLASS) { - width = **RESX; - height = **RESY; + newBox.w = **RESX; + newBox.h = **RESY; CWLSurface::surfaceFromWlr(SURF)->m_bFillIgnoreSmall = true; } - (*(origSurfaceSize)g_pSurfaceSizeHook->m_pOriginal)(surface, x, y, width, height); + (*(origSurfaceSize)g_pSurfaceSizeHook->m_pOriginal)(surface, newBox); } void hkSurfaceDamage(wlr_surface* surface, pixman_region32_t* damage) { @@ -111,10 +114,15 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { bool success = !FNS.empty(); if (success) g_pMouseMotionHook = HyprlandAPI::createFunctionHook(PHANDLE, FNS[0].address, (void*)::hkNotifyMotion); - FNS = HyprlandAPI::findFunctionsByName(PHANDLE, "wlr_xwayland_surface_configure"); - success = success && !FNS.empty(); - if (success) - g_pSurfaceSizeHook = HyprlandAPI::createFunctionHook(PHANDLE, FNS[0].address, (void*)::hkSetWindowSize); + FNS = HyprlandAPI::findFunctionsByName(PHANDLE, "configure"); + for (auto& fn : FNS) { + if (!fn.signature.contains("XWaylandSurface")) + continue; + + g_pSurfaceSizeHook = HyprlandAPI::createFunctionHook(PHANDLE, fn.address, (void*)::hkSetWindowSize); + } + success = success && g_pSurfaceSizeHook; + FNS = HyprlandAPI::findFunctionsByName(PHANDLE, "wlr_surface_get_effective_damage"); success = success && !FNS.empty(); if (success)