]> git.lizzy.rs Git - bspwm.git/blob - types.c
New message: 'list_rules'
[bspwm.git] / types.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <xcb/xcb.h>
4 #include <xcb/xcb_event.h>
5 #include "bspwm.h"
6 #include "settings.h"
7 #include "types.h"
8
9 node_t *make_node(void)
10 {
11     node_t *n = malloc(sizeof(node_t));
12     n->parent = n->first_child = n->second_child = NULL;
13     n->split_ratio = SPLIT_RATIO;
14     n->split_type = TYPE_VERTICAL;
15     n->client = NULL;
16     n->vacant = false;
17     return n;
18 }
19
20 monitor_t *make_monitor(xcb_rectangle_t *rect)
21 {
22     monitor_t *m = malloc(sizeof(monitor_t));
23     snprintf(m->name, sizeof(m->name), "%s%02d", DEFAULT_MON_NAME, ++monitor_uid);
24     m->prev = m->next = NULL;
25     m->desk = m->last_desk = NULL;
26     if (rect != NULL)
27         m->rectangle = *rect;
28     else
29         warn("no rectangle was given for monitor '%s'\n", m->name);
30     m->top_padding = m->right_padding = m->bottom_padding = m->left_padding = 0;
31     return m;
32 }
33
34 desktop_t *make_desktop(const char *name)
35 {
36     desktop_t *d = malloc(sizeof(desktop_t));
37     if (name == NULL)
38         snprintf(d->name, sizeof(d->name), "%s%02d", DEFAULT_DESK_NAME, ++desktop_uid);
39     else
40         strncpy(d->name, name, sizeof(d->name));
41     d->layout = LAYOUT_TILED;
42     d->prev = d->next = NULL;
43     d->root = d->focus = d->last_focus = NULL;
44     return d;
45 }
46
47 client_t *make_client(xcb_window_t win)
48 {
49     client_t *c = malloc(sizeof(client_t));
50     strncpy(c->class_name, MISSING_VALUE, sizeof(c->class_name));
51     c->uid = ++client_uid;
52     c->border_width = border_width;
53     c->window = win;
54     c->floating = c->transient = c->fullscreen = c->locked = c->urgent = false;
55     return c;
56 }
57
58 rule_t *make_rule(void)
59 {
60     rule_t *r = malloc(sizeof(rule_t));
61     r->uid = ++rule_uid;
62     r->effect.floating = false;
63     r->effect.monitor = NULL;
64     r->effect.desktop = NULL;
65     r->next = NULL;
66     return r;
67 }
68
69 pointer_state_t *make_pointer_state(void)
70 {
71     pointer_state_t *p = malloc(sizeof(pointer_state_t));
72     return p;
73 }