2022-04-11 19:51:37 +02:00
|
|
|
#include "Workspace.hpp"
|
|
|
|
#include "../Compositor.hpp"
|
|
|
|
|
|
|
|
CWorkspace::CWorkspace(int monitorID) {
|
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
|
|
|
|
|
|
|
|
if (!PMONITOR) {
|
|
|
|
Debug::log(ERR, "Attempted a creation of CWorkspace with an invalid monitor?");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_iMonitorID = monitorID;
|
|
|
|
|
|
|
|
m_pWlrHandle = wlr_ext_workspace_handle_v1_create(PMONITOR->pWLRWorkspaceGroupHandle);
|
|
|
|
|
|
|
|
// set geometry here cuz we can
|
|
|
|
wl_array_init(&m_wlrCoordinateArr);
|
|
|
|
*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;
|
|
|
|
wlr_ext_workspace_handle_v1_set_coordinates(m_pWlrHandle, &m_wlrCoordinateArr);
|
2022-04-12 21:00:46 +02:00
|
|
|
wlr_ext_workspace_handle_v1_set_hidden(m_pWlrHandle, false);
|
|
|
|
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
|
2022-05-12 11:27:31 +02:00
|
|
|
|
|
|
|
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);
|
2022-05-17 13:24:23 +02:00
|
|
|
m_fAlpha.m_pWorkspace = this;
|
2022-05-16 23:13:32 +02:00
|
|
|
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);
|
2022-04-11 19:51:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CWorkspace::~CWorkspace() {
|
2022-05-12 11:27:31 +02:00
|
|
|
m_vRenderOffset.unregister();
|
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
Debug::log(LOG, "Destroying workspace ID %d", m_iID);
|
|
|
|
|
2022-04-11 19:51:37 +02:00
|
|
|
if (m_pWlrHandle) {
|
|
|
|
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
|
|
|
|
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
|
|
|
|
m_pWlrHandle = nullptr;
|
|
|
|
}
|
2022-05-16 23:13:32 +02:00
|
|
|
}
|
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
2022-05-16 23:13:32 +02:00
|
|
|
const auto ANIMSTYLE = g_pConfigManager->getString("animations:workspaces_style");
|
|
|
|
|
|
|
|
if (ANIMSTYLE == "fade") {
|
2022-05-18 12:39:20 +02:00
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
|
|
|
|
|
2022-05-16 23:13:32 +02:00
|
|
|
if (in) {
|
|
|
|
m_fAlpha.setValueAndWarp(0.f);
|
|
|
|
m_fAlpha = 255.f;
|
|
|
|
} else {
|
|
|
|
m_fAlpha.setValueAndWarp(255.f);
|
|
|
|
m_fAlpha = 0.f;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// fallback is slide
|
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
2022-05-18 12:39:20 +02:00
|
|
|
|
|
|
|
m_fAlpha.setValueAndWarp(255.f); // fix a bug, if switching from fade -> slide.
|
|
|
|
|
2022-05-16 23:13:32 +02:00
|
|
|
if (in) {
|
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
|
|
|
|
m_vRenderOffset = Vector2D(0, 0);
|
|
|
|
} else {
|
|
|
|
m_vRenderOffset = Vector2D(left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
|
|
|
|
}
|
|
|
|
}
|
2022-05-30 20:05:38 +02:00
|
|
|
|
|
|
|
if (instant) {
|
|
|
|
m_vRenderOffset.warp();
|
|
|
|
m_fAlpha.warp();
|
|
|
|
}
|
2022-05-25 10:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorkspace::setActive(bool on) {
|
|
|
|
if (m_pWlrHandle) {
|
|
|
|
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, on);
|
|
|
|
}
|
2022-05-30 20:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorkspace::moveToMonitor(const int& id) {
|
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(id);
|
|
|
|
|
|
|
|
if (!PMONITOR)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
|
|
|
|
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
|
|
|
|
|
|
|
|
m_pWlrHandle = wlr_ext_workspace_handle_v1_create(PMONITOR->pWLRWorkspaceGroupHandle);
|
|
|
|
|
|
|
|
// set geometry here cuz we can
|
|
|
|
wl_array_init(&m_wlrCoordinateArr);
|
|
|
|
*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;
|
|
|
|
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);
|
|
|
|
|
|
|
|
wlr_ext_workspace_handle_v1_set_name(m_pWlrHandle, m_szName.c_str());
|
2022-04-11 19:51:37 +02:00
|
|
|
}
|