mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2026-05-08 19:58:01 +02:00
hyprscrolling: register built-in scrolling algorithm API
This commit is contained in:
parent
b85a56b953
commit
c275f74c12
2 changed files with 6 additions and 26 deletions
|
|
@ -9,6 +9,6 @@ CXXFLAGS ?= -O2
|
|||
CXXFLAGS += -shared -fPIC -std=c++2b
|
||||
|
||||
all:
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(EXTRA_FLAGS) main.cpp Scrolling.cpp -o hyprscrolling.so `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon`
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(EXTRA_FLAGS) main.cpp -o hyprscrolling.so `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon`
|
||||
clean:
|
||||
rm ./hyprscrolling.so
|
||||
|
|
|
|||
|
|
@ -1,33 +1,15 @@
|
|||
#define WLR_USE_UNSTABLE
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <hyprland/src/includes.hpp>
|
||||
#include <sstream>
|
||||
|
||||
#define private public
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <hyprland/src/desktop/DesktopTypes.hpp>
|
||||
#include <hyprland/src/config/ConfigManager.hpp>
|
||||
#include <hyprland/src/render/Renderer.hpp>
|
||||
#include <hyprland/src/managers/KeybindManager.hpp>
|
||||
#undef private
|
||||
|
||||
#include <hyprutils/string/VarList.hpp>
|
||||
using namespace Hyprutils::String;
|
||||
#include <hyprland/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp>
|
||||
|
||||
#include "globals.hpp"
|
||||
#include "Scrolling.hpp"
|
||||
|
||||
// Do NOT change this function.
|
||||
APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
||||
return HYPRLAND_API_VERSION;
|
||||
}
|
||||
|
||||
UP<CScrollingLayout> g_pScrollingLayout;
|
||||
|
||||
//
|
||||
|
||||
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
PHANDLE = handle;
|
||||
|
||||
|
|
@ -40,9 +22,9 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
throw std::runtime_error("[hs] Version mismatch");
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
|
||||
g_pScrollingLayout = makeUnique<CScrollingLayout>();
|
||||
bool success = HyprlandAPI::addTiledAlgo(PHANDLE, "scrolling", &typeid(Layout::Tiled::CScrollingAlgorithm), []() -> UP<Layout::ITiledAlgorithm> {
|
||||
return makeUnique<Layout::Tiled::CScrollingAlgorithm>();
|
||||
});
|
||||
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:fullscreen_on_one_column", Hyprlang::INT{0});
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:column_width", Hyprlang::FLOAT{0.5F});
|
||||
|
|
@ -50,7 +32,6 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:follow_focus", Hyprlang::INT{1});
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:follow_debounce_ms", Hyprlang::INT{0});
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:explicit_column_widths", Hyprlang::STRING{"0.333, 0.5, 0.667, 1.0"});
|
||||
HyprlandAPI::addLayout(PHANDLE, "scrolling", g_pScrollingLayout.get());
|
||||
|
||||
if (!success) {
|
||||
HyprlandAPI::addNotification(PHANDLE, "[hyprscrolling] Failure in initialization: failed to register dispatchers", CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
|
||||
|
|
@ -61,6 +42,5 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
}
|
||||
|
||||
APICALL EXPORT void PLUGIN_EXIT() {
|
||||
HyprlandAPI::removeLayout(PHANDLE, g_pScrollingLayout.get());
|
||||
g_pScrollingLayout.reset();
|
||||
HyprlandAPI::removeAlgo(PHANDLE, "scrolling");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue