mirror of
https://github.com/labwc/labwc.git
synced 2026-03-03 01:40:37 -05:00
workspaces: slight struct reordering
This commit is contained in:
parent
750d37b16c
commit
d9866aafa5
9 changed files with 40 additions and 38 deletions
|
|
@ -297,9 +297,11 @@ struct server {
|
||||||
struct wlr_scene_tree *menu_tree;
|
struct wlr_scene_tree *menu_tree;
|
||||||
|
|
||||||
/* Workspaces */
|
/* Workspaces */
|
||||||
struct wl_list workspaces; /* struct workspace.link */
|
struct {
|
||||||
struct workspace *workspace_current;
|
struct wl_list all; /* struct workspace.link */
|
||||||
struct workspace *workspace_last;
|
struct workspace *current;
|
||||||
|
struct workspace *last;
|
||||||
|
} workspaces;
|
||||||
|
|
||||||
struct wl_list outputs;
|
struct wl_list outputs;
|
||||||
struct wl_listener new_output;
|
struct wl_listener new_output;
|
||||||
|
|
|
||||||
|
|
@ -982,7 +982,7 @@ actions_run(struct view *activator, struct server *server,
|
||||||
* a required argument for both SendToDesktop and GoToDesktop.
|
* a required argument for both SendToDesktop and GoToDesktop.
|
||||||
*/
|
*/
|
||||||
struct workspace *target = workspaces_find(
|
struct workspace *target = workspaces_find(
|
||||||
server->workspace_current, to, wrap);
|
server->workspaces.current, to, wrap);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ get_special(struct server *server, struct wlr_scene_node *node)
|
||||||
}
|
}
|
||||||
if (node->parent == server->view_tree) {
|
if (node->parent == server->view_tree) {
|
||||||
struct workspace *workspace;
|
struct workspace *workspace;
|
||||||
wl_list_for_each(workspace, &server->workspaces, link) {
|
wl_list_for_each(workspace, &server->workspaces.all, link) {
|
||||||
if (&workspace->tree->node == node) {
|
if (&workspace->tree->node == node) {
|
||||||
return workspace->name;
|
return workspace->name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ desktop_topmost_focusable_view(struct server *server)
|
||||||
struct view *view;
|
struct view *view;
|
||||||
struct wl_list *node_list;
|
struct wl_list *node_list;
|
||||||
struct wlr_scene_node *node;
|
struct wlr_scene_node *node;
|
||||||
node_list = &server->workspace_current->tree->children;
|
node_list = &server->workspaces.current->tree->children;
|
||||||
wl_list_for_each_reverse(node, node_list, link) {
|
wl_list_for_each_reverse(node, node_list, link) {
|
||||||
if (!node->data) {
|
if (!node->data) {
|
||||||
/* We found some non-view, most likely the region overlay */
|
/* We found some non-view, most likely the region overlay */
|
||||||
|
|
@ -185,7 +185,7 @@ desktop_focus_output(struct output *output)
|
||||||
struct wlr_scene_node *node;
|
struct wlr_scene_node *node;
|
||||||
struct wlr_output_layout *layout = output->server->output_layout;
|
struct wlr_output_layout *layout = output->server->output_layout;
|
||||||
struct wl_list *list_head =
|
struct wl_list *list_head =
|
||||||
&output->server->workspace_current->tree->children;
|
&output->server->workspaces.current->tree->children;
|
||||||
wl_list_for_each_reverse(node, list_head, link) {
|
wl_list_for_each_reverse(node, list_head, link) {
|
||||||
if (!node->data) {
|
if (!node->data) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ display_osd(struct output *output, struct wl_array *views)
|
||||||
struct server *server = output->server;
|
struct server *server = output->server;
|
||||||
struct theme *theme = server->theme;
|
struct theme *theme = server->theme;
|
||||||
bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
|
bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
|
||||||
const char *workspace_name = server->workspace_current->name;
|
const char *workspace_name = server->workspaces.current->name;
|
||||||
|
|
||||||
float scale = output->wlr_output->scale;
|
float scale = output->wlr_output->scale;
|
||||||
int w = theme->osd_window_switcher_width;
|
int w = theme->osd_window_switcher_width;
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ matches_criteria(struct view *view, enum lab_view_criteria criteria)
|
||||||
* special in that they live in a different tree.
|
* special in that they live in a different tree.
|
||||||
*/
|
*/
|
||||||
struct server *server = view->server;
|
struct server *server = view->server;
|
||||||
if (view->scene_tree->node.parent != server->workspace_current->tree
|
if (view->scene_tree->node.parent != server->workspaces.current->tree
|
||||||
&& !view_is_always_on_top(view)) {
|
&& !view_is_always_on_top(view)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1451,7 +1451,7 @@ view_toggle_always_on_top(struct view *view)
|
||||||
{
|
{
|
||||||
assert(view);
|
assert(view);
|
||||||
if (view_is_always_on_top(view)) {
|
if (view_is_always_on_top(view)) {
|
||||||
view->workspace = view->server->workspace_current;
|
view->workspace = view->server->workspaces.current;
|
||||||
wlr_scene_node_reparent(&view->scene_tree->node,
|
wlr_scene_node_reparent(&view->scene_tree->node,
|
||||||
view->workspace->tree);
|
view->workspace->tree);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1473,7 +1473,7 @@ view_toggle_always_on_bottom(struct view *view)
|
||||||
{
|
{
|
||||||
assert(view);
|
assert(view);
|
||||||
if (view_is_always_on_bottom(view)) {
|
if (view_is_always_on_bottom(view)) {
|
||||||
view->workspace = view->server->workspace_current;
|
view->workspace = view->server->workspaces.current;
|
||||||
wlr_scene_node_reparent(&view->scene_tree->node,
|
wlr_scene_node_reparent(&view->scene_tree->node,
|
||||||
view->workspace->tree);
|
view->workspace->tree);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ _osd_update(struct server *server)
|
||||||
theme->osd_workspace_switcher_boxes_height == 0;
|
theme->osd_workspace_switcher_boxes_height == 0;
|
||||||
|
|
||||||
/* Dimensions */
|
/* Dimensions */
|
||||||
size_t workspace_count = wl_list_length(&server->workspaces);
|
size_t workspace_count = wl_list_length(&server->workspaces.all);
|
||||||
uint16_t marker_width = workspace_count * (rect_width + padding) - padding;
|
uint16_t marker_width = workspace_count * (rect_width + padding) - padding;
|
||||||
uint16_t width = margin * 2 + (marker_width < 200 ? 200 : marker_width);
|
uint16_t width = margin * 2 + (marker_width < 200 ? 200 : marker_width);
|
||||||
uint16_t height = margin * (hide_boxes ? 2 : 3) + rect_height + font_height(&rc.font_osd);
|
uint16_t height = margin * (hide_boxes ? 2 : 3) + rect_height + font_height(&rc.font_osd);
|
||||||
|
|
@ -106,8 +106,8 @@ _osd_update(struct server *server)
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
if (!hide_boxes) {
|
if (!hide_boxes) {
|
||||||
x = (width - marker_width) / 2;
|
x = (width - marker_width) / 2;
|
||||||
wl_list_for_each(workspace, &server->workspaces, link) {
|
wl_list_for_each(workspace, &server->workspaces.all, link) {
|
||||||
bool active = workspace == server->workspace_current;
|
bool active = workspace == server->workspaces.current;
|
||||||
set_cairo_color(cairo, server->theme->osd_label_text_color);
|
set_cairo_color(cairo, server->theme->osd_label_text_color);
|
||||||
cairo_rectangle(cairo, x, margin,
|
cairo_rectangle(cairo, x, margin,
|
||||||
rect_width - padding, rect_height);
|
rect_width - padding, rect_height);
|
||||||
|
|
@ -128,7 +128,7 @@ _osd_update(struct server *server)
|
||||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||||
|
|
||||||
/* Center workspace indicator on the x axis */
|
/* Center workspace indicator on the x axis */
|
||||||
int req_width = font_width(&rc.font_osd, server->workspace_current->name);
|
int req_width = font_width(&rc.font_osd, server->workspaces.current->name);
|
||||||
req_width = MIN(req_width, width - 2 * margin);
|
req_width = MIN(req_width, width - 2 * margin);
|
||||||
x = (width - req_width) / 2;
|
x = (width - req_width) / 2;
|
||||||
if (!hide_boxes) {
|
if (!hide_boxes) {
|
||||||
|
|
@ -141,7 +141,7 @@ _osd_update(struct server *server)
|
||||||
pango_layout_set_font_description(layout, desc);
|
pango_layout_set_font_description(layout, desc);
|
||||||
pango_layout_set_width(layout, req_width * PANGO_SCALE);
|
pango_layout_set_width(layout, req_width * PANGO_SCALE);
|
||||||
pango_font_description_free(desc);
|
pango_font_description_free(desc);
|
||||||
pango_layout_set_text(layout, server->workspace_current->name, -1);
|
pango_layout_set_text(layout, server->workspaces.current->name, -1);
|
||||||
pango_cairo_show_layout(cairo, layout);
|
pango_cairo_show_layout(cairo, layout);
|
||||||
|
|
||||||
g_object_unref(layout);
|
g_object_unref(layout);
|
||||||
|
|
@ -180,9 +180,9 @@ add_workspace(struct server *server, const char *name)
|
||||||
workspace->server = server;
|
workspace->server = server;
|
||||||
workspace->name = xstrdup(name);
|
workspace->name = xstrdup(name);
|
||||||
workspace->tree = wlr_scene_tree_create(server->view_tree);
|
workspace->tree = wlr_scene_tree_create(server->view_tree);
|
||||||
wl_list_append(&server->workspaces, &workspace->link);
|
wl_list_append(&server->workspaces.all, &workspace->link);
|
||||||
if (!server->workspace_current) {
|
if (!server->workspaces.current) {
|
||||||
server->workspace_current = workspace;
|
server->workspaces.current = workspace;
|
||||||
} else {
|
} else {
|
||||||
wlr_scene_node_set_enabled(&workspace->tree->node, false);
|
wlr_scene_node_set_enabled(&workspace->tree->node, false);
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +260,7 @@ _osd_show(struct server *server)
|
||||||
void
|
void
|
||||||
workspaces_init(struct server *server)
|
workspaces_init(struct server *server)
|
||||||
{
|
{
|
||||||
wl_list_init(&server->workspaces);
|
wl_list_init(&server->workspaces.all);
|
||||||
|
|
||||||
struct workspace *conf;
|
struct workspace *conf;
|
||||||
wl_list_for_each(conf, &rc.workspace_config.workspaces, link) {
|
wl_list_for_each(conf, &rc.workspace_config.workspaces, link) {
|
||||||
|
|
@ -278,13 +278,13 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
||||||
{
|
{
|
||||||
assert(target);
|
assert(target);
|
||||||
struct server *server = target->server;
|
struct server *server = target->server;
|
||||||
if (target == server->workspace_current) {
|
if (target == server->workspaces.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable the old workspace */
|
/* Disable the old workspace */
|
||||||
wlr_scene_node_set_enabled(
|
wlr_scene_node_set_enabled(
|
||||||
&server->workspace_current->tree->node, false);
|
&server->workspaces.current->tree->node, false);
|
||||||
|
|
||||||
/* Move Omnipresent views to new workspace */
|
/* Move Omnipresent views to new workspace */
|
||||||
struct view *view;
|
struct view *view;
|
||||||
|
|
@ -300,10 +300,10 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
||||||
wlr_scene_node_set_enabled(&target->tree->node, true);
|
wlr_scene_node_set_enabled(&target->tree->node, true);
|
||||||
|
|
||||||
/* Save the last visited workspace */
|
/* Save the last visited workspace */
|
||||||
server->workspace_last = server->workspace_current;
|
server->workspaces.last = server->workspaces.current;
|
||||||
|
|
||||||
/* Make sure new views will spawn on the new workspace */
|
/* Make sure new views will spawn on the new workspace */
|
||||||
server->workspace_current = target;
|
server->workspaces.current = target;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we are focusing what the user sees.
|
* Make sure we are focusing what the user sees.
|
||||||
|
|
@ -362,7 +362,7 @@ workspaces_find(struct workspace *anchor, const char *name, bool wrap)
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
struct workspace *target;
|
struct workspace *target;
|
||||||
size_t wants_index = parse_workspace_index(name);
|
size_t wants_index = parse_workspace_index(name);
|
||||||
struct wl_list *workspaces = &anchor->server->workspaces;
|
struct wl_list *workspaces = &anchor->server->workspaces.all;
|
||||||
|
|
||||||
if (wants_index) {
|
if (wants_index) {
|
||||||
wl_list_for_each(target, workspaces, link) {
|
wl_list_for_each(target, workspaces, link) {
|
||||||
|
|
@ -373,7 +373,7 @@ workspaces_find(struct workspace *anchor, const char *name, bool wrap)
|
||||||
} else if (!strcasecmp(name, "current")) {
|
} else if (!strcasecmp(name, "current")) {
|
||||||
return anchor;
|
return anchor;
|
||||||
} else if (!strcasecmp(name, "last")) {
|
} else if (!strcasecmp(name, "last")) {
|
||||||
return anchor->server->workspace_last;
|
return anchor->server->workspaces.last;
|
||||||
} else if (!strcasecmp(name, "left")) {
|
} else if (!strcasecmp(name, "left")) {
|
||||||
return get_prev(anchor, workspaces, wrap);
|
return get_prev(anchor, workspaces, wrap);
|
||||||
} else if (!strcasecmp(name, "right")) {
|
} else if (!strcasecmp(name, "right")) {
|
||||||
|
|
@ -408,7 +408,7 @@ workspaces_reconfigure(struct server *server)
|
||||||
* - Destroy workspaces if fewer workspace are desired
|
* - Destroy workspaces if fewer workspace are desired
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct wl_list *actual_workspace_link = server->workspaces.next;
|
struct wl_list *actual_workspace_link = server->workspaces.all.next;
|
||||||
|
|
||||||
struct workspace *configured_workspace;
|
struct workspace *configured_workspace;
|
||||||
wl_list_for_each(configured_workspace,
|
wl_list_for_each(configured_workspace,
|
||||||
|
|
@ -416,7 +416,7 @@ workspaces_reconfigure(struct server *server)
|
||||||
struct workspace *actual_workspace = wl_container_of(
|
struct workspace *actual_workspace = wl_container_of(
|
||||||
actual_workspace_link, actual_workspace, link);
|
actual_workspace_link, actual_workspace, link);
|
||||||
|
|
||||||
if (actual_workspace_link == &server->workspaces) {
|
if (actual_workspace_link == &server->workspaces.all) {
|
||||||
/* # of configured workspaces increased */
|
/* # of configured workspaces increased */
|
||||||
wlr_log(WLR_DEBUG, "Adding workspace \"%s\"",
|
wlr_log(WLR_DEBUG, "Adding workspace \"%s\"",
|
||||||
configured_workspace->name);
|
configured_workspace->name);
|
||||||
|
|
@ -433,16 +433,16 @@ workspaces_reconfigure(struct server *server)
|
||||||
actual_workspace_link = actual_workspace_link->next;
|
actual_workspace_link = actual_workspace_link->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actual_workspace_link == &server->workspaces) {
|
if (actual_workspace_link == &server->workspaces.all) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* # of configured workspaces decreased */
|
/* # of configured workspaces decreased */
|
||||||
overlay_hide(&server->seat);
|
overlay_hide(&server->seat);
|
||||||
struct workspace *first_workspace =
|
struct workspace *first_workspace =
|
||||||
wl_container_of(server->workspaces.next, first_workspace, link);
|
wl_container_of(server->workspaces.all.next, first_workspace, link);
|
||||||
|
|
||||||
while (actual_workspace_link != &server->workspaces) {
|
while (actual_workspace_link != &server->workspaces.all) {
|
||||||
struct workspace *actual_workspace = wl_container_of(
|
struct workspace *actual_workspace = wl_container_of(
|
||||||
actual_workspace_link, actual_workspace, link);
|
actual_workspace_link, actual_workspace, link);
|
||||||
|
|
||||||
|
|
@ -456,12 +456,12 @@ workspaces_reconfigure(struct server *server)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server->workspace_current == actual_workspace) {
|
if (server->workspaces.current == actual_workspace) {
|
||||||
workspaces_switch_to(first_workspace,
|
workspaces_switch_to(first_workspace,
|
||||||
/* update_focus */ true);
|
/* update_focus */ true);
|
||||||
}
|
}
|
||||||
if (server->workspace_last == actual_workspace) {
|
if (server->workspaces.last == actual_workspace) {
|
||||||
server->workspace_last = first_workspace;
|
server->workspaces.last = first_workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
actual_workspace_link = actual_workspace_link->next;
|
actual_workspace_link = actual_workspace_link->next;
|
||||||
|
|
@ -473,8 +473,8 @@ void
|
||||||
workspaces_destroy(struct server *server)
|
workspaces_destroy(struct server *server)
|
||||||
{
|
{
|
||||||
struct workspace *workspace, *tmp;
|
struct workspace *workspace, *tmp;
|
||||||
wl_list_for_each_safe(workspace, tmp, &server->workspaces, link) {
|
wl_list_for_each_safe(workspace, tmp, &server->workspaces.all, link) {
|
||||||
destroy_workspace(workspace);
|
destroy_workspace(workspace);
|
||||||
}
|
}
|
||||||
assert(wl_list_empty(&server->workspaces));
|
assert(wl_list_empty(&server->workspaces.all));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -840,7 +840,7 @@ xdg_toplevel_new(struct wl_listener *listener, void *data)
|
||||||
view->output->wlr_output->scale);
|
view->output->wlr_output->scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
view->workspace = server->workspace_current;
|
view->workspace = server->workspaces.current;
|
||||||
view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
|
view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
|
||||||
wlr_scene_node_set_enabled(&view->scene_tree->node, false);
|
wlr_scene_node_set_enabled(&view->scene_tree->node, false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -985,7 +985,7 @@ xwayland_view_create(struct server *server,
|
||||||
xwayland_view->xwayland_surface = xsurface;
|
xwayland_view->xwayland_surface = xsurface;
|
||||||
xsurface->data = view;
|
xsurface->data = view;
|
||||||
|
|
||||||
view->workspace = server->workspace_current;
|
view->workspace = server->workspaces.current;
|
||||||
view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
|
view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
|
||||||
node_descriptor_create(&view->scene_tree->node, LAB_NODE_DESC_VIEW, view);
|
node_descriptor_create(&view->scene_tree->node, LAB_NODE_DESC_VIEW, view);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue