]> git.sur5r.net Git - i3/i3/blob - src/container.c
implement con_id for matching containers, extend testcase
[i3/i3] / src / container.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  */
11
12 #include "data.h"
13 #include "log.h"
14
15 /*
16  * Returns the mode of the given container (or MODE_DEFAULT if a NULL pointer
17  * was passed in order to save a few explicit checks in other places). If
18  * for_frame was set to true, the special case of having exactly one client
19  * in a container is handled so that MODE_DEFAULT is returned. For some parts
20  * of the rendering, this is interesting, other parts need the real mode.
21  *
22  */
23 int container_mode(Container *con, bool for_frame) {
24         int num_clients = 0;
25         Client *client;
26
27         if (con == NULL || con->mode == MODE_DEFAULT)
28                 return MODE_DEFAULT;
29
30         if (!for_frame)
31                 return con->mode;
32
33         CIRCLEQ_FOREACH(client, &(con->clients), clients)
34                 num_clients++;
35
36         /* If the container contains only one client, mode is irrelevant */
37         if (num_clients == 1) {
38                 DLOG("mode to default\n");
39                 return MODE_DEFAULT;
40         }
41
42         return con->mode;
43 }