mirror of
https://github.com/labwc/labwc.git
synced 2026-02-06 04:06:33 -05:00
Merge pull request #2030 from Consolatis/wip/cosmic_workspaces
Initial implementation of cosmic-workspace-unstable-v1
This commit is contained in:
commit
d18e67eea8
22 changed files with 1578 additions and 38 deletions
|
|
@ -1,6 +1,8 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef LABWC_ARRAY_H
|
||||
#define LABWC_ARRAY_H
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
/*
|
||||
|
|
@ -41,4 +43,34 @@ wl_array_len(struct wl_array *array)
|
|||
pos && (const char *)pos >= (const char *)(array)->data; \
|
||||
(pos)--)
|
||||
|
||||
/**
|
||||
* array_add() - add item to wl_array and exit on allocation error
|
||||
* @_arr: wl_array to add the item to
|
||||
* @_val: the item to add to the array
|
||||
*
|
||||
* Let us illustrate the function of this macro by an example:
|
||||
*
|
||||
* uint32_t value = 5;
|
||||
* array_add(array, value);
|
||||
*
|
||||
* ...is the equivalent of the code below which is how you would
|
||||
* otherwise use the wl_array API:
|
||||
*
|
||||
* uint32_t *elm = wl_array_add(array, sizeof(uint32_t));
|
||||
* if (!elm) {
|
||||
* perror("failed to allocate memory");
|
||||
* exit(EXIT_FAILURE);
|
||||
* }
|
||||
* *elm = value;
|
||||
*/
|
||||
#define array_add(_arr, _val) do { \
|
||||
__typeof__(_val) *_entry = wl_array_add( \
|
||||
(_arr), sizeof(__typeof__(_val))); \
|
||||
if (!_entry) { \
|
||||
perror("Failed to allocate memory"); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
*_entry = (_val); \
|
||||
} while (0)
|
||||
|
||||
#endif /* LABWC_ARRAY_H */
|
||||
|
|
|
|||
|
|
@ -299,9 +299,16 @@ struct server {
|
|||
struct wlr_scene_tree *menu_tree;
|
||||
|
||||
/* Workspaces */
|
||||
struct wl_list workspaces; /* struct workspace.link */
|
||||
struct workspace *workspace_current;
|
||||
struct workspace *workspace_last;
|
||||
struct {
|
||||
struct wl_list all; /* struct workspace.link */
|
||||
struct workspace *current;
|
||||
struct workspace *last;
|
||||
struct lab_cosmic_workspace_manager *cosmic_manager;
|
||||
struct lab_cosmic_workspace_group *cosmic_group;
|
||||
struct {
|
||||
struct wl_listener layout_output_added;
|
||||
} on;
|
||||
} workspaces;
|
||||
|
||||
struct wl_list outputs;
|
||||
struct wl_listener new_output;
|
||||
|
|
|
|||
61
include/protocols/cosmic-workspaces-internal.h
Normal file
61
include/protocols/cosmic-workspaces-internal.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef LABWC_PROTOCOLS_COSMIC_WORKSPACES_INTERNAL_H
|
||||
#define LABWC_PROTOCOLS_COSMIC_WORKSPACES_INTERNAL_H
|
||||
|
||||
struct lab_cosmic_workspace;
|
||||
struct lab_cosmic_workspace_group;
|
||||
struct lab_cosmic_workspace_manager;
|
||||
|
||||
enum pending_change {
|
||||
/* group events */
|
||||
CW_PENDING_WS_CREATE = 1 << 0,
|
||||
|
||||
/* ws events*/
|
||||
CW_PENDING_WS_ACTIVATE = 1 << 1,
|
||||
CW_PENDING_WS_DEACTIVATE = 1 << 2,
|
||||
CW_PENDING_WS_REMOVE = 1 << 3,
|
||||
};
|
||||
|
||||
struct transaction {
|
||||
uint32_t change;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct transaction_workspace {
|
||||
struct transaction base;
|
||||
struct lab_cosmic_workspace *workspace;
|
||||
};
|
||||
|
||||
struct transaction_group {
|
||||
struct transaction base;
|
||||
struct lab_cosmic_workspace_group *group;
|
||||
char *new_workspace_name;
|
||||
};
|
||||
|
||||
struct session_context {
|
||||
int ref_count;
|
||||
struct wl_list transactions;
|
||||
};
|
||||
|
||||
struct wl_resource_addon {
|
||||
struct session_context *ctx;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct wl_resource_addon *resource_addon_create(struct session_context *ctx);
|
||||
|
||||
void transaction_add_workspace_ev(struct lab_cosmic_workspace *ws,
|
||||
struct wl_resource *resource, enum pending_change change);
|
||||
|
||||
void transaction_add_workspace_group_ev(struct lab_cosmic_workspace_group *group,
|
||||
struct wl_resource *resource, enum pending_change change,
|
||||
const char *new_workspace_name);
|
||||
|
||||
void resource_addon_destroy(struct wl_resource_addon *addon);
|
||||
|
||||
void group_output_send_initial_state(struct lab_cosmic_workspace_group *group,
|
||||
struct wl_resource *group_resource);
|
||||
|
||||
void manager_schedule_done_event(struct lab_cosmic_workspace_manager *manager);
|
||||
|
||||
#endif /* LABWC_PROTOCOLS_COSMIC_WORKSPACES_INTERNAL_H */
|
||||
94
include/protocols/cosmic-workspaces.h
Normal file
94
include/protocols/cosmic-workspaces.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef LABWC_PROTOCOLS_COSMIC_WORKSPACES_H
|
||||
#define LABWC_PROTOCOLS_COSMIC_WORKSPACES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
struct wlr_output;
|
||||
|
||||
struct lab_cosmic_workspace_manager {
|
||||
struct wl_global *global;
|
||||
struct wl_list groups;
|
||||
uint32_t caps;
|
||||
struct wl_event_source *idle_source;
|
||||
struct wl_event_loop *event_loop;
|
||||
|
||||
struct {
|
||||
struct wl_listener display_destroy;
|
||||
} on;
|
||||
|
||||
struct wl_list resources;
|
||||
};
|
||||
|
||||
struct lab_cosmic_workspace_group {
|
||||
struct lab_cosmic_workspace_manager *manager;
|
||||
struct wl_list workspaces;
|
||||
struct wl_array capabilities;
|
||||
struct {
|
||||
struct wl_signal create_workspace;
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct wl_list link;
|
||||
struct wl_list outputs;
|
||||
struct wl_list resources;
|
||||
};
|
||||
|
||||
struct lab_cosmic_workspace {
|
||||
struct lab_cosmic_workspace_group *group;
|
||||
char *name;
|
||||
struct wl_array coordinates;
|
||||
struct wl_array capabilities;
|
||||
uint32_t state; /* enum lab_cosmic_workspace_state */
|
||||
uint32_t state_pending; /* enum lab_cosmic_workspace_state */
|
||||
|
||||
struct {
|
||||
struct wl_signal activate;
|
||||
struct wl_signal deactivate;
|
||||
struct wl_signal remove;
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct wl_list link;
|
||||
struct wl_list resources;
|
||||
};
|
||||
|
||||
enum lab_cosmic_workspace_caps {
|
||||
CW_CAP_NONE = 0,
|
||||
CW_CAP_GRP_ALL = 0x000000ff,
|
||||
CW_CAP_WS_ALL = 0x0000ff00,
|
||||
|
||||
/* group caps */
|
||||
CW_CAP_GRP_WS_CREATE = 1 << 0,
|
||||
|
||||
/* workspace caps */
|
||||
CW_CAP_WS_ACTIVATE = 1 << 8,
|
||||
CW_CAP_WS_DEACTIVATE = 1 << 9,
|
||||
CW_CAP_WS_REMOVE = 1 << 10,
|
||||
};
|
||||
|
||||
struct lab_cosmic_workspace_manager *lab_cosmic_workspace_manager_create(
|
||||
struct wl_display *display, uint32_t caps, uint32_t version);
|
||||
|
||||
struct lab_cosmic_workspace_group *lab_cosmic_workspace_group_create(
|
||||
struct lab_cosmic_workspace_manager *manager);
|
||||
|
||||
void lab_cosmic_workspace_group_output_enter(
|
||||
struct lab_cosmic_workspace_group *group, struct wlr_output *output);
|
||||
|
||||
void lab_cosmic_workspace_group_output_leave(
|
||||
|
||||
struct lab_cosmic_workspace_group *group, struct wlr_output *output);
|
||||
void lab_cosmic_workspace_group_destroy(struct lab_cosmic_workspace_group *group);
|
||||
|
||||
struct lab_cosmic_workspace *lab_cosmic_workspace_create(struct lab_cosmic_workspace_group *group);
|
||||
void lab_cosmic_workspace_set_name(struct lab_cosmic_workspace *workspace, const char *name);
|
||||
void lab_cosmic_workspace_set_active(struct lab_cosmic_workspace *workspace, bool enabled);
|
||||
void lab_cosmic_workspace_set_urgent(struct lab_cosmic_workspace *workspace, bool enabled);
|
||||
void lab_cosmic_workspace_set_hidden(struct lab_cosmic_workspace *workspace, bool enabled);
|
||||
void lab_cosmic_workspace_set_coordinates(struct lab_cosmic_workspace *workspace,
|
||||
struct wl_array *coordinates);
|
||||
void lab_cosmic_workspace_destroy(struct lab_cosmic_workspace *workspace);
|
||||
|
||||
#endif /* LABWC_PROTOCOLS_COSMIC_WORKSPACES_H */
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
struct seat;
|
||||
struct server;
|
||||
|
|
@ -19,6 +20,13 @@ struct workspace {
|
|||
|
||||
char *name;
|
||||
struct wlr_scene_tree *tree;
|
||||
|
||||
struct lab_cosmic_workspace *cosmic_workspace;
|
||||
struct {
|
||||
struct wl_listener activate;
|
||||
struct wl_listener deactivate;
|
||||
struct wl_listener remove;
|
||||
} on;
|
||||
};
|
||||
|
||||
void workspaces_init(struct server *server);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue