diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 1f755be0..73ed8439 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -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); @@ -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}); @@ -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) { @@ -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)) @@ -2368,10 +2342,6 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con const auto PWORKSPACE = m_vWorkspaces.emplace_back(std::make_unique(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; @@ -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; } diff --git a/src/Compositor.hpp b/src/Compositor.hpp index eb396cf1..2661af27 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -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; @@ -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&); @@ -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(); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 2c353ab2..ce9da11b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -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(); } diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index c1f3c4db..4582584a 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -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; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index d82005e3..5b30e351 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -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) { @@ -392,15 +385,11 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(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 = ""; } @@ -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; @@ -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); } diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index d24ca162..9e6fecc5 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -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(); diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index 09149ec8..eed42925 100644 --- a/src/helpers/Workspace.cpp +++ b/src/helpers/Workspace.cpp @@ -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(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.x; - *reinterpret_cast(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); @@ -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); } @@ -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(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.x; - *reinterpret_cast(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() { diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index a7ee0e7a..07b5694c 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -3,9 +3,9 @@ #include "AnimatedVariable.hpp" #include #include "../defines.hpp" -#include "../wlrunstable/wlr_ext_workspace_v1.hpp" -enum eFullscreenMode : uint8_t { +enum eFullscreenMode : uint8_t +{ FULLSCREEN_FULL = 0, FULLSCREEN_MAXIMIZED }; @@ -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; diff --git a/src/includes.hpp b/src/includes.hpp index 23624a0a..c81ee9fe 100644 --- a/src/includes.hpp +++ b/src/includes.hpp @@ -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" diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c8e8088e..0f1cd139 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -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; @@ -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); } } }; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 1739e7cc..210eaecc 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -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; diff --git a/src/wlrunstable/wlr_ext_workspace_v1.cpp b/src/wlrunstable/wlr_ext_workspace_v1.cpp deleted file mode 100644 index ccfdabc3..00000000 --- a/src/wlrunstable/wlr_ext_workspace_v1.cpp +++ /dev/null @@ -1,594 +0,0 @@ -#include "../includes.hpp" -#include "../helpers/MiscFunctions.hpp" -#include "ext-workspace-unstable-v1-protocol.h" - -#include -#include -#include -#include "wlr_ext_workspace_v1.hpp" -#include -#include -#include "../Compositor.hpp" - -#define WORKSPACE_V1_VERSION 1 - -static void workspace_handle_destroy(struct wl_client* client, struct wl_resource* resource); - -static void workspace_handle_activate(struct wl_client* client, struct wl_resource* resource); - -static void workspace_handle_deactivate(struct wl_client* client, struct wl_resource* resource); - -static void workspace_handle_remove(struct wl_client* client, struct wl_resource* resource); - -static void workspace_group_handle_handle_create_workspace(struct wl_client* client, struct wl_resource* resource, const char* arg); - -static void workspace_group_handle_handle_destroy(struct wl_client* client, struct wl_resource* resource); - -static void workspace_manager_commit(struct wl_client* client, struct wl_resource* resource); - -static void workspace_manager_stop(struct wl_client* client, struct wl_resource* resource); - -// - -inline static struct zext_workspace_handle_v1_interface workspace_handle_impl = { - .destroy = workspace_handle_destroy, - .activate = workspace_handle_activate, - .deactivate = workspace_handle_deactivate, - .remove = workspace_handle_remove, -}; - -inline static struct zext_workspace_group_handle_v1_interface workspace_group_impl = { - .create_workspace = workspace_group_handle_handle_create_workspace, - .destroy = workspace_group_handle_handle_destroy, -}; - -inline static struct zext_workspace_manager_v1_interface workspace_manager_impl = { - .commit = workspace_manager_commit, - .stop = workspace_manager_stop, -}; - -static void workspace_manager_idle_send_done(void* data) { - struct wlr_ext_workspace_manager_v1* manager = (wlr_ext_workspace_manager_v1*)data; - struct wl_resource * resource, *tmp; - wl_resource_for_each_safe(resource, tmp, &manager->resources) { - zext_workspace_manager_v1_send_done(resource); - } - - manager->idle_source = NULL; -} - -static void workspace_manager_update_idle_source(struct wlr_ext_workspace_manager_v1* manager) { - if (manager->idle_source) { - return; - } - - manager->idle_source = wl_event_loop_add_idle(manager->event_loop, workspace_manager_idle_send_done, manager); -} - -static struct wlr_ext_workspace_handle_v1* workspace_from_resource(struct wl_resource* resource) { - assert(wl_resource_instance_of(resource, &zext_workspace_handle_v1_interface, &workspace_handle_impl)); - return (wlr_ext_workspace_handle_v1*)wl_resource_get_user_data(resource); -} - -static struct wlr_ext_workspace_group_handle_v1* workspace_group_from_resource(struct wl_resource* resource) { - assert(wl_resource_instance_of(resource, &zext_workspace_group_handle_v1_interface, &workspace_group_impl)); - return (wlr_ext_workspace_group_handle_v1*)wl_resource_get_user_data(resource); -} - -static void workspace_handle_destroy(struct wl_client* client, struct wl_resource* resource) { - wl_resource_destroy(resource); -} - -static void workspace_handle_activate(struct wl_client* client, struct wl_resource* resource) { - struct wlr_ext_workspace_handle_v1* workspace = workspace_from_resource(resource); - if (!workspace) { - return; - } - - workspace->pending |= WLR_EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE; - workspace->requestsActivate = true; -} - -static void workspace_handle_remove(struct wl_client* client, struct wl_resource* resource) { - struct wlr_ext_workspace_handle_v1* workspace = workspace_from_resource(resource); - if (!workspace) { - return; - } - - wl_signal_emit_mutable(&workspace->events.remove_request, NULL); -} - -static void workspace_handle_deactivate(struct wl_client* client, struct wl_resource* resource) { - struct wlr_ext_workspace_handle_v1* workspace = workspace_from_resource(resource); - if (!workspace) { - return; - } - - workspace->pending &= ~WLR_EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE; -} - -static void workspace_handle_resource_destroy(struct wl_resource* resource) { - wl_list_remove(wl_resource_get_link(resource)); -} - -static bool push_entry_in_array(struct wl_array* array, uint32_t entry) { - uint32_t* index = (uint32_t*)wl_array_add(array, sizeof(uint32_t)); - if (index == NULL) { - return false; - } - *index = entry; - return true; -} - -static bool fill_array_from_workspace_state(struct wl_array* array, uint32_t state) { - if ((state & WLR_EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE) && !push_entry_in_array(array, ZEXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE)) { - return false; - } - if ((state & WLR_EXT_WORKSPACE_HANDLE_V1_STATE_URGENT) && !push_entry_in_array(array, ZEXT_WORKSPACE_HANDLE_V1_STATE_URGENT)) { - return false; - } - if ((state & WLR_EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN) && !push_entry_in_array(array, ZEXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN)) { - return false; - } - - return true; -} - -static void workspace_handle_send_details_to_resource(struct wlr_ext_workspace_handle_v1* workspace, struct wl_resource* resource) { - if (workspace->name) { - zext_workspace_handle_v1_send_name(resource, workspace->name); - } - - if (workspace->coordinates.size > 0) { - zext_workspace_handle_v1_send_coordinates(resource, &workspace->coordinates); - } - - struct wl_array state; - wl_array_init(&state); - if (!fill_array_from_workspace_state(&state, workspace->server_state)) { - wl_resource_post_no_memory(resource); - wl_array_release(&state); - return; - } - - zext_workspace_handle_v1_send_state(resource, &state); -} - -void wlr_ext_workspace_handle_v1_set_name(struct wlr_ext_workspace_handle_v1* workspace, const char* name) { - free(workspace->name); - workspace->name = strdup(name); - - struct wl_resource *tmp, *resource; - wl_resource_for_each_safe(resource, tmp, &workspace->resources) { - zext_workspace_handle_v1_send_name(resource, name); - } - - workspace_manager_update_idle_source(workspace->group->manager); -} - -void wlr_ext_workspace_handle_v1_set_coordinates(struct wlr_ext_workspace_handle_v1* workspace, struct wl_array* coordinates) { - wl_array_copy(&workspace->coordinates, coordinates); - - struct wl_resource *tmp, *resource; - wl_resource_for_each_safe(resource, tmp, &workspace->resources) { - zext_workspace_handle_v1_send_coordinates(resource, coordinates); - } - - workspace_manager_update_idle_source(workspace->group->manager); -} - -static void workspace_send_state(struct wlr_ext_workspace_handle_v1* workspace) { - struct wl_array state; - wl_array_init(&state); - - if (!fill_array_from_workspace_state(&state, workspace->server_state)) { - struct wl_resource* resource; - wl_resource_for_each(resource, &workspace->resources) { - wl_resource_post_no_memory(resource); - } - - wl_array_release(&state); - return; - } - - struct wl_resource *tmp, *resource; - wl_resource_for_each_safe(resource, tmp, &workspace->resources) { - zext_workspace_handle_v1_send_state(resource, &state); - } - - wl_array_release(&state); - workspace_manager_update_idle_source(workspace->group->manager); -} - -void wlr_ext_workspace_handle_v1_set_active(struct wlr_ext_workspace_handle_v1* workspace, bool activate) { - if (activate) { - workspace->server_state |= WLR_EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE; - } else { - workspace->server_state &= ~WLR_EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE; - } - - workspace_send_state(workspace); -} - -void wlr_ext_workspace_handle_v1_set_urgent(struct wlr_ext_workspace_handle_v1* workspace, bool urgent) { - if (urgent) { - workspace->server_state |= WLR_EXT_WORKSPACE_HANDLE_V1_STATE_URGENT; - } else { - workspace->server_state &= ~WLR_EXT_WORKSPACE_HANDLE_V1_STATE_URGENT; - } - - workspace_send_state(workspace); -} - -void wlr_ext_workspace_handle_v1_set_hidden(struct wlr_ext_workspace_handle_v1* workspace, bool hidden) { - if (hidden) { - workspace->server_state |= WLR_EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN; - } else { - workspace->server_state &= ~WLR_EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN; - } - - workspace_send_state(workspace); -} - -static struct wl_resource* create_workspace_resource_for_group_resource(struct wlr_ext_workspace_handle_v1* workspace, struct wl_resource* group_resource) { - - struct wl_client* client = wl_resource_get_client(group_resource); - struct wl_resource* resource = wl_resource_create(client, &zext_workspace_handle_v1_interface, wl_resource_get_version(group_resource), 0); - if (!resource) { - wl_client_post_no_memory(client); - return NULL; - } - - wl_resource_set_implementation(resource, &workspace_handle_impl, workspace, workspace_handle_resource_destroy); - - wl_list_insert(&workspace->resources, wl_resource_get_link(resource)); - zext_workspace_group_handle_v1_send_workspace(group_resource, resource); - - return resource; -} - -struct wlr_ext_workspace_handle_v1* wlr_ext_workspace_handle_v1_create(struct wlr_ext_workspace_group_handle_v1* group) { - struct wlr_ext_workspace_handle_v1* workspace = (wlr_ext_workspace_handle_v1*)calloc(1, sizeof(struct wlr_ext_workspace_handle_v1)); - if (!workspace) { - return NULL; - } - - workspace->group = group; - wl_list_insert(&group->workspaces, &workspace->link); - wl_array_init(&workspace->coordinates); - wl_list_init(&workspace->resources); - wl_signal_init(&workspace->events.remove_request); - wl_signal_init(&workspace->events.destroy); - - struct wl_resource *tmp, *group_resource; - wl_resource_for_each_safe(group_resource, tmp, &group->resources) { - create_workspace_resource_for_group_resource(workspace, group_resource); - } - - return workspace; -} - -void wlr_ext_workspace_handle_v1_destroy(struct wlr_ext_workspace_handle_v1* workspace) { - if (!workspace) { - return; - } - - wl_signal_emit_mutable(&workspace->events.destroy, workspace); - - workspace_manager_update_idle_source(workspace->group->manager); - - struct wl_resource *tmp, *resource; - wl_resource_for_each_safe(resource, tmp, &workspace->resources) { - zext_workspace_handle_v1_send_remove(resource); - - wl_resource_set_user_data(resource, NULL); - wl_list_remove(&resource->link); - wl_list_init(&resource->link); - } - - wl_array_release(&workspace->coordinates); - wl_list_remove(&workspace->link); - free(workspace->name); -} - -static void workspace_group_handle_handle_create_workspace(struct wl_client* client, struct wl_resource* resource, const char* arg) { - struct wlr_ext_workspace_group_handle_v1* group = workspace_group_from_resource(resource); - - struct wlr_ext_workspace_group_handle_v1_create_workspace_event event; - event.workspace_group = group; - event.name = arg; - wl_signal_emit_mutable(&group->events.create_workspace_request, &event); -} - -static void workspace_group_handle_handle_destroy(struct wl_client* client, struct wl_resource* resource) { - wl_resource_destroy(resource); -} - -static void workspace_group_resource_destroy(struct wl_resource* resource) { - wl_list_remove(wl_resource_get_link(resource)); -} - -/** - * Create the workspace group resource and child workspace resources as well. - */ -static struct wl_resource* create_workspace_group_resource_for_resource(struct wlr_ext_workspace_group_handle_v1* group, struct wl_resource* manager_resource) { - struct wl_client* client = wl_resource_get_client(manager_resource); - struct wl_resource* resource = wl_resource_create(client, &zext_workspace_group_handle_v1_interface, wl_resource_get_version(manager_resource), 0); - if (!resource) { - wl_client_post_no_memory(client); - return NULL; - } - - wl_resource_set_implementation(resource, &workspace_group_impl, group, workspace_group_resource_destroy); - - wl_list_insert(&group->resources, wl_resource_get_link(resource)); - zext_workspace_manager_v1_send_workspace_group(manager_resource, resource); - - struct wlr_ext_workspace_handle_v1 *tmp, *workspace; - wl_list_for_each_safe(workspace, tmp, &group->workspaces, link) { - struct wl_resource* workspace_resource = create_workspace_resource_for_group_resource(workspace, resource); - workspace_handle_send_details_to_resource(workspace, workspace_resource); - } - - return resource; -} - -static void send_output_to_group_resource(struct wl_resource* group_resource, struct wlr_output* output, bool enter) { - struct wl_client* client = wl_resource_get_client(group_resource); - struct wl_resource *output_resource, *tmp; - - wl_resource_for_each_safe(output_resource, tmp, &output->resources) { - if (wl_resource_get_client(output_resource) == client) { - if (enter) { - zext_workspace_group_handle_v1_send_output_enter(group_resource, output_resource); - } else { - zext_workspace_group_handle_v1_send_output_leave(group_resource, output_resource); - } - } - } -} - -static void group_send_output(struct wlr_ext_workspace_group_handle_v1* group, struct wlr_output* output, bool enter) { - struct wl_resource *resource, *tmp; - wl_resource_for_each_safe(resource, tmp, &group->resources) { - send_output_to_group_resource(resource, output, enter); - } -} - -static void workspace_handle_output_bind(struct wl_listener* listener, void* data) { - struct wlr_output_event_bind* evt = (wlr_output_event_bind*)data; - struct wlr_ext_workspace_group_handle_v1_output* output = wl_container_of(listener, output, output_bind); - struct wl_client* client = wl_resource_get_client(evt->resource); - - struct wl_resource * group_resource, *tmp; - wl_resource_for_each_safe(group_resource, tmp, &output->group_handle->resources) { - if (client == wl_resource_get_client(group_resource)) { - zext_workspace_group_handle_v1_send_output_enter(group_resource, evt->resource); - } - } - - workspace_manager_update_idle_source(output->group_handle->manager); -} - -static void workspace_handle_output_destroy(struct wl_listener* listener, void* data) { - struct wlr_ext_workspace_group_handle_v1_output* output = wl_container_of(listener, output, output_destroy); - wlr_ext_workspace_group_handle_v1_output_leave(output->group_handle, output->output); -} - -void wlr_ext_workspace_group_handle_v1_output_enter(struct wlr_ext_workspace_group_handle_v1* group, struct wlr_output* output) { - struct wlr_ext_workspace_group_handle_v1_output* group_output; - wl_list_for_each(group_output, &group->outputs, link) { - if (group_output->output == output) { - return; // we have already sent output_enter event - } - } - - group_output = (wlr_ext_workspace_group_handle_v1_output*)calloc(1, sizeof(struct wlr_ext_workspace_group_handle_v1_output)); - if (!group_output) { - wlr_log(WLR_ERROR, "failed to allocate memory for workspace output"); - return; - } - - group_output->output = output; - group_output->group_handle = group; - wl_list_insert(&group->outputs, &group_output->link); - - group_output->output_bind.notify = workspace_handle_output_bind; - wl_signal_add(&output->events.bind, &group_output->output_bind); - - group_output->output_destroy.notify = workspace_handle_output_destroy; - wl_signal_add(&output->events.destroy, &group_output->output_destroy); - - group_send_output(group, output, true); -} - -static void group_output_destroy(struct wlr_ext_workspace_group_handle_v1_output* output) { - wl_list_remove(&output->link); - wl_list_remove(&output->output_destroy.link); - free(output); -} - -void wlr_ext_workspace_group_handle_v1_output_leave(struct wlr_ext_workspace_group_handle_v1* group, struct wlr_output* output) { - struct wlr_ext_workspace_group_handle_v1_output* group_output_iterator; - struct wlr_ext_workspace_group_handle_v1_output* group_output = NULL; - - wl_list_for_each(group_output_iterator, &group->outputs, link) { - if (group_output_iterator->output == output) { - group_output = group_output_iterator; - break; - } - } - - if (group_output) { - group_send_output(group, output, false); - group_output_destroy(group_output); - } else { - // XXX: log an error? crash? - } -} - -static void group_send_details_to_resource(struct wlr_ext_workspace_group_handle_v1* group, struct wl_resource* resource) { - struct wlr_ext_workspace_group_handle_v1_output* output; - wl_list_for_each(output, &group->outputs, link) { - send_output_to_group_resource(resource, output->output, true); - } -} - -struct wlr_ext_workspace_group_handle_v1* wlr_ext_workspace_group_handle_v1_create(struct wlr_ext_workspace_manager_v1* manager) { - - struct wlr_ext_workspace_group_handle_v1* group = (wlr_ext_workspace_group_handle_v1*)calloc(1, sizeof(struct wlr_ext_workspace_group_handle_v1)); - if (!group) { - return NULL; - } - - group->manager = manager; - wl_list_insert(&manager->groups, &group->link); - - wl_list_init(&group->outputs); - wl_list_init(&group->resources); - wl_list_init(&group->workspaces); - wl_signal_init(&group->events.create_workspace_request); - wl_signal_init(&group->events.destroy); - - struct wl_resource *tmp, *manager_resource; - wl_resource_for_each_safe(manager_resource, tmp, &manager->resources) { - create_workspace_group_resource_for_resource(group, manager_resource); - } - - return group; -} - -void wlr_ext_workspace_group_handle_v1_destroy(struct wlr_ext_workspace_group_handle_v1* group) { - if (!group) { - return; - } - - struct wlr_ext_workspace_handle_v1 *workspace, *tmp; - wl_list_for_each_safe(workspace, tmp, &group->workspaces, link) { - wlr_ext_workspace_handle_v1_destroy(workspace); - } - - wl_signal_emit_mutable(&group->events.destroy, group); - workspace_manager_update_idle_source(group->manager); - - struct wlr_ext_workspace_group_handle_v1_output *output, *tmp2; - wl_list_for_each_safe(output, tmp2, &group->outputs, link) { - group_output_destroy(output); - } - - struct wl_resource *tmp3, *resource; - wl_resource_for_each_safe(resource, tmp3, &group->resources) { - zext_workspace_group_handle_v1_send_remove(resource); - - wl_resource_set_user_data(resource, NULL); - wl_list_remove(&resource->link); - wl_list_init(&resource->link); - } - - free(group); -} - -static struct wlr_ext_workspace_manager_v1* manager_from_resource(struct wl_resource* resource) { - assert(wl_resource_instance_of(resource, &zext_workspace_manager_v1_interface, &workspace_manager_impl)); - return (wlr_ext_workspace_manager_v1*)wl_resource_get_user_data(resource); -} - -static void workspace_manager_commit(struct wl_client* client, struct wl_resource* resource) { - struct wlr_ext_workspace_manager_v1* manager = manager_from_resource(resource); - if (!manager) { - return; - } - - std::vector toSwitchTo; - - struct wlr_ext_workspace_group_handle_v1* group; - struct wlr_ext_workspace_handle_v1* workspace; - wl_list_for_each(group, &manager->groups, link) { - wl_list_for_each(workspace, &group->workspaces, link) { - if (workspace->requestsActivate) { - const auto PWORKSPACE = g_pCompositor->getWorkspaceByWorkspaceHandle(workspace); - - if (PWORKSPACE) - toSwitchTo.push_back(PWORKSPACE); - - workspace->requestsActivate = false; - } - - workspace->current = workspace->pending; - } - } - - for (auto& ws : toSwitchTo) - g_pCompositor->getMonitorFromID(ws->m_iMonitorID)->changeWorkspace(ws); - - wl_signal_emit_mutable(&manager->events.commit, manager); -} - -static void workspace_manager_stop(struct wl_client* client, struct wl_resource* resource) { - struct wlr_ext_workspace_manager_v1* manager = manager_from_resource(resource); - if (!manager) { - return; - } - - zext_workspace_manager_v1_send_finished(resource); - wl_resource_destroy(resource); -} - -static void workspace_manager_resource_destroy(struct wl_resource* resource) { - wl_list_remove(wl_resource_get_link(resource)); -} - -static void workspace_manager_bind(struct wl_client* client, void* data, uint32_t version, uint32_t id) { - struct wlr_ext_workspace_manager_v1* manager = (wlr_ext_workspace_manager_v1*)data; - struct wl_resource* resource = wl_resource_create(client, &zext_workspace_manager_v1_interface, version, id); - if (!resource) { - wl_client_post_no_memory(client); - return; - } - wl_resource_set_implementation(resource, &workspace_manager_impl, manager, workspace_manager_resource_destroy); - - wl_list_insert(&manager->resources, wl_resource_get_link(resource)); - - struct wlr_ext_workspace_group_handle_v1 *group, *tmp; - wl_list_for_each_safe(group, tmp, &manager->groups, link) { - struct wl_resource* group_resource = create_workspace_group_resource_for_resource(group, resource); - group_send_details_to_resource(group, group_resource); - } - - zext_workspace_manager_v1_send_done(resource); -} - -static void handle_display_destroy(struct wl_listener* listener, void* data) { - struct wlr_ext_workspace_manager_v1* manager = wl_container_of(listener, manager, display_destroy); - - wl_signal_emit_mutable(&manager->events.destroy, manager); - wl_list_remove(&manager->display_destroy.link); - wl_global_destroy(manager->global); - - free(manager); -} - -struct wlr_ext_workspace_manager_v1* wlr_ext_workspace_manager_v1_create(struct wl_display* display) { - - struct wlr_ext_workspace_manager_v1* manager = (wlr_ext_workspace_manager_v1*)calloc(1, sizeof(struct wlr_ext_workspace_manager_v1)); - if (!manager) { - return NULL; - } - - manager->event_loop = wl_display_get_event_loop(display); - manager->global = wl_global_create(display, &zext_workspace_manager_v1_interface, WORKSPACE_V1_VERSION, manager, workspace_manager_bind); - if (!manager->global) { - free(manager); - return NULL; - } - - wl_signal_init(&manager->events.destroy); - wl_signal_init(&manager->events.commit); - wl_list_init(&manager->resources); - wl_list_init(&manager->groups); - - manager->display_destroy.notify = handle_display_destroy; - wl_display_add_destroy_listener(display, &manager->display_destroy); - - return manager; -} diff --git a/src/wlrunstable/wlr_ext_workspace_v1.hpp b/src/wlrunstable/wlr_ext_workspace_v1.hpp deleted file mode 100644 index 8ca1ef74..00000000 --- a/src/wlrunstable/wlr_ext_workspace_v1.hpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This an unstable interface of wlroots. No guarantees are made regarding the - * future consistency of this API. - */ - -#ifndef WLR_TYPES_WLR_WORKSPACE_V1_H -#define WLR_TYPES_WLR_WORKSPACE_V1_H - -#include -#include - -struct wlr_ext_workspace_manager_v1 { - struct wl_event_loop* event_loop; - struct wl_event_source* idle_source; - - struct wl_global* global; - struct wl_list resources; // wl_resource_get_link - struct wl_list groups; // wlr_ext_workspace_group_handle_v1::link - - struct wl_listener display_destroy; - - struct { - struct wl_signal commit; // wlr_ext_workspace_manager_v1 - struct wl_signal destroy; - } events; - - void* data; -}; - -struct wlr_ext_workspace_group_handle_v1 { - struct wl_list link; // wlr_ext_workspace_manager_v1::groups - struct wl_list resources; // wl_ext_resource_get_link - - struct wl_list workspaces; // wlr_ext_workspace_handle_v1::link - struct wl_list outputs; // wlr_ext_workspace_group_handle_v1_output::link - - struct wlr_ext_workspace_manager_v1* manager; - - struct { - // wlr_ext_workspace_group_handle_v1_create_workspace_event - struct wl_signal create_workspace_request; - struct wl_signal destroy; - } events; - - void* data; -}; - -struct wlr_ext_workspace_group_handle_v1_create_workspace_event { - struct wlr_ext_workspace_group_handle_v1* workspace_group; - const char* name; -}; - -struct wlr_ext_workspace_group_handle_v1_output { - struct wl_list link; // wlr_ext_workspace_group_handle_v1::outputs - struct wl_listener output_bind; - struct wl_listener output_destroy; - struct wlr_output* output; - - struct wlr_ext_workspace_group_handle_v1* group_handle; -}; - -enum wlr_ext_workspace_handle_v1_state -{ - WLR_EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE = 1 << 0, - WLR_EXT_WORKSPACE_HANDLE_V1_STATE_URGENT = 1 << 1, - WLR_EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN = 1 << 2, -}; - -struct wlr_ext_workspace_handle_v1 { - struct wl_list link; // wlr_ext_workspace_group_handle_v1::workspaces - struct wl_list resources; - - struct wlr_ext_workspace_group_handle_v1* group; - - // request from the client - uint32_t pending, current; - bool requestsActivate; - - // set by the compositor - uint32_t server_state; - - char* name; - struct wl_array coordinates; - - struct { - struct wl_signal remove_request; - struct wl_signal destroy; - } events; - - void* data; -}; - -struct wlr_ext_workspace_manager_v1* wlr_ext_workspace_manager_v1_create(struct wl_display* display); - -struct wlr_ext_workspace_group_handle_v1* wlr_ext_workspace_group_handle_v1_create(struct wlr_ext_workspace_manager_v1* manager); - -/** - * Destroy the workspace group and all workspaces inside it. - */ -void wlr_ext_workspace_group_handle_v1_destroy(struct wlr_ext_workspace_group_handle_v1* group); - -/** - * Create a new workspace in the workspace group. - * Note that the compositor must set the workspace name immediately after - * creating it. - */ -struct wlr_ext_workspace_handle_v1* wlr_ext_workspace_handle_v1_create(struct wlr_ext_workspace_group_handle_v1* group); - -void wlr_ext_workspace_handle_v1_destroy(struct wlr_ext_workspace_handle_v1* workspace); - -void wlr_ext_workspace_group_handle_v1_output_enter(struct wlr_ext_workspace_group_handle_v1* group, struct wlr_output* output); - -void wlr_ext_workspace_group_handle_v1_output_leave(struct wlr_ext_workspace_group_handle_v1* group, struct wlr_output* output); - -void wlr_ext_workspace_handle_v1_set_name(struct wlr_ext_workspace_handle_v1* workspace, const char* name); - -void wlr_ext_workspace_handle_v1_set_coordinates(struct wlr_ext_workspace_handle_v1* workspace, struct wl_array* coordinates); - -void wlr_ext_workspace_handle_v1_set_active(struct wlr_ext_workspace_handle_v1* workspace, bool active); - -void wlr_ext_workspace_handle_v1_set_urgent(struct wlr_ext_workspace_handle_v1* workspace, bool urgent); - -void wlr_ext_workspace_handle_v1_set_hidden(struct wlr_ext_workspace_handle_v1* workspace, bool hidden); - -#endif