From b19b091c92c174dca6eda3c9ab43de6650e77d41 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Sat, 21 Oct 2023 16:40:41 +0200 Subject: [PATCH] Layer audioflyin on top of fullscreen windows LAYER_TOP (The previously hardcoded layer) draws below fullscreen windows (at least on Hyprland). For the flyin we want it to be always on top, so LAYER_OVERLAY is used instead now. --- src/AudioFlyin.cpp | 2 ++ src/Window.cpp | 8 +++++++- src/Window.h | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/AudioFlyin.cpp b/src/AudioFlyin.cpp index 297945c..edaf14b 100644 --- a/src/AudioFlyin.cpp +++ b/src/AudioFlyin.cpp @@ -150,6 +150,8 @@ namespace AudioFlyin padding = Widget::Create(); mainWidget->AddChild(std::move(padding)); + // We want the audio flyin on top of fullscreen windows + window.SetLayer(Layer::Overlay); window.SetExclusive(false); window.SetAnchor(Anchor::Bottom); window.SetMainWidget(std::move(mainWidget)); diff --git a/src/Window.cpp b/src/Window.cpp index e6a9c10..bfe725f 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -48,7 +48,13 @@ void Window::Run() m_Window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_layer_init_for_window(m_Window); - gtk_layer_set_layer(m_Window, GTK_LAYER_SHELL_LAYER_TOP); + + switch (m_Layer) + { + case Layer::Top: gtk_layer_set_layer(m_Window, GTK_LAYER_SHELL_LAYER_TOP); break; + case Layer::Overlay: gtk_layer_set_layer(m_Window, GTK_LAYER_SHELL_LAYER_OVERLAY); break; + } + if (m_Exclusive) gtk_layer_auto_exclusive_zone_enable(m_Window); diff --git a/src/Window.h b/src/Window.h index 64ac667..32cf7f2 100644 --- a/src/Window.h +++ b/src/Window.h @@ -12,6 +12,12 @@ enum class Anchor }; DEFINE_ENUM_FLAGS(Anchor); +enum class Layer +{ + Top, + Overlay +}; + class Window { public: @@ -29,6 +35,7 @@ public: void SetAnchor(Anchor anchor) { m_Anchor = anchor; } void SetMargin(Anchor anchor, int32_t margin); void SetExclusive(bool exclusive) { m_Exclusive = exclusive; } + void SetLayer(Layer layer) { m_Layer = layer;} void SetMainWidget(std::unique_ptr&& mainWidget); @@ -47,6 +54,7 @@ private: Anchor m_Anchor; std::array, 4> m_Margin; bool m_Exclusive = true; + Layer m_Layer = Layer::Top; int32_t m_MonitorID; GdkMonitor* m_Monitor = nullptr;