mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 05:29:48 +01:00
Added a special workspace
This commit is contained in:
parent
df722cbb86
commit
0055efc4f1
13 changed files with 216 additions and 32 deletions
|
@ -314,6 +314,15 @@ bool CCompositor::windowExists(CWindow* pWindow) {
|
||||||
|
|
||||||
CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
|
CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
|
||||||
const auto PMONITOR = getMonitorFromVector(pos);
|
const auto PMONITOR = getMonitorFromVector(pos);
|
||||||
|
|
||||||
|
if (PMONITOR->specialWorkspaceOpen) {
|
||||||
|
for (auto& w : m_lWindows) {
|
||||||
|
wlr_box box = {w.m_vRealPosition.vec().x, w.m_vRealPosition.vec().y, w.m_vRealSize.vec().x, w.m_vRealSize.vec().y};
|
||||||
|
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, pos.x, pos.y) && w.m_bIsMapped && !w.m_bIsFloating && !w.m_bHidden)
|
||||||
|
return &w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
||||||
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
|
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
|
||||||
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
||||||
|
@ -332,6 +341,15 @@ CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
|
||||||
|
|
||||||
CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
|
CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
|
||||||
const auto PMONITOR = getMonitorFromVector(pos);
|
const auto PMONITOR = getMonitorFromVector(pos);
|
||||||
|
|
||||||
|
if (PMONITOR->specialWorkspaceOpen) {
|
||||||
|
for (auto& w : m_lWindows) {
|
||||||
|
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y};
|
||||||
|
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, pos.x, pos.y) && !w.m_bIsFloating && !w.m_bHidden)
|
||||||
|
return &w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& w : m_lWindows) {
|
for (auto& w : m_lWindows) {
|
||||||
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y};
|
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y};
|
||||||
if (w.m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w.m_iWorkspaceID == PMONITOR->activeWorkspace && !w.m_bIsFloating && !w.m_bHidden)
|
if (w.m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w.m_iWorkspaceID == PMONITOR->activeWorkspace && !w.m_bIsFloating && !w.m_bHidden)
|
||||||
|
@ -343,6 +361,16 @@ CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
|
||||||
|
|
||||||
CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
const auto PMONITOR = getMonitorFromVector(pos);
|
const auto PMONITOR = getMonitorFromVector(pos);
|
||||||
|
|
||||||
|
// special workspace
|
||||||
|
if (PMONITOR->specialWorkspaceOpen) {
|
||||||
|
for (auto& w : m_lWindows) {
|
||||||
|
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y};
|
||||||
|
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && w.m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w.m_bHidden)
|
||||||
|
return &w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
||||||
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
|
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
|
||||||
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
||||||
|
@ -362,6 +390,14 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
CWindow* CCompositor::windowFromCursor() {
|
CWindow* CCompositor::windowFromCursor() {
|
||||||
const auto PMONITOR = getMonitorFromCursor();
|
const auto PMONITOR = getMonitorFromCursor();
|
||||||
|
|
||||||
|
if (PMONITOR->specialWorkspaceOpen) {
|
||||||
|
for (auto& w : m_lWindows) {
|
||||||
|
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y};
|
||||||
|
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsMapped)
|
||||||
|
return &w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
||||||
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
|
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
|
||||||
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
||||||
|
@ -576,6 +612,9 @@ bool CCompositor::isWorkspaceVisible(const int& w) {
|
||||||
for (auto& m : m_lMonitors) {
|
for (auto& m : m_lMonitors) {
|
||||||
if (m.activeWorkspace == w)
|
if (m.activeWorkspace == w)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (m.specialWorkspaceOpen && w == SPECIAL_WORKSPACE_ID)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -595,6 +634,14 @@ void CCompositor::sanityCheckWorkspaces() {
|
||||||
if ((getWindowsOnWorkspace(it->m_iID) == 0 && !isWorkspaceVisible(it->m_iID))) {
|
if ((getWindowsOnWorkspace(it->m_iID) == 0 && !isWorkspaceVisible(it->m_iID))) {
|
||||||
it = m_lWorkspaces.erase(it);
|
it = m_lWorkspaces.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (it->m_iID == SPECIAL_WORKSPACE_ID && getWindowsOnWorkspace(it->m_iID) == 0) {
|
||||||
|
for (auto& m : m_lMonitors) {
|
||||||
|
m.specialWorkspaceOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
it = m_lWorkspaces.erase(it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,3 +65,5 @@
|
||||||
#ifndef GIT_DIRTY
|
#ifndef GIT_DIRTY
|
||||||
#define GIT_DIRTY "?"
|
#define GIT_DIRTY "?"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SPECIAL_WORKSPACE_ID -99
|
|
@ -25,10 +25,10 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
CWindow* PWINDOW = (CWindow*)owner;
|
CWindow* PWINDOW = (CWindow*)owner;
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
|
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
const auto PWORKSPACE = PMONITOR->specialWorkspaceOpen ? g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
||||||
PWINDOW->m_bMappedX11 = true;
|
PWINDOW->m_bMappedX11 = true;
|
||||||
PWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace;
|
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceOpen ? SPECIAL_WORKSPACE_ID : PMONITOR->activeWorkspace;
|
||||||
PWINDOW->m_bIsMapped = true;
|
PWINDOW->m_bIsMapped = true;
|
||||||
PWINDOW->m_bReadyToDelete = false;
|
PWINDOW->m_bReadyToDelete = false;
|
||||||
PWINDOW->m_bFadingOut = false;
|
PWINDOW->m_bFadingOut = false;
|
||||||
|
|
|
@ -149,8 +149,6 @@ public:
|
||||||
return false; // unreachable
|
return false; // unreachable
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void warp() {
|
void warp() {
|
||||||
switch (m_eVarType) {
|
switch (m_eVarType) {
|
||||||
case AVARTYPE_FLOAT: {
|
case AVARTYPE_FLOAT: {
|
||||||
|
@ -170,6 +168,8 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
Vector2D m_vValue = Vector2D(0,0);
|
Vector2D m_vValue = Vector2D(0,0);
|
||||||
float m_fValue = 0;
|
float m_fValue = 0;
|
||||||
CColor m_cValue;
|
CColor m_cValue;
|
||||||
|
|
|
@ -125,7 +125,10 @@ bool isDirection(const std::string& arg) {
|
||||||
|
|
||||||
int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
int result = INT_MAX;
|
int result = INT_MAX;
|
||||||
if (in.find("name:") == 0) {
|
if (in.find("special") == 0) {
|
||||||
|
outName = "special";
|
||||||
|
return SPECIAL_WORKSPACE_ID;
|
||||||
|
} else if (in.find("name:") == 0) {
|
||||||
const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1);
|
const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1);
|
||||||
const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
|
const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
|
||||||
if (!WORKSPACE) {
|
if (!WORKSPACE) {
|
||||||
|
|
|
@ -30,6 +30,9 @@ struct SMonitor {
|
||||||
bool needsFrameSkip = false;
|
bool needsFrameSkip = false;
|
||||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
|
||||||
|
// for the special workspace
|
||||||
|
bool specialWorkspaceOpen = false;
|
||||||
|
|
||||||
// Double-linked list because we need to have constant mem addresses for signals
|
// Double-linked list because we need to have constant mem addresses for signals
|
||||||
// We have to store pointers and use raw new/delete because they might be moved between them
|
// We have to store pointers and use raw new/delete because they might be moved between them
|
||||||
// and I am lazy
|
// and I am lazy
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Workspace.hpp"
|
#include "Workspace.hpp"
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
|
|
||||||
CWorkspace::CWorkspace(int monitorID) {
|
CWorkspace::CWorkspace(int monitorID, bool special) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
|
||||||
|
|
||||||
if (!PMONITOR) {
|
if (!PMONITOR) {
|
||||||
|
@ -11,15 +11,19 @@ CWorkspace::CWorkspace(int monitorID) {
|
||||||
|
|
||||||
m_iMonitorID = monitorID;
|
m_iMonitorID = monitorID;
|
||||||
|
|
||||||
m_pWlrHandle = wlr_ext_workspace_handle_v1_create(PMONITOR->pWLRWorkspaceGroupHandle);
|
m_bIsSpecialWorkspace = special;
|
||||||
|
|
||||||
// set geometry here cuz we can
|
if (!special) {
|
||||||
wl_array_init(&m_wlrCoordinateArr);
|
m_pWlrHandle = wlr_ext_workspace_handle_v1_create(PMONITOR->pWLRWorkspaceGroupHandle);
|
||||||
*reinterpret_cast<int*>(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.x;
|
|
||||||
*reinterpret_cast<int*>(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.y;
|
// set geometry here cuz we can
|
||||||
wlr_ext_workspace_handle_v1_set_coordinates(m_pWlrHandle, &m_wlrCoordinateArr);
|
wl_array_init(&m_wlrCoordinateArr);
|
||||||
wlr_ext_workspace_handle_v1_set_hidden(m_pWlrHandle, false);
|
*reinterpret_cast<int*>(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.x;
|
||||||
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
|
*reinterpret_cast<int*>(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.y;
|
||||||
|
wlr_ext_workspace_handle_v1_set_coordinates(m_pWlrHandle, &m_wlrCoordinateArr);
|
||||||
|
wlr_ext_workspace_handle_v1_set_hidden(m_pWlrHandle, false);
|
||||||
|
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
|
||||||
|
}
|
||||||
|
|
||||||
m_vRenderOffset.m_pWorkspace = this;
|
m_vRenderOffset.m_pWorkspace = this;
|
||||||
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
|
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
|
||||||
|
@ -82,7 +86,7 @@ void CWorkspace::setActive(bool on) {
|
||||||
void CWorkspace::moveToMonitor(const int& id) {
|
void CWorkspace::moveToMonitor(const int& id) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(id);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(id);
|
||||||
|
|
||||||
if (!PMONITOR)
|
if (!PMONITOR || m_bIsSpecialWorkspace)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
|
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
|
||||||
|
|
|
@ -10,7 +10,7 @@ enum eFullscreenMode : uint8_t {
|
||||||
|
|
||||||
class CWorkspace {
|
class CWorkspace {
|
||||||
public:
|
public:
|
||||||
CWorkspace(int monitorID);
|
CWorkspace(int monitorID, bool special = false);
|
||||||
~CWorkspace();
|
~CWorkspace();
|
||||||
|
|
||||||
// Workspaces ID-based have IDs > 0
|
// Workspaces ID-based have IDs > 0
|
||||||
|
@ -29,6 +29,9 @@ public:
|
||||||
CAnimatedVariable m_vRenderOffset;
|
CAnimatedVariable m_vRenderOffset;
|
||||||
CAnimatedVariable m_fAlpha;
|
CAnimatedVariable m_fAlpha;
|
||||||
|
|
||||||
|
// "scratchpad"
|
||||||
|
bool m_bIsSpecialWorkspace = false;
|
||||||
|
|
||||||
// user-set
|
// user-set
|
||||||
bool m_bDefaultFloating = false;
|
bool m_bDefaultFloating = false;
|
||||||
bool m_bDefaultPseudo = false;
|
bool m_bDefaultPseudo = false;
|
||||||
|
|
|
@ -160,10 +160,20 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_vRealSize = calcSize;
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
|
||||||
PWINDOW->m_vRealPosition = calcPos;
|
|
||||||
|
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
if (PWORKSPACE->m_bIsSpecialWorkspace) {
|
||||||
|
// if special, we adjust the coords a bit
|
||||||
|
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * 0.8f) / 2.f;
|
||||||
|
PWINDOW->m_vRealSize = calcSize * 0.8f;
|
||||||
|
|
||||||
|
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * 0.8f);
|
||||||
|
} else {
|
||||||
|
PWINDOW->m_vRealSize = calcSize;
|
||||||
|
PWINDOW->m_vRealPosition = calcPos;
|
||||||
|
|
||||||
|
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
|
@ -184,7 +194,7 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
SDwindleNodeData* OPENINGON;
|
SDwindleNodeData* OPENINGON;
|
||||||
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
|
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
|
||||||
|
|
||||||
if (PMONITOR->ID == MONFROMCURSOR->ID && PNODE->workspaceID == PMONITOR->activeWorkspace) {
|
if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (PNODE->workspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen))) {
|
||||||
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
||||||
|
|
||||||
// happens on reserved area
|
// happens on reserved area
|
||||||
|
@ -196,6 +206,11 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
|
|
||||||
Debug::log(LOG, "OPENINGON: %x, Workspace: %i, Monitor: %i", OPENINGON, PNODE->workspaceID, PMONITOR->ID);
|
Debug::log(LOG, "OPENINGON: %x, Workspace: %i, Monitor: %i", OPENINGON, PNODE->workspaceID, PMONITOR->ID);
|
||||||
|
|
||||||
|
if (OPENINGON->workspaceID != PNODE->workspaceID) {
|
||||||
|
// special workspace handling
|
||||||
|
OPENINGON = getFirstNodeOnWorkspace(PNODE->workspaceID);
|
||||||
|
}
|
||||||
|
|
||||||
// if it's the first, it's easy. Make it fullscreen.
|
// if it's the first, it's easy. Make it fullscreen.
|
||||||
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
|
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
|
||||||
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
|
@ -356,8 +371,21 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
|
|
||||||
|
if (!PWORKSPACE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (PMONITOR->specialWorkspaceOpen) {
|
||||||
|
const auto TOPNODE = getMasterNodeOnWorkspace(SPECIAL_WORKSPACE_ID);
|
||||||
|
|
||||||
|
if (TOPNODE && PMONITOR) {
|
||||||
|
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
|
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
|
TOPNODE->recalcSizePosRecursive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore any recalc events if we have a fullscreen window.
|
// Ignore any recalc events if we have a fullscreen window.
|
||||||
if (!PWORKSPACE || PWORKSPACE->m_bHasFullscreenWindow)
|
if (PWORKSPACE->m_bHasFullscreenWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->activeWorkspace);
|
const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->activeWorkspace);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
|
|
||||||
// then, we check if the workspace doesnt have a fullscreen window
|
// then, we check if the workspace doesnt have a fullscreen window
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface) {
|
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
|
||||||
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
||||||
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
||||||
|
@ -113,7 +113,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
// only check floating because tiled cant be over fullscreen
|
// only check floating because tiled cant be over fullscreen
|
||||||
for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) {
|
for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) {
|
||||||
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
||||||
if (w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) {
|
if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) {
|
||||||
pFoundWindow = &(*w);
|
pFoundWindow = &(*w);
|
||||||
|
|
||||||
if (!pFoundWindow->m_bIsX11) {
|
if (!pFoundWindow->m_bIsX11) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["exit"] = exitHyprland;
|
m_mDispatchers["exit"] = exitHyprland;
|
||||||
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor;
|
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor;
|
||||||
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
||||||
|
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::addKeybind(SKeybind kb) {
|
void CKeybindManager::addKeybind(SKeybind kb) {
|
||||||
|
@ -153,6 +154,10 @@ void CKeybindManager::toggleActiveFloating(std::string args) {
|
||||||
if (g_pCompositor->windowValidMapped(ACTIVEWINDOW)) {
|
if (g_pCompositor->windowValidMapped(ACTIVEWINDOW)) {
|
||||||
ACTIVEWINDOW->m_bIsFloating = !ACTIVEWINDOW->m_bIsFloating;
|
ACTIVEWINDOW->m_bIsFloating = !ACTIVEWINDOW->m_bIsFloating;
|
||||||
|
|
||||||
|
if (ACTIVEWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) {
|
||||||
|
moveActiveToWorkspace(std::to_string(g_pCompositor->getMonitorFromID(ACTIVEWINDOW->m_iMonitorID)->activeWorkspace));
|
||||||
|
}
|
||||||
|
|
||||||
ACTIVEWINDOW->m_vRealPosition.setValue(ACTIVEWINDOW->m_vRealPosition.vec() + Vector2D(5, 5));
|
ACTIVEWINDOW->m_vRealPosition.setValue(ACTIVEWINDOW->m_vRealPosition.vec() + Vector2D(5, 5));
|
||||||
ACTIVEWINDOW->m_vSize = ACTIVEWINDOW->m_vRealPosition.vec() - Vector2D(10, 10);
|
ACTIVEWINDOW->m_vSize = ACTIVEWINDOW->m_vRealPosition.vec() - Vector2D(10, 10);
|
||||||
|
|
||||||
|
@ -191,12 +196,20 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
|
|
||||||
const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
||||||
|
|
||||||
|
if (workspaceToChangeTo == SPECIAL_WORKSPACE_ID)
|
||||||
|
PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID;
|
||||||
|
|
||||||
// if it's not visible, make it visible.
|
// if it's not visible, make it visible.
|
||||||
if (!g_pCompositor->isWorkspaceVisible(workspaceToChangeTo)) {
|
if (!g_pCompositor->isWorkspaceVisible(workspaceToChangeTo)) {
|
||||||
const auto OLDWORKSPACEID = PMONITOR->activeWorkspace;
|
const auto OLDWORKSPACEID = PMONITOR->activeWorkspace;
|
||||||
|
|
||||||
// change it
|
// change it
|
||||||
PMONITOR->activeWorkspace = workspaceToChangeTo;
|
PMONITOR->specialWorkspaceOpen = false;
|
||||||
|
|
||||||
|
if (workspaceToChangeTo != SPECIAL_WORKSPACE_ID)
|
||||||
|
PMONITOR->activeWorkspace = workspaceToChangeTo;
|
||||||
|
else
|
||||||
|
PMONITOR->specialWorkspaceOpen = true;
|
||||||
|
|
||||||
// we need to move XWayland windows to narnia or otherwise they will still process our cursor and shit
|
// we need to move XWayland windows to narnia or otherwise they will still process our cursor and shit
|
||||||
// and that'd be annoying as hell
|
// and that'd be annoying as hell
|
||||||
|
@ -220,7 +233,6 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName));
|
g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the monitor is not the one our cursor's at, warp to it.
|
// If the monitor is not the one our cursor's at, warp to it.
|
||||||
if (PMONITOR != g_pCompositor->getMonitorFromCursor()) {
|
if (PMONITOR != g_pCompositor->getMonitorFromCursor()) {
|
||||||
Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f;
|
Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f;
|
||||||
|
@ -260,20 +272,26 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE)
|
if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE)
|
||||||
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
||||||
|
|
||||||
g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID);
|
g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID, workspaceToChangeTo == SPECIAL_WORKSPACE_ID);
|
||||||
const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
|
const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
|
||||||
|
|
||||||
// start anim on new workspace
|
// start anim on new workspace
|
||||||
PWORKSPACE->startAnim(true, ANIMTOLEFT);
|
PWORKSPACE->startAnim(true, ANIMTOLEFT);
|
||||||
|
|
||||||
// We are required to set the name here immediately
|
// We are required to set the name here immediately
|
||||||
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, workspaceName.c_str());
|
if (workspaceToChangeTo != SPECIAL_WORKSPACE_ID)
|
||||||
|
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, workspaceName.c_str());
|
||||||
|
|
||||||
PWORKSPACE->m_iID = workspaceToChangeTo;
|
PWORKSPACE->m_iID = workspaceToChangeTo;
|
||||||
PWORKSPACE->m_iMonitorID = PMONITOR->ID;
|
PWORKSPACE->m_iMonitorID = PMONITOR->ID;
|
||||||
PWORKSPACE->m_szName = workspaceName;
|
PWORKSPACE->m_szName = workspaceName;
|
||||||
|
|
||||||
PMONITOR->activeWorkspace = workspaceToChangeTo;
|
PMONITOR->specialWorkspaceOpen = false;
|
||||||
|
|
||||||
|
if (workspaceToChangeTo != SPECIAL_WORKSPACE_ID)
|
||||||
|
PMONITOR->activeWorkspace = workspaceToChangeTo;
|
||||||
|
else
|
||||||
|
PMONITOR->specialWorkspaceOpen = true;
|
||||||
|
|
||||||
// we need to move XWayland windows to narnia or otherwise they will still process our cursor and shit
|
// we need to move XWayland windows to narnia or otherwise they will still process our cursor and shit
|
||||||
// and that'd be annoying as hell
|
// and that'd be annoying as hell
|
||||||
|
@ -368,6 +386,17 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vRealPosition.vec() + g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition);
|
PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vRealPosition.vec() + g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition);
|
||||||
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// undo the damage if we are moving to the special workspace
|
||||||
|
if (WORKSPACEID == SPECIAL_WORKSPACE_ID) {
|
||||||
|
changeworkspace(std::to_string(OLDWORKSPACE->m_iID));
|
||||||
|
OLDWORKSPACE->startAnim(true, true, true);
|
||||||
|
toggleSpecialWorkspace("");
|
||||||
|
g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false, true);
|
||||||
|
|
||||||
|
for (auto& m : g_pCompositor->m_lMonitors)
|
||||||
|
m.specialWorkspaceOpen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
|
@ -748,3 +777,43 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
|
||||||
|
|
||||||
g_pCompositor->moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
|
g_pCompositor->moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
|
|
||||||
|
if (g_pCompositor->getWindowsOnWorkspace(SPECIAL_WORKSPACE_ID) == 0) {
|
||||||
|
Debug::log(LOG, "Can't open empty special workspace!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool open = false;
|
||||||
|
|
||||||
|
for (auto& m : g_pCompositor->m_lMonitors) {
|
||||||
|
if (m.specialWorkspaceOpen) {
|
||||||
|
open = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open)
|
||||||
|
Debug::log(LOG, "Toggling special workspace to closed");
|
||||||
|
else
|
||||||
|
Debug::log(LOG, "Toggling special workspace to open");
|
||||||
|
|
||||||
|
if (open) {
|
||||||
|
for (auto& m : g_pCompositor->m_lMonitors) {
|
||||||
|
if (m.specialWorkspaceOpen != !open) {
|
||||||
|
m.specialWorkspaceOpen = !open;
|
||||||
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID);
|
||||||
|
|
||||||
|
g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_pCompositor->m_pLastMonitor->specialWorkspaceOpen = true;
|
||||||
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID);
|
||||||
|
|
||||||
|
g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pInputManager->refocus();
|
||||||
|
}
|
|
@ -53,6 +53,7 @@ private:
|
||||||
static void exitHyprland(std::string);
|
static void exitHyprland(std::string);
|
||||||
static void moveCurrentWorkspaceToMonitor(std::string);
|
static void moveCurrentWorkspaceToMonitor(std::string);
|
||||||
static void moveWorkspaceToMonitor(std::string);
|
static void moveWorkspaceToMonitor(std::string);
|
||||||
|
static void toggleSpecialWorkspace(std::string);
|
||||||
|
|
||||||
friend class CCompositor;
|
friend class CCompositor;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,6 +46,9 @@ bool shouldRenderWindow(CWindow* pWindow, SMonitor* pMonitor) {
|
||||||
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
|
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (pMonitor->specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +179,10 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (w.m_bIsFloating)
|
if (w.m_bIsFloating)
|
||||||
continue; // floating are in second pass
|
continue; // floating are in the second pass
|
||||||
|
|
||||||
|
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
|
||||||
|
continue; // special are in the third pass
|
||||||
|
|
||||||
if (!shouldRenderWindow(&w, PMONITOR))
|
if (!shouldRenderWindow(&w, PMONITOR))
|
||||||
continue;
|
continue;
|
||||||
|
@ -193,6 +199,24 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
if (!w.m_bIsFloating)
|
if (!w.m_bIsFloating)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!shouldRenderWindow(&w, PMONITOR))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// render the bad boy
|
||||||
|
renderWindow(&w, PMONITOR, time, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and then special
|
||||||
|
for (auto& w : g_pCompositor->m_lWindows) {
|
||||||
|
if (!g_pCompositor->windowValidMapped(&w) && !w.m_bFadingOut)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (w.m_iWorkspaceID != SPECIAL_WORKSPACE_ID)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!shouldRenderWindow(&w, PMONITOR))
|
if (!shouldRenderWindow(&w, PMONITOR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue