mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 10:45:59 +01:00
wlr-ext-workspace: remove protocol impl
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)
This commit is contained in:
parent
5035f5fc68
commit
bb0933437f
13 changed files with 9 additions and 853 deletions
|
@ -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<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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<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 = "";
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
@ -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<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() {
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
@ -32,8 +32,6 @@ class CWorkspace {
|
|||
bool m_bHasFullscreenWindow = false;
|
||||
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
|
||||
|
||||
wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;
|
||||
|
||||
wl_array m_wlrCoordinateArr;
|
||||
|
||||
// for animations
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,594 +0,0 @@
|
|||
#include "../includes.hpp"
|
||||
#include "../helpers/MiscFunctions.hpp"
|
||||
#include "ext-workspace-unstable-v1-protocol.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "wlr_ext_workspace_v1.hpp"
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/util/log.h>
|
||||
#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<CWorkspace*> 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;
|
||||
}
|
|
@ -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 <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
||||
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
|
Loading…
Reference in a new issue