aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 20:39:27 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 20:39:50 -0500
commitaeda2e077f6184ecd26dc078c7b5db7f0dc54fd7 (patch)
tree0e84fc6ce2409ef5c60210efd18cb0981e3f9cf7 /sway/tree/workspace.c
parentMerge pull request #1472 from martinetd/wlroots (diff)
downloadsway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.tar.gz
sway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.tar.zst
sway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.zip
Add workspace to outputs
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
new file mode 100644
index 00000000..e8ed4102
--- /dev/null
+++ b/sway/tree/workspace.c
@@ -0,0 +1,26 @@
1#define _XOPEN_SOURCE 500
2#include <stdbool.h>
3#include <stdlib.h>
4#include <stdio.h>
5#include "sway/container.h"
6#include "log.h"
7
8void next_name_map(swayc_t *ws, void *data) {
9 int *count = data;
10 ++count;
11}
12
13char *workspace_next_name(const char *output_name) {
14 sway_log(L_DEBUG, "Workspace: Generating new workspace name for output %s",
15 output_name);
16 int count = 0;
17 next_name_map(&root_container, &count);
18 ++count;
19 int len = snprintf(NULL, 0, "%d", count);
20 char *name = malloc(len + 1);
21 if (!sway_assert(name, "Failed to allocate workspace name")) {
22 return NULL;
23 }
24 snprintf(name, len + 1, "%d", count);
25 return name;
26}