mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
Fullscreen and Maximize
This commit is contained in:
parent
0a0177d019
commit
cdfccf632c
3 changed files with 115 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#include "globals.hpp"
|
||||||
#include "Hy3Layout.hpp"
|
#include "Hy3Layout.hpp"
|
||||||
|
|
||||||
#include <src/Compositor.hpp>
|
#include <src/Compositor.hpp>
|
||||||
|
@ -286,7 +287,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
|
||||||
const auto* border_size = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
const auto* border_size = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
const auto* gaps_in = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
const auto* gaps_in = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||||
const auto* gaps_out = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
const auto* gaps_out = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||||
static auto* const single_window_no_gaps = &g_pConfigManager->getConfigValuePtr("plugin:hy3:no_gaps_when_only")->intValue;
|
static auto* const single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue;
|
||||||
|
|
||||||
if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) {
|
if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) {
|
||||||
Debug::log(ERR, "Node %p holding invalid window %p!!", node, window);
|
Debug::log(ERR, "Node %p holding invalid window %p!!", node, window);
|
||||||
|
@ -503,8 +504,52 @@ bool Hy3Layout::isWindowTiled(CWindow* window) {
|
||||||
return this->getNodeFromWindow(window) != nullptr;
|
return this->getNodeFromWindow(window) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3Layout::recalculateMonitor(const int& eIdleInhibitMode) {
|
void Hy3Layout::recalculateMonitor(const int& monitor_id) {
|
||||||
; // empty
|
const auto monitor = g_pCompositor->getMonitorFromID(monitor_id);
|
||||||
|
if (monitor == nullptr) return;
|
||||||
|
|
||||||
|
const auto workspace = g_pCompositor->getWorkspaceByID(monitor->activeWorkspace);
|
||||||
|
if (workspace == nullptr) return;
|
||||||
|
|
||||||
|
g_pHyprRenderer->damageMonitor(monitor);
|
||||||
|
|
||||||
|
if (monitor->specialWorkspaceID) {
|
||||||
|
const auto top_node = this->getWorkspaceRootGroup(monitor->specialWorkspaceID);
|
||||||
|
|
||||||
|
if (top_node != nullptr) {
|
||||||
|
top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
|
||||||
|
top_node->size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight;
|
||||||
|
top_node->recalcSizePosRecursive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workspace->m_bHasFullscreenWindow) {
|
||||||
|
const auto window = g_pCompositor->getFullscreenWindowOnWorkspace(workspace->m_iID);
|
||||||
|
|
||||||
|
if (workspace->m_efFullscreenMode == FULLSCREEN_FULL) {
|
||||||
|
window->m_vRealPosition = monitor->vecPosition;
|
||||||
|
window->m_vRealSize = monitor->vecSize;
|
||||||
|
} else {
|
||||||
|
// Vaxry's hack from below, but again
|
||||||
|
|
||||||
|
Hy3Node fakeNode = {
|
||||||
|
.data = window,
|
||||||
|
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
||||||
|
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
|
||||||
|
.workspace_id = window->m_iWorkspaceID,
|
||||||
|
};
|
||||||
|
|
||||||
|
this->applyNodeDataToWindow(&fakeNode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const auto top_node = this->getWorkspaceRootGroup(monitor->specialWorkspaceID);
|
||||||
|
|
||||||
|
if (top_node) {
|
||||||
|
top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
|
||||||
|
top_node->size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight;
|
||||||
|
top_node->recalcSizePosRecursive();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3Layout::recalculateWindow(CWindow* pWindow) {
|
void Hy3Layout::recalculateWindow(CWindow* pWindow) {
|
||||||
|
@ -515,8 +560,66 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
; // empty
|
; // empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3Layout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode mode, bool on) {
|
void Hy3Layout::fullscreenRequestForWindow(CWindow* window, eFullscreenMode fullscreen_mode, bool on) {
|
||||||
; // empty
|
if (!g_pCompositor->windowValidMapped(window)) return;
|
||||||
|
if (on == window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) return;
|
||||||
|
|
||||||
|
const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID);
|
||||||
|
const auto workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID);
|
||||||
|
if (workspace->m_bHasFullscreenWindow && on) return;
|
||||||
|
|
||||||
|
window->m_bIsFullscreen = on;
|
||||||
|
workspace->m_bHasFullscreenWindow = !workspace->m_bHasFullscreenWindow;
|
||||||
|
|
||||||
|
if (!window->m_bIsFullscreen) {
|
||||||
|
auto* node = this->getNodeFromWindow(window);
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
// restore node positioning if tiled
|
||||||
|
this->applyNodeDataToWindow(node);
|
||||||
|
} else {
|
||||||
|
// restore floating position if not
|
||||||
|
window->m_vRealPosition = window->m_vLastFloatingPosition;
|
||||||
|
window->m_vRealSize = window->m_vLastFloatingSize;
|
||||||
|
|
||||||
|
window->m_sSpecialRenderData.rounding = true;
|
||||||
|
window->m_sSpecialRenderData.border = true;
|
||||||
|
window->m_sSpecialRenderData.decorate = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
workspace->m_efFullscreenMode = fullscreen_mode;
|
||||||
|
|
||||||
|
// save position and size if floating
|
||||||
|
if (window->m_bIsFloating) {
|
||||||
|
window->m_vLastFloatingPosition = window->m_vRealPosition.goalv();
|
||||||
|
window->m_vPosition = window->m_vRealPosition.goalv();
|
||||||
|
window->m_vLastFloatingSize = window->m_vRealSize.goalv();
|
||||||
|
window->m_vSize = window->m_vRealSize.goalv();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullscreen_mode == FULLSCREEN_FULL) {
|
||||||
|
Debug::log(LOG, "fullscreen");
|
||||||
|
window->m_vRealPosition = monitor->vecPosition;
|
||||||
|
window->m_vRealSize = monitor->vecSize;
|
||||||
|
} else {
|
||||||
|
Debug::log(LOG, "vaxry hack");
|
||||||
|
// Copy of vaxry's massive hack
|
||||||
|
|
||||||
|
Hy3Node fakeNode = {
|
||||||
|
.data = window,
|
||||||
|
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
||||||
|
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
|
||||||
|
.workspace_id = window->m_iWorkspaceID,
|
||||||
|
};
|
||||||
|
|
||||||
|
this->applyNodeDataToWindow(&fakeNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pCompositor->updateWindowAnimatedDecorationValues(window);
|
||||||
|
g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goalv());
|
||||||
|
g_pCompositor->moveWindowToTop(window);
|
||||||
|
this->recalculateMonitor(monitor->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string content) {
|
std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string content) {
|
||||||
|
|
3
src/globals.hpp
Normal file
3
src/globals.hpp
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include <src/plugins/PluginAPI.hpp>
|
||||||
|
|
||||||
|
inline HANDLE PHANDLE = nullptr;
|
|
@ -1,9 +1,10 @@
|
||||||
#include <src/plugins/PluginAPI.hpp>
|
#include <src/plugins/PluginAPI.hpp>
|
||||||
|
|
||||||
|
#include "globals.hpp"
|
||||||
#include "Hy3Layout.hpp"
|
#include "Hy3Layout.hpp"
|
||||||
#include "src/Compositor.hpp"
|
#include "src/Compositor.hpp"
|
||||||
|
#include "src/config/ConfigManager.hpp"
|
||||||
|
|
||||||
inline HANDLE PHANDLE = nullptr;
|
|
||||||
inline std::unique_ptr<Hy3Layout> g_Hy3Layout;
|
inline std::unique_ptr<Hy3Layout> g_Hy3Layout;
|
||||||
|
|
||||||
APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
||||||
|
@ -68,6 +69,8 @@ void dispatch_movefocus(std::string arg) {
|
||||||
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
PHANDLE = handle;
|
PHANDLE = handle;
|
||||||
|
|
||||||
|
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only", SConfigValue{.intValue = 0});
|
||||||
|
|
||||||
g_Hy3Layout = std::make_unique<Hy3Layout>();
|
g_Hy3Layout = std::make_unique<Hy3Layout>();
|
||||||
HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());
|
HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue