mirror of
https://github.com/ItsDrike/hyprland-dwindle-autogroup.git
synced 2024-11-10 02:59:41 +00:00
Add custom wrapper overriding togglegroup dispatcher
This commit is contained in:
parent
1ae38874f2
commit
2788905750
25
src/main.cpp
25
src/main.cpp
|
@ -2,8 +2,23 @@
|
||||||
|
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
|
|
||||||
|
#include <src/layout/DwindleLayout.hpp>
|
||||||
|
#include <src/managers/KeybindManager.hpp>
|
||||||
|
#include <src/managers/LayoutManager.hpp>
|
||||||
|
|
||||||
const CColor s_pluginColor = {0x61 / 255.0f, 0xAF / 255.0f, 0xEF / 255.0f, 1.0f};
|
const CColor s_pluginColor = {0x61 / 255.0f, 0xAF / 255.0f, 0xEF / 255.0f, 1.0f};
|
||||||
|
|
||||||
|
inline std::function<void(std::string)> originalToggleGroup = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
void toggleGroup(std::string args)
|
||||||
|
{
|
||||||
|
// Run the original function, creating the group
|
||||||
|
originalToggleGroup(args);
|
||||||
|
|
||||||
|
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Group toggeld!", s_pluginColor, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
// Do NOT change this function.
|
// Do NOT change this function.
|
||||||
APICALL EXPORT std::string PLUGIN_API_VERSION()
|
APICALL EXPORT std::string PLUGIN_API_VERSION()
|
||||||
{
|
{
|
||||||
|
@ -14,14 +29,22 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle)
|
||||||
{
|
{
|
||||||
PHANDLE = handle;
|
PHANDLE = handle;
|
||||||
|
|
||||||
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Initialized successfully!", s_pluginColor, 5000);
|
originalToggleGroup = g_pKeybindManager->m_mDispatchers["togglegroup"];
|
||||||
|
HyprlandAPI::addDispatcher(PHANDLE, "togglegroup", toggleGroup);
|
||||||
|
|
||||||
HyprlandAPI::reloadConfig();
|
HyprlandAPI::reloadConfig();
|
||||||
|
|
||||||
|
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Initialized successfully!", s_pluginColor, 5000);
|
||||||
|
|
||||||
return {"dwindle-autogroup", "Dwindle Autogroup", "ItsDrike", "1.0"};
|
return {"dwindle-autogroup", "Dwindle Autogroup", "ItsDrike", "1.0"};
|
||||||
}
|
}
|
||||||
|
|
||||||
APICALL EXPORT void PLUGIN_EXIT()
|
APICALL EXPORT void PLUGIN_EXIT()
|
||||||
{
|
{
|
||||||
|
// Since we added the "togglegroup" dispatcher ourselves, by default, the cleanup would just remove it
|
||||||
|
// but we want to restore it back to the original function instead
|
||||||
|
HyprlandAPI::removeDispatcher(PHANDLE, "togglegroup");
|
||||||
|
g_pKeybindManager->m_mDispatchers["togglegroup"] = originalToggleGroup;
|
||||||
|
|
||||||
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Unloaded successfully!", s_pluginColor, 5000);
|
HyprlandAPI::addNotification(PHANDLE, "[dwindle-autogroup] Unloaded successfully!", s_pluginColor, 5000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue