]> git.sur5r.net Git - i3/i3/blob - src/workspace.c
Bugfix: Don’t hide assigned clients to inactive but visible workspaces (Thanks xeen)
[i3/i3] / src / workspace.c
1 /*
2  * vim:ts=8:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * © 2009 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  * workspace.c: Functions for modifying workspaces
11  *
12  */
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <err.h>
16
17 #include "util.h"
18 #include "data.h"
19 #include "i3.h"
20 #include "config.h"
21 #include "xcb.h"
22
23 /*
24  * Sets the name (or just its number) for the given workspace. This has to
25  * be called for every workspace as the rendering function
26  * (render_internal_bar) relies on workspace->name and workspace->name_len
27  * being ready-to-use.
28  *
29  */
30 void workspace_set_name(Workspace *ws, const char *name) {
31         char *label;
32         int ret;
33
34         if (name != NULL)
35                 ret = asprintf(&label, "%d: %s", ws->num + 1, name);
36         else ret = asprintf(&label, "%d", ws->num + 1);
37
38         if (ret == -1)
39                 errx(1, "asprintf() failed");
40
41         FREE(ws->name);
42
43         ws->name = convert_utf8_to_ucs2(label, &(ws->name_len));
44         ws->text_width = predict_text_width(global_conn, config.font, ws->name, ws->name_len);
45
46         free(label);
47 }
48
49 /*
50  * Returns true if the workspace is currently visible. Especially important for
51  * multi-monitor environments, as they can have multiple currenlty active
52  * workspaces.
53  *
54  */
55 bool workspace_is_visible(Workspace *ws) {
56         return (ws->screen->current_workspace == ws->num);
57 }