cdfccf632cbd8806b13ef12b320695e7168590cb
- Author
- outfoxxed <outfoxxed@outfoxxed.me>
- Committer
- outfoxxed <outfoxxed@outfoxxed.me>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index de95f6a1ce1faba3eb18a7116e131692a7f0a471..7bb8c8636030f70aa13d078628bb368cf1c342cd 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -1,3 +1,4 @@
6+#include "globals.hpp"
7 #include "Hy3Layout.hpp"
8
9 #include <src/Compositor.hpp>
10@@ -286,7 +287,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
11 const auto* border_size = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
12 const auto* gaps_in = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
13 const auto* gaps_out = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
14- static auto* const single_window_no_gaps = &g_pConfigManager->getConfigValuePtr("plugin:hy3:no_gaps_when_only")->intValue;
15+ static auto* const single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue;
16
17 if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) {
18 Debug::log(ERR, "Node %p holding invalid window %p!!", node, window);
19@@ -503,8 +504,52 @@ bool Hy3Layout::isWindowTiled(CWindow* window) {
20 return this->getNodeFromWindow(window) != nullptr;
21 }
22
23-void Hy3Layout::recalculateMonitor(const int& eIdleInhibitMode) {
24- ; // empty
25+void Hy3Layout::recalculateMonitor(const int& monitor_id) {
26+ const auto monitor = g_pCompositor->getMonitorFromID(monitor_id);
27+ if (monitor == nullptr) return;
28+
29+ const auto workspace = g_pCompositor->getWorkspaceByID(monitor->activeWorkspace);
30+ if (workspace == nullptr) return;
31+
32+ g_pHyprRenderer->damageMonitor(monitor);
33+
34+ if (monitor->specialWorkspaceID) {
35+ const auto top_node = this->getWorkspaceRootGroup(monitor->specialWorkspaceID);
36+
37+ if (top_node != nullptr) {
38+ top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
39+ top_node->size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight;
40+ top_node->recalcSizePosRecursive();
41+ }
42+ }
43+
44+ if (workspace->m_bHasFullscreenWindow) {
45+ const auto window = g_pCompositor->getFullscreenWindowOnWorkspace(workspace->m_iID);
46+
47+ if (workspace->m_efFullscreenMode == FULLSCREEN_FULL) {
48+ window->m_vRealPosition = monitor->vecPosition;
49+ window->m_vRealSize = monitor->vecSize;
50+ } else {
51+ // Vaxry's hack from below, but again
52+
53+ Hy3Node fakeNode = {
54+ .data = window,
55+ .position = monitor->vecPosition + monitor->vecReservedTopLeft,
56+ .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
57+ .workspace_id = window->m_iWorkspaceID,
58+ };
59+
60+ this->applyNodeDataToWindow(&fakeNode);
61+ }
62+ } else {
63+ const auto top_node = this->getWorkspaceRootGroup(monitor->specialWorkspaceID);
64+
65+ if (top_node) {
66+ top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
67+ top_node->size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight;
68+ top_node->recalcSizePosRecursive();
69+ }
70+ }
71 }
72
73 void Hy3Layout::recalculateWindow(CWindow* pWindow) {
74@@ -515,8 +560,66 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
75 ; // empty
76 }
77
78-void Hy3Layout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode mode, bool on) {
79- ; // empty
80+void Hy3Layout::fullscreenRequestForWindow(CWindow* window, eFullscreenMode fullscreen_mode, bool on) {
81+ if (!g_pCompositor->windowValidMapped(window)) return;
82+ if (on == window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) return;
83+
84+ const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID);
85+ const auto workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID);
86+ if (workspace->m_bHasFullscreenWindow && on) return;
87+
88+ window->m_bIsFullscreen = on;
89+ workspace->m_bHasFullscreenWindow = !workspace->m_bHasFullscreenWindow;
90+
91+ if (!window->m_bIsFullscreen) {
92+ auto* node = this->getNodeFromWindow(window);
93+
94+ if (node) {
95+ // restore node positioning if tiled
96+ this->applyNodeDataToWindow(node);
97+ } else {
98+ // restore floating position if not
99+ window->m_vRealPosition = window->m_vLastFloatingPosition;
100+ window->m_vRealSize = window->m_vLastFloatingSize;
101+
102+ window->m_sSpecialRenderData.rounding = true;
103+ window->m_sSpecialRenderData.border = true;
104+ window->m_sSpecialRenderData.decorate = true;
105diff --git a/src/globals.hpp b/src/globals.hpp
106new file mode 100644
107index 0000000000000000000000000000000000000000..8aac0ed85f6f543fb89425d7dbc2942ebfe0a5a2
108--- /dev/null
109+++ b/src/globals.hpp
110@@ -0,0 +1,3 @@
111+#include <src/plugins/PluginAPI.hpp>
112+
113+inline HANDLE PHANDLE = nullptr;
114diff --git a/src/main.cpp b/src/main.cpp
115index f5f2321eb34acebffa3b82e9be7d1ef6f3d9a0f1..ca9ce62de09c88da8c51bc56e3176137a72eba81 100644
116--- a/src/main.cpp
117+++ b/src/main.cpp
118@@ -1,9 +1,10 @@
119 #include <src/plugins/PluginAPI.hpp>
120
121+#include "globals.hpp"
122 #include "Hy3Layout.hpp"
123 #include "src/Compositor.hpp"
124+#include "src/config/ConfigManager.hpp"
125
126-inline HANDLE PHANDLE = nullptr;
127 inline std::unique_ptr<Hy3Layout> g_Hy3Layout;
128
129 APICALL EXPORT std::string PLUGIN_API_VERSION() {
130@@ -68,6 +69,8 @@ void dispatch_movefocus(std::string arg) {
131 APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
132 PHANDLE = handle;
133
134+ HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only", SConfigValue{.intValue = 0});
135+
136 g_Hy3Layout = std::make_unique<Hy3Layout>();
137 HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());
138