]> git.mdlowis.com Git - proto/labwc.git/commitdiff
workspaces: slight struct reordering
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 25 Jul 2024 19:56:05 +0000 (21:56 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 2 Aug 2024 17:35:36 +0000 (19:35 +0200)
include/labwc.h
src/action.c
src/debug.c
src/desktop.c
src/osd.c
src/view.c
src/workspaces.c
src/xdg.c
src/xwayland.c

index 77bb41d4cfeee61920191cde5167111ede250508..3439a0994e9a75b19bf0eb385716a57526672dcf 100644 (file)
@@ -297,9 +297,11 @@ 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;
+       } workspaces;
 
        struct wl_list outputs;
        struct wl_listener new_output;
index 0aa45d7a863b5e51feeacfeece7e95bbf648e0a5..e976a4467a5569a68b7a0255a5cb00da97e303f4 100644 (file)
@@ -982,7 +982,7 @@ actions_run(struct view *activator, struct server *server,
                                 * a required argument for both SendToDesktop and GoToDesktop.
                                 */
                                struct workspace *target = workspaces_find(
-                                       server->workspace_current, to, wrap);
+                                       server->workspaces.current, to, wrap);
                                if (!target) {
                                        break;
                                }
index d5750feaab5b0c5533c39518ad6fbb6cc36754ac..7fb2672d5e0e6dac3779634585ecce9b92d2ae37 100644 (file)
@@ -106,7 +106,7 @@ get_special(struct server *server, struct wlr_scene_node *node)
        }
        if (node->parent == server->view_tree) {
                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) {
                                return workspace->name;
                        }
index 2c0db207817f537eb3dfcb0ca4caebaedd6ffbeb..353132ef37e4c5c556f6c2b52d812b012ae46009 100644 (file)
@@ -145,7 +145,7 @@ desktop_topmost_focusable_view(struct server *server)
        struct view *view;
        struct wl_list *node_list;
        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) {
                if (!node->data) {
                        /* 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_output_layout *layout = output->server->output_layout;
        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) {
                if (!node->data) {
                        continue;
index 91dbd27006ab7e65c14df9ac079307f74192a45a..7e2aedab848e845214c07ea552dde6debd2de5fb 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -331,7 +331,7 @@ display_osd(struct output *output, struct wl_array *views)
        struct server *server = output->server;
        struct theme *theme = server->theme;
        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;
        int w = theme->osd_window_switcher_width;
index 8dd5e796ccab6e49caff701b028665f7a0c98869..f68db65e42a9d4de8843430cf4a989d6ebf2b886 100644 (file)
@@ -140,7 +140,7 @@ matches_criteria(struct view *view, enum lab_view_criteria criteria)
                 * special in that they live in a different tree.
                 */
                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)) {
                        return false;
                }
@@ -1451,7 +1451,7 @@ view_toggle_always_on_top(struct view *view)
 {
        assert(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,
                        view->workspace->tree);
        } else {
@@ -1473,7 +1473,7 @@ view_toggle_always_on_bottom(struct view *view)
 {
        assert(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,
                        view->workspace->tree);
        } else {
index 76dc93d643fbeb2a36031d9404ab0b3b8f279c20..8e9b912f67845c4eeaf7a68a4516256ffa72baf0 100644 (file)
@@ -66,7 +66,7 @@ _osd_update(struct server *server)
                theme->osd_workspace_switcher_boxes_height == 0;
 
        /* 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 width = margin * 2 + (marker_width < 200 ? 200 : marker_width);
        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;
                if (!hide_boxes) {
                        x = (width - marker_width) / 2;
-                       wl_list_for_each(workspace, &server->workspaces, link) {
-                               bool active =  workspace == server->workspace_current;
+                       wl_list_for_each(workspace, &server->workspaces.all, link) {
+                               bool active =  workspace == server->workspaces.current;
                                set_cairo_color(cairo, server->theme->osd_label_text_color);
                                cairo_rectangle(cairo, x, margin,
                                        rect_width - padding, rect_height);
@@ -128,7 +128,7 @@ _osd_update(struct server *server)
                pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 
                /* 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);
                x = (width - req_width) / 2;
                if (!hide_boxes) {
@@ -141,7 +141,7 @@ _osd_update(struct server *server)
                pango_layout_set_font_description(layout, desc);
                pango_layout_set_width(layout, req_width * PANGO_SCALE);
                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);
 
                g_object_unref(layout);
@@ -180,9 +180,9 @@ add_workspace(struct server *server, const char *name)
        workspace->server = server;
        workspace->name = xstrdup(name);
        workspace->tree = wlr_scene_tree_create(server->view_tree);
-       wl_list_append(&server->workspaces, &workspace->link);
-       if (!server->workspace_current) {
-               server->workspace_current = workspace;
+       wl_list_append(&server->workspaces.all, &workspace->link);
+       if (!server->workspaces.current) {
+               server->workspaces.current = workspace;
        } else {
                wlr_scene_node_set_enabled(&workspace->tree->node, false);
        }
@@ -260,7 +260,7 @@ _osd_show(struct server *server)
 void
 workspaces_init(struct server *server)
 {
-       wl_list_init(&server->workspaces);
+       wl_list_init(&server->workspaces.all);
 
        struct workspace *conf;
        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);
        struct server *server = target->server;
-       if (target == server->workspace_current) {
+       if (target == server->workspaces.current) {
                return;
        }
 
        /* Disable the old workspace */
        wlr_scene_node_set_enabled(
-               &server->workspace_current->tree->node, false);
+               &server->workspaces.current->tree->node, false);
 
        /* Move Omnipresent views to new workspace */
        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);
 
        /* 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 */
-       server->workspace_current = target;
+       server->workspaces.current = target;
 
        /*
         * 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;
        struct workspace *target;
        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) {
                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")) {
                return anchor;
        } else if (!strcasecmp(name, "last")) {
-               return anchor->server->workspace_last;
+               return anchor->server->workspaces.last;
        } else if (!strcasecmp(name, "left")) {
                return get_prev(anchor, workspaces, wrap);
        } else if (!strcasecmp(name, "right")) {
@@ -408,7 +408,7 @@ workspaces_reconfigure(struct server *server)
         *   - 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;
        wl_list_for_each(configured_workspace,
@@ -416,7 +416,7 @@ workspaces_reconfigure(struct server *server)
                struct workspace *actual_workspace = wl_container_of(
                        actual_workspace_link, actual_workspace, link);
 
-               if (actual_workspace_link == &server->workspaces) {
+               if (actual_workspace_link == &server->workspaces.all) {
                        /* # of configured workspaces increased */
                        wlr_log(WLR_DEBUG, "Adding workspace \"%s\"",
                                configured_workspace->name);
@@ -433,16 +433,16 @@ workspaces_reconfigure(struct server *server)
                actual_workspace_link = actual_workspace_link->next;
        }
 
-       if (actual_workspace_link == &server->workspaces) {
+       if (actual_workspace_link == &server->workspaces.all) {
                return;
        }
 
        /* # of configured workspaces decreased */
        overlay_hide(&server->seat);
        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(
                        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,
                                /* update_focus */ true);
                }
-               if (server->workspace_last == actual_workspace) {
-                       server->workspace_last = first_workspace;
+               if (server->workspaces.last == actual_workspace) {
+                       server->workspaces.last = first_workspace;
                }
 
                actual_workspace_link = actual_workspace_link->next;
@@ -473,8 +473,8 @@ void
 workspaces_destroy(struct server *server)
 {
        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);
        }
-       assert(wl_list_empty(&server->workspaces));
+       assert(wl_list_empty(&server->workspaces.all));
 }
index f67796da3627c98bf9a020f61c05aecd8fc24ecd..ed48cbf0ecdc20630af280f6f92ab236fb7c320d 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -840,7 +840,7 @@ xdg_toplevel_new(struct wl_listener *listener, void *data)
                        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);
        wlr_scene_node_set_enabled(&view->scene_tree->node, false);
 
index 738c2b17d0df566f072fc853ae3bd48d280155e3..8fc87d2bb1278e5b4df75aada9c4910844577ad9 100644 (file)
@@ -985,7 +985,7 @@ xwayland_view_create(struct server *server,
        xwayland_view->xwayland_surface = xsurface;
        xsurface->data = view;
 
-       view->workspace = server->workspace_current;
+       view->workspace = server->workspaces.current;
        view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
        node_descriptor_create(&view->scene_tree->node, LAB_NODE_DESC_VIEW, view);