]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: support <desktops number=>
authorSachin Bhat <sachubhat17@gmail.com>
Sat, 24 Jun 2023 12:36:06 +0000 (20:36 +0800)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 25 Jun 2023 09:31:13 +0000 (10:31 +0100)
include/config/rcxml.h
src/config/rcxml.c

index 29468a4258334f7a634aea2387cbfb49c7ea69d7..d7ae5eb8323a2a4f67c277cbb588293f37e65397 100644 (file)
@@ -69,7 +69,7 @@ struct rcxml {
 
        struct {
                int popuptime;
-               int count;
+               int min_nr_workspaces;
                struct wl_list workspaces;  /* struct workspace.link */
        } workspace_config;
 
index 1b275761cb60f74af4ad73ddabec765ba194a649..1a384c9041d13b4380b0743253168c03e9474a2a 100644 (file)
@@ -616,7 +616,7 @@ entry(xmlNode *node, char *nodename, char *content)
        } else if (!strcasecmp(nodename, "popupTime.desktops")) {
                rc.workspace_config.popuptime = atoi(content);
        } else if (!strcasecmp(nodename, "number.desktops")) {
-               rc.workspace_config.count = MAX(1, atoi(content));
+               rc.workspace_config.min_nr_workspaces = MAX(1, atoi(content));
        }
 }
 
@@ -759,7 +759,7 @@ rcxml_init(void)
        rc.window_switcher.outlines = true;
 
        rc.workspace_config.popuptime = INT_MIN;
-       rc.workspace_config.count = 1;
+       rc.workspace_config.min_nr_workspaces = 1;
 }
 
 static struct {
@@ -1048,14 +1048,14 @@ post_processing(void)
                assert(l && libinput_category_get_default() == l);
        }
 
-       int workspaces_configured = wl_list_length(&rc.workspace_config.workspaces);
-       if (workspaces_configured < rc.workspace_config.count) {
+       int nr_workspaces = wl_list_length(&rc.workspace_config.workspaces);
+       if (nr_workspaces < rc.workspace_config.min_nr_workspaces) {
                struct workspace *workspace;
-               char workspace_name[32]; // Maximum length of workspace name "Workspace X"
-               for (int i = workspaces_configured; i < rc.workspace_config.count; i++) {
+               for (int i = nr_workspaces; i < rc.workspace_config.min_nr_workspaces; i++) {
                        workspace = znew(*workspace);
-                       snprintf(workspace_name, sizeof(workspace_name), "Workspace %d", i + 1);
-                       workspace->name = xstrdup(workspace_name);
+                       char *workspace_name = malloc(sizeof(char) * 32);
+                       snprintf(workspace_name, 32, "Workspace %d", i + 1);
+                       workspace->name = workspace_name;
                        wl_list_append(&rc.workspace_config.workspaces, &workspace->link);
                }
        }