mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-25 21:37:33 -04:00
fix: update ext-workspace
This commit is contained in:
parent
2a3493fee2
commit
586ee8e699
3 changed files with 203 additions and 159 deletions
|
|
@ -7,15 +7,11 @@
|
||||||
typedef struct Monitor Monitor;
|
typedef struct Monitor Monitor;
|
||||||
|
|
||||||
struct workspace {
|
struct workspace {
|
||||||
struct wl_list link; // Link in global workspaces list
|
struct wl_list link;
|
||||||
uint32_t tag; // Numeric identifier (1-9, 0=overview)
|
uint32_t tag;
|
||||||
Monitor *m; // Associated monitor
|
Monitor *m;
|
||||||
struct wlr_ext_workspace_handle_v1 *ext_workspace; // Protocol object
|
struct wlr_ext_workspace_handle_v1 *ext_workspace;
|
||||||
/* Event listeners */
|
struct wl_listener commit;
|
||||||
struct wl_listener activate;
|
|
||||||
struct wl_listener deactivate;
|
|
||||||
struct wl_listener assign;
|
|
||||||
struct wl_listener remove;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1 *ext_manager;
|
struct wlr_ext_workspace_manager_v1 *ext_manager;
|
||||||
|
|
@ -43,30 +39,60 @@ void toggle_workspace(struct workspace *target) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_ext_workspace_activate(struct wl_listener *listener,
|
static void handle_ext_commit(struct wl_listener *listener, void *data) {
|
||||||
void *data) {
|
struct wlr_ext_workspace_v1_commit_event *event = data;
|
||||||
struct workspace *workspace =
|
struct wlr_ext_workspace_v1_request *request;
|
||||||
wl_container_of(listener, workspace, activate);
|
|
||||||
|
|
||||||
if (workspace->m->isoverview) {
|
wl_list_for_each(request, event->requests, link) {
|
||||||
return;
|
switch (request->type) {
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE: {
|
||||||
|
if (!request->activate.workspace) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct workspace *workspace = NULL;
|
||||||
|
struct workspace *w;
|
||||||
|
wl_list_for_each(w, &workspaces, link) {
|
||||||
|
if (w->ext_workspace == request->activate.workspace) {
|
||||||
|
workspace = w;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!workspace || workspace->m->isoverview) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto_workspace(workspace);
|
||||||
|
wlr_log(WLR_INFO, "ext activating workspace %d", workspace->tag);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE: {
|
||||||
|
if (!request->deactivate.workspace) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct workspace *workspace = NULL;
|
||||||
|
struct workspace *w;
|
||||||
|
wl_list_for_each(w, &workspaces, link) {
|
||||||
|
if (w->ext_workspace == request->deactivate.workspace) {
|
||||||
|
workspace = w;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!workspace || workspace->m->isoverview) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle_workspace(workspace);
|
||||||
|
wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
goto_workspace(workspace);
|
|
||||||
wlr_log(WLR_INFO, "ext activating workspace %d", workspace->tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_ext_workspace_deactivate(struct wl_listener *listener,
|
|
||||||
void *data) {
|
|
||||||
struct workspace *workspace =
|
|
||||||
wl_container_of(listener, workspace, deactivate);
|
|
||||||
|
|
||||||
if (workspace->m->isoverview) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle_workspace(workspace);
|
|
||||||
wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_name_from_tag(uint32_t tag) {
|
static const char *get_name_from_tag(uint32_t tag) {
|
||||||
|
|
@ -76,8 +102,6 @@ static const char *get_name_from_tag(uint32_t tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_workspace(struct workspace *workspace) {
|
void destroy_workspace(struct workspace *workspace) {
|
||||||
wl_list_remove(&workspace->activate.link);
|
|
||||||
wl_list_remove(&workspace->deactivate.link);
|
|
||||||
wlr_ext_workspace_handle_v1_destroy(workspace->ext_workspace);
|
wlr_ext_workspace_handle_v1_destroy(workspace->ext_workspace);
|
||||||
wl_list_remove(&workspace->link);
|
wl_list_remove(&workspace->link);
|
||||||
free(workspace);
|
free(workspace);
|
||||||
|
|
@ -112,17 +136,12 @@ static void add_workspace_by_tag(int32_t tag, Monitor *m) {
|
||||||
workspace->m = m;
|
workspace->m = m;
|
||||||
workspace->ext_workspace = wlr_ext_workspace_handle_v1_create(
|
workspace->ext_workspace = wlr_ext_workspace_handle_v1_create(
|
||||||
ext_manager, name, EXT_WORKSPACE_ENABLE_CAPS);
|
ext_manager, name, EXT_WORKSPACE_ENABLE_CAPS);
|
||||||
|
|
||||||
|
workspace->ext_workspace->data = workspace;
|
||||||
|
|
||||||
wlr_ext_workspace_handle_v1_set_group(workspace->ext_workspace,
|
wlr_ext_workspace_handle_v1_set_group(workspace->ext_workspace,
|
||||||
m->ext_group);
|
m->ext_group);
|
||||||
wlr_ext_workspace_handle_v1_set_name(workspace->ext_workspace, name);
|
wlr_ext_workspace_handle_v1_set_name(workspace->ext_workspace, name);
|
||||||
|
|
||||||
workspace->activate.notify = handle_ext_workspace_activate;
|
|
||||||
wl_signal_add(&workspace->ext_workspace->events.activate,
|
|
||||||
&workspace->activate);
|
|
||||||
|
|
||||||
workspace->deactivate.notify = handle_ext_workspace_deactivate;
|
|
||||||
wl_signal_add(&workspace->ext_workspace->events.deactivate,
|
|
||||||
&workspace->deactivate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwl_ext_workspace_printstatus(Monitor *m) {
|
void dwl_ext_workspace_printstatus(Monitor *m) {
|
||||||
|
|
@ -180,8 +199,11 @@ void refresh_monitors_workspaces_status(Monitor *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void workspaces_init() {
|
void workspaces_init() {
|
||||||
/* Create the global workspace manager with activation capability */
|
|
||||||
ext_manager = wlr_ext_workspace_manager_v1_create(dpy, 1);
|
ext_manager = wlr_ext_workspace_manager_v1_create(dpy, 1);
|
||||||
/* Initialize the global workspaces list */
|
|
||||||
wl_list_init(&workspaces);
|
wl_list_init(&workspaces);
|
||||||
|
|
||||||
|
static struct wl_listener commit_listener;
|
||||||
|
commit_listener.notify = handle_ext_commit;
|
||||||
|
wl_signal_add(&ext_manager->events.commit, &commit_listener);
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// bash on: https://gitlab.freedesktop.org/tokyo4j/wlroots/-/tree/ext-workspace
|
|
||||||
// TODO: remove this file
|
|
||||||
// refer: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5115
|
|
||||||
|
|
||||||
#include "wlr_ext_workspace_v1.h"
|
#include "wlr_ext_workspace_v1.h"
|
||||||
#include "ext-workspace-v1-protocol.h"
|
#include "ext-workspace-v1-protocol.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -11,27 +7,6 @@
|
||||||
|
|
||||||
#define EXT_WORKSPACE_V1_VERSION 1
|
#define EXT_WORKSPACE_V1_VERSION 1
|
||||||
|
|
||||||
enum wlr_ext_workspace_v1_request_type {
|
|
||||||
WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE,
|
|
||||||
WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE,
|
|
||||||
WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE,
|
|
||||||
WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN,
|
|
||||||
WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_request {
|
|
||||||
enum wlr_ext_workspace_v1_request_type type;
|
|
||||||
|
|
||||||
// CREATE_WORKSPACE
|
|
||||||
char *name;
|
|
||||||
// CREATE_WORKSPACE / ASSIGN
|
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group;
|
|
||||||
// ACTIVATE / DEACTIVATE / ASSIGN / REMOVE
|
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace;
|
|
||||||
|
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_v1_resource.requests
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_group_output {
|
struct wlr_ext_workspace_v1_group_output {
|
||||||
struct wlr_output *output;
|
struct wlr_output *output;
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group;
|
struct wlr_ext_workspace_group_handle_v1 *group;
|
||||||
|
|
@ -117,7 +92,7 @@ static void workspace_handle_activate(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE;
|
||||||
req->workspace = workspace_res->workspace;
|
req->activate.workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +111,7 @@ workspace_handle_deactivate(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE;
|
||||||
req->workspace = workspace_res->workspace;
|
req->deactivate.workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,8 +132,8 @@ static void workspace_handle_assign(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN;
|
||||||
req->group = group_res->group;
|
req->assign.group = group_res->group;
|
||||||
req->workspace = workspace_res->workspace;
|
req->assign.workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,7 +151,7 @@ static void workspace_handle_remove(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE;
|
||||||
req->workspace = workspace_res->workspace;
|
req->remove.workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,14 +177,14 @@ static void group_handle_create_workspace(struct wl_client *client,
|
||||||
wl_resource_post_no_memory(group_resource);
|
wl_resource_post_no_memory(group_resource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->name = strdup(name);
|
req->create_workspace.name = strdup(name);
|
||||||
if (!req->name) {
|
if (!req->create_workspace.name) {
|
||||||
free(req);
|
free(req);
|
||||||
wl_resource_post_no_memory(group_resource);
|
wl_resource_post_no_memory(group_resource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE;
|
||||||
req->group = group_res->group;
|
req->create_workspace.group = group_res->group;
|
||||||
wl_list_insert(group_res->manager->requests.prev, &req->link);
|
wl_list_insert(group_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,10 +288,55 @@ static struct wlr_ext_workspace_group_v1_resource *create_group_resource(
|
||||||
return group_res;
|
return group_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_request(struct wlr_ext_workspace_v1_request *req) {
|
static void
|
||||||
wl_list_remove(&req->link);
|
destroy_requests(struct wlr_ext_workspace_manager_v1_resource *manager_res) {
|
||||||
free(req->name);
|
struct wlr_ext_workspace_v1_request *req, *tmp;
|
||||||
free(req);
|
wl_list_for_each_safe(req, tmp, &manager_res->requests, link) {
|
||||||
|
if (req->type == WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE) {
|
||||||
|
free(req->create_workspace.name);
|
||||||
|
}
|
||||||
|
wl_list_remove(&req->link);
|
||||||
|
free(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clear_requests_by(struct wlr_ext_workspace_manager_v1_resource *manager_res,
|
||||||
|
struct wlr_ext_workspace_group_handle_v1 *group,
|
||||||
|
struct wlr_ext_workspace_handle_v1 *workspace) {
|
||||||
|
struct wlr_ext_workspace_v1_request *req, *tmp;
|
||||||
|
wl_list_for_each_safe(req, tmp, &manager_res->requests, link) {
|
||||||
|
switch (req->type) {
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE:
|
||||||
|
if (group && req->create_workspace.group == group) {
|
||||||
|
req->create_workspace.group = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE:
|
||||||
|
if (workspace && req->activate.workspace == workspace) {
|
||||||
|
req->activate.workspace = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE:
|
||||||
|
if (workspace && req->deactivate.workspace == workspace) {
|
||||||
|
req->deactivate.workspace = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN:
|
||||||
|
if (workspace && req->assign.workspace == workspace) {
|
||||||
|
req->assign.workspace = NULL;
|
||||||
|
}
|
||||||
|
if (group && req->assign.group == group) {
|
||||||
|
req->assign.group = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE:
|
||||||
|
if (workspace && req->remove.workspace == workspace) {
|
||||||
|
req->remove.workspace = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manager_handle_commit(struct wl_client *client,
|
static void manager_handle_commit(struct wl_client *client,
|
||||||
|
|
@ -327,32 +347,11 @@ static void manager_handle_commit(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp;
|
struct wlr_ext_workspace_v1_commit_event commit_event = {
|
||||||
wl_list_for_each_safe(req, tmp, &manager_res->requests, link) {
|
.requests = &manager_res->requests,
|
||||||
switch (req->type) {
|
};
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE:;
|
wl_signal_emit_mutable(&manager_res->manager->events.commit, &commit_event);
|
||||||
struct wlr_ext_workspace_group_handle_v1_create_workspace_event
|
destroy_requests(manager_res);
|
||||||
event = {
|
|
||||||
.name = req->name,
|
|
||||||
};
|
|
||||||
wl_signal_emit_mutable(&req->group->events.create_workspace,
|
|
||||||
&event);
|
|
||||||
break;
|
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE:
|
|
||||||
wl_signal_emit_mutable(&req->workspace->events.activate, NULL);
|
|
||||||
break;
|
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE:
|
|
||||||
wl_signal_emit_mutable(&req->workspace->events.deactivate, NULL);
|
|
||||||
break;
|
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN:
|
|
||||||
wl_signal_emit_mutable(&req->workspace->events.assign, req->group);
|
|
||||||
break;
|
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE:
|
|
||||||
wl_signal_emit_mutable(&req->workspace->events.remove, NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
destroy_request(req);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_idle(void *data) {
|
static void handle_idle(void *data) {
|
||||||
|
|
@ -406,10 +405,8 @@ static const struct ext_workspace_manager_v1_interface manager_impl = {
|
||||||
|
|
||||||
static void destroy_manager_resource(
|
static void destroy_manager_resource(
|
||||||
struct wlr_ext_workspace_manager_v1_resource *manager_res) {
|
struct wlr_ext_workspace_manager_v1_resource *manager_res) {
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp;
|
destroy_requests(manager_res);
|
||||||
wl_list_for_each_safe(req, tmp, &manager_res->requests, link) {
|
|
||||||
destroy_request(req);
|
|
||||||
}
|
|
||||||
struct wlr_ext_workspace_v1_resource *workspace_res, *tmp2;
|
struct wlr_ext_workspace_v1_resource *workspace_res, *tmp2;
|
||||||
wl_list_for_each_safe(workspace_res, tmp2,
|
wl_list_for_each_safe(workspace_res, tmp2,
|
||||||
&manager_res->workspace_resources,
|
&manager_res->workspace_resources,
|
||||||
|
|
@ -531,6 +528,7 @@ static void manager_handle_display_destroy(struct wl_listener *listener,
|
||||||
wl_container_of(listener, manager, display_destroy);
|
wl_container_of(listener, manager, display_destroy);
|
||||||
|
|
||||||
wl_signal_emit_mutable(&manager->events.destroy, NULL);
|
wl_signal_emit_mutable(&manager->events.destroy, NULL);
|
||||||
|
assert(wl_list_empty(&manager->events.commit.listener_list));
|
||||||
assert(wl_list_empty(&manager->events.destroy.listener_list));
|
assert(wl_list_empty(&manager->events.destroy.listener_list));
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group, *tmp;
|
struct wlr_ext_workspace_group_handle_v1 *group, *tmp;
|
||||||
|
|
@ -583,6 +581,7 @@ wlr_ext_workspace_manager_v1_create(struct wl_display *display,
|
||||||
wl_list_init(&manager->groups);
|
wl_list_init(&manager->groups);
|
||||||
wl_list_init(&manager->workspaces);
|
wl_list_init(&manager->workspaces);
|
||||||
wl_list_init(&manager->resources);
|
wl_list_init(&manager->resources);
|
||||||
|
wl_signal_init(&manager->events.commit);
|
||||||
wl_signal_init(&manager->events.destroy);
|
wl_signal_init(&manager->events.destroy);
|
||||||
|
|
||||||
return manager;
|
return manager;
|
||||||
|
|
@ -601,7 +600,6 @@ wlr_ext_workspace_group_handle_v1_create(
|
||||||
|
|
||||||
wl_list_init(&group->outputs);
|
wl_list_init(&group->outputs);
|
||||||
wl_list_init(&group->resources);
|
wl_list_init(&group->resources);
|
||||||
wl_signal_init(&group->events.create_workspace);
|
|
||||||
wl_signal_init(&group->events.destroy);
|
wl_signal_init(&group->events.destroy);
|
||||||
|
|
||||||
wl_list_insert(manager->groups.prev, &group->link);
|
wl_list_insert(manager->groups.prev, &group->link);
|
||||||
|
|
@ -689,7 +687,6 @@ void wlr_ext_workspace_group_handle_v1_destroy(
|
||||||
|
|
||||||
wl_signal_emit_mutable(&group->events.destroy, NULL);
|
wl_signal_emit_mutable(&group->events.destroy, NULL);
|
||||||
|
|
||||||
assert(wl_list_empty(&group->events.create_workspace.listener_list));
|
|
||||||
assert(wl_list_empty(&group->events.destroy.listener_list));
|
assert(wl_list_empty(&group->events.destroy.listener_list));
|
||||||
|
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace;
|
struct wlr_ext_workspace_handle_v1 *workspace;
|
||||||
|
|
@ -708,12 +705,7 @@ void wlr_ext_workspace_group_handle_v1_destroy(
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_res, &group->manager->resources, link) {
|
wl_list_for_each(manager_res, &group->manager->resources, link) {
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp2;
|
clear_requests_by(manager_res, group, NULL);
|
||||||
wl_list_for_each_safe(req, tmp2, &manager_res->requests, link) {
|
|
||||||
if (req->group == group) {
|
|
||||||
destroy_request(req);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_group_output *group_output, *tmp3;
|
struct wlr_ext_workspace_v1_group_output *group_output, *tmp3;
|
||||||
|
|
@ -822,13 +814,9 @@ wlr_ext_workspace_handle_v1_create(struct wlr_ext_workspace_manager_v1 *manager,
|
||||||
|
|
||||||
wl_list_init(&workspace->resources);
|
wl_list_init(&workspace->resources);
|
||||||
wl_array_init(&workspace->coordinates);
|
wl_array_init(&workspace->coordinates);
|
||||||
wl_signal_init(&workspace->events.activate);
|
|
||||||
wl_signal_init(&workspace->events.deactivate);
|
|
||||||
wl_signal_init(&workspace->events.remove);
|
|
||||||
wl_signal_init(&workspace->events.assign);
|
|
||||||
wl_signal_init(&workspace->events.destroy);
|
wl_signal_init(&workspace->events.destroy);
|
||||||
|
|
||||||
wl_list_insert(&manager->workspaces, &workspace->link);
|
wl_list_insert(manager->workspaces.prev, &workspace->link);
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_res, &manager->resources, link) {
|
wl_list_for_each(manager_res, &manager->resources, link) {
|
||||||
|
|
@ -855,10 +843,6 @@ void wlr_ext_workspace_handle_v1_destroy(
|
||||||
|
|
||||||
wl_signal_emit_mutable(&workspace->events.destroy, NULL);
|
wl_signal_emit_mutable(&workspace->events.destroy, NULL);
|
||||||
|
|
||||||
assert(wl_list_empty(&workspace->events.activate.listener_list));
|
|
||||||
assert(wl_list_empty(&workspace->events.deactivate.listener_list));
|
|
||||||
assert(wl_list_empty(&workspace->events.remove.listener_list));
|
|
||||||
assert(wl_list_empty(&workspace->events.assign.listener_list));
|
|
||||||
assert(wl_list_empty(&workspace->events.destroy.listener_list));
|
assert(wl_list_empty(&workspace->events.destroy.listener_list));
|
||||||
|
|
||||||
if (workspace->group) {
|
if (workspace->group) {
|
||||||
|
|
@ -873,12 +857,7 @@ void wlr_ext_workspace_handle_v1_destroy(
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_res, &workspace->manager->resources, link) {
|
wl_list_for_each(manager_res, &workspace->manager->resources, link) {
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp2;
|
clear_requests_by(manager_res, NULL, workspace);
|
||||||
wl_list_for_each_safe(req, tmp2, &manager_res->requests, link) {
|
|
||||||
if (req->workspace == workspace) {
|
|
||||||
destroy_request(req);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_schedule_done(workspace->manager);
|
manager_schedule_done(workspace->manager);
|
||||||
|
|
@ -929,23 +908,22 @@ void wlr_ext_workspace_handle_v1_set_name(
|
||||||
manager_schedule_done(workspace->manager);
|
manager_schedule_done(workspace->manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool array_equal(struct wl_array *a, struct wl_array *b) {
|
|
||||||
return (a->size == b->size) &&
|
|
||||||
(a->size == 0 || memcmp(a->data, b->data, a->size) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wlr_ext_workspace_handle_v1_set_coordinates(
|
void wlr_ext_workspace_handle_v1_set_coordinates(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace,
|
struct wlr_ext_workspace_handle_v1 *workspace, const uint32_t *coords,
|
||||||
struct wl_array *coordinates) {
|
size_t coords_len) {
|
||||||
assert(coordinates);
|
size_t size = coords_len * sizeof(coords[0]);
|
||||||
|
if (size == workspace->coordinates.size &&
|
||||||
if (array_equal(&workspace->coordinates, coordinates)) {
|
(size == 0 || memcmp(workspace->coordinates.data, coords, size) == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_array_release(&workspace->coordinates);
|
wl_array_release(&workspace->coordinates);
|
||||||
wl_array_init(&workspace->coordinates);
|
wl_array_init(&workspace->coordinates);
|
||||||
wl_array_copy(&workspace->coordinates, coordinates);
|
struct wl_array arr = {
|
||||||
|
.data = (void *)coords,
|
||||||
|
.size = size,
|
||||||
|
};
|
||||||
|
wl_array_copy(&workspace->coordinates, &arr);
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_resource *workspace_res;
|
struct wlr_ext_workspace_v1_resource *workspace_res;
|
||||||
wl_list_for_each(workspace_res, &workspace->resources, link) {
|
wl_list_for_each(workspace_res, &workspace->resources, link) {
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,69 @@
|
||||||
// bash on: https://gitlab.freedesktop.org/tokyo4j/wlroots/-/tree/ext-workspace
|
/*
|
||||||
// TODO: remove this file
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||||
// refer: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5115
|
* future consistency of this API.
|
||||||
|
*/
|
||||||
|
#ifndef WLR_USE_UNSTABLE
|
||||||
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WLR_TYPES_WLR_EXT_WORKSPACE_V1_H
|
||||||
|
#define WLR_TYPES_WLR_EXT_WORKSPACE_V1_H
|
||||||
|
|
||||||
#include <wayland-protocols/ext-workspace-v1-enum.h>
|
#include <wayland-protocols/ext-workspace-v1-enum.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
|
|
||||||
struct wlr_output;
|
struct wlr_output;
|
||||||
|
|
||||||
|
enum wlr_ext_workspace_v1_request_type {
|
||||||
|
WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE,
|
||||||
|
WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE,
|
||||||
|
WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE,
|
||||||
|
WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN,
|
||||||
|
WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_ext_workspace_v1_request {
|
||||||
|
enum wlr_ext_workspace_v1_request_type type;
|
||||||
|
struct wl_list link; // wlr_ext_workspace_manager_v1_resource.requests
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
char *name;
|
||||||
|
struct wlr_ext_workspace_group_handle_v1
|
||||||
|
*group; // NULL if destroyed
|
||||||
|
} create_workspace;
|
||||||
|
struct {
|
||||||
|
struct wlr_ext_workspace_handle_v1 *workspace; // NULL if destroyed
|
||||||
|
} activate;
|
||||||
|
struct {
|
||||||
|
struct wlr_ext_workspace_handle_v1 *workspace; // NULL if destroyed
|
||||||
|
} deactivate;
|
||||||
|
struct {
|
||||||
|
struct wlr_ext_workspace_handle_v1 *workspace; // NULL if destroyed
|
||||||
|
struct wlr_ext_workspace_group_handle_v1
|
||||||
|
*group; // NULL if destroyed
|
||||||
|
} assign;
|
||||||
|
struct {
|
||||||
|
struct wlr_ext_workspace_handle_v1 *workspace; // NULL if destroyed
|
||||||
|
} remove;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_ext_workspace_v1_commit_event {
|
||||||
|
struct wl_list *requests; // wlr_ext_workspace_v1_request.link
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1 {
|
struct wlr_ext_workspace_manager_v1 {
|
||||||
struct wl_global *global;
|
struct wl_global *global;
|
||||||
struct wl_list groups; // wlr_ext_workspace_group_handle_v1.link
|
struct wl_list groups; // wlr_ext_workspace_group_handle_v1.link
|
||||||
struct wl_list workspaces; // wlr_ext_workspace_handle_v1.link
|
struct wl_list workspaces; // wlr_ext_workspace_handle_v1.link
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
struct wl_signal commit; // wlr_ext_workspace_v1_commit_event
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_list resources; // wlr_ext_workspace_manager_v1_resource.link
|
struct wl_list resources; // wlr_ext_workspace_manager_v1_resource.link
|
||||||
struct wl_event_source *idle_source;
|
struct wl_event_source *idle_source;
|
||||||
|
|
@ -24,21 +72,17 @@ struct wlr_ext_workspace_manager_v1 {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_handle_v1_create_workspace_event {
|
|
||||||
const char *name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_handle_v1 {
|
struct wlr_ext_workspace_group_handle_v1 {
|
||||||
struct wlr_ext_workspace_manager_v1 *manager;
|
struct wlr_ext_workspace_manager_v1 *manager;
|
||||||
uint32_t caps; // ext_workspace_group_handle_v1_group_capabilities
|
uint32_t caps; // ext_workspace_group_handle_v1_group_capabilities
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal
|
|
||||||
create_workspace; // wlr_ext_workspace_group_handle_v1_create_workspace_event
|
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_v1.groups
|
struct wl_list link; // wlr_ext_workspace_manager_v1.groups
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_list outputs; // wlr_ext_workspace_v1_group_output.link
|
struct wl_list outputs; // wlr_ext_workspace_v1_group_output.link
|
||||||
struct wl_list resources; // wlr_ext_workspace_manager_v1_resource.link
|
struct wl_list resources; // wlr_ext_workspace_manager_v1_resource.link
|
||||||
|
|
@ -55,15 +99,13 @@ struct wlr_ext_workspace_handle_v1 {
|
||||||
uint32_t state; // ext_workspace_handle_v1_state
|
uint32_t state; // ext_workspace_handle_v1_state
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal activate;
|
|
||||||
struct wl_signal deactivate;
|
|
||||||
struct wl_signal remove;
|
|
||||||
struct wl_signal assign; // wlr_ext_workspace_group_handle_v1
|
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_v1.workspaces
|
struct wl_list link; // wlr_ext_workspace_manager_v1.workspaces
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_list resources; // wlr_ext_workspace_v1_resource.link
|
struct wl_list resources; // wlr_ext_workspace_v1_resource.link
|
||||||
};
|
};
|
||||||
|
|
@ -96,11 +138,13 @@ void wlr_ext_workspace_handle_v1_set_group(
|
||||||
void wlr_ext_workspace_handle_v1_set_name(
|
void wlr_ext_workspace_handle_v1_set_name(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace, const char *name);
|
struct wlr_ext_workspace_handle_v1 *workspace, const char *name);
|
||||||
void wlr_ext_workspace_handle_v1_set_coordinates(
|
void wlr_ext_workspace_handle_v1_set_coordinates(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace,
|
struct wlr_ext_workspace_handle_v1 *workspace, const uint32_t *coords,
|
||||||
struct wl_array *coordinates);
|
size_t coords_len);
|
||||||
void wlr_ext_workspace_handle_v1_set_active(
|
void wlr_ext_workspace_handle_v1_set_active(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
||||||
void wlr_ext_workspace_handle_v1_set_urgent(
|
void wlr_ext_workspace_handle_v1_set_urgent(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
||||||
void wlr_ext_workspace_handle_v1_set_hidden(
|
void wlr_ext_workspace_handle_v1_set_hidden(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue