From f150886e63151bb72320cb31b6848bb102cf7757 Mon Sep 17 00:00:00 2001 From: Pete Appleton Date: Sat, 20 Jan 2024 11:51:43 +0000 Subject: [PATCH] Avoid GCC build warnings - Add `default` to switch statements to ensure that a defined value is returned from non-void functions - Add `HY3_ENABLE_UNUSED_BLOCKS` option (default: `FALSE`) which controls a `#if` pre-processor directive surrounding the apparently unused `unfullscreen` label (and associated block) in `Hy3Layout.cpp` --- CMakeLists.txt | 1 + src/Hy3Layout.cpp | 9 +++++++-- src/Hy3Node.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e83ac..0074e30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(hy3 SHARED ) option(HY3_NO_VERSION_CHECK "Disable hyprland version check" FALSE) +option(HY3_ENABLE_UNUSED_BLOCKS "Enable the compilation of unused blocks" FALSE) if (HY3_NO_VERSION_CHECK) target_compile_definitions(hy3 PRIVATE -DHY3_NO_VERSION_CHECK=TRUE) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index bca5224..f4c793f 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -752,6 +752,7 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { switch (node->data.type) { case Hy3NodeType::Window: return node->data.as_window; case Hy3NodeType::Group: return nullptr; + default: return nullptr; } } @@ -1072,7 +1073,7 @@ void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow) ); Hy3Node* expand_actor = nullptr; - auto* parent = node->removeFromParentRecursive(&expand_actor); + node->removeFromParentRecursive(&expand_actor); if (expand_actor != nullptr) expand_actor->recalcSizePosRecursive(); changeNodeWorkspaceRecursive(*node, workspace); @@ -1402,12 +1403,14 @@ fullscreen: window->m_vRealPosition = monitor->vecPosition; window->m_vRealSize = monitor->vecSize; goto fsupdate; +#ifdef HY3_ENABLE_UNUSED_BLOCKS unfullscreen: if (node->data.type != Hy3NodeType::Window) return; window = node->data.as_window; window->m_bIsFullscreen = false; workspace->m_bHasFullscreenWindow = false; goto fsupdate; +#endif fsupdate: g_pCompositor->updateWindowAnimatedDecorationValues(window); g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goalv()); @@ -1427,11 +1430,13 @@ bool Hy3Layout::shouldRenderSelected(CWindow* window) { switch (focused->data.type) { case Hy3NodeType::Window: return focused->data.as_window == window; - case Hy3NodeType::Group: + case Hy3NodeType::Group: { auto* node = this->getNodeFromWindow(window); if (node == nullptr) return false; return focused->data.as_group.hasChild(node); } + default: return false; + } } Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) { diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp index 35fd752..84565ee 100644 --- a/src/Hy3Node.cpp +++ b/src/Hy3Node.cpp @@ -174,6 +174,7 @@ CWindow* Hy3Node::bringToTop() { } return nullptr; + default: return nullptr; } } @@ -237,6 +238,7 @@ Hy3Node* Hy3Node::getFocusedNode(bool ignore_group_focus, bool stop_at_expanded) stop_at_expanded ); } + default: return nullptr; } } @@ -584,6 +586,7 @@ bool Hy3Node::isUrgent() { } return false; + default: return false; } }