mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
cosmic-workspaces: labwc integration
This commit is contained in:
parent
31f4336ed6
commit
904e0d2e97
4 changed files with 61 additions and 0 deletions
|
|
@ -301,6 +301,11 @@ struct server {
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "node.h"
|
||||
#include "output-state.h"
|
||||
#include "output-virtual.h"
|
||||
#include "protocols/cosmic-workspaces.h"
|
||||
#include "regions.h"
|
||||
#include "view.h"
|
||||
#include "xwayland.h"
|
||||
|
|
@ -276,6 +277,9 @@ add_output_to_layout(struct server *server, struct output *output)
|
|||
wlr_scene_output_layout_add_output(server->scene_layout,
|
||||
layout_output, output->scene_output);
|
||||
}
|
||||
|
||||
lab_cosmic_workspace_group_output_enter(
|
||||
server->workspaces.cosmic_group, output->wlr_output);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -567,6 +571,10 @@ output_config_apply(struct server *server,
|
|||
|
||||
if (need_to_remove) {
|
||||
regions_evacuate_output(output);
|
||||
|
||||
lab_cosmic_workspace_group_output_leave(
|
||||
server->workspaces.cosmic_group, output->wlr_output);
|
||||
|
||||
/*
|
||||
* At time of writing, wlr_output_layout_remove()
|
||||
* indirectly destroys the wlr_scene_output, but
|
||||
|
|
|
|||
|
|
@ -15,10 +15,13 @@
|
|||
#include "common/mem.h"
|
||||
#include "input/keyboard.h"
|
||||
#include "labwc.h"
|
||||
#include "protocols/cosmic-workspaces.h"
|
||||
#include "view.h"
|
||||
#include "workspaces.h"
|
||||
#include "xwayland.h"
|
||||
|
||||
#define COSMIC_WORKSPACES_VERSION 1
|
||||
|
||||
/* Internal helpers */
|
||||
static size_t
|
||||
parse_workspace_index(const char *name)
|
||||
|
|
@ -172,6 +175,15 @@ _osd_update(struct server *server)
|
|||
}
|
||||
}
|
||||
|
||||
/* cosmic workspace handlers */
|
||||
static void
|
||||
handle_workspace_activate(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct workspace *workspace = wl_container_of(listener, workspace, on.activate);
|
||||
workspaces_switch_to(workspace, /* update_focus */ true);
|
||||
wlr_log(WLR_INFO, "activating workspace %s", workspace->name);
|
||||
}
|
||||
|
||||
/* Internal API */
|
||||
static void
|
||||
add_workspace(struct server *server, const char *name)
|
||||
|
|
@ -186,6 +198,15 @@ add_workspace(struct server *server, const char *name)
|
|||
} else {
|
||||
wlr_scene_node_set_enabled(&workspace->tree->node, false);
|
||||
}
|
||||
|
||||
bool active = server->workspaces.current == workspace;
|
||||
workspace->cosmic_workspace = lab_cosmic_workspace_create(server->workspaces.cosmic_group);
|
||||
lab_cosmic_workspace_set_name(workspace->cosmic_workspace, name);
|
||||
lab_cosmic_workspace_set_active(workspace->cosmic_workspace, active);
|
||||
lab_cosmic_workspace_set_hidden(workspace->cosmic_workspace, !active);
|
||||
|
||||
workspace->on.activate.notify = handle_workspace_activate;
|
||||
wl_signal_add(&workspace->cosmic_workspace->events.activate, &workspace->on.activate);
|
||||
}
|
||||
|
||||
static struct workspace *
|
||||
|
|
@ -260,6 +281,13 @@ _osd_show(struct server *server)
|
|||
void
|
||||
workspaces_init(struct server *server)
|
||||
{
|
||||
server->workspaces.cosmic_manager = lab_cosmic_workspace_manager_create(
|
||||
server->wl_display, /* capabilities */ CW_CAP_WS_ACTIVATE,
|
||||
COSMIC_WORKSPACES_VERSION);
|
||||
|
||||
server->workspaces.cosmic_group = lab_cosmic_workspace_group_create(
|
||||
server->workspaces.cosmic_manager);
|
||||
|
||||
wl_list_init(&server->workspaces.all);
|
||||
|
||||
struct workspace *conf;
|
||||
|
|
@ -286,6 +314,11 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
|||
wlr_scene_node_set_enabled(
|
||||
&server->workspaces.current->tree->node, false);
|
||||
|
||||
lab_cosmic_workspace_set_active(
|
||||
server->workspaces.current->cosmic_workspace, false);
|
||||
lab_cosmic_workspace_set_hidden(
|
||||
server->workspaces.current->cosmic_workspace, true);
|
||||
|
||||
/* Move Omnipresent views to new workspace */
|
||||
struct view *view;
|
||||
enum lab_view_criteria criteria =
|
||||
|
|
@ -331,6 +364,9 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
|||
|
||||
/* Ensure that only currently visible fullscreen windows hide the top layer */
|
||||
desktop_update_top_layer_visiblity(server);
|
||||
|
||||
lab_cosmic_workspace_set_active(target->cosmic_workspace, true);
|
||||
lab_cosmic_workspace_set_hidden(target->cosmic_workspace, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -395,6 +431,8 @@ destroy_workspace(struct workspace *workspace)
|
|||
wlr_scene_node_destroy(&workspace->tree->node);
|
||||
zfree(workspace->name);
|
||||
wl_list_remove(&workspace->link);
|
||||
|
||||
lab_cosmic_workspace_destroy(workspace->cosmic_workspace);
|
||||
free(workspace);
|
||||
}
|
||||
|
||||
|
|
@ -429,6 +467,8 @@ workspaces_reconfigure(struct server *server)
|
|||
actual_workspace->name, configured_workspace->name);
|
||||
free(actual_workspace->name);
|
||||
actual_workspace->name = xstrdup(configured_workspace->name);
|
||||
lab_cosmic_workspace_set_name(
|
||||
actual_workspace->cosmic_workspace, actual_workspace->name);
|
||||
}
|
||||
actual_workspace_link = actual_workspace_link->next;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue