f150886e63151bb72320cb31b6848bb102cf7757

Author
Pete Appleton <pete+git@catcity.me.uk>
Committer
Pete Appleton <pete+git@catcity.me.uk>
Date

Message

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`

Diff

 1diff --git a/CMakeLists.txt b/CMakeLists.txt
 2index e4e83ac4a0734e84212dae66fe5f8dd366a95891..0074e3005c9e32cfd4a28f6d337e5078c8fb678e 100644
 3--- a/CMakeLists.txt
 4+++ b/CMakeLists.txt
 5@@ -23,6 +23,7 @@ add_library(hy3 SHARED
 6 )
 7 
 8 option(HY3_NO_VERSION_CHECK "Disable hyprland version check" FALSE)
 9+option(HY3_ENABLE_UNUSED_BLOCKS "Enable the compilation of unused blocks" FALSE)
10 
11 if (HY3_NO_VERSION_CHECK)
12 	target_compile_definitions(hy3 PRIVATE -DHY3_NO_VERSION_CHECK=TRUE)
13diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
14index bca5224ae5f9878c7c7260386b242f6ff58c0a80..f4c793ff7a491b4b6a43ad123b9cc0c594344c36 100644
15--- a/src/Hy3Layout.cpp
16+++ b/src/Hy3Layout.cpp
17@@ -752,6 +752,7 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
18 	switch (node->data.type) {
19 	case Hy3NodeType::Window: return node->data.as_window;
20 	case Hy3NodeType::Group: return nullptr;
21+	default: return nullptr;
22 	}
23 }
24 
25@@ -1072,7 +1073,7 @@ void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow)
26 		);
27 
28 		Hy3Node* expand_actor = nullptr;
29-		auto* parent = node->removeFromParentRecursive(&expand_actor);
30+		node->removeFromParentRecursive(&expand_actor);
31 		if (expand_actor != nullptr) expand_actor->recalcSizePosRecursive();
32 
33 		changeNodeWorkspaceRecursive(*node, workspace);
34@@ -1402,12 +1403,14 @@ fullscreen:
35 	window->m_vRealPosition = monitor->vecPosition;
36 	window->m_vRealSize = monitor->vecSize;
37 	goto fsupdate;
38+#ifdef HY3_ENABLE_UNUSED_BLOCKS
39 unfullscreen:
40 	if (node->data.type != Hy3NodeType::Window) return;
41 	window = node->data.as_window;
42 	window->m_bIsFullscreen = false;
43 	workspace->m_bHasFullscreenWindow = false;
44 	goto fsupdate;
45+#endif
46 fsupdate:
47 	g_pCompositor->updateWindowAnimatedDecorationValues(window);
48 	g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goalv());
49@@ -1427,11 +1430,13 @@ bool Hy3Layout::shouldRenderSelected(CWindow* window) {
50 
51 	switch (focused->data.type) {
52 	case Hy3NodeType::Window: return focused->data.as_window == window;
53-	case Hy3NodeType::Group:
54+	case Hy3NodeType::Group: {
55 		auto* node = this->getNodeFromWindow(window);
56 		if (node == nullptr) return false;
57 		return focused->data.as_group.hasChild(node);
58 	}
59+	default: return false;
60+	}
61 }
62 
63 Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) {
64diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp
65index 35fd75294cab4943c663245c2d22f0cebff4c641..84565ee482bf54f76ceab9c0e6e4c1f30aa2f6cc 100644
66--- a/src/Hy3Node.cpp
67+++ b/src/Hy3Node.cpp
68@@ -174,6 +174,7 @@ CWindow* Hy3Node::bringToTop() {
69 		}
70 
71 		return nullptr;
72+	default: return nullptr;
73 	}
74 }
75 
76@@ -237,6 +238,7 @@ Hy3Node* Hy3Node::getFocusedNode(bool ignore_group_focus, bool stop_at_expanded)
77 			    stop_at_expanded
78 			);
79 		}
80+	default: return nullptr;
81 	}
82 }
83 
84@@ -584,6 +586,7 @@ bool Hy3Node::isUrgent() {
85 		}
86 
87 		return false;
88+	default: return false;
89 	}
90 }
91