From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Tue, 10 Dec 2024 05:26:19 +0000 (+0100) Subject: ext-workspace protocol integration X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=8156b91306e7d2ddca9bb17ae5c7f119bfd7de03;p=proto%2Flabwc.git ext-workspace protocol integration --- diff --git a/include/labwc.h b/include/labwc.h index ef5d9c03..6e5d7fdd 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -311,6 +311,8 @@ struct server { struct workspace *last; struct lab_cosmic_workspace_manager *cosmic_manager; struct lab_cosmic_workspace_group *cosmic_group; + struct lab_ext_workspace_manager *ext_manager; + struct lab_ext_workspace_group *ext_group; struct { struct wl_listener layout_output_added; } on; diff --git a/include/workspaces.h b/include/workspaces.h index f0980b05..f5543548 100644 --- a/include/workspaces.h +++ b/include/workspaces.h @@ -27,6 +27,14 @@ struct workspace { struct wl_listener deactivate; struct wl_listener remove; } on_cosmic; + + struct lab_ext_workspace *ext_workspace; + struct { + struct wl_listener activate; + struct wl_listener deactivate; + struct wl_listener assign; + struct wl_listener remove; + } on_ext; }; void workspaces_init(struct server *server); diff --git a/src/output.c b/src/output.c index 7de1c010..decdf07b 100644 --- a/src/output.c +++ b/src/output.c @@ -28,6 +28,7 @@ #include "output-state.h" #include "output-virtual.h" #include "protocols/cosmic-workspaces.h" +#include "protocols/ext-workspace.h" #include "regions.h" #include "view.h" #include "xwayland.h" @@ -284,6 +285,8 @@ add_output_to_layout(struct server *server, struct output *output) lab_cosmic_workspace_group_output_enter( server->workspaces.cosmic_group, output->wlr_output); + lab_ext_workspace_group_output_enter( + server->workspaces.ext_group, output->wlr_output); /* (Re-)create regions from config */ regions_reconfigure_output(output); @@ -596,6 +599,8 @@ output_config_apply(struct server *server, lab_cosmic_workspace_group_output_leave( server->workspaces.cosmic_group, output->wlr_output); + lab_ext_workspace_group_output_leave( + server->workspaces.ext_group, output->wlr_output); /* * At time of writing, wlr_output_layout_remove() diff --git a/src/workspaces.c b/src/workspaces.c index a475b7de..20009fb9 100644 --- a/src/workspaces.c +++ b/src/workspaces.c @@ -16,11 +16,13 @@ #include "input/keyboard.h" #include "labwc.h" #include "protocols/cosmic-workspaces.h" +#include "protocols/ext-workspace.h" #include "view.h" #include "workspaces.h" #include "xwayland.h" #define COSMIC_WORKSPACES_VERSION 1 +#define EXT_WORKSPACES_VERSION 1 /* Internal helpers */ static size_t @@ -185,6 +187,15 @@ handle_cosmic_workspace_activate(struct wl_listener *listener, void *data) wlr_log(WLR_INFO, "cosmic activating workspace %s", workspace->name); } +/* ext workspace handlers */ +static void +handle_ext_workspace_activate(struct wl_listener *listener, void *data) +{ + struct workspace *workspace = wl_container_of(listener, workspace, on_ext.activate); + workspaces_switch_to(workspace, /* update_focus */ true); + wlr_log(WLR_INFO, "ext activating workspace %s", workspace->name); +} + /* Internal API */ static void add_workspace(struct server *server, const char *name) @@ -210,6 +221,17 @@ add_workspace(struct server *server, const char *name) workspace->on_cosmic.activate.notify = handle_cosmic_workspace_activate; wl_signal_add(&workspace->cosmic_workspace->events.activate, &workspace->on_cosmic.activate); + + /* ext */ + workspace->ext_workspace = lab_ext_workspace_create( + server->workspaces.ext_manager, /*id*/ NULL); + lab_ext_workspace_assign_to_group(workspace->ext_workspace, server->workspaces.ext_group); + lab_ext_workspace_set_name(workspace->ext_workspace, name); + lab_ext_workspace_set_active(workspace->ext_workspace, active); + + workspace->on_ext.activate.notify = handle_ext_workspace_activate; + wl_signal_add(&workspace->ext_workspace->events.activate, + &workspace->on_ext.activate); } static struct workspace * @@ -288,9 +310,16 @@ workspaces_init(struct server *server) server->wl_display, /* capabilities */ CW_CAP_WS_ACTIVATE, COSMIC_WORKSPACES_VERSION); + server->workspaces.ext_manager = lab_ext_workspace_manager_create( + server->wl_display, /* capabilities */ WS_CAP_WS_ACTIVATE, + EXT_WORKSPACES_VERSION); + server->workspaces.cosmic_group = lab_cosmic_workspace_group_create( server->workspaces.cosmic_manager); + server->workspaces.ext_group = lab_ext_workspace_group_create( + server->workspaces.ext_manager); + wl_list_init(&server->workspaces.all); struct workspace *conf; @@ -319,6 +348,8 @@ workspaces_switch_to(struct workspace *target, bool update_focus) lab_cosmic_workspace_set_active( server->workspaces.current->cosmic_workspace, false); + lab_ext_workspace_set_active( + server->workspaces.current->ext_workspace, false); /* Move Omnipresent views to new workspace */ struct view *view; @@ -374,6 +405,7 @@ workspaces_switch_to(struct workspace *target, bool update_focus) desktop_update_top_layer_visiblity(server); lab_cosmic_workspace_set_active(target->cosmic_workspace, true); + lab_ext_workspace_set_active(target->ext_workspace, true); } void @@ -440,6 +472,7 @@ destroy_workspace(struct workspace *workspace) wl_list_remove(&workspace->link); lab_cosmic_workspace_destroy(workspace->cosmic_workspace); + lab_ext_workspace_destroy(workspace->ext_workspace); free(workspace); } @@ -476,6 +509,8 @@ workspaces_reconfigure(struct server *server) actual_workspace->name = xstrdup(configured_workspace->name); lab_cosmic_workspace_set_name( actual_workspace->cosmic_workspace, actual_workspace->name); + lab_ext_workspace_set_name( + actual_workspace->ext_workspace, actual_workspace->name); } actual_workspace_link = actual_workspace_link->next; }