Find correct function based on demangled signature

This commit is contained in:
ItsDrike 2023-04-01 00:06:56 +02:00
parent 312eeaeb34
commit 9e665e359c
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -101,12 +101,26 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle)
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "getNodeFromWindow");
g_pNodeFromWindow = (nodeFromWindowT)METHODS[1].address;
originalToggleGroup = g_pKeybindManager->m_mDispatchers["togglegroup"];
HyprlandAPI::addDispatcher(PHANDLE, "togglegroup", toggleGroup);
for (auto& method : METHODS) {
if (method.demangled == "CHyprDwindleLayout::getNodeFromWindow(CWindow*)") {
g_pNodeFromWindow = (nodeFromWindowT)method.address;
break;
}
}
HyprlandAPI::reloadConfig();
if (g_pNodeFromWindow == nullptr) {
Debug::log(ERR, "getNodeFromWindow funnction for dwindle layout wasn't found! This function's signature probably changed, report this");
HyprlandAPI::addNotification(
PHANDLE, "[dwindle-autogroup] Initialization failed!! getNodeFromWindow functio not found", s_pluginColor, 10000);
}
else {
originalToggleGroup = g_pKeybindManager->m_mDispatchers["togglegroup"];
HyprlandAPI::addDispatcher(PHANDLE, "togglegroup", toggleGroup);
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Initialized successfully!", s_pluginColor, 5000);
HyprlandAPI::reloadConfig();
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Initialized successfully!", s_pluginColor, 5000);
}
return {"dwindle-autogroup", "Dwindle Autogroup", "ItsDrike", "1.0"};
}