]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ext-workspace protocol integration
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 10 Dec 2024 05:26:19 +0000 (06:26 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 23 Dec 2024 03:14:53 +0000 (04:14 +0100)
include/labwc.h
include/workspaces.h
src/output.c
src/workspaces.c

index ef5d9c03ac0c72ab92837e97b318dd49b43c72b7..6e5d7fdd164770d73328b5c33cdfcf01f7022580 100644 (file)
@@ -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;
index f0980b0599369a11330c631dc642cd0c97c25b59..f55435483f9d22c7729d73c74d9925f7e482afe2 100644 (file)
@@ -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);
index 7de1c010aa9a54095562e8ac0186ebfdf673bffe..decdf07b9ff97f8f40e015ad980f3786204bc45d 100644 (file)
@@ -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()
index a475b7de4647435cf6af5ee185bec9b1b188b5e9..20009fb9de42483ebb799ed77bd29e35023d3f28 100644 (file)
 #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;
        }