Skip to content

Commit

Permalink
wlr-ext-workspace: remove protocol impl
Browse files Browse the repository at this point in the history
Various reasons: 1st, memory issues. 2nd, MR got closed (see https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/merge_requests/35) 3rd, not needed anymore (waybar has its own hyprland/workspaces module)
  • Loading branch information
vaxerski committed Sep 1, 2023
1 parent 5035f5f commit bb09334
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 853 deletions.
33 changes: 1 addition & 32 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ void CCompositor::initServer() {
m_sWLRInhibitMgr = wlr_input_inhibit_manager_create(m_sWLDisplay);
m_sWLRKbShInhibitMgr = wlr_keyboard_shortcuts_inhibit_v1_create(m_sWLDisplay);

m_sWLREXTWorkspaceMgr = wlr_ext_workspace_manager_v1_create(m_sWLDisplay);

m_sWLRPointerConstraints = wlr_pointer_constraints_v1_create(m_sWLDisplay);

m_sWLRRelPointerMgr = wlr_relative_pointer_manager_v1_create(m_sWLDisplay);
Expand Down Expand Up @@ -909,16 +907,8 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {

updateWindowAnimatedDecorationValues(pWindow);

// Handle urgency hint on the workspace
if (pWindow->m_bIsUrgent) {
if (pWindow->m_bIsUrgent)
pWindow->m_bIsUrgent = false;
if (!hasUrgentWindowOnWorkspace(pWindow->m_iWorkspaceID)) {
const auto PWORKSPACE = getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE->m_pWlrHandle) {
wlr_ext_workspace_handle_v1_set_urgent(PWORKSPACE->m_pWlrHandle, 0);
}
}
}

// Send an event
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", g_pXWaylandManager->getAppIDClass(pWindow) + "," + pWindow->m_szTitle});
Expand Down Expand Up @@ -1480,13 +1470,6 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
return nullptr;
}

void CCompositor::deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude) {
for (auto& w : m_vWorkspaces) {
if (w->m_pWlrHandle && w->m_pWlrHandle != exclude)
w->setActive(false);
}
}

CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) {
bool gotToWindow = false;
for (auto& w : m_vWindows) {
Expand Down Expand Up @@ -1565,15 +1548,6 @@ CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
return nullptr;
}

CWorkspace* CCompositor::getWorkspaceByWorkspaceHandle(const wlr_ext_workspace_handle_v1* handle) {
for (auto& ws : m_vWorkspaces) {
if (ws->m_pWlrHandle == handle)
return ws.get();
}

return nullptr;
}

bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
for (auto& m : m_vMonitors) {
if (VECINRECT(point, m->vecPosition.x, m->vecPosition.y, m->vecSize.x + m->vecPosition.x, m->vecSize.y + m->vecPosition.y))
Expand Down Expand Up @@ -2368,10 +2342,6 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con

const auto PWORKSPACE = m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(monID, NAME, SPECIAL)).get();

// We are required to set the name here immediately
if (!SPECIAL)
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, NAME.c_str());

PWORKSPACE->m_iID = id;
PWORKSPACE->m_iMonitorID = monID;

Expand All @@ -2388,7 +2358,6 @@ void CCompositor::renameWorkspace(const int& id, const std::string& name) {
return;

Debug::log(LOG, "renameWorkspace: Renaming workspace %d to '%s'", id, name.c_str());
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, name.c_str());
PWORKSPACE->m_szName = name;
}

Expand Down
3 changes: 0 additions & 3 deletions src/Compositor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class CCompositor {
wlr_keyboard_shortcuts_inhibit_manager_v1* m_sWLRKbShInhibitMgr;
wlr_egl* m_sWLREGL;
int m_iDRMFD;
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
Expand Down Expand Up @@ -151,7 +150,6 @@ class CCompositor {
CWorkspace* getWorkspaceByID(const int&);
CWorkspace* getWorkspaceByName(const std::string&);
CWorkspace* getWorkspaceByString(const std::string&);
CWorkspace* getWorkspaceByWorkspaceHandle(const wlr_ext_workspace_handle_v1*);
void sanityCheckWorkspaces();
void updateWorkspaceWindowDecos(const int&);
int getWindowsOnWorkspace(const int&);
Expand All @@ -165,7 +163,6 @@ class CCompositor {
void moveWindowToTop(CWindow*);
void cleanupFadingOut(const int& monid);
CWindow* getWindowInDirection(CWindow*, char);
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
int getNextAvailableNamedWorkspace();
Expand Down
5 changes: 0 additions & 5 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1976,11 +1976,6 @@ void CConfigManager::dispatchExecOnce() {
g_pInputManager->setTouchDeviceConfigs();
g_pInputManager->setTabletConfigs();

// set ws names again
for (auto& ws : g_pCompositor->m_vWorkspaces) {
wlr_ext_workspace_handle_v1_set_name(ws->m_pWlrHandle, ws->m_szName.c_str());
}

// check for user's possible errors with their setup and notify them if needed
g_pCompositor->performUserChecks();
}
Expand Down
5 changes: 0 additions & 5 deletions src/events/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,6 @@ void Events::listener_activateXDG(wl_listener* listener, void* data) {

PWINDOW->m_bIsUrgent = true;

const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
if (PWORKSPACE->m_pWlrHandle) {
wlr_ext_workspace_handle_v1_set_urgent(PWORKSPACE->m_pWlrHandle, 1);
}

if (!*PFOCUSONACTIVATE)
return;

Expand Down
22 changes: 0 additions & 22 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,6 @@ void CMonitor::onConnect(bool noRule) {
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %lx", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x,
(int)vecPixelSize.y, output);

// add a WLR workspace group
if (!pWLRWorkspaceGroupHandle) {
pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr);
}

wlr_ext_workspace_group_handle_v1_output_enter(pWLRWorkspaceGroupHandle, output);

setupDefaultWS(monitorRule);

for (auto& ws : g_pCompositor->m_vWorkspaces) {
Expand Down Expand Up @@ -392,15 +385,11 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {

PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(ID, newDefaultWorkspaceName)).get();

// We are required to set the name here immediately
wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str());

PNEWWORKSPACE->m_iID = WORKSPACEID;
}

activeWorkspace = PNEWWORKSPACE->m_iID;

g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
PNEWWORKSPACE->setActive(true);
PNEWWORKSPACE->m_szLastMonitor = "";
}
Expand Down Expand Up @@ -527,14 +516,6 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {
return;
}

if (pWorkspace->m_iID == activeWorkspace) {
// in some cases (e.g. workspace from one monitor to another)
// we need to send this
g_pCompositor->deactivateAllWLRWorkspaces(pWorkspace->m_pWlrHandle);
pWorkspace->setActive(true);
return;
}

const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(activeWorkspace);

activeWorkspace = pWorkspace->m_iID;
Expand Down Expand Up @@ -574,9 +555,6 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {

g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);

// set some flags and fire event
g_pCompositor->deactivateAllWLRWorkspaces(pWorkspace->m_pWlrHandle);
pWorkspace->setActive(true);
g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_szName});
EMIT_HOOK_EVENT("workspace", pWorkspace);
}
Expand Down
4 changes: 0 additions & 4 deletions src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ class CMonitor {
DYNLISTENER(monitorCommit);
DYNLISTENER(monitorBind);

// hack: a group = workspaces on a monitor.
// I don't really care lol :P
wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;

// methods
void onConnect(bool noRule);
void onDisconnect();
Expand Down
42 changes: 2 additions & 40 deletions src/helpers/Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
m_szName = name;
m_bIsSpecialWorkspace = special;

if (!special) {
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);
}

m_vRenderOffset.m_pWorkspace = this;
m_vRenderOffset.create(AVARTYPE_VECTOR, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
nullptr, AVARDAMAGE_ENTIRE);
Expand All @@ -45,12 +33,6 @@ CWorkspace::~CWorkspace() {

Debug::log(LOG, "Destroying workspace ID %d", m_iID);

if (m_pWlrHandle) {
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
m_pWlrHandle = nullptr;
}

g_pEventManager->postEvent({"destroyworkspace", m_szName});
EMIT_HOOK_EVENT("destroyWorkspace", this);
}
Expand Down Expand Up @@ -149,31 +131,11 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
}

void CWorkspace::setActive(bool on) {
if (m_pWlrHandle) {
wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, on);
}
; // empty until https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/40
}

void CWorkspace::moveToMonitor(const int& id) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(id);

if (!PMONITOR || m_bIsSpecialWorkspace)
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());
; // empty until https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/40
}

CWindow* CWorkspace::getLastFocusedWindow() {
Expand Down
12 changes: 5 additions & 7 deletions src/helpers/Workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "AnimatedVariable.hpp"
#include <string>
#include "../defines.hpp"
#include "../wlrunstable/wlr_ext_workspace_v1.hpp"

enum eFullscreenMode : uint8_t {
enum eFullscreenMode : uint8_t
{
FULLSCREEN_FULL = 0,
FULLSCREEN_MAXIMIZED
};
Expand All @@ -29,12 +29,10 @@ class CWorkspace {
std::string name = "";
} m_sPrevWorkspace;

bool m_bHasFullscreenWindow = false;
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
bool m_bHasFullscreenWindow = false;
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;

wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;

wl_array m_wlrCoordinateArr;
wl_array m_wlrCoordinateArr;

// for animations
CAnimatedVariable m_vRenderOffset;
Expand Down
3 changes: 0 additions & 3 deletions src/includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,3 @@ extern "C" {
#endif

#include "helpers/Vector2D.hpp"

#include "ext-workspace-unstable-v1-protocol.h"
#include "wlrunstable/wlr_ext_workspace_v1.hpp"
6 changes: 0 additions & 6 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
const auto PNEWMAINWORKSPACE = g_pCompositor->getWorkspaceByID(monitor->activeWorkspace);

g_pCompositor->setActiveMonitor(monitor);
g_pCompositor->deactivateAllWLRWorkspaces(PNEWMAINWORKSPACE->m_pWlrHandle);
PNEWMAINWORKSPACE->setActive(true);
PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE);

const auto PNEWWORKSPACE = monitor->specialWorkspaceID != 0 ? g_pCompositor->getWorkspaceByID(monitor->specialWorkspaceID) : PNEWMAINWORKSPACE;
Expand Down Expand Up @@ -1011,12 +1009,8 @@ void CKeybindManager::moveFocusTo(std::string args) {
if (PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) {
// event
const auto PNEWMON = g_pCompositor->getMonitorFromID(PWINDOWTOCHANGETO->m_iMonitorID);
const auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOWTOCHANGETO->m_iWorkspaceID);

g_pCompositor->setActiveMonitor(PNEWMON);

g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
PNEWWORKSPACE->setActive(true);
}
}
};
Expand Down
8 changes: 1 addition & 7 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {

g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());

if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor && (*PMOUSEFOCUSMON || refocus)) {
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor && (*PMOUSEFOCUSMON || refocus))
g_pCompositor->setActiveMonitor(PMONITOR);

// set active workspace and deactivate all other in wlr
const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle);
ACTIVEWORKSPACE->setActive(true);
}

if (g_pSessionLockManager->isSessionLocked()) {
const auto PSLS = PMONITOR ? g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->ID) : nullptr;

Expand Down
Loading

0 comments on commit bb09334

Please sign in to comment.