Add option to disable the manual flyin animation

Instead of sidetracking the compositor which leads to issues on
Hyprland, let the compositor do the animations instead.

Fixes https://github.com/scorpion-26/gBar/issues/96
This commit is contained in:
scorpion-26 2024-10-13 23:37:41 +02:00
parent b1e2c2ed26
commit 2f3f973f7c
6 changed files with 31 additions and 8 deletions

View file

@ -150,6 +150,11 @@ AudioScrollSpeed: 5
# Display numbers instead of a slider for the two audio widgets. Doesn't affect the audio flyin # Display numbers instead of a slider for the two audio widgets. Doesn't affect the audio flyin
AudioNumbers: false AudioNumbers: false
# Manually perform the flyin animation for the audio widget. Enabling this can cause some graphical issues (Damage tracking issues after the flyin disappers) on Hyprland.
# So it is recommended to disable this on Hyprland and configure the flyin animation there:
# layerrule = animation slide, gbar-audio
ManualFlyinAnimation: false
# Command that is run to check if there are out-of-date packages. # Command that is run to check if there are out-of-date packages.
# The script should return *ONLY* a number. If it doesn't output a number, updates are no longer checked. # The script should return *ONLY* a number. If it doesn't output a number, updates are no longer checked.
# Default value is applicable for Arch Linux. (See data/update.sh for a human-readable version) # Default value is applicable for Arch Linux. (See data/update.sh for a human-readable version)

View file

@ -78,6 +78,9 @@ namespace AudioFlyin
} }
msOpen++; msOpen++;
if (Config::Get().manualFlyinAnimation)
{
auto marginFunction = [](int32_t x) -> int32_t auto marginFunction = [](int32_t x) -> int32_t
{ {
// A inverted, cutoff 'V' shape // A inverted, cutoff 'V' shape
@ -86,6 +89,8 @@ namespace AudioFlyin
return (int32_t)std::min(-std::abs((double)x - (double)curCloseTime / 2) * steepness + (double)curCloseTime / 2, (double)height); return (int32_t)std::min(-std::abs((double)x - (double)curCloseTime / 2) * steepness + (double)curCloseTime / 2, (double)height);
}; };
win->SetMargin(Anchor::Bottom, marginFunction(msOpen)); win->SetMargin(Anchor::Bottom, marginFunction(msOpen));
}
if (msOpen >= curCloseTime) if (msOpen >= curCloseTime)
{ {
win->Close(); win->Close();
@ -151,9 +156,16 @@ namespace AudioFlyin
mainWidget->AddChild(std::move(padding)); mainWidget->AddChild(std::move(padding));
// We want the audio flyin on top of fullscreen windows // We want the audio flyin on top of fullscreen windows
window.SetLayerNamespace("gbar-audio");
window.SetLayer(Layer::Overlay); window.SetLayer(Layer::Overlay);
window.SetExclusive(false); window.SetExclusive(false);
window.SetAnchor(Anchor::Bottom); window.SetAnchor(Anchor::Bottom);
window.SetMainWidget(std::move(mainWidget)); window.SetMainWidget(std::move(mainWidget));
if (!Config::Get().manualFlyinAnimation)
{
// Do the margin here, so we don't need to update it every frame
window.SetMargin(Anchor::Bottom, DynCtx::height);
}
} }
} }

View file

@ -289,6 +289,7 @@ void Config::Load(const std::string& overrideConfigLocation)
AddConfigVar("AudioInput", config.audioInput, lineView, foundProperty); AddConfigVar("AudioInput", config.audioInput, lineView, foundProperty);
AddConfigVar("AudioRevealer", config.audioRevealer, lineView, foundProperty); AddConfigVar("AudioRevealer", config.audioRevealer, lineView, foundProperty);
AddConfigVar("AudioNumbers", config.audioNumbers, lineView, foundProperty); AddConfigVar("AudioNumbers", config.audioNumbers, lineView, foundProperty);
AddConfigVar("ManualFlyinAnimation", config.manualFlyinAnimation, lineView, foundProperty);
AddConfigVar("NetworkWidget", config.networkWidget, lineView, foundProperty); AddConfigVar("NetworkWidget", config.networkWidget, lineView, foundProperty);
AddConfigVar("WorkspaceScrollOnMonitor", config.workspaceScrollOnMonitor, lineView, foundProperty); AddConfigVar("WorkspaceScrollOnMonitor", config.workspaceScrollOnMonitor, lineView, foundProperty);
AddConfigVar("WorkspaceScrollInvert", config.workspaceScrollInvert, lineView, foundProperty); AddConfigVar("WorkspaceScrollInvert", config.workspaceScrollInvert, lineView, foundProperty);

View file

@ -60,6 +60,7 @@ public:
bool audioRevealer = false; bool audioRevealer = false;
bool audioInput = false; bool audioInput = false;
bool audioNumbers = false; // Affects both audio sliders bool audioNumbers = false; // Affects both audio sliders
bool manualFlyinAnimation = false; // Do the flyin animation via margin updating
bool networkWidget = true; bool networkWidget = true;
bool workspaceScrollOnMonitor = true; // Scroll through workspaces on monitor instead of all bool workspaceScrollOnMonitor = true; // Scroll through workspaces on monitor instead of all
bool workspaceScrollInvert = false; // Up = +1, instead of Up = -1 bool workspaceScrollInvert = false; // Up = +1, instead of Up = -1

View file

@ -140,6 +140,8 @@ void Window::Create()
case Layer::Overlay: gtk_layer_set_layer(m_Window, GTK_LAYER_SHELL_LAYER_OVERLAY); break; case Layer::Overlay: gtk_layer_set_layer(m_Window, GTK_LAYER_SHELL_LAYER_OVERLAY); break;
} }
gtk_layer_set_namespace(m_Window, m_LayerNamespace.c_str());
if (m_Exclusive) if (m_Exclusive)
gtk_layer_auto_exclusive_zone_enable(m_Window); gtk_layer_auto_exclusive_zone_enable(m_Window);

View file

@ -37,6 +37,7 @@ public:
void SetMargin(Anchor anchor, int32_t margin); void SetMargin(Anchor anchor, int32_t margin);
void SetExclusive(bool exclusive) { m_Exclusive = exclusive; } void SetExclusive(bool exclusive) { m_Exclusive = exclusive; }
void SetLayer(Layer layer) { m_Layer = layer; } void SetLayer(Layer layer) { m_Layer = layer; }
void SetLayerNamespace(const std::string& layerNamespace) { m_LayerNamespace = layerNamespace; }
void SetMainWidget(std::unique_ptr<Widget>&& mainWidget); void SetMainWidget(std::unique_ptr<Widget>&& mainWidget);
@ -69,6 +70,7 @@ private:
std::array<std::pair<Anchor, int32_t>, 4> m_Margin; std::array<std::pair<Anchor, int32_t>, 4> m_Margin;
bool m_Exclusive = true; bool m_Exclusive = true;
Layer m_Layer = Layer::Top; Layer m_Layer = Layer::Top;
std::string m_LayerNamespace = "gbar";
// The monitor we are currently on. // The monitor we are currently on.
std::string m_MonitorName; std::string m_MonitorName;