added createworkspace destroyworkspace events

This commit is contained in:
vaxerski 2022-06-28 12:39:56 +02:00
parent a2e009bd9f
commit 3cbd69e703
4 changed files with 9 additions and 7 deletions

View file

@ -135,13 +135,12 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID);
PNEWWORKSPACE->startAnim(true,true,true); PNEWWORKSPACE->startAnim(true,true,true);
} else { } else {
PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID, newDefaultWorkspaceName);
// 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(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str()); wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str());
PNEWWORKSPACE->m_iID = WORKSPACEID; PNEWWORKSPACE->m_iID = WORKSPACEID;
PNEWWORKSPACE->m_szName = newDefaultWorkspaceName;
} }
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;

View file

@ -1,7 +1,7 @@
#include "Workspace.hpp" #include "Workspace.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
CWorkspace::CWorkspace(int monitorID, bool special) { CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
if (!PMONITOR) { if (!PMONITOR) {
@ -10,7 +10,7 @@ CWorkspace::CWorkspace(int monitorID, bool special) {
} }
m_iMonitorID = monitorID; m_iMonitorID = monitorID;
m_szName = name;
m_bIsSpecialWorkspace = special; m_bIsSpecialWorkspace = special;
if (!special) { if (!special) {
@ -30,6 +30,8 @@ CWorkspace::CWorkspace(int monitorID, bool special) {
m_fAlpha.m_pWorkspace = this; m_fAlpha.m_pWorkspace = this;
m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE); m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
m_fAlpha.setValueAndWarp(255.f); m_fAlpha.setValueAndWarp(255.f);
g_pEventManager->postEvent({"createworkspace", m_szName});
} }
CWorkspace::~CWorkspace() { CWorkspace::~CWorkspace() {
@ -42,6 +44,8 @@ CWorkspace::~CWorkspace() {
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle); wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
m_pWlrHandle = nullptr; m_pWlrHandle = nullptr;
} }
g_pEventManager->postEvent({"destroyworkspace", m_szName});
} }
void CWorkspace::startAnim(bool in, bool left, bool instant) { void CWorkspace::startAnim(bool in, bool left, bool instant) {

View file

@ -10,7 +10,7 @@ enum eFullscreenMode : uint8_t {
class CWorkspace { class CWorkspace {
public: public:
CWorkspace(int monitorID, bool special = false); CWorkspace(int monitorID, std::string name, bool special = false);
~CWorkspace(); ~CWorkspace();
// Workspaces ID-based have IDs > 0 // Workspaces ID-based have IDs > 0

View file

@ -336,7 +336,7 @@ 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, workspaceToChangeTo == SPECIAL_WORKSPACE_ID); g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID, workspaceName, 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
@ -348,7 +348,6 @@ void CKeybindManager::changeworkspace(std::string args) {
PWORKSPACE->m_iID = workspaceToChangeTo; PWORKSPACE->m_iID = workspaceToChangeTo;
PWORKSPACE->m_iMonitorID = PMONITOR->ID; PWORKSPACE->m_iMonitorID = PMONITOR->ID;
PWORKSPACE->m_szName = workspaceName;
PMONITOR->specialWorkspaceOpen = false; PMONITOR->specialWorkspaceOpen = false;