fix: do not crash instantly with a bad any_cast

This commit is contained in:
Matias 2025-06-16 18:18:40 +02:00
parent 24134f9f90
commit a468b15bda
No known key found for this signature in database
GPG Key ID: ED35A6AC65A06B69
2 changed files with 24 additions and 107 deletions

View File

@ -1,107 +1,11 @@
monitor=,preferred,auto,auto monitor=,preferred,auto,auto
# TODO: does not work!! # 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 { debug {
disable_logs = false 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 ### ### KEYBINDINGS ###

View File

@ -115,17 +115,17 @@ CFramebuffer* CWindowTransformer::transform(CFramebuffer* in) {
return &off; return &off;
} }
void onNewWindow(void* self, std::any data) { void onNewWindow(std::any data) {
// data is guaranteed // data is guaranteed
auto* const PWINDOW = std::any_cast<CWindow*>(data); auto PWINDOW = std::any_cast<PHLWINDOW>(data);
ptrs.push_back(static_cast<CWindowTransformer*>(PWINDOW->m_transformers.emplace_back(new CWindowTransformer{}).get())); ptrs.push_back(static_cast<CWindowTransformer*>(PWINDOW->m_transformers.emplace_back(new CWindowTransformer{}).get()));
HyprlandAPI::addNotification(PHANDLE, "onnewwindow", CHyprColor{0.f, 1.f, 1.f, 1.f}, 5000); HyprlandAPI::addNotification(PHANDLE, "onnewwindow", CHyprColor{0.f, 1.f, 1.f, 1.f}, 5000);
std::println("onnewwindow"); std::println("onnewwindow");
throw "up"; Debug::log(ERR,"Hit the function.");
} }
static SP<HOOK_CALLBACK_FN> g_p = nullptr;
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
PHANDLE = 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 // ALWAYS add this to your plugins. It will prevent random crashes coming from
// mismatched header versions. // mismatched header versions.
if (HASH != GIT_COMMIT_HASH) { if (HASH != GIT_COMMIT_HASH) {
HyprlandAPI::addNotification(PHANDLE, "[WiggleWobble] Mismatched headers! Can't proceed.", HyprlandAPI::addNotification(
CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000); PHANDLE,
"[WiggleWobble] Mismatched headers! Can't proceed.",
CHyprColor {1.0, 0.2, 0.2, 1.0},
5000
);
throw std::runtime_error("[WiggleWobble] Version mismatch"); throw std::runtime_error("[WiggleWobble] Version mismatch");
} }
g_p = HyprlandAPI::registerCallbackDynamic(
static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(self, data); }); PHANDLE,
"openWindow",
[](void* self, SCallbackInfo& info, std::any data) { onNewWindow(data); }
);
HyprlandAPI::reloadConfig(); 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}; return {"wigglewobble", "Wobbly windows for Hyprland", "All-Purpose Mat", PLUGIN_VERSION};
} }
APICALL EXPORT void PLUGIN_EXIT() { APICALL EXPORT void PLUGIN_EXIT() {
throw "down"; g_p = nullptr;
} }