From a468b15bdacfd0ff5cb458b77738b636d3ccd0f1 Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 16 Jun 2025 18:18:40 +0200 Subject: [PATCH] fix: do not crash instantly with a bad any_cast --- hyprlandd.conf | 98 +------------------------------------------------- src/main.cpp | 33 +++++++++++------ 2 files changed, 24 insertions(+), 107 deletions(-) diff --git a/hyprlandd.conf b/hyprlandd.conf index f9172a0..d6b65ba 100644 --- a/hyprlandd.conf +++ b/hyprlandd.conf @@ -1,107 +1,11 @@ monitor=,preferred,auto,auto # TODO: does not work!! -exec-once=sh -c "hyprctl plugin load $(pwd)/build/src/libhyprwiggle.so" +#exec-once=sh -c "hyprctl plugin load $(pwd)/build/src/libhyprwiggle.so" debug { disable_logs = false } -general { - gaps_in = 5 - gaps_out = 20 - - border_size = 2 - - col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg - col.inactive_border = rgba(595959aa) - resize_on_border = false - allow_tearing = false - layout = dwindle -} - -decoration { - rounding = 10 - rounding_power = 2 - - active_opacity = 1.0 - inactive_opacity = 1.0 - - shadow { - enabled = true - range = 4 - render_power = 3 - color = rgba(1a1a1aee) - } - - blur { - enabled = true - size = 3 - passes = 1 - - vibrancy = 0.1696 - } -} - -animations { - enabled = yes, please :) - - bezier = easeOutQuint,0.23,1,0.32,1 - bezier = easeInOutCubic,0.65,0.05,0.36,1 - bezier = linear,0,0,1,1 - bezier = almostLinear,0.5,0.5,0.75,1.0 - bezier = quick,0.15,0,0.1,1 - - animation = global, 1, 10, default - animation = border, 1, 5.39, easeOutQuint - animation = windows, 1, 4.79, easeOutQuint - animation = windowsIn, 1, 4.1, easeOutQuint, popin 87% - animation = windowsOut, 1, 1.49, linear, popin 87% - animation = fadeIn, 1, 1.73, almostLinear - animation = fadeOut, 1, 1.46, almostLinear - animation = fade, 1, 3.03, quick - animation = layers, 1, 3.81, easeOutQuint - animation = layersIn, 1, 4, easeOutQuint, fade - animation = layersOut, 1, 1.5, linear, fade - animation = fadeLayersIn, 1, 1.79, almostLinear - animation = fadeLayersOut, 1, 1.39, almostLinear - animation = workspaces, 1, 1.94, almostLinear, fade - animation = workspacesIn, 1, 1.21, almostLinear, fade - animation = workspacesOut, 1, 1.94, almostLinear, fade -} - -dwindle { - pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below - preserve_split = true # You probably want this -} - -master { - new_status = master -} - -misc { - force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers - disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :( -} - -input { - kb_layout = us - kb_variant = - kb_model = - kb_options = - kb_rules = - - follow_mouse = 1 - - sensitivity = 0 # -1.0 - 1.0, 0 means no modification. - - touchpad { - natural_scroll = false - } -} - -gestures { - workspace_swipe = false -} ################### ### KEYBINDINGS ### diff --git a/src/main.cpp b/src/main.cpp index 53c49a1..1945181 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,17 +115,17 @@ CFramebuffer* CWindowTransformer::transform(CFramebuffer* in) { return &off; } -void onNewWindow(void* self, std::any data) { +void onNewWindow(std::any data) { // data is guaranteed - auto* const PWINDOW = std::any_cast(data); - + auto PWINDOW = std::any_cast(data); ptrs.push_back(static_cast(PWINDOW->m_transformers.emplace_back(new CWindowTransformer{}).get())); HyprlandAPI::addNotification(PHANDLE, "onnewwindow", CHyprColor{0.f, 1.f, 1.f, 1.f}, 5000); std::println("onnewwindow"); - throw "up"; + Debug::log(ERR,"Hit the function."); } +static SP g_p = nullptr; APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; @@ -135,21 +135,34 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { // ALWAYS add this to your plugins. It will prevent random crashes coming from // mismatched header versions. if (HASH != GIT_COMMIT_HASH) { - HyprlandAPI::addNotification(PHANDLE, "[WiggleWobble] Mismatched headers! Can't proceed.", - CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000); + HyprlandAPI::addNotification( + PHANDLE, + "[WiggleWobble] Mismatched headers! Can't proceed.", + CHyprColor {1.0, 0.2, 0.2, 1.0}, + 5000 + ); throw std::runtime_error("[WiggleWobble] Version mismatch"); } - - static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(self, data); }); + g_p = HyprlandAPI::registerCallbackDynamic( + PHANDLE, + "openWindow", + [](void* self, SCallbackInfo& info, std::any data) { onNewWindow(data); } + ); HyprlandAPI::reloadConfig(); - HyprlandAPI::addNotification(PHANDLE, "[WiggleWobble] Successfully loaded!", CHyprColor{0.f, 1.f, 1.f, 1.f}, 5000); + HyprlandAPI::addNotification( + PHANDLE, + "[WiggleWobble] Successfully loaded!", + CHyprColor {0.f, 1.f, 1.f, 1.f}, + 5000 + ); return {"wigglewobble", "Wobbly windows for Hyprland", "All-Purpose Mat", PLUGIN_VERSION}; } APICALL EXPORT void PLUGIN_EXIT() { - throw "down"; + g_p = nullptr; } +